diff options
| author | Keith M Wesolowski <wesolows@foobazco.org> | 2014-11-05 16:45:30 +0000 |
|---|---|---|
| committer | Keith M Wesolowski <wesolows@foobazco.org> | 2014-11-05 16:45:30 +0000 |
| commit | 87b686ff2607883beb10d16fe4be553b9e88ab45 (patch) | |
| tree | 00f9ece88cc6540fd9ffbbfb29216fbf48a8ae10 | |
| parent | 700c7c3645f333094887a448691679d6b2959d9c (diff) | |
| parent | 786d1eec1cd1cac7e26243d118cd209e84bc6bb9 (diff) | |
| download | illumos-joyent-87b686ff2607883beb10d16fe4be553b9e88ab45.tar.gz | |
[illumos-gate merge]
commit 786d1eec1cd1cac7e26243d118cd209e84bc6bb9
4174 Torch the old and unmaintained Sun-dhcp
commit f07f0fb66492a2792d4da5e0a6f9a92b4c581ab3
5041 man pages needed for some wide character routines
commit acd07c6b871cfa70bc42c9278037a17c430897b6
4449 Offlined vdevs are online after reboot
commit 2f5a01126fee81fbe9fff04d4412c2834e3944b8
5272 dev_err(9F) ignores special first character of message (explicit NULL check)
Manifests:
usr/src/pkg/manifests/SUNWcs.mf (ignore)
usr/src/pkg/manifests/consolidation-osnet-osnet-message-files.mf (ignore)
usr/src/pkg/manifests/network-dhcp-dhcpmgr.mf (ignore)
usr/src/pkg/manifests/service-network-dhcp-datastore-binfiles.mf (torch)
usr/src/pkg/manifests/service-network-dhcp.mf (torch)
usr/src/pkg/manifests/system-library.man3c.inc (add man pages)
501 files changed, 555 insertions, 99642 deletions
diff --git a/exception_lists/packaging b/exception_lists/packaging index b634364a5f..f9635c141e 100644 --- a/exception_lists/packaging +++ b/exception_lists/packaging @@ -23,6 +23,7 @@ # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # Copyright 2011 Nexenta Systems, Inc. All rights reserved. # Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved. +# Copyright 2014 Garrett D'Amore <garrett@damore.org> # # @@ -65,14 +66,8 @@ usr/lib/sparcv9/llib-lsoftcrypto.ln sparc # standalone's DHCP implementation, and the kernel (nfs_dlboot). # They contain interfaces which are currently private. # -usr/include/dhcp_svc_confkey.h -usr/include/dhcp_svc_confopt.h -usr/include/dhcp_svc_private.h usr/include/dhcp_symbol.h usr/include/sys/sunos_dhcp_class.h -usr/lib/libdhcpsvc.so -usr/lib/llib-ldhcpsvc -usr/lib/llib-ldhcpsvc.ln # # Private MAC driver header files # @@ -349,7 +349,6 @@ f etc/init.d/PRESERVE 0744 root sys f etc/init.d/README 0644 root sys f etc/init.d/acct 0744 root sys f etc/init.d/devlinks 0744 root sys -f etc/init.d/dhcp 0744 root sys f etc/init.d/dodatadm.udaplt 0744 root sys f etc/init.d/drvconfig 0744 root sys f etc/init.d/ldap.client 0744 root sys @@ -1334,9 +1333,7 @@ s lib/libdevid.so=libdevid.so.1 f lib/libdevinfo.so.1 0755 root bin s lib/libdevinfo.so=libdevinfo.so.1 f lib/libdhcpagent.so.1 0755 root bin -s lib/libdhcpagent.so=libdhcpagent.so.1 f lib/libdhcputil.so.1 0755 root bin -s lib/libdhcputil.so=libdhcputil.so.1 f lib/libdl.so.1 0755 root bin s lib/libdl.so=libdl.so.1 f lib/libdladm.so.1 0755 root bin @@ -2621,19 +2618,6 @@ f usr/include/device_info.h 0644 root bin f usr/include/devid.h 0644 root bin f usr/include/devmgmt.h 0644 root bin f usr/include/devpoll.h 0644 root bin -f usr/include/dhcp_hostconf.h 0644 root bin -f usr/include/dhcp_impl.h 0644 root bin -f usr/include/dhcp_inittab.h 0644 root bin -f usr/include/dhcp_stable.h 0644 root bin -f usr/include/dhcp_svc_confkey.h 0644 root bin -f usr/include/dhcp_svc_confopt.h 0644 root bin -f usr/include/dhcp_svc_private.h 0644 root bin -f usr/include/dhcp_svc_public.h 0644 root bin -f usr/include/dhcp_symbol.h 0644 root bin -f usr/include/dhcp_symbol_common.h 0644 root bin -f usr/include/dhcpagent_ipc.h 0644 root bin -f usr/include/dhcpagent_util.h 0644 root bin -f usr/include/dhcpmsg.h 0644 root bin f usr/include/dial.h 0644 root bin f usr/include/directory.h 0644 root bin f usr/include/dirent.h 0644 root bin @@ -4260,7 +4244,6 @@ f usr/include/sys/sunldi.h 0644 root bin f usr/include/sys/sunldi_impl.h 0644 root bin f usr/include/sys/sunmdi.h 0644 root bin f usr/include/sys/sunndi.h 0644 root bin -f usr/include/sys/sunos_dhcp_class.h 0644 root bin f usr/include/sys/sunpm.h 0644 root bin f usr/include/sys/suntpi.h 0644 root bin f usr/include/sys/suntty.h 0644 root bin @@ -5978,23 +5961,12 @@ f usr/lib/inet/amd64/in.iked 0555 root bin f usr/lib/inet/certdb 0555 root bin f usr/lib/inet/certlocal 0555 root bin f usr/lib/inet/certrldb 0555 root bin -d usr/lib/inet/dhcp 0755 root bin -d usr/lib/inet/dhcp/nsu 0755 root bin -f usr/lib/inet/dhcp/nsu/rfc2136.so.1 0755 root bin -d usr/lib/inet/dhcp/svc 0755 root bin -f usr/lib/inet/dhcp/svc/ds_SUNWbinfiles.so.1 0755 root bin -s usr/lib/inet/dhcp/svc/ds_SUNWbinfiles.so=ds_SUNWbinfiles.so.1 -f usr/lib/inet/dhcp/svc/ds_SUNWfiles.so.0 0755 root bin -f usr/lib/inet/dhcp/svc/ds_SUNWfiles.so.1 0755 root bin -s usr/lib/inet/dhcp/svc/ds_SUNWfiles.so=ds_SUNWfiles.so.1 -f usr/lib/inet/dsvclockd 0555 root bin d usr/lib/inet/i86 0755 root bin d usr/lib/inet/ilb 0755 root bin f usr/lib/inet/ilb/ilb_probe 0555 root bin f usr/lib/inet/ilbd 0555 root bin f usr/lib/inet/in.chargend 0555 root bin f usr/lib/inet/in.daytimed 0555 root bin -f usr/lib/inet/in.dhcpd 0555 root bin f usr/lib/inet/in.discardd 0555 root bin f usr/lib/inet/in.echod 0555 root bin h usr/lib/inet/in.iked=usr/lib/isaexec @@ -6158,11 +6130,8 @@ s usr/lib/libdevid.so=../../lib/libdevid.so.1 s usr/lib/libdevinfo.so.1=../../lib/libdevinfo.so.1 s usr/lib/libdevinfo.so=../../lib/libdevinfo.so.1 s usr/lib/libdhcpagent.so.1=../../lib/libdhcpagent.so.1 -s usr/lib/libdhcpagent.so=../../lib/libdhcpagent.so.1 f usr/lib/libdhcpsvc.so.1 0755 root bin -s usr/lib/libdhcpsvc.so=libdhcpsvc.so.1 s usr/lib/libdhcputil.so.1=../../lib/libdhcputil.so.1 -s usr/lib/libdhcputil.so=../../lib/libdhcputil.so.1 f usr/lib/libdisasm.so.1 0755 root bin s usr/lib/libdisasm.so=libdisasm.so.1 f usr/lib/libdiskmgt.so.1 0755 root bin @@ -13707,8 +13676,12 @@ s usr/share/man/man3c/watof.3c=wcstod.3c s usr/share/man/man3c/watoi.3c=wcstol.3c s usr/share/man/man3c/watol.3c=wcstol.3c s usr/share/man/man3c/watoll.3c=wcstol.3c +f usr/share/man/man3c/wcpcpy.3c 0444 root bin +s usr/share/man/man3c/wcpncpy.3c=wcpcpy.3c f usr/share/man/man3c/wcrtomb.3c 0444 root bin s usr/share/man/man3c/wcrtomb_l.3c=wcrtomb.3c +f usr/share/man/man3c/wcscasecmp.3c 0444 root bin +s usr/share/man/man3c/wcscasecmp_l.3c=wcscasecmp.3c s usr/share/man/man3c/wcscat.3c=wcstring.3c s usr/share/man/man3c/wcschr.3c=wcstring.3c s usr/share/man/man3c/wcscmp.3c=wcstring.3c @@ -13716,12 +13689,16 @@ f usr/share/man/man3c/wcscoll.3c 0444 root bin s usr/share/man/man3c/wcscoll_l.3c=wcscoll.3c s usr/share/man/man3c/wcscpy.3c=wcstring.3c s usr/share/man/man3c/wcscspn.3c=wcstring.3c +f usr/share/man/man3c/wcsdup.3c 0444 root bin s usr/share/man/man3c/wcsetno.3c=cset.3c f usr/share/man/man3c/wcsftime.3c 0444 root bin -s usr/share/man/man3c/wcslen.3c=wcstring.3c +f usr/share/man/man3c/wcslen.3c 0444 root bin +s usr/share/man/man3c/wcsncasecmp.3c=wcscasecmp.3c +s usr/share/man/man3c/wcsncasecmp_l.3c=wcscasecmp.3c s usr/share/man/man3c/wcsncat.3c=wcstring.3c s usr/share/man/man3c/wcsncmp.3c=wcstring.3c s usr/share/man/man3c/wcsncpy.3c=wcstring.3c +s usr/share/man/man3c/wcsnlen.3c=wcslen.3c s usr/share/man/man3c/wcsnrtombs.3c=wcsrtombs.3c s usr/share/man/man3c/wcsnrtombs_l.3c=wcsrtombs.3c s usr/share/man/man3c/wcspbrk.3c=wcstring.3c @@ -17957,9 +17934,6 @@ s usr/share/man/man4/devid_cache.4=devices.4 s usr/share/man/man4/devname_cache.4=devices.4 f usr/share/man/man4/dfstab.4 0444 root bin f usr/share/man/man4/dhcp_inittab.4 0444 root bin -f usr/share/man/man4/dhcp_network.4 0444 root bin -f usr/share/man/man4/dhcpsvc.conf.4 0444 root bin -f usr/share/man/man4/dhcptab.4 0444 root bin f usr/share/man/man4/dialups.4 0444 root bin s usr/share/man/man4/dir.4=dir_ufs.4 f usr/share/man/man4/dir_ufs.4 0444 root bin @@ -18177,7 +18151,6 @@ f usr/share/man/man5/crypt_sunmd5.5 0444 root bin f usr/share/man/man5/crypt_unix.5 0444 root bin f usr/share/man/man5/device_clean.5 0444 root bin f usr/share/man/man5/dhcp.5 0444 root bin -f usr/share/man/man5/dhcp_modules.5 0444 root bin f usr/share/man/man5/environ.5 0444 root bin f usr/share/man/man5/epoll.5 0444 root bin f usr/share/man/man5/eqn.5 0444 root bin diff --git a/usr/src/Makefile.lint b/usr/src/Makefile.lint index a9a9a14dfd..98f57fdfe0 100644 --- a/usr/src/Makefile.lint +++ b/usr/src/Makefile.lint @@ -74,9 +74,7 @@ COMMON_SUBDIRS = \ cmd/cmd-inet/sbin \ cmd/cmd-inet/usr.bin \ cmd/cmd-inet/usr.lib/bridged \ - cmd/cmd-inet/usr.lib/dsvclockd \ cmd/cmd-inet/usr.lib/ilbd \ - cmd/cmd-inet/usr.lib/in.dhcpd \ cmd/cmd-inet/usr.lib/in.mpathd \ cmd/cmd-inet/usr.lib/in.ndpd \ cmd/cmd-inet/usr.lib/inetd \ @@ -367,8 +365,6 @@ COMMON_SUBDIRS = \ lib/libdevid \ lib/libdevinfo \ lib/libdhcpagent \ - lib/libdhcpdu \ - lib/libdhcpsvc \ lib/libdhcputil \ lib/libdisasm \ lib/libdiskmgt \ diff --git a/usr/src/Targetdirs b/usr/src/Targetdirs index 7c2e8a7270..79fdd83e6f 100644 --- a/usr/src/Targetdirs +++ b/usr/src/Targetdirs @@ -26,6 +26,7 @@ # Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved. # Copyright (c) 2013 RackTop Systems. # Copyright 2013 Nexenta Systems, Inc. All rights reserved. +# Copyright 2014 Garrett D'Amore <garrett@damore.org> # # @@ -273,10 +274,6 @@ DIRS= \ /usr/lib/gss \ /usr/lib/hal \ /usr/lib/inet \ - /usr/lib/inet/dhcp \ - /usr/lib/inet/dhcp/nsu \ - /usr/lib/inet/dhcp/svc \ - /usr/lib/inet/dhcp/svcadm \ /usr/lib/inet/ilb \ /usr/lib/inet/$(MACH32) \ /usr/lib/inet/wanboot \ diff --git a/usr/src/cmd/Makefile.check b/usr/src/cmd/Makefile.check index 0b4e5e43dc..f442650fca 100644 --- a/usr/src/cmd/Makefile.check +++ b/usr/src/cmd/Makefile.check @@ -20,6 +20,7 @@ # # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2014 Garrett D'Amore <garrett@damore.org> include ../Makefile.master @@ -82,7 +83,6 @@ MANIFEST_SUBDIRS= \ cmd-inet/usr.lib/ilbd \ cmd-inet/usr.lib/in.chargend \ cmd-inet/usr.lib/in.daytimed \ - cmd-inet/usr.lib/in.dhcpd \ cmd-inet/usr.lib/in.discardd \ cmd-inet/usr.lib/in.echod \ cmd-inet/usr.lib/in.ndpd \ diff --git a/usr/src/cmd/cmd-inet/Makefile b/usr/src/cmd/cmd-inet/Makefile index b2ff14c38b..d484bfac79 100644 --- a/usr/src/cmd/cmd-inet/Makefile +++ b/usr/src/cmd/cmd-inet/Makefile @@ -20,13 +20,14 @@ # # # Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2014 Garrett D'Amore <garrett@damore.org> # include ../Makefile.cmd SUBDIRS= etc lib sbin usr.bin usr.sbin usr.lib usr.sadm -MSGSUBDIRS= usr.bin usr.sbin usr.lib usr.sadm -POFILES= usr.bin/usr.bin.po usr.sbin/usr.sbin.po usr.sadm/usr.sadm.po +MSGSUBDIRS= usr.bin usr.sbin usr.lib +POFILES= usr.bin/usr.bin.po usr.sbin/usr.sbin.po POFILE= cmd-inet.po all:= TARGET= all diff --git a/usr/src/cmd/cmd-inet/usr.lib/Makefile b/usr/src/cmd/cmd-inet/usr.lib/Makefile index db8505ec87..718d4ed15a 100644 --- a/usr/src/cmd/cmd-inet/usr.lib/Makefile +++ b/usr/src/cmd/cmd-inet/usr.lib/Makefile @@ -21,20 +21,20 @@ # # Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2014 Garrett D'Amore <garrett@damore.org> # -SUBDIRS= bridged dhcp dsvclockd ilbd in.chargend in.daytimed \ - in.discardd in.echod in.dhcpd in.mpathd in.ndpd \ +SUBDIRS= bridged ilbd in.chargend in.daytimed \ + in.discardd in.echod in.mpathd in.ndpd \ in.ripngd in.timed inetd mdnsd ncaconfd pppoe \ slpd vrrpd wanboot wpad -MSGSUBDIRS= dsvclockd ilbd in.dhcpd inetd ncaconfd vrrpd wanboot +MSGSUBDIRS= ilbd inetd ncaconfd vrrpd wanboot include ../../Makefile.cmd include ./Makefile.lib -POFILES= dsvclockd/dsvclockd.po in.dhcpd/in.dhcpd.po \ - inetd/inetd.po ncaconfd/ncaconfd.po vrrpd/vrrpd.po \ +POFILES= inetd/inetd.po ncaconfd/ncaconfd.po vrrpd/vrrpd.po \ wanboot/wanboot.po POFILE= usr.lib.po @@ -54,18 +54,9 @@ install: $(SUBDIRS) -$(LN) $(ISAEXEC) $(ROOTLIBINET)/in.iked -_msg: $(MSGSUBDIRS) +_msg: $(MSGSUBDIRS) -# -# The reason this rule checks for the existence of the -# Makefile is that some of the directories do not exist -# in our exportable source builds or in OpenSolaris. -# $(SUBDIRS): FRC - @if [ -f $@/Makefile ]; then \ - cd $@; pwd; $(MAKE) $(TARGET); \ - else \ - true; \ - fi + @cd $@; pwd; $(MAKE) $(MFLAGS) $(TARGET) FRC: diff --git a/usr/src/cmd/cmd-inet/usr.lib/dhcp/Makefile b/usr/src/cmd/cmd-inet/usr.lib/dhcp/Makefile deleted file mode 100644 index 545a6af747..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/dhcp/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2000-2001 by Sun Microsystems, Inc. -# All rights reserved. -# -# cmd/cmd-inet/usr.lib/dhcp/Makefile -# - -PROG = dhcpconfig dhtadm pntadm - -include ../../../Makefile.cmd - -ROOTLIBDHCP= $(ROOTLIBINET)/dhcp/svcadm - -ROOTLIBDHCPPROG= $(PROG:%=$(ROOTLIBDHCP)/%) - - -.KEEP_STATE: - -all: $(PROG) - -include ../Makefile.lib - -$(ROOTLIBDHCP)/%: % $(ROOTLIBDHCP) - $(INS.file) - -$(ROOTLIBDHCP): $(ROOTLIBINET) - $(INS.dir) - -install: all $(ROOTLIBDHCPPROG) - -clean lint _msg: - -include ../../../Makefile.targ diff --git a/usr/src/cmd/cmd-inet/usr.lib/dhcp/dhcpconfig.sh b/usr/src/cmd/cmd-inet/usr.lib/dhcp/dhcpconfig.sh deleted file mode 100644 index e1b013886d..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/dhcp/dhcpconfig.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -DMDIR=/usr/lib/inet/dhcp/svcadm -L10NDIR=/usr/share/lib/locale -WBEMDIR=/usr/sadm/lib/wbem - -CLASSPATH=${L10NDIR}:${DMDIR}/dhcpcli.jar:${DMDIR}/dhcpsvc.jar:${DMDIR}/dhcpcommon.jar:${WBEMDIR}/providerutility.jar -export CLASSPATH - -LD_LIBRARY_PATH=${WBEMDIR} -export LD_LIBRARY_PATH - -exec /usr/java/bin/java com.sun.dhcpmgr.cli.dhcpconfig.DhcpCfg "$@" diff --git a/usr/src/cmd/cmd-inet/usr.lib/dhcp/dhtadm.sh b/usr/src/cmd/cmd-inet/usr.lib/dhcp/dhtadm.sh deleted file mode 100644 index 7dad0bdd02..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/dhcp/dhtadm.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -DMDIR=/usr/lib/inet/dhcp/svcadm -L10NDIR=/usr/share/lib/locale - -CLASSPATH=${L10NDIR}:${DMDIR}/dhcpcli.jar:${DMDIR}/dhcpsvc.jar:${DMDIR}/dhcpcommon.jar -export CLASSPATH - -exec /usr/java/bin/java com.sun.dhcpmgr.cli.dhtadm.DhtAdm "$@" diff --git a/usr/src/cmd/cmd-inet/usr.lib/dhcp/pntadm.sh b/usr/src/cmd/cmd-inet/usr.lib/dhcp/pntadm.sh deleted file mode 100644 index 4b5b972228..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/dhcp/pntadm.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -DMDIR=/usr/lib/inet/dhcp/svcadm -L10NDIR=/usr/share/lib/locale -WBEMDIR=/usr/sadm/lib/wbem - -CLASSPATH=${L10NDIR}:${DMDIR}/dhcpcli.jar:${DMDIR}/dhcpsvc.jar:${DMDIR}/dhcpcommon.jar:${WBEMDIR}/providerutility.jar -export CLASSPATH - -LD_LIBRARY_PATH=${WBEMDIR} -export LD_LIBRARY_PATH - -exec /usr/java/bin/java com.sun.dhcpmgr.cli.pntadm.PntAdm "$@" diff --git a/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/Makefile b/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/Makefile deleted file mode 100644 index f6c8f79b0c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -PROG = dsvclockd -OBJS = dsvclockd.o container.o datastore.o -SRCS = $(OBJS:.o=.c) - -include ../../../Makefile.cmd - -POFILE = p$(PROG).po -POFILES = $(OBJS:.o=.po) - -LDLIBS += -ldhcputil -ldhcpsvc -CPPFLAGS += -D_REENTRANT -CERRWARN += -_gcc=-Wno-parentheses -XGETFLAGS += -a - -.KEEP_STATE: - -all: $(PROG) - -$(PROG): $(OBJS) - $(LINK.c) -o $@ $(OBJS) $(LDLIBS) - $(POST_PROCESS) - -include ../Makefile.lib - -install: all $(ROOTLIBINETPROG) - -clean: - $(RM) $(OBJS) - -lint: lint_SRCS - -$(POFILE): $(POFILES) - $(RM) $@ - $(CAT) $(POFILES) > $@ - -include ../../../Makefile.targ diff --git a/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/container.c b/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/container.c deleted file mode 100644 index c840be940f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/container.c +++ /dev/null @@ -1,725 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/types.h> -#include <synch.h> -#include <assert.h> -#include <stdlib.h> -#include <string.h> -#include <stdio.h> -#include <fcntl.h> -#include <errno.h> -#include <dhcpmsg.h> -#include <unistd.h> -#include <dhcp_svc_private.h> - -#include "container.h" - -/* - * Container locking code -- warning: serious pain ahead. - * - * This code synchronizes access to a given container across multiple - * threads in this (dsvclockd) process, and optionally synchronizes across - * multiple instances of dsvclockd running on different hosts. The - * synchronization allows multiple readers or a single writer at one time. - * - * Since by definition there is at most one dsvclockd running per host and - * all requests by all threads in all processes running on that host funnel - * into it, this code effectively synchronizes access to a given container - * across all threads in all processes running on a given host. This means - * that the optional synchronization across multiple instances of dsvclockd - * on different hosts provides true cross-host synchronization for all - * threads in all processes on all cooperating machines (though all hosts - * must have write access to a common directory). - * - * The container synchronization here should be viewed as a two step - * process, where the first step is optional: - * - * 1. Synchronize access across the set of cooperating dsvclockd's - * on multiple hosts. This is known as acquiring the host lock. - * - * 2. Synchronize access across the set of threads running inside - * this dsvclockd process. This is known as acquiring the - * intra-process lock. - * - * In order to implement the first (host lock) step, we use fcntl()-based - * file locking on a file inside an NFS-shared directory and rely on NFS to - * do our synchronization for us. Note that this can only be used to - * implement the first step since fcntl()-based locks are process locks, - * and the effects of using these locks with multiple threads are not - * defined. Furthermore, note that this means it requires some fancy - * footwork to ensure that only one thread in a given dsvclockd process - * tries to acquire the fcntl() lock for that process. - * - * In order to implement the second step, we use custom-made reader-writer - * locks since the stock Solaris ones don't quite have the semantics we - * need -- in particular, we need to relax the requirement that the thread - * which acquired the lock is the one releasing it. - * - * Lock ordering guidelines: - * - * For the most part, this code does not acquire more than one container - * lock at a time -- whenever feasible, please do the same. If you must - * acquire more than one lock at a time, the correct order is: - * - * 1. cn_nholds_lock - * 2. cn_lock - * 3. cn_hlock_lock - */ - -static int host_lock(dsvcd_container_t *, int, boolean_t); -static int host_unlock(dsvcd_container_t *); -static unsigned int cn_nlocks(dsvcd_container_t *); - -/* - * Create a container identified by `cn_id'; returns an instance of the new - * container upon success, or NULL on failure. Note that `cn_id' is - * treated as a pathname and thus must be a unique name for the container - * across all containers, container versions, and datastores -- additionally, - * if `crosshost' is set, then the directory named by `cn_id' must be a - * directory mounted on all cooperating hosts. - */ -dsvcd_container_t * -cn_create(const char *cn_id, boolean_t crosshost) -{ - dsvcd_container_t *cn; - - dhcpmsg(MSG_VERBOSE, "creating %scontainer synchpoint `%s'", crosshost ? - "crosshost " : "", cn_id); - - cn = calloc(1, sizeof (dsvcd_container_t)); - if (cn == NULL) - return (NULL); - - cn->cn_id = strdup(cn_id); - if (cn->cn_id == NULL) { - free(cn); - return (NULL); - } - - (void) mutex_init(&cn->cn_lock, USYNC_THREAD, NULL); - (void) mutex_init(&cn->cn_hlock_lock, USYNC_THREAD, NULL); - (void) mutex_init(&cn->cn_nholds_lock, USYNC_THREAD, NULL); - - (void) cond_init(&cn->cn_hlockcv, USYNC_THREAD, NULL); - - cn->cn_whead = NULL; - cn->cn_wtail = NULL; - cn->cn_nholds = 0; - cn->cn_closing = B_FALSE; - cn->cn_crosshost = crosshost; - cn->cn_hlockstate = CN_HUNLOCKED; - cn->cn_hlockcount = 0; - - return (cn); -} - -/* - * Destroy container `cn'; wait a decent amount of time for activity on the - * container to quiesce first. If the caller has not prohibited other - * threads from calling into the container yet, this may take a long time. - */ -void -cn_destroy(dsvcd_container_t *cn) -{ - unsigned int attempts; - unsigned int nstalelocks; - - dhcpmsg(MSG_VERBOSE, "destroying container synchpoint `%s'", cn->cn_id); - - (void) mutex_lock(&cn->cn_lock); - cn->cn_closing = B_TRUE; - (void) mutex_unlock(&cn->cn_lock); - - /* - * Wait for up to CN_DESTROY_WAIT seconds for all the lock holders - * to relinquish their locks. If the container has locks that seem - * to be stale, then warn the user before destroying it. The locks - * will be unlocked automatically when we exit. - */ - for (attempts = 0; attempts < CN_DESTROY_WAIT; attempts++) { - nstalelocks = cn_nlocks(cn); - if (nstalelocks == 0) - break; - - (void) sleep(1); - } - - if (nstalelocks == 1) { - dhcpmsg(MSG_WARNING, "unlocking stale lock on " - "container `%s'", cn->cn_id); - } else if (nstalelocks != 0) { - dhcpmsg(MSG_WARNING, "unlocking %d stale locks on " - "container `%s'", nstalelocks, cn->cn_id); - } - - (void) cond_destroy(&cn->cn_hlockcv); - (void) mutex_destroy(&cn->cn_nholds_lock); - (void) mutex_destroy(&cn->cn_hlock_lock); - (void) mutex_destroy(&cn->cn_lock); - - free(cn->cn_id); - free(cn); -} - -/* - * Wait (block) until a lock of type `locktype' is obtained on container - * `cn'. Returns a DSVC_* return code; if DSVC_SUCCESS is returned, then - * the lock is held upon return. Must be called with the container's - * cn_nholds_lock held on entry; returns with it unlocked. - */ -static int -cn_wait_for_lock(dsvcd_container_t *cn, dsvcd_locktype_t locktype) -{ - dsvcd_waitlist_t waititem; - int retval = DSVC_SUCCESS; - - assert(MUTEX_HELD(&cn->cn_nholds_lock)); - assert(cn->cn_nholds != 0); - - waititem.wl_next = NULL; - waititem.wl_prev = NULL; - waititem.wl_locktype = locktype; - (void) cond_init(&waititem.wl_cv, USYNC_THREAD, NULL); - - /* - * Chain our stack-local waititem onto the list; this keeps us from - * having to worry about allocation failures and also makes it easy - * for cn_unlock() to just pull us off the list without worrying - * about freeing the memory. - * - * Note that we can do this because by definition we are blocked in - * this function until we are signalled. - */ - if (cn->cn_whead != NULL) { - waititem.wl_prev = cn->cn_wtail; - cn->cn_wtail->wl_next = &waititem; - cn->cn_wtail = &waititem; - } else { - cn->cn_whead = &waititem; - cn->cn_wtail = &waititem; - } - - do { - if (cond_wait(&waititem.wl_cv, &cn->cn_nholds_lock) != 0) { - dhcpmsg(MSG_DEBUG, "cn_wait_for_lock: cond_wait error"); - retval = DSVC_INTERNAL; - break; - } - } while ((locktype == DSVCD_RDLOCK && cn->cn_nholds == -1) || - (locktype == DSVCD_WRLOCK && cn->cn_nholds != 0)); - - (void) cond_destroy(&waititem.wl_cv); - - assert(MUTEX_HELD(&cn->cn_nholds_lock)); - - /* - * We got woken up; pull ourselves off of the local waitlist. - */ - if (waititem.wl_prev != NULL) - waititem.wl_prev->wl_next = waititem.wl_next; - else - cn->cn_whead = waititem.wl_next; - - if (waititem.wl_next != NULL) - waititem.wl_next->wl_prev = waititem.wl_prev; - else - cn->cn_wtail = waititem.wl_prev; - - if (retval == DSVC_SUCCESS) { - if (locktype == DSVCD_WRLOCK) - cn->cn_nholds = -1; - else - cn->cn_nholds++; - } - - /* - * If we just acquired a read lock and the next waiter is waiting - * for a readlock too, signal the waiter. Note that we wake each - * reader up one-by-one like this to avoid excessive contention on - * cn_nholds_lock. - */ - if (locktype == DSVCD_RDLOCK && cn->cn_whead != NULL && - cn->cn_whead->wl_locktype == DSVCD_RDLOCK) - (void) cond_signal(&cn->cn_whead->wl_cv); - - (void) mutex_unlock(&cn->cn_nholds_lock); - return (retval); -} - -/* - * Lock container `cn' for reader (shared) access. If the container cannot - * be locked immediately (there is currently a writer lock held or a writer - * lock waiting for the lock), then if `nonblock' is B_TRUE, DSVC_BUSY is - * returned. Otherwise, block until the lock can be obtained. Returns a - * DSVC_* code. - */ -int -cn_rdlock(dsvcd_container_t *cn, boolean_t nonblock) -{ - int retval; - - /* - * The container is going away; no new lock requests. - */ - (void) mutex_lock(&cn->cn_lock); - if (cn->cn_closing) { - (void) mutex_unlock(&cn->cn_lock); - return (DSVC_SYNCH_ERR); - } - (void) mutex_unlock(&cn->cn_lock); - - /* - * See if we can grab the lock without having to block; only - * possible if we can acquire the host lock without blocking, if - * the lock is not currently owned by a writer and if there are no - * writers currently enqueued for accessing this lock (we know that - * if there's a waiter it must be a writer since this code doesn't - * enqueue readers until there's a writer enqueued). We enqueue - * these requests to improve fairness. - */ - (void) mutex_lock(&cn->cn_nholds_lock); - - if (cn->cn_nholds != -1 && cn->cn_whead == NULL && - host_lock(cn, F_RDLCK, B_TRUE) == DSVC_SUCCESS) { - cn->cn_nholds++; - (void) mutex_unlock(&cn->cn_nholds_lock); - return (DSVC_SUCCESS); - } - - (void) mutex_unlock(&cn->cn_nholds_lock); - - /* - * Cannot grab the lock without blocking somewhere; wait until we - * can grab the host lock, then with that lock held obtain our - * intra-process lock. - */ - if (nonblock) - return (DSVC_BUSY); - retval = host_lock(cn, F_RDLCK, B_FALSE); - if (retval != DSVC_SUCCESS) - return (retval); - - /* - * We've got the read lock; if there aren't any writers currently - * contending for our intra-process lock then succeed immediately. - * It's possible for there to be waiters but for nholds to be zero - * via the following scenario: - * - * 1. The last holder of a lock unlocks, dropping nholds to - * zero and signaling the head waiter on the waitlist. - * - * 2. The last holder drops cn_nholds_lock. - * - * 3. We acquire cn_nholds_lock before the signaled waiter - * does. - * - * Note that this case won't cause a deadlock even if we didn't - * check for it here (when the waiter finally gets cn_nholds_lock, - * it'll find that the waitlist is once again non-NULL, and signal - * the us). However, as an optimization, handle the case here. - */ - (void) mutex_lock(&cn->cn_nholds_lock); - if (cn->cn_nholds != -1 && - (cn->cn_whead == NULL || cn->cn_nholds == 0)) { - cn->cn_nholds++; - (void) mutex_unlock(&cn->cn_nholds_lock); - return (DSVC_SUCCESS); - } - - /* cn_wait_for_lock() will drop cn_nholds_lock */ - retval = cn_wait_for_lock(cn, DSVCD_RDLOCK); - if (retval != DSVC_SUCCESS) { - (void) host_unlock(cn); - return (retval); - } - return (DSVC_SUCCESS); -} - -/* - * Lock container `cn' for writer (exclusive) access. If the container - * cannot be locked immediately (there are currently readers or a writer), - * then if `nonblock' is B_TRUE, DSVC_BUSY is returned. Otherwise, block - * until the lock can be obtained. Returns a DSVC_* code. - */ -int -cn_wrlock(dsvcd_container_t *cn, boolean_t nonblock) -{ - int retval; - - /* - * The container is going away; no new lock requests. - */ - (void) mutex_lock(&cn->cn_lock); - if (cn->cn_closing) { - (void) mutex_unlock(&cn->cn_lock); - return (DSVC_SYNCH_ERR); - } - (void) mutex_unlock(&cn->cn_lock); - - /* - * See if we can grab the lock without having to block; only - * possible if there are no current writers within our process and - * that we can immediately acquire the host lock. - */ - (void) mutex_lock(&cn->cn_nholds_lock); - - if (cn->cn_nholds == 0 && - host_lock(cn, F_WRLCK, B_TRUE) == DSVC_SUCCESS) { - cn->cn_nholds = -1; - (void) mutex_unlock(&cn->cn_nholds_lock); - return (DSVC_SUCCESS); - } - - (void) mutex_unlock(&cn->cn_nholds_lock); - - /* - * Cannot grab the lock without blocking somewhere; wait until we - * can grab the host lock, then with that lock held obtain our - * intra-process lock. - */ - if (nonblock) - return (DSVC_BUSY); - retval = host_lock(cn, F_WRLCK, B_FALSE); - if (retval != DSVC_SUCCESS) - return (retval); - - /* - * We've got the host lock; if there aren't any writers currently - * contending for our intra-process lock then succeed immediately. - */ - (void) mutex_lock(&cn->cn_nholds_lock); - if (cn->cn_nholds == 0) { - cn->cn_nholds = -1; - (void) mutex_unlock(&cn->cn_nholds_lock); - return (DSVC_SUCCESS); - } - - /* cn_wait_for_lock() will drop cn_nholds_lock */ - retval = cn_wait_for_lock(cn, DSVCD_WRLOCK); - if (retval != DSVC_SUCCESS) { - (void) host_unlock(cn); - return (retval); - } - return (DSVC_SUCCESS); -} - -/* - * Unlock reader or writer lock on container `cn'; returns a DSVC_* code - */ -int -cn_unlock(dsvcd_container_t *cn) -{ - (void) mutex_lock(&cn->cn_nholds_lock); - - if (cn->cn_nholds == 0) { - (void) mutex_unlock(&cn->cn_nholds_lock); - return (DSVC_SYNCH_ERR); - } - - if (cn->cn_nholds != -1 && cn->cn_nholds != 1) { - cn->cn_nholds--; - (void) host_unlock(cn); - (void) mutex_unlock(&cn->cn_nholds_lock); - return (DSVC_SUCCESS); - } - - /* - * The last reader or a writer just unlocked -- signal the first - * waiter. To avoid a thundering herd, we only signal the first - * waiter, even if there are multiple readers ready to go -- - * instead, each reader is responsible for signaling the next - * in cn_wait_for_lock(). - */ - cn->cn_nholds = 0; - if (cn->cn_whead != NULL) - (void) cond_signal(&cn->cn_whead->wl_cv); - - (void) host_unlock(cn); - (void) mutex_unlock(&cn->cn_nholds_lock); - - return (DSVC_SUCCESS); -} - -/* - * Find out what kind of lock is on `cn'. Note that this is just a - * snapshot in time and without additional locks the answer may be invalid - * by the time the function returns. - */ -dsvcd_locktype_t -cn_locktype(dsvcd_container_t *cn) -{ - int nholds; - - (void) mutex_lock(&cn->cn_nholds_lock); - nholds = cn->cn_nholds; - (void) mutex_unlock(&cn->cn_nholds_lock); - - if (nholds == 0) - return (DSVCD_NOLOCK); - else if (nholds > 0) - return (DSVCD_RDLOCK); - else - return (DSVCD_WRLOCK); -} - -/* - * Obtain a lock of type `locktype' on container `cn' such that we have - * shared or exclusive access to this container across all hosts. If - * `nonblock' is true and the lock cannot be obtained return DSVC_BUSY. If - * the lock is already held, the number of instances of the lock "checked - * out" by this host is incremented. - */ -static int -host_lock(dsvcd_container_t *cn, int locktype, boolean_t nonblock) -{ - struct flock flock; - int fd; - char *basename, lockpath[MAXPATHLEN]; - int error; - - if (!cn->cn_crosshost) - return (DSVC_SUCCESS); - - /* - * Before we wait for a while, see if the container is going away; - * if so, fail now so the container can drain quicker.. - */ - (void) mutex_lock(&cn->cn_lock); - if (cn->cn_closing) { - (void) mutex_unlock(&cn->cn_lock); - return (DSVC_SYNCH_ERR); - } - (void) mutex_unlock(&cn->cn_lock); - - /* - * Note that we only wait if (1) there's already a thread trying to - * grab the host lock on our host or if (2) this host currently - * holds a host shared lock and we need an exclusive lock. Note - * that we do *not* wait in the following situations: - * - * * This host holds an exclusive host lock and another - * exclusive host lock request comes in. We rely on the - * intra-process lock to do the synchronization. - * - * * This host holds an exclusive host lock and a shared host - * lock request comes in. Since this host already has - * exclusive access, we already implicitly hold the shared - * host lock as far as this host is concerned, so just rely - * on the intra-process lock to do the synchronization. - * - * These semantics make sense as long as one remembers that the - * host lock merely provides exclusive or shared access for a given - * host or set of hosts -- that is, exclusive access is exclusive - * access for that machine, not for the given request. - */ - (void) mutex_lock(&cn->cn_hlock_lock); - - while (cn->cn_hlockstate == CN_HPENDING || - cn->cn_hlockstate == CN_HRDLOCKED && locktype == F_WRLCK) { - if (nonblock) { - (void) mutex_unlock(&cn->cn_hlock_lock); - return (DSVC_BUSY); - } - - if (cond_wait(&cn->cn_hlockcv, &cn->cn_hlock_lock) != 0) { - (void) mutex_unlock(&cn->cn_hlock_lock); - return (DSVC_SYNCH_ERR); - } - } - - if (cn->cn_hlockstate == CN_HRDLOCKED || - cn->cn_hlockstate == CN_HWRLOCKED) { - /* - * Already locked; just bump the held lock count. - */ - assert(cn->cn_hlockcount > 0); - cn->cn_hlockcount++; - (void) mutex_unlock(&cn->cn_hlock_lock); - return (DSVC_SUCCESS); - } - - /* - * We're the thread that's going to try to acquire the host lock. - */ - - assert(cn->cn_hlockcount == 0); - - /* - * Create the lock file as a hidden file in the directory named by - * cn_id. So if cn_id is /var/dhcp/SUNWfiles1_dhcptab, we want the - * lock file to be /var/dhcp/.SUNWfiles1_dhcptab.lock. Please, no - * giggles about the snprintf(). - */ - basename = strrchr(cn->cn_id, '/'); - if (basename == NULL) - basename = cn->cn_id; - else - basename++; - - (void) snprintf(lockpath, MAXPATHLEN, "%.*s.%s.lock", - basename - cn->cn_id, cn->cn_id, basename); - fd = open(lockpath, O_RDWR|O_CREAT, 0600); - if (fd == -1) { - (void) mutex_unlock(&cn->cn_hlock_lock); - return (DSVC_SYNCH_ERR); - } - - cn->cn_hlockstate = CN_HPENDING; - (void) mutex_unlock(&cn->cn_hlock_lock); - - flock.l_len = 0; - flock.l_type = locktype; - flock.l_start = 0; - flock.l_whence = SEEK_SET; - - if (fcntl(fd, nonblock ? F_SETLK : F_SETLKW, &flock) == -1) { - /* - * For some reason we couldn't acquire the lock. Reset the - * host lock state to "unlocked" and signal another thread - * (if there's one waiting) to pick up where we left off. - */ - error = errno; - (void) mutex_lock(&cn->cn_hlock_lock); - cn->cn_hlockstate = CN_HUNLOCKED; - (void) cond_signal(&cn->cn_hlockcv); - (void) mutex_unlock(&cn->cn_hlock_lock); - (void) close(fd); - return (error == EAGAIN ? DSVC_BUSY : DSVC_SYNCH_ERR); - } - - /* - * Got the lock; wake up all the waiters since they can all succeed - */ - (void) mutex_lock(&cn->cn_hlock_lock); - cn->cn_hlockstate = (locktype == F_WRLCK ? CN_HWRLOCKED : CN_HRDLOCKED); - cn->cn_hlockcount++; - cn->cn_hlockfd = fd; - (void) cond_broadcast(&cn->cn_hlockcv); - (void) mutex_unlock(&cn->cn_hlock_lock); - - return (DSVC_SUCCESS); -} - -/* - * Unlock a checked out instance of a shared or exclusive lock on container - * `cn'; if the number of checked out instances goes to zero, then the host - * lock is unlocked so that other hosts may compete for it. - */ -static int -host_unlock(dsvcd_container_t *cn) -{ - struct flock flock; - - if (!cn->cn_crosshost) - return (DSVC_SUCCESS); - - assert(cn->cn_hlockcount > 0); - - (void) mutex_lock(&cn->cn_hlock_lock); - if (cn->cn_hlockcount > 1) { - /* - * Not the last unlock by this host; just decrement the - * held lock count. - */ - cn->cn_hlockcount--; - (void) mutex_unlock(&cn->cn_hlock_lock); - return (DSVC_SUCCESS); - } - - flock.l_len = 0; - flock.l_type = F_UNLCK; - flock.l_start = 0; - flock.l_whence = SEEK_SET; - - if (fcntl(cn->cn_hlockfd, F_SETLK, &flock) == -1) { - (void) mutex_unlock(&cn->cn_hlock_lock); - return (DSVC_SYNCH_ERR); - } - - /* - * Note that we don't unlink the lockfile for a number of reasons, - * the most blatant reason being: - * - * 1. Several hosts lock the lockfile for shared access. - * 2. One host unlocks the lockfile and unlinks it (here). - * 3. Another host comes in, goes to exclusively lock the - * lockfile, finds no lockfile, and creates a new one - * (meanwhile, the other hosts are still accessing the - * container through the unlinked lockfile). - * - * We could put in some hairy code to try to unlink lockfiles - * elsewhere (when possible), but it hardly seems worth it since - * inodes are cheap. - */ - - (void) close(cn->cn_hlockfd); - cn->cn_hlockcount = 0; - cn->cn_hlockstate = CN_HUNLOCKED; - /* - * We need to signal `cn_hlockcv' in case there are threads which - * are waiting on it to attempt flock() exclusive access (see the - * comments in host_lock() for more details about this case). - */ - (void) cond_signal(&cn->cn_hlockcv); - (void) mutex_unlock(&cn->cn_hlock_lock); - - return (DSVC_SUCCESS); -} - -/* - * Return the number of locks currently held for container `cn'. - */ -static unsigned int -cn_nlocks(dsvcd_container_t *cn) -{ - unsigned int nlocks; - - (void) mutex_lock(&cn->cn_nholds_lock); - (void) mutex_lock(&cn->cn_hlock_lock); - - switch (cn->cn_nholds) { - case 0: - nlocks = cn->cn_hlockcount; - break; - case -1: - nlocks = 1; - break; - default: - nlocks = cn->cn_nholds; - break; - } - - dhcpmsg(MSG_DEBUG, "cn_nlocks: nholds=%d hlockstate=%d hlockcount=%d", - cn->cn_nholds, cn->cn_hlockstate, cn->cn_hlockcount); - - (void) mutex_unlock(&cn->cn_hlock_lock); - (void) mutex_unlock(&cn->cn_nholds_lock); - - return (nlocks); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/container.h b/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/container.h deleted file mode 100644 index 45694dcf62..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/container.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef DSVCD_CONTAINER_H -#define DSVCD_CONTAINER_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/types.h> -#include <synch.h> - -#include "dsvclockd.h" - -/* - * Container-related data structures, functions and constants. See - * comments in container.c for a description of how to use the exported - * functions. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Number of seconds to wait for container lockholders to relinquish all - * locks on a given container (when it's being destroyed). - */ -#define CN_DESTROY_WAIT 60 - -/* - * Describes a thread waiting to access a given container; exactly one per - * waiting thread. - */ -typedef struct dsvcd_waitlist { - struct dsvcd_waitlist *wl_next; /* next waiter in list */ - struct dsvcd_waitlist *wl_prev; /* prev waiter in list */ - cond_t wl_cv; /* our condition variable */ - dsvcd_locktype_t wl_locktype; /* type of lock we want */ -} dsvcd_waitlist_t; - -/* - * States for the host lock state machine. The state machine is a simple - * cycle of UNLOCKED->PENDING->{RD,WR}LOCKED->UNLOCKED->... - */ -enum cn_hlockstate { CN_HUNLOCKED, CN_HPENDING, CN_HRDLOCKED, CN_HWRLOCKED }; - -/* - * Describes a given container within a datastore. There is at most one of - * these per datastore container (there may be none if there are no current - * consumers of a given container within a datastore). If there is more - * than one open handle to a given container (through multiple calls to - * open_d?()) there will still only be one dsvcd_container_t for that - * container. This object is used to synchronize access to an underlying - * container through use of its custom reader/writer lock (it can't use the - * rwlock_t's built into Solaris because we need locks that do not care if - * the unlocking thread is the same as the locking thread). It also - * contains other per-container information like the container id. - */ -typedef struct dsvcd_container { - char *cn_id; /* container's id */ - boolean_t cn_crosshost; /* synchronize across hosts */ - boolean_t cn_closing; /* container is going away */ - mutex_t cn_lock; /* protects preceding fields */ - - dsvcd_waitlist_t *cn_whead; /* head of wait list */ - dsvcd_waitlist_t *cn_wtail; /* tail of wait list */ - int cn_nholds; /* num readers (-1 == writer) */ - mutex_t cn_nholds_lock; /* for nholds and waitlist */ - - int cn_hlockfd; /* host lock file descriptor */ - int cn_hlockcount; /* current # of host locks */ - enum cn_hlockstate cn_hlockstate; /* host lock state */ - cond_t cn_hlockcv; /* host lock condvar */ - mutex_t cn_hlock_lock; /* mutex for cn_hlock* */ - - /* - * These fields are used to keep metadata state regarding the - * container and are actually maintained by the containing - * datastore, not the container. - */ - uint_t cn_nout; /* number checked out */ - time_t cn_lastrel; /* last released */ - uint32_t cn_idhash; /* hash before modulation */ - struct dsvcd_container *cn_next; /* hash chain next */ - struct dsvcd_container *cn_prev; /* hash chain prev */ -} dsvcd_container_t; - -extern dsvcd_container_t *cn_create(const char *, boolean_t); -extern void cn_destroy(dsvcd_container_t *); -extern int cn_rdlock(dsvcd_container_t *, boolean_t); -extern int cn_wrlock(dsvcd_container_t *, boolean_t); -extern int cn_unlock(dsvcd_container_t *); -extern dsvcd_locktype_t cn_locktype(dsvcd_container_t *); - -#ifdef __cplusplus -} -#endif - -#endif /* DSVCD_CONTAINER_H */ diff --git a/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/datastore.c b/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/datastore.c deleted file mode 100644 index e0d0def375..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/datastore.c +++ /dev/null @@ -1,311 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/types.h> -#include <stdlib.h> -#include <string.h> -#include <stropts.h> -#include <synch.h> -#include <fcntl.h> -#include <unistd.h> -#include <stdio.h> -#include <dhcp_svc_private.h> -#include <sys/time.h> -#include <dhcpmsg.h> - -#include "dsvclockd.h" -#include "datastore.h" - -static uint32_t ds_hash(const char *); - -/* - * Create a datastore named `ds_name' and a door which will service requests - * for this datastore. When the door is called, callback `ds_callback'. - * Returns the created datastore. - */ -dsvcd_datastore_t * -ds_create(const char *ds_name, dsvcd_svc_t *ds_callback) -{ - char door_path[MAXPATHLEN]; - dsvcd_datastore_t *ds = NULL; - int fd; - unsigned int i; - door_info_t info; - - dhcpmsg(MSG_VERBOSE, "managing locks for datastore `%s'", ds_name); - - ds = malloc(sizeof (dsvcd_datastore_t)); - if (ds == NULL) { - dhcpmsg(MSG_ERR, "cannot manage locks for datastore `%s'", - ds_name); - return (NULL); - } - - ds->ds_name = strdup(ds_name); - if (ds->ds_name == NULL) { - dhcpmsg(MSG_ERR, "cannot manage locks for datastore `%s'", - ds_name); - free(ds); - return (NULL); - } - - ds->ds_doorfd = door_create((void (*)())ds_callback, ds, - DOOR_REFUSE_DESC | DOOR_NO_CANCEL); - if (ds->ds_doorfd == -1) { - dhcpmsg(MSG_ERR, "cannot create door for datastore `%s'", - ds_name); - free(ds->ds_name); - free(ds); - return (NULL); - } - - for (i = 0; i < DSVCD_DS_HASH_SIZE; i++) { - ds->ds_hash[i].cl_head = NULL; - (void) mutex_init(&ds->ds_hash[i].cl_lock, USYNC_THREAD, 0); - } - - /* - * Create the door name in the filesystem. First, check to see if - * a door already exists at the specified pathname. If it does, - * and the server process (no doubt another copy of us) is already - * running, then fail. Otherwise, unlink the old door and fattach - * a new one. - */ - (void) snprintf(door_path, sizeof (door_path), DSVCD_DOOR_FMT, ds_name); - - fd = open(door_path, O_RDWR); - if (fd != -1) { - if (door_info(fd, &info) == 0 && info.di_target != -1) { - dhcpmsg(MSG_ERROR, "%s is in use by process %lu", - door_path, info.di_target); - (void) close(fd); - (void) close(ds->ds_doorfd); - free(ds->ds_name); - free(ds); - return (NULL); - } - (void) close(fd); - (void) unlink(door_path); - } - - fd = open(door_path, O_CREAT|O_EXCL|O_RDWR, 0644); - if (fd == -1) { - dhcpmsg(MSG_ERR, "cannot create door rendezvous for datastore " - "`%s'", ds_name); - (void) close(ds->ds_doorfd); - free(ds->ds_name); - free(ds); - return (NULL); - } - (void) close(fd); - - /* - * Attach the door onto the name - */ - if (fattach(ds->ds_doorfd, door_path) == -1) { - dhcpmsg(MSG_ERR, "cannot fattach door rendezvous for datastore " - "`%s'", ds_name); - (void) close(ds->ds_doorfd); - free(ds->ds_name); - free(ds); - return (NULL); - } - - return (ds); -} - -/* - * Destroy a datastore `ds' and its associated containers, and remove - * its door from the filesystem. - */ -void -ds_destroy(dsvcd_datastore_t *ds) -{ - unsigned int i; - char door_path[MAXPATHLEN]; - dsvcd_container_t *cn, *cn_next; - - dhcpmsg(MSG_VERBOSE, "stopping lock management for datastore `%s'", - ds->ds_name); - - /* - * Detach and revoke access to the door. The detach makes it so - * new callers who open the door will fail; the revoke makes it - * so that callers that already have a door descriptor will fail. - * We do this prior to calling cn_destroy() to make it easier for - * the container lockcount to drain. - */ - (void) snprintf(door_path, MAXPATHLEN, DSVCD_DOOR_FMT, ds->ds_name); - (void) fdetach(door_path); - (void) unlink(door_path); - (void) door_revoke(ds->ds_doorfd); - (void) close(ds->ds_doorfd); - - /* - * Destroy all the underlying containers. We're single-threaded at - * this point, so don't worry about locks. - */ - for (i = 0; i < DSVCD_DS_HASH_SIZE; i++) { - for (cn = ds->ds_hash[i].cl_head; cn != NULL; cn = cn_next) { - cn_next = cn->cn_next; - cn_destroy(cn); - } - (void) mutex_destroy(&ds->ds_hash[i].cl_lock); - } - - free(ds->ds_name); - free(ds); -} - -/* - * Get a container with id `cn_id' from datastore `ds'; create the - * container if it does not exist. If `crosshost' is set and the container - * does not yet exist, then the container will synchronize across hosts. . - * If the container cannot be found or created, NULL is returned. When the - * calling thread is done with the container, ds_release_container() must - * be called. - */ -dsvcd_container_t * -ds_get_container(dsvcd_datastore_t *ds, const char *cn_id, boolean_t crosshost) -{ - dsvcd_container_list_t *cn_list; - dsvcd_container_t *cn; - uint32_t idhash = ds_hash(cn_id); - - cn_list = &ds->ds_hash[idhash % DSVCD_DS_HASH_SIZE]; - (void) mutex_lock(&cn_list->cl_lock); - - for (cn = cn_list->cl_head; cn != NULL; cn = cn->cn_next) { - if (idhash == cn->cn_idhash && strcmp(cn_id, cn->cn_id) == 0) - break; - } - - if (cn == NULL) { - cn = cn_create(cn_id, crosshost); - if (cn != NULL) { - if (cn_list->cl_head != NULL) - cn_list->cl_head->cn_prev = cn; - - cn->cn_next = cn_list->cl_head; - cn->cn_prev = NULL; - cn_list->cl_head = cn; - cn->cn_idhash = idhash; - cn->cn_nout = 0; - cn->cn_lastrel = 0; - } - } - - if (cn != NULL) - cn->cn_nout++; - - (void) mutex_unlock(&cn_list->cl_lock); - return (cn); -} - -/* - * Release a container `cn' belonging to datastore `ds'. Once a container - * has been released, it can no longer be used by the releasing thread. - * Used to track the number of active instances of a container. - */ -void -ds_release_container(dsvcd_datastore_t *ds, dsvcd_container_t *cn) -{ - dsvcd_container_list_t *cn_list; - uint32_t idhash = ds_hash(cn->cn_id); - - cn_list = &ds->ds_hash[idhash % DSVCD_DS_HASH_SIZE]; - - (void) mutex_lock(&cn_list->cl_lock); - - cn->cn_nout--; - cn->cn_lastrel = time(NULL); - - (void) mutex_unlock(&cn_list->cl_lock); -} - -/* - * Destroy any containers in datastore `ds' that have not been accessed in - * the last `idle' seconds. Return the number of destroyed (reaped) - * containers. - */ -unsigned int -ds_reap_containers(dsvcd_datastore_t *ds, unsigned int idle) -{ - dsvcd_container_list_t *cn_list; - dsvcd_container_t *cn, *cn_next; - unsigned int i, nreaped = 0; - - for (i = 0; i < DSVCD_DS_HASH_SIZE; i++) { - cn_list = &ds->ds_hash[i]; - - (void) mutex_lock(&cn_list->cl_lock); - for (cn = cn_list->cl_head; cn != NULL; cn = cn_next) { - cn_next = cn->cn_next; - - /* - * Since a container is not checked out across a - * lock operation, we must check if the lock is - * held as well as the number of instances checked - * out. - */ - if (cn->cn_nout != 0 || - cn_locktype(cn) != DSVCD_NOLOCK || - cn->cn_lastrel + idle >= time(NULL)) - continue; - - if (cn == cn_list->cl_head) - cn_list->cl_head = cn->cn_next; - else - cn->cn_prev->cn_next = cn->cn_next; - - if (cn->cn_next != NULL) - cn->cn_next->cn_prev = cn->cn_prev; - - cn_destroy(cn); - nreaped++; - } - (void) mutex_unlock(&cn_list->cl_lock); - } - - return (nreaped); -} - -/* - * Hash a container identified by `cn_id' into a 32-bit unsigned integer - * suitable for use as a key in a hash table. - */ -static uint32_t -ds_hash(const char *cn_id) -{ - uint32_t result = 0; - unsigned int i; - - for (i = 0; cn_id[i] != '\0'; i++) - result += cn_id[i] << i; - - return (result); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/datastore.h b/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/datastore.h deleted file mode 100644 index 8d977e3057..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/datastore.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef DSVCD_DATASTORE_H -#define DSVCD_DATASTORE_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/types.h> -#include <synch.h> -#include <door.h> - -#include "container.h" - -/* - * Datastore-related data structures, functions and constants. See - * comments in datastore.c for a description of how to use the exported - * functions. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#define DSVCD_DS_HASH_SIZE 100 - -/* - * A linked list of dsvcd_container_t structures. Contains a lock, - * `cl_lock', which is used for controlling manipulation of `cl_head'. - */ -typedef struct { - mutex_t cl_lock; /* protects the list */ - dsvcd_container_t *cl_head; /* linked list of containers */ - uint8_t cl_pad[8]; /* prevent false sharing */ -} dsvcd_container_list_t; - -/* - * Describes the underlying datastore itself. There is exactly one - * dsvcd_datastore_t per datastore using doors (so currently, there are - * two: one for `ds_files' and one for `ds_data'). Contains per-datastore - * information, like the door descriptor being used by dsvclockd to listen - * to requests for this datastore, the datastore name, and a list of all - * open containers for this datastore. Instances of this data structure - * are allocated when dsvclockd is started. - */ -typedef struct dsvcd_datastore { - char *ds_name; /* datastore name */ - int ds_doorfd; /* datastore door */ - - /* - * This hash is used to speed up the open() routine so that a given - * container can be located quicker. Hash based on the filename, - * and use it as an index into the array.. - */ - dsvcd_container_list_t ds_hash[DSVCD_DS_HASH_SIZE]; -} dsvcd_datastore_t; - -typedef void dsvcd_svc_t(void *, dsvcd_request_t *, size_t, door_desc_t *, - uint_t); - -extern dsvcd_datastore_t *ds_create(const char *, dsvcd_svc_t *); -extern void ds_destroy(dsvcd_datastore_t *); -extern unsigned int ds_reap_containers(dsvcd_datastore_t *, unsigned int); -extern void ds_release_container(dsvcd_datastore_t *, dsvcd_container_t *); -extern dsvcd_container_t *ds_get_container(dsvcd_datastore_t *, const char *, - boolean_t); - -#ifdef __cplusplus -} -#endif - -#endif /* DSVCD_DATASTORE_H */ diff --git a/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/dsvclockd.c b/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/dsvclockd.c deleted file mode 100644 index 7c52222040..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/dsvclockd.c +++ /dev/null @@ -1,866 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * #define _POSIX_PTHREAD_SEMANTICS before #including <signal.h> so that we - * get the right (POSIX) version of sigwait(2). - */ -#define _POSIX_PTHREAD_SEMANTICS - -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/mman.h> -#include <sys/sysmacros.h> -#include <dhcp_svc_private.h> -#include <pthread.h> -#include <stdlib.h> -#include <dhcpmsg.h> -#include <assert.h> -#include <stddef.h> -#include <stdio.h> -#include <stdio_ext.h> -#include <string.h> -#include <unistd.h> -#include <signal.h> -#include <locale.h> -#include <synch.h> -#include <sys/resource.h> - -#include "datastore.h" -#include "dsvclockd.h" - -/* - * The DHCP service daemon synchronizes access to containers within a given - * datastore. Any datastore which is willing to accept the synchronization - * constraints imposed by the DHCP service daemon can use this daemon in - * lieu of rolling their own synchronization code. - * - * See $SRC/lib/libdhcpsvc/private/README.synch for more information. - */ - -#ifndef TEXT_DOMAIN -#define TEXT_DOMAIN "SYS_TEST" -#endif - -#define DSVCD_REAP_INTERVAL (60 * 60 * 24) /* seconds, thus once a day */ -#define DSVCD_REAP_THRESH (60 * 60) /* seconds, thus 1 hour stale */ -#define DSVCD_STACK_REDSIZE (8 * 1024) /* redzone size, in bytes */ -#define UD_RECLAIM_MAX 128 /* unlock door descriptors */ - -/* - * Unlock descriptor -- one for each lock granted. This descriptor is used - * to subsequently unlock the granted lock (and to synchronize unlocking of - * the lock; see svc_unlock() below for details). - */ -typedef struct dsvcd_unlock_desc { - int ud_fd; - mutex_t ud_lock; - dsvcd_container_t *ud_cn; - struct dsvcd_unlock_desc *ud_next; -} dsvcd_unlock_desc_t; - -static mutex_t ud_reclaim_lock = DEFAULTMUTEX; -static unsigned int ud_reclaim_count = 0; -static dsvcd_unlock_desc_t *ud_reclaim_list = NULL; - -static void *reaper(void *); -static int daemonize(void); -static void *stack_create(unsigned int *); -static void stack_destroy(void *, unsigned int); -static void doorserv_create(door_info_t *); -static dsvcd_unlock_desc_t *ud_create(dsvcd_container_t *, int *); -static void ud_destroy(dsvcd_unlock_desc_t *, boolean_t); -static dsvcd_svc_t svc_lock, svc_unlock; - -int -main(int argc, char **argv) -{ - dsvcd_datastore_t **ds_table; - dsvc_datastore_t dd; - dsvc_synchtype_t synchtype; - char **modules; - unsigned int i, j; - int debug_level = 0; - boolean_t is_daemon = B_TRUE; - boolean_t is_verbose = B_FALSE; - int sig, nmodules, nsynchmods, c; - sigset_t sigset; - char signame[SIG2STR_MAX]; - char *progname; - void *stackbase; - unsigned int stacksize = 16 * 1024; - struct rlimit rl; - - (void) setlocale(LC_ALL, ""); - (void) textdomain(TEXT_DOMAIN); - - /* - * Mask all signals except SIGABRT; doing this here ensures that - * all threads created through door_create() have them masked too. - */ - (void) sigfillset(&sigset); - (void) sigdelset(&sigset, SIGABRT); - (void) thr_sigsetmask(SIG_BLOCK, &sigset, NULL); - - /* - * Figure out our program name; just keep the final piece so that - * our dhcpmsg() messages don't get too long. - */ - progname = strrchr(argv[0], '/'); - if (progname != NULL) - progname++; - else - progname = argv[0]; - - /* - * Set the door thread creation procedure so that all of our - * threads are created with thread stacks with backing store. - */ - (void) door_server_create(doorserv_create); - - while ((c = getopt(argc, argv, "d:fv")) != EOF) { - switch (c) { - - case 'd': - debug_level = atoi(optarg); - break; - - case 'f': - is_daemon = B_FALSE; - break; - - case 'v': - is_verbose = B_TRUE; - break; - - case '?': - (void) fprintf(stderr, - gettext("usage: %s [-dn] [-f] [-v]\n"), progname); - return (EXIT_FAILURE); - - default: - break; - } - } - - if (geteuid() != 0) { - dhcpmsg_init(progname, B_FALSE, is_verbose, debug_level); - dhcpmsg(MSG_ERROR, "must be super-user"); - dhcpmsg_fini(); - return (EXIT_FAILURE); - } - - if (is_daemon && daemonize() == 0) { - dhcpmsg_init(progname, B_FALSE, is_verbose, debug_level); - dhcpmsg(MSG_ERROR, "cannot become daemon, exiting"); - dhcpmsg_fini(); - return (EXIT_FAILURE); - } - - dhcpmsg_init(progname, is_daemon, is_verbose, debug_level); - (void) atexit(dhcpmsg_fini); - - /* - * Max out the number available descriptors since we need to - * allocate two per held lock. - */ - rl.rlim_cur = RLIM_INFINITY; - rl.rlim_max = RLIM_INFINITY; - if (setrlimit(RLIMIT_NOFILE, &rl) == -1) - dhcpmsg(MSG_ERR, "setrlimit failed"); - - (void) enable_extended_FILE_stdio(-1, -1); - - if (enumerate_dd(&modules, &nmodules) != DSVC_SUCCESS) { - dhcpmsg(MSG_ERROR, "cannot enumerate public modules, exiting"); - return (EXIT_FAILURE); - } - - /* - * NOTE: this code assumes that a module that needs dsvclockd will - * always need it (even as the container version is ramped). If - * this becomes bogus in a future release, we'll have to make this - * logic more sophisticated. - */ - nsynchmods = nmodules; - for (i = 0; i < nmodules; i++) { - dd.d_resource = modules[i]; - dd.d_conver = DSVC_CUR_CONVER; - dd.d_location = ""; - if (module_synchtype(&dd, &synchtype) != DSVC_SUCCESS) { - dhcpmsg(MSG_WARNING, "cannot determine synchronization " - "type for `%s', skipping", modules[i]); - free(modules[i]); - modules[i] = NULL; - nsynchmods--; - continue; - } - if ((synchtype & DSVC_SYNCH_STRATMASK) != DSVC_SYNCH_DSVCD) { - free(modules[i]); - modules[i] = NULL; - nsynchmods--; - } - } - - if (nsynchmods == 0) { - dhcpmsg(MSG_INFO, "no public modules need synchronization"); - return (EXIT_SUCCESS); - } - - /* - * Allocate the datastore table; include one extra entry so that - * the table is NULL-terminated. - */ - ds_table = calloc(nsynchmods + 1, sizeof (dsvcd_datastore_t *)); - if (ds_table == NULL) { - dhcpmsg(MSG_ERR, "cannot allocate datastore table, exiting"); - return (EXIT_FAILURE); - } - ds_table[nsynchmods] = NULL; - - /* - * Create the datastores (which implicitly creates the doors). - * then sit around and wait for requests to come in on the doors. - */ - for (i = 0, j = 0; i < nmodules; i++) { - if (modules[i] != NULL) { - ds_table[j] = ds_create(modules[i], svc_lock); - if (ds_table[j] == NULL) { - while (j-- > 0) - ds_destroy(ds_table[j]); - return (EXIT_FAILURE); - } - free(modules[i]); - j++; - } - } - free(modules); - - stackbase = stack_create(&stacksize); - if (stackbase == NULL) - dhcpmsg(MSG_ERR, "cannot create reaper stack; containers " - "will not be reaped"); - else { - errno = thr_create(stackbase, stacksize, reaper, ds_table, - THR_DAEMON, NULL); - if (errno != 0) { - dhcpmsg(MSG_ERR, "cannot create reaper thread; " - "containers will not be reaped"); - stack_destroy(stackbase, stacksize); - } - } - - /* - * Synchronously wait for a QUIT, TERM, or INT, then shutdown. - */ - (void) sigemptyset(&sigset); - (void) sigaddset(&sigset, SIGQUIT); - (void) sigaddset(&sigset, SIGTERM); - (void) sigaddset(&sigset, SIGINT); - - (void) sigwait(&sigset, &sig); - if (sig != SIGTERM && sig != SIGQUIT && sig != SIGINT) - dhcpmsg(MSG_WARNING, "received unexpected signal"); - - if (sig2str(sig, signame) == -1) - (void) strlcpy(signame, "???", sizeof (signame)); - - dhcpmsg(MSG_INFO, "shutting down via SIG%s", signame); - - for (i = 0; i < nsynchmods; i++) - ds_destroy(ds_table[i]); - - return (EXIT_SUCCESS); -} - -/* - * Sanity check that dsvcd_request_t `req' (which is `reqsize' bytes long) - * is a correctly formed request; if not, return an error which will be - * returned to the door caller. - */ -static int -check_door_req(dsvcd_request_t *req, size_t reqsize, size_t minsize) -{ - door_cred_t cred; - - if (req == NULL) { - dhcpmsg(MSG_WARNING, "empty request, ignoring"); - return (DSVC_SYNCH_ERR); - } - - /* - * Check credentials; we don't allow any non-super-user requests - * since this would open a denial-of-service hole (since a lock - * could be checked out indefinitely). - */ - if (door_cred(&cred) != 0) { - dhcpmsg(MSG_WARNING, "request with unknown credentials"); - return (DSVC_ACCESS); - } - - if (cred.dc_euid != 0) { - dhcpmsg(MSG_WARNING, "request with non-super-user credentials"); - return (DSVC_ACCESS); - } - - /* - * Check the version and size; we check this before checking the - * size of the request structure since an "incompatible version" - * message is more helpful than a "short request" message. - */ - if (reqsize > offsetof(dsvcd_request_t, rq_version) && - req->rq_version != DSVCD_DOOR_VERSION) { - dhcpmsg(MSG_WARNING, "request with unsupported version `%d'", - req->rq_version); - return (DSVC_SYNCH_ERR); - } - - if (reqsize < minsize) { - dhcpmsg(MSG_VERBOSE, "short request (%d bytes, minimum %d " - "bytes)", reqsize, minsize); - return (DSVC_SYNCH_ERR); - } - - return (DSVC_SUCCESS); -} - - -/* - * Service a lock request `req' passed across the door for datastore `ds'. - * After verifying that the request is well-formed, locks the container and - * creates an "unlock" door descriptor that the client uses to unlock the - * door (either explicitly through door_call()) or implicitly through - * terminating abnormally). - */ -/* ARGSUSED */ -static void -svc_lock(void *cookie, dsvcd_request_t *req, size_t reqsize, - door_desc_t *doorp, uint_t ndoors) -{ - dsvcd_reply_t reply; - door_desc_t door_desc; - dsvcd_lock_request_t *lreq = (dsvcd_lock_request_t *)req; - dsvcd_datastore_t *ds = (dsvcd_datastore_t *)cookie; - dsvcd_container_t *cn; - dsvcd_unlock_desc_t *ud; - char conid[MAXPATHLEN]; - unsigned int attempts = 0; - - reply.rp_version = DSVCD_DOOR_VERSION; - reply.rp_retval = check_door_req(req, reqsize, - sizeof (dsvcd_lock_request_t)); - if (reply.rp_retval != DSVC_SUCCESS) { - (void) door_return((char *)&reply, sizeof (reply), NULL, 0); - return; - } - - /* - * Verify that this is a lock request; if in the future we support - * other requests, we'll have to abstract this a bit. - */ - if (req->rq_reqtype != DSVCD_LOCK) { - dhcpmsg(MSG_WARNING, "unsupported request `%d' on lock " - "request door", req->rq_reqtype); - reply.rp_retval = DSVC_SYNCH_ERR; - (void) door_return((char *)&reply, sizeof (reply), NULL, 0); - return; - } - if (lreq->lrq_locktype != DSVCD_RDLOCK && - lreq->lrq_locktype != DSVCD_WRLOCK) { - dhcpmsg(MSG_WARNING, "request for unsupported locktype `%d'", - lreq->lrq_locktype); - reply.rp_retval = DSVC_SYNCH_ERR; - (void) door_return((char *)&reply, sizeof (reply), NULL, 0); - return; - } - - /* - * Find the container; create if it doesn't already exist. We do - * this as a single operation to avoid race conditions. - */ - (void) snprintf(conid, sizeof (conid), "%s/%s%d_%s", lreq->lrq_loctoken, - ds->ds_name, lreq->lrq_conver, lreq->lrq_conname); - cn = ds_get_container(ds, conid, lreq->lrq_crosshost); - if (cn == NULL) { - reply.rp_retval = DSVC_NO_MEMORY; - (void) door_return((char *)&reply, sizeof (reply), NULL, 0); - return; - } - - /* - * We need another door descriptor which is passed back with the - * request. This descriptor is used when the caller wants to - * gracefully unlock or when the caller terminates abnormally. - */ - ud = ud_create(cn, &reply.rp_retval); - if (ud == NULL) { - ds_release_container(ds, cn); - (void) door_return((char *)&reply, sizeof (reply), NULL, 0); - return; - } - - /* - * We pass a duped door descriptor with the DOOR_RELEASE flag set - * instead of just passing the descriptor itself to handle the case - * where the client has gone away before we door_return(). Since - * we duped, the door descriptor itself will have a refcount of 2 - * when we go to pass it to the client; if the client does not - * exist, the DOOR_RELEASE will drop the count from 2 to 1 which - * will cause a DOOR_UNREF_DATA call. - * - * In the regular (non-error) case, the door_return() will handoff - * the descriptor to the client, bumping the refcount to 3, and - * then the DOOR_RELEASE will drop the count to 2. If the client - * terminates abnormally after this point, the count will drop from - * 2 to 1 which will cause a DOOR_UNREF_DATA call. If the client - * unlocks gracefully, the refcount will still be 2 when the unlock - * door server procedure is called, and the unlock procedure will - * unlock the lock and note that the lock has been unlocked (so - * that we know the DOOR_UNREF_DATA call generated from the client - * subsequently closing the unlock descriptor is benign). - * - * Note that a DOOR_UNREF_DATA call will be generated *any time* - * the refcount goes from 2 to 1 -- even if *we* cause it to - * happen, which by default will happen in some of the error logic - * below (when we close the duped descriptor). To prevent this - * scenario, we tell ud_destroy() *not* to cache the unlock - * descriptor, which forces it to blow away the descriptor using - * door_revoke(), making the close() that follows benign. - */ - door_desc.d_attributes = DOOR_DESCRIPTOR|DOOR_RELEASE; - door_desc.d_data.d_desc.d_descriptor = dup(ud->ud_fd); - if (door_desc.d_data.d_desc.d_descriptor == -1) { - dhcpmsg(MSG_ERR, "cannot dup unlock door; denying %s " - "lock request", cn->cn_id); - ud_destroy(ud, B_TRUE); - ds_release_container(ds, cn); - reply.rp_retval = DSVC_NO_RESOURCES; - (void) door_return((char *)&reply, sizeof (reply), NULL, 0); - return; - } - - /* - * Acquire the actual read or write lock on the container. - */ - dhcpmsg(MSG_DEBUG, "tid %d: %s locking %s", thr_self(), - lreq->lrq_locktype == DSVCD_RDLOCK ? "read" : "write", cn->cn_id); - - if (lreq->lrq_locktype == DSVCD_RDLOCK) - reply.rp_retval = cn_rdlock(cn, lreq->lrq_nonblock); - else if (lreq->lrq_locktype == DSVCD_WRLOCK) - reply.rp_retval = cn_wrlock(cn, lreq->lrq_nonblock); - - dhcpmsg(MSG_DEBUG, "tid %d: %s %s lock operation: %s", thr_self(), - cn->cn_id, lreq->lrq_locktype == DSVCD_RDLOCK ? "read" : "write", - dhcpsvc_errmsg(reply.rp_retval)); - - ds_release_container(ds, cn); - if (reply.rp_retval != DSVC_SUCCESS) { - ud_destroy(ud, B_FALSE); - (void) close(door_desc.d_data.d_desc.d_descriptor); - (void) door_return((char *)&reply, sizeof (reply), NULL, 0); - return; - } - - while (door_return((char *)&reply, sizeof (reply), &door_desc, 1) - == -1 && errno == EMFILE) { - if (lreq->lrq_nonblock) { - dhcpmsg(MSG_WARNING, "unable to grant lock; client" - " is out of file descriptors"); - (void) cn_unlock(cn); - ud_destroy(ud, B_FALSE); - (void) close(door_desc.d_data.d_desc.d_descriptor); - reply.rp_retval = DSVC_BUSY; - (void) door_return((char *)&reply, sizeof (reply), - NULL, 0); - return; - } - - if (attempts++ == 0) { - dhcpmsg(MSG_WARNING, "unable to grant lock; client" - " is out of file descriptors (retrying)"); - } - (void) poll(NULL, 0, 100); - } -} - -/* - * Service an unlock request `req' passed across the door associated with - * the unlock token `cookie'. We may be called explicitly (in which case - * the request is a well-formed dsvcd_request_t) or implicitly (in which - * case our request is set to the value DOOR_UNREF_DATA); this latter case - * occurs when a process holding a lock terminates. In either case, unlock - * the lock; in the implicit case, log a message as well. - */ -/* ARGSUSED */ -static void -svc_unlock(void *cookie, dsvcd_request_t *req, size_t reqsize, - door_desc_t *doorp, uint_t ndoors) -{ - dsvcd_unlock_desc_t *ud = cookie; - dsvcd_container_t *cn; - dsvcd_reply_t reply; - - /* - * Although unlock descriptors are handed out to only a single - * thread who has been granted a lock (ergo it seems that only one - * thread should be able to call us back), there's a potential race - * here if the process crashes while in this door_call(), since - * both this thread and the unref kernel upcall thread may run at - * the same time. Protect against this case with a mutex. - */ - (void) mutex_lock(&ud->ud_lock); - cn = ud->ud_cn; - - /* - * First handle the case where the lock owner has closed the unlock - * descriptor, either because they have unlocked the lock and are - * thus done using the descriptor, or because they crashed. In the - * second case, print a message. - */ - if (req == DOOR_UNREF_DATA) { - /* - * The last reference is ours; we can free the descriptor. - */ - (void) mutex_unlock(&ud->ud_lock); - ud_destroy(ud, B_TRUE); - - /* - * Normal case: the caller is closing the unlock descriptor - * on a lock they've already unlocked -- just return. - */ - if (cn == NULL) { - (void) door_return(NULL, 0, NULL, 0); - return; - } - - /* - * Error case: the caller has crashed while holding the - * unlock descriptor (or is otherwise in violation of - * protocol). Since all datastores are required to be - * robust even if unexpected termination occurs, we assume - * the container is not corrupt, even if the process - * crashed with the write lock held. - */ - switch (cn_locktype(cn)) { - case DSVCD_RDLOCK: - dhcpmsg(MSG_WARNING, "process exited while reading " - "`%s'; unlocking", cn->cn_id); - (void) cn_unlock(cn); - break; - - case DSVCD_WRLOCK: - dhcpmsg(MSG_WARNING, "process exited while writing " - "`%s'; unlocking", cn->cn_id); - dhcpmsg(MSG_WARNING, "note that this write operation " - "may or may not have succeeded"); - (void) cn_unlock(cn); - break; - - case DSVCD_NOLOCK: - dhcpmsg(MSG_CRIT, "unreferenced unheld lock"); - break; - } - - (void) door_return(NULL, 0, NULL, 0); - return; - } - - /* - * Verify that this is a unlock request; if in the future we support - * other requests, we'll have to abstract this a bit. - */ - reply.rp_version = DSVCD_DOOR_VERSION; - reply.rp_retval = check_door_req(req, reqsize, - sizeof (dsvcd_unlock_request_t)); - if (reply.rp_retval != DSVC_SUCCESS) { - (void) mutex_unlock(&ud->ud_lock); - (void) door_return((char *)&reply, sizeof (reply), NULL, 0); - return; - } - - if (req->rq_reqtype != DSVCD_UNLOCK) { - dhcpmsg(MSG_WARNING, "unsupported request `%d' on unlock " - "request door", req->rq_reqtype); - (void) mutex_unlock(&ud->ud_lock); - reply.rp_retval = DSVC_SYNCH_ERR; - (void) door_return((char *)&reply, sizeof (reply), NULL, 0); - return; - } - - /* - * Attempt to unlock an already-unlocked container; log and return. - */ - if (cn == NULL) { - dhcpmsg(MSG_WARNING, "process tried to re-unlock a lock"); - (void) mutex_unlock(&ud->ud_lock); - reply.rp_retval = DSVC_SYNCH_ERR; - (void) door_return((char *)&reply, sizeof (reply), NULL, 0); - return; - } - ud->ud_cn = NULL; - - /* - * Unlock the container; note that after cn_unlock() has been done - * cn->cn_id is no longer accessible. - */ - dhcpmsg(MSG_DEBUG, "tid %d: unlocking %s", thr_self(), cn->cn_id); - reply.rp_retval = cn_unlock(cn); - dhcpmsg(MSG_DEBUG, "tid %d: unlock operation: %s", thr_self(), - dhcpsvc_errmsg(reply.rp_retval)); - - /* - * Even though we've unlocked the lock, we cannot yet destroy the - * unlock descriptor (even if we revoke the door) because it's - * possible the unref thread is already waiting on ud_lock. - */ - (void) mutex_unlock(&ud->ud_lock); - (void) door_return((char *)&reply, sizeof (reply), NULL, 0); -} - -/* - * Reap containers that have not been recently used. - */ -static void * -reaper(void *ds_table_raw) -{ - dsvcd_datastore_t **ds_table; - unsigned int i, nreaped; - - ds_table = (dsvcd_datastore_t **)ds_table_raw; - for (;;) { - (void) sleep(DSVCD_REAP_INTERVAL); - for (i = 0; ds_table[i] != NULL; i++) { - nreaped = ds_reap_containers(ds_table[i], - DSVCD_REAP_THRESH); - if (nreaped > 0) { - dhcpmsg(MSG_VERBOSE, "reaped %u container " - "synchpoints from %s", nreaped, - ds_table[i]->ds_name); - } - } - } - /* NOTREACHED */ - return (NULL); -} - -/* - * Daemonize the process. - */ -static int -daemonize(void) -{ - switch (fork()) { - - case -1: - return (0); - - case 0: - /* - * Lose our controlling terminal, and become both a session - * leader and a process group leader. - */ - if (setsid() == -1) - return (0); - - /* - * Under POSIX, a session leader can accidentally (through - * open(2)) acquire a controlling terminal if it does not - * have one. Just to be safe, fork() again so we are not a - * session leader. - */ - switch (fork()) { - - case -1: - return (0); - - case 0: - (void) signal(SIGHUP, SIG_IGN); - (void) chdir("/"); - (void) umask(022); - closefrom(0); - break; - - default: - _exit(EXIT_SUCCESS); - } - break; - - default: - _exit(EXIT_SUCCESS); - } - - return (1); -} - -/* - * Create an unlock descriptor for container `cn' -- returns an unlock - * descriptor on success, or NULL on failure; the reason for failure is in - * `retvalp'. Since creating door descriptors is expensive, we keep a few - * cache a small list of old descriptors around on a reclaim list and only - * allocate a new one if the list is empty. - */ -static dsvcd_unlock_desc_t * -ud_create(dsvcd_container_t *cn, int *retvalp) -{ - dsvcd_unlock_desc_t *ud; - - *retvalp = DSVC_SUCCESS; - (void) mutex_lock(&ud_reclaim_lock); - if (ud_reclaim_list != NULL) { - ud = ud_reclaim_list; - ud_reclaim_list = ud->ud_next; - ud_reclaim_count--; - (void) mutex_unlock(&ud_reclaim_lock); - } else { - (void) mutex_unlock(&ud_reclaim_lock); - ud = malloc(sizeof (dsvcd_unlock_desc_t)); - if (ud == NULL) { - dhcpmsg(MSG_WARNING, "cannot allocate unlock door " - "descriptor; denying %s lock request", cn->cn_id); - *retvalp = DSVC_NO_MEMORY; - return (NULL); - } - - (void) mutex_init(&ud->ud_lock, USYNC_THREAD, NULL); - ud->ud_fd = door_create((void (*)())svc_unlock, ud, - DOOR_UNREF_MULTI | DOOR_REFUSE_DESC | DOOR_NO_CANCEL); - if (ud->ud_fd == -1) { - dhcpmsg(MSG_WARNING, "cannot create unlock door; " - "denying %s lock request", cn->cn_id); - free(ud); - *retvalp = DSVC_NO_RESOURCES; - return (NULL); - } - } - - ud->ud_next = NULL; - ud->ud_cn = cn; - return (ud); -} - -/* - * Destroy the unlock descriptor `ud' -- `ud' must be unlocked on entry. - * If there's room and `cacheable' is set, then, keep the unlock descriptor - * on the reclaim list to lower future creation cost. - */ -static void -ud_destroy(dsvcd_unlock_desc_t *ud, boolean_t cacheable) -{ - assert(!MUTEX_HELD(&ud->ud_lock)); - - ud->ud_cn = NULL; - (void) mutex_lock(&ud_reclaim_lock); - if (cacheable && ud_reclaim_count < UD_RECLAIM_MAX) { - ud->ud_next = ud_reclaim_list; - ud_reclaim_list = ud; - ud_reclaim_count++; - (void) mutex_unlock(&ud_reclaim_lock); - } else { - (void) mutex_unlock(&ud_reclaim_lock); - (void) door_revoke(ud->ud_fd); - (void) mutex_destroy(&ud->ud_lock); - free(ud); - } -} - -/* - * Create a stack of `*stacksizep' bytes (rounded up to the nearest page) - * including a redzone for catching stack overflow. Set `stacksizep' to - * point to the actual usable size of the stack (i.e., everything but the - * redzone). Returns a pointer to the base of the stack (not including the - * redzone). - */ -static void * -stack_create(unsigned int *stacksizep) -{ - caddr_t stackbase; - unsigned int redzone = roundup(DSVCD_STACK_REDSIZE, PAGESIZE); - unsigned int stacksize = *stacksizep; - - if (stacksize < sysconf(_SC_THREAD_STACK_MIN)) - stacksize = sysconf(_SC_THREAD_STACK_MIN); - - stacksize = roundup(stacksize, PAGESIZE); - stackbase = mmap(NULL, stacksize + redzone, PROT_READ | PROT_WRITE, - MAP_ANON | MAP_PRIVATE, -1, 0); - if (stackbase == MAP_FAILED) - return (NULL); - - *stacksizep = stacksize; - (void) mprotect(stackbase, redzone, PROT_NONE); - return (stackbase + redzone); -} - -/* - * Destroy the stack of `stacksize' bytes pointed to by `stackbase'. - */ -static void -stack_destroy(void *stackbase, unsigned int stacksize) -{ - unsigned int redzone = roundup(DSVCD_STACK_REDSIZE, PAGESIZE); - - (void) munmap((caddr_t)stackbase - redzone, stacksize + redzone); -} - -/* - * Start function for door server threads; turns off thread cancellation - * and then parks in the kernel via door_return(). - */ -/* ARGSUSED */ -static void * -doorserv_thread(void *arg) -{ - (void) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); - (void) door_return(NULL, 0, NULL, 0); - return (NULL); -} - -/* - * Creation function for door server threads. We require door threads to - * have 32K of backed stack. This is a guess but will be more than - * sufficient for our uses, since door threads have a shallow call depth - * and the functions use little automatic storage. - */ -/* ARGSUSED */ -static void -doorserv_create(door_info_t *infop) -{ - void *stackbase; - unsigned int stacksize = 32 * 1024; - - stackbase = stack_create(&stacksize); - if (stackbase != NULL) { - errno = thr_create(stackbase, stacksize, doorserv_thread, NULL, - THR_BOUND | THR_DETACHED, NULL); - if (errno != 0) { - dhcpmsg(MSG_ERR, "cannot create door server thread; " - "server thread pool will not be grown"); - stack_destroy(stackbase, stacksize); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/dsvclockd.h b/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/dsvclockd.h deleted file mode 100644 index 688a6d316b..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/dsvclockd/dsvclockd.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef DSVCD_DSVCLOCKD_H -#define DSVCD_DSVCLOCKD_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/param.h> -#include <sys/types.h> - -/* - * Data structures and constants that are shared between dsvclockd and - * libdhcpsvc. This protocol is project-private and is thus subject to - * change at any time. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#define DSVCD_DOOR_VERSION 1 /* current protocol version */ -#define DSVCD_PATH "/usr/lib/inet/dsvclockd" -#define DSVCD_DOOR_FMT "/var/run/dsvclockd_%s_door" - -typedef enum { DSVCD_LOCK, DSVCD_UNLOCK } dsvcd_reqtype_t; -typedef enum { DSVCD_NOLOCK, DSVCD_RDLOCK, DSVCD_WRLOCK } dsvcd_locktype_t; - -typedef struct { - uint8_t rq_version; /* version of the API */ - dsvcd_reqtype_t rq_reqtype; /* request type */ -} dsvcd_request_t; - -typedef struct { - uint8_t rp_version; /* version of the API */ - int32_t rp_retval; /* DSVC_* return value */ -} dsvcd_reply_t; - -typedef struct { - dsvcd_request_t lrq_request; /* generic request header */ - dsvcd_locktype_t lrq_locktype; /* reader or writer */ - uint8_t lrq_nonblock; /* cannot block if true */ - uint8_t lrq_crosshost; /* do cross-host synch */ - - /* - * The caller filling in this request must provide their current - * container version and a name for their container which is - * per-datastore unique (but need not be unique across datastores - * or different versions of the same container.) - * - * The `lrq_loctoken' field must contain a token which "names" a - * given location where the container exists -- note that a given - * location must have exactly one name, though it's permissible for - * more than one location to have the same name (in this case, - * containers from these locations will be synchronized with one - * another, which will hamper performance). Note that standard - * pathnames do not meet the first constraint (e.g., /var/dhcp and - * /var/../var/dhcp are two different names for the same location), - * but pathnames processed by realpath(3C) do. - * - * If the caller wants cross-host synchronization, then - * `lrq_crosshost' must be set and `lrq_loctoken' must be a - * realpath(3C)'d directory that all hosts can access. - */ - int lrq_conver; - char lrq_conname[64]; - char lrq_loctoken[MAXPATHLEN]; -} dsvcd_lock_request_t; - -typedef struct { - dsvcd_request_t urq_request; /* generic request header */ -} dsvcd_unlock_request_t; - -#ifdef __cplusplus -} -#endif - -#endif /* DSVCD_DSVCLOCKD_H */ diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/Makefile b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/Makefile deleted file mode 100644 index 4b8b6a3678..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/cmd-inet/usr.lib/in.dhcpd/Makefile -# - -CMN_DIR = $(SRC)/common/net/dhcp -NSU_DIR = $(ROOTLIBINET)/dhcp/nsu - -PROG = in.dhcpd -MANIFEST= dhcp-server.xml - -LOCAL_OBJS = bootp.o dhcp.o dhcptab.o encode.o generic.o hash.o icmp.o \ - interfaces.o logging.o main.o misc.o per_dnet.o relay.o -LOCAL_SRCS = $(LOCAL_OBJS:%.o=%.c) - -CMN_OBJS = ipv4_sum.o -CMN_SRCS = $(CMN_OBJS:%.o=$(CMN_DIR)/%.c) - -SRCS = $(LOCAL_SRCS) $(CMN_SRCS) -OBJS = $(LOCAL_OBJS) $(CMN_OBJS) - -include ../../../Makefile.cmd - -ROOTMANIFESTDIR= $(ROOTSVCNETWORK) - -CPPFLAGS += -DNDEBUG -DNPROBE -D_REENTRANT -I./ -I$(CMN_DIR) -# -# -erroff=E_BAD_FORMAT_STR2 added to workaround bug 6696366 -# -LINTFLAGS += -u -erroff=E_BAD_FORMAT_STR2 -LDFLAGS += -L$(NSU_DIR) -R/usr/lib/inet/dhcp/nsu $(MAPFILE.NGB:%=-M%) -LDLIBS += $(NSU_DIR)/rfc2136.so.1 -ldhcpsvc -ldhcputil -linetutil \ - -lsocket -lnsl -lmtmalloc -lresolv -lint := LDLIBS = $(LDLIBS.cmd) -ldhcpsvc -ldhcputil -linetutil -lsocket -lnsl - -CERRWARN += -_gcc=-Wno-uninitialized -CERRWARN += -_gcc=-Wno-unused-label -CERRWARN += -_gcc=-Wno-parentheses - -# -# Debugging support; toggle on if needed. -# -#CPPFLAGS += -DDEBUG # if used, remove -DNDEBUG above -#CPPFLAGS += -DTNF_DEBUG -#COPTFLAG = -g -#COPTFLAG += -xprofile=func - -# for messaging catalog. No messages are present in CMN_DIR sources. -POFILES = $(LOCAL_OBJS:%.o=%.po) -XGETFLAGS += -a -x in.dhcpd.xcl - -.PARALLEL: $(OBJS) -.WAIT: $(PROG) -.KEEP_STATE: - -all: $(PROG) - -$(PROG): $(OBJS) $(MAPFILE.NGB) - $(LINK.c) $(OBJS) -o $@ $(LDLIBS) - $(POST_PROCESS) - -include ../Makefile.lib - -install: all $(ROOTLIBINETPROG) $(ROOTMANIFEST) - -%.o: $(CMN_DIR)/%.c - $(COMPILE.c) $(OUTPUT_OPTION) $< - $(POST_PROCESS_O) - -$(POFILE): $(POFILES) - $(RM) $@ - $(CAT) $(POFILES) > $@ - -check: $(CHKMANIFEST) - -clean: - $(RM) $(OBJS) - -lint: lint_SRCS - -include ../../../Makefile.targ diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/README.caching b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/README.caching deleted file mode 100644 index a8f9dad855..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/README.caching +++ /dev/null @@ -1,164 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -The DHCP server cache implementation -Zhenghui.Xie@sun.com - - -#ident "%Z%%M% %I% %E% SMI" - -INTRODUCTION -============ - -The Solaris DHCP server implements a caching mechanism to: - - * Ensure the ACK is consistent with the original OFFER, so that - subsequent requests get the same answer. - * Ensure the same IP address isn't offered to a different client. - * Improve performance by reducing the frequency of datastore lookups. - -IMPLEMENTATION OVERVIEW -======================= - -The cache implementation consists of a number of hash tables and lists, -enumerated below, along with a timeout and refresh mechanism: - - * A global DHCP table hash (ntable): - - Each active network table (dvsc_dnet_t) is hashed by subnet number - into a global hash called 'ntable'. The dsvc_dnet_t itself - contains a variety of information about each subnet, an access - handle to the underlying datastore, and a variety of caches which - we describe next. - - An ntable hash entry will be removed after DHCP_NET_THRESHOLD - seconds of inactivity. - - * A per-network client hash (ctable): - - Each client structure (dsvc_clnt_t) is hashed by client identifier - into the per-network ctable. This table is used by the interface - worker thread to get client information. - - A ctable hash entry will be removed if the client does not communicate - with the server for DHCP_CLIENT_THRESHOLD seconds. - - * A per-network offer hash (itable): - - The IP address associated with each pending OFFER is hashed into - the per-network itable. This table is used to reserve the offered - and in-use IP addresses on the given network. - - An itable hash entry will be removed if more than DSVC_CV_OFFER_TTL - seconds elapse without update_offer() being called on it. - - * A per-network free record list (freerec): - - This is a cache of free records, populated with any unused records - retrieved from previous datastore lookups or from IP addresses that - have been explicitly released by DHCP clients. This is the first - list select_offer() consults. - - An entry in the freerec list expires after DSVC_CV_CACHE_TTL seconds. - - * A per-network least recently used record list (lrurec) - - This is a cache of least recently used records, populated with any - unused records retrieved from a previous datastore lookup for - LRU records. This is the second list select_offer() consults, after - checking freerec. - - An entry in the lrurec list expires after DSVC_CV_CACHE_TTL seconds. - -The concurrency between the datastore and cached records is handled by the -underlying datastore implementation using perimeters and is transparent to -in.dhcpd. $SRC/lib/libdhcpsvc/private/{private.c,public.c} implement the -functions used by in.dhcpd and DHCP server admin tools to lookup and modify -the underlying datastore records. - -TRANSACTIONS -============ - -When in.dhcpd receives a packet from a client, the interface thread first -calls open_dnet() to retrieve the dsvc_dnet_t which describes the network. -The dsvc_dnet_t is either in the ntable hash, in which case it is returned, -or a new dsvc_dnet_t is allocated and inserted to ntable. Then, using the -dsvc_dnet_t, the interface thread calls open_clnt(), which searches the -dsvc_dnet_t's ctable hash and returns the client structure (dsvc_clnt_t) if -found. Otherwise, a new dsvc_clnt_t is allocated and inserted into the -ctable. Finally, the packet is put to the client's packet list so that the -client thread can process it. - -The client thread then processes the packet according to whether it's a -DISCOVER, REQUEST, RELEASE, or DECLINE. - -For a DISCOVER: - - 1. If there is a pre-assigned IP for this client and the cached offer - is not timed out, then use the IP and the record in the - dsvc_clnt_t and make an OFFER. - - 2. If there is a pre-assigned IP but the cached offer is expired, - remove the cached OFFER from the itable, and try to find a new - record for the client (see below). - - 3. If there is no pre-assigned IP for this client, just try to find - a new record for the client (see following text). - - To find a new record, the client thread first searches the datastore - for a record matching the client identifier provided in the packet. - If none is found, then the free record list (freerec) and least - recently used record list (lrurec) are searched, in that order. If - either freerec or lrurec is empty, or the head record on either list - is expired, in.dhcpd removes any existing records and attempts to - repopulate them by performing datastore lookups. Finally, any - unused records are cached for later use. - - If a usable record is found, the server generates and sends an OFFER - to the client. Once sent, the client's dsvc_clnt_t is inserted to - the dsvc_dnet_t's itable if it is a new IP, or the itable is refreshed - if it is a pre-assigned IP. - -For a REQUEST: - - 1. If the REQUEST is a reply to a previous OFFER, it checks if the - OFFER has expired. If not, the itable timer is reset, the client - record is updated, and the ACK is sent. If it is expired and the - address cannot be confirmed to still be free, the REQUEST is - silently ignored (and the client should eventually drop back - to DISCOVER). - - 2. If the REQUEST is associated with a client INIT-REBOOT or a client - extending a lease, then the client thread does a datastore lookup - by client identifier. If a match is found, the record is updated - and an ACK is sent. - -If the packet is a RELEASE, the client thread modifies the record in the -datastore so that it is marked free, and, if successful, puts the record onto -the free record list (freerec). - -Finally, if the packet is a DECLINE, the client thread modifies the record in -the datastore so that it is marked unusable. diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/THIRDPARTYLICENSE b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/THIRDPARTYLICENSE deleted file mode 100644 index 89526f8fee..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/THIRDPARTYLICENSE +++ /dev/null @@ -1,19 +0,0 @@ - * Copyright 1988, 1991 by Carnegie Mellon University - * - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Carnegie Mellon University not be used - * in advertising or publicity pertaining to distribution of the software - * without specific, written prior permission. - * - * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. - * IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF - * THIS SOFTWARE. diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/THIRDPARTYLICENSE.descrip b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/THIRDPARTYLICENSE.descrip deleted file mode 100644 index 7d54fbb275..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/THIRDPARTYLICENSE.descrip +++ /dev/null @@ -1 +0,0 @@ -DHCP SERVER SOFTWARE diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/bootp.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/bootp.c deleted file mode 100644 index c74aab4504..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/bootp.c +++ /dev/null @@ -1,406 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <stdarg.h> -#include <sys/types.h> -#include <errno.h> -#include <assert.h> -#include <string.h> -#include <syslog.h> -#include <sys/socket.h> -#include <net/if.h> -#include <netinet/in.h> -#include <netinet/if_ether.h> -#include <arpa/inet.h> -#include <nss_dbdefs.h> -#include <netinet/dhcp.h> -#include <netdb.h> -#include <dhcp_symbol.h> -#include "dhcpd.h" -#include "per_dnet.h" -#include "interfaces.h" -#include <locale.h> - -/* - * This file contains the code which implements the BOOTP compatibility. - */ - -/* - * We are guaranteed that the packet received is a BOOTP request packet, - * e.g., *NOT* a DHCP packet. - */ -void -bootp(dsvc_clnt_t *pcd, PKT_LIST *plp) -{ - boolean_t result, existing_offer = B_FALSE; - int err, write_error = DSVC_SUCCESS, flags = 0; - int pkt_len; - uint_t crecords = 0, irecords = 0, srecords = 0, clen; - uint32_t query; - PKT *rep_pktp = NULL; - IF *ifp = pcd->ifp; - dsvc_dnet_t *pnd = pcd->pnd; - uchar_t *optp; - dn_rec_t dn, ndn, *dnp; - dn_rec_list_t *dncp = NULL, *dnip = NULL, *dnlp = NULL; - struct in_addr ciaddr; - struct in_addr no_ip; /* network order IP */ - ENCODE *ecp, *hecp; - MACRO *mp, *nmp, *cmp; - time_t now = time(NULL); - DHCP_MSG_CATEGORIES log; - struct hostent h, *hp; - char ntoab[INET_ADDRSTRLEN], cipbuf[INET_ADDRSTRLEN]; - char cidbuf[DHCP_MAX_OPT_SIZE]; - char hbuf[NSS_BUFLEN_HOSTS]; - - ciaddr.s_addr = htonl(INADDR_ANY); - -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, "BOOTP request received on %s\n", ifp->nm); -#endif /* DEBUG */ - - if (pcd->off_ip.s_addr != htonl(INADDR_ANY) && - PCD_OFFER_TIMEOUT(pcd, now)) - purge_offer(pcd, B_TRUE, B_TRUE); - - if (pcd->off_ip.s_addr != htonl(INADDR_ANY)) { - existing_offer = B_TRUE; - dnlp = pcd->dnlp; - assert(dnlp != NULL); - dnp = dnlp->dnl_rec; - no_ip.s_addr = htonl(dnp->dn_cip.s_addr); - crecords = 1; - } else { - /* - * Try to find a CID entry for the client. We don't care about - * lease info here, since a BOOTP client always has a permanent - * lease. We also don't care about the entry owner either, - * unless we end up allocating a new entry for the client. - */ - DSVC_QINIT(query); - - DSVC_QEQ(query, DN_QCID); - (void) memcpy(dn.dn_cid, pcd->cid, pcd->cid_len); - dn.dn_cid_len = pcd->cid_len; - - DSVC_QEQ(query, DN_QFBOOTP_ONLY); - dn.dn_flags = DN_FBOOTP_ONLY; - - /* - * If a client address (ciaddr) is given, we simply trust that - * the client knows what it's doing, and we use that IP address - * to locate the client's record. If we can't find the client's - * record, then we keep silent. If the client id of the record - * doesn't match this client, then either the client or our - * database is inconsistent, and we'll ignore it (notice - * message generated). - */ - ciaddr.s_addr = plp->pkt->ciaddr.s_addr; - if (ciaddr.s_addr != htonl(INADDR_ANY)) { - DSVC_QEQ(query, DN_QCIP); - dn.dn_cip.s_addr = ntohl(ciaddr.s_addr); - } - - dnlp = dhcp_lookup_dd_classify(pcd->pnd, B_FALSE, query, - -1, &dn, (void **)&dncp, S_CID); - if (dnlp != NULL) { - crecords = 1; - dnp = dnlp->dnl_rec; - if (dnp->dn_flags & DN_FUNUSABLE) - goto leave_bootp; - no_ip.s_addr = htonl(dnp->dn_cip.s_addr); - } - } - - (void) inet_ntop(AF_INET, &no_ip, cipbuf, sizeof (cipbuf)); - - if (crecords == 0 && !be_automatic) { - if (verbose) { - dhcpmsg(LOG_INFO, "BOOTP client: %1$s is looking for " - "a configuration on net %2$s\n", pcd->cidbuf, - pnd->network); - } - goto leave_bootp; - } - - /* - * If the client thinks it knows who it is (ciaddr), and this doesn't - * match our registered IP address, then display an error message and - * give up. - */ - if (ciaddr.s_addr != htonl(INADDR_ANY) && crecords == 0) { - /* - * If the client specified an IP address, then let's check - * whether it is available, since we have no CID mapping - * registered for this client. If it is available and - * unassigned but owned by a different server, we ignore the - * client. - */ - DSVC_QINIT(query); - - DSVC_QEQ(query, DN_QCIP); - dn.dn_cip.s_addr = ntohl(ciaddr.s_addr); - (void) inet_ntop(AF_INET, &ciaddr, cipbuf, sizeof (cipbuf)); - - DSVC_QEQ(query, DN_QFBOOTP_ONLY); - dn.dn_flags = DN_FBOOTP_ONLY; - - dnip = NULL; - dnlp = dhcp_lookup_dd_classify(pcd->pnd, B_FALSE, query, - -1, &dn, (void **)&dncp, S_CID); - if (dnlp == NULL) { - /* - * We have no record of this client's IP address, thus - * we really can't respond to this client, because it - * doesn't have a configuration. - */ - if (verbose) { - dhcpmsg(LOG_INFO, "No configuration for BOOTP " - "client: %1$s. IP address: %2$s not " - "administered by this server.\n", - pcd->cidbuf, inet_ntop(AF_INET, &ciaddr, - ntoab, sizeof (ntoab))); - } - goto leave_bootp; - } else - irecords = 1; - - dnp = dnlp->dnl_rec; - if (dnp->dn_flags & DN_FUNUSABLE) - goto leave_bootp; - - if (dn.dn_cid_len != 0) { - if (dn.dn_cid_len != pcd->cid_len || memcmp(dn.dn_cid, - pcd->cid, pcd->cid_len) != 0) { - if (verbose) { - clen = sizeof (cidbuf); - (void) octet_to_hexascii(dn.dn_cid, - dn.dn_cid_len, cidbuf, &clen); - dhcpmsg(LOG_INFO, "BOOTP client: %1$s " - "thinks it owns %2$s, but that " - "address belongs to %3$s. Ignoring " - "client.\n", pcd->cidbuf, cipbuf, - cidbuf); - } - goto leave_bootp; - } - } else { - if (match_ownerip(htonl(dn.dn_sip.s_addr)) == NULL) { - if (verbose) { - no_ip.s_addr = - htonl(dnp->dn_sip.s_addr); - dhcpmsg(LOG_INFO, "BOOTP client: %1$s " - "believes it owns %2$s. That " - "address is free, but is owned by " - "DHCP server %3$s. Ignoring " - "client.\n", pcd->cidbuf, cipbuf, - inet_ntop(AF_INET, &no_ip, ntoab, - sizeof (ntoab))); - } - goto leave_bootp; - } - } - no_ip.s_addr = htonl(dnp->dn_cip.s_addr); - (void) inet_ntop(AF_INET, &no_ip, cipbuf, sizeof (cipbuf)); - } - - if (crecords == 0) { - /* - * The dhcp-network table did not have any matching entries. - * Try to allocate a new one if possible. - */ - if (irecords == 0 && select_offer(pnd, plp, pcd, &dnlp)) { - dnp = dnlp->dnl_rec; - no_ip.s_addr = htonl(dnp->dn_cip.s_addr); - (void) inet_ntop(AF_INET, &no_ip, cipbuf, - sizeof (cipbuf)); - srecords = 1; - } - } - - if (crecords == 0 && irecords == 0 && srecords == 0) { - dhcpmsg(LOG_NOTICE, - "(%1$s) No more BOOTP IP addresses for %2$s network.\n", - pcd->cidbuf, pnd->network); - goto leave_bootp; - } - - /* Check the address. But only if client doesn't know its address. */ - ndn = *dnp; /* struct copy */ - no_ip.s_addr = htonl(ndn.dn_cip.s_addr); - (void) inet_ntop(AF_INET, &no_ip, cipbuf, sizeof (cipbuf)); - if (ciaddr.s_addr == htonl(INADDR_ANY)) { - if ((ifp->flags & IFF_NOARP) == 0) - (void) set_arp(ifp, &no_ip, NULL, 0, DHCP_ARP_DEL); - if (!noping) { - /* - * If icmp echo check fails, - * let the plp fall by the wayside. - */ - errno = icmp_echo_check(&no_ip, &result); - if (errno != 0) { - dhcpmsg(LOG_ERR, "ICMP ECHO check cannot be " - "performed for: %s, ignoring\n", cipbuf); - goto leave_bootp; - } - if (result) { - dhcpmsg(LOG_ERR, "ICMP ECHO reply to BOOTP " - "OFFER candidate: %s, disabling.\n", - cipbuf); - - ndn.dn_flags |= DN_FUNUSABLE; - - if ((err = dhcp_modify_dd_entry(pnd->dh, - dnp, &ndn)) == DSVC_SUCCESS) { - /* Keep the cached entry current. */ - *dnp = ndn; /* struct copy */ - } - - logtrans(P_BOOTP, L_ICMP_ECHO, 0, no_ip, - server_ip, plp); - - goto leave_bootp; - } - } - } - - /* - * It is possible that the client could specify a REQUEST list, - * but then it would be a DHCP client, wouldn't it? Only copy the - * std option list, since that potentially could be changed by - * load_options(). - */ - ecp = NULL; - if (!no_dhcptab) { - open_macros(); - if ((nmp = get_macro(pnd->network)) != NULL) - ecp = dup_encode_list(nmp->head); - if ((mp = get_macro(dnp->dn_macro)) != NULL) - ecp = combine_encodes(ecp, mp->head, ENC_DONT_COPY); - if ((cmp = get_macro(pcd->cidbuf)) != NULL) - ecp = combine_encodes(ecp, cmp->head, ENC_DONT_COPY); - - /* If dhcptab configured to return hostname, do so. */ - if (find_encode(ecp, DSYM_INTERNAL, CD_BOOL_HOSTNAME) != - NULL) { - hp = gethostbyaddr_r((char *)&ndn.dn_cip, - sizeof (struct in_addr), AF_INET, &h, hbuf, - sizeof (hbuf), &err); - if (hp != NULL) { - hecp = make_encode(DSYM_STANDARD, - CD_HOSTNAME, strlen(hp->h_name), - hp->h_name, ENC_COPY); - replace_encode(&ecp, hecp, ENC_DONT_COPY); - } - } - } - - /* Produce a BOOTP reply. */ - rep_pktp = gen_bootp_pkt(sizeof (PKT), plp->pkt); - - rep_pktp->op = BOOTREPLY; - optp = rep_pktp->options; - - /* - * Set the client's "your" IP address if client doesn't know it, - * otherwise echo the client's ciaddr back to him. - */ - if (ciaddr.s_addr == htonl(INADDR_ANY)) - rep_pktp->yiaddr.s_addr = htonl(ndn.dn_cip.s_addr); - else - rep_pktp->ciaddr.s_addr = ciaddr.s_addr; - - /* - * Omit lease time options implicitly, e.g. - * ~(DHCP_DHCP_CLNT | DHCP_SEND_LEASE) - */ - - if (!plp->rfc1048) - flags |= DHCP_NON_RFC1048; - - /* Now load in configured options. */ - pkt_len = load_options(flags, plp, rep_pktp, sizeof (PKT), optp, ecp, - NULL); - - free_encode_list(ecp); - if (!no_dhcptab) - close_macros(); - - if (pkt_len < sizeof (PKT)) - pkt_len = sizeof (PKT); - - /* - * Only perform a write if we have selected an entry not yet - * assigned to the client (a matching DN_FBOOTP_ONLY entry from - * ip address lookup, or an unassigned entry from select_offer()). - */ - if (srecords > 0 || irecords > 0) { - (void) memcpy(&ndn.dn_cid, pcd->cid, pcd->cid_len); - ndn.dn_cid_len = pcd->cid_len; - - write_error = dhcp_modify_dd_entry(pnd->dh, dnp, &ndn); - - /* Keep state of the cached entry current. */ - *dnp = ndn; /* struct copy */ - - log = L_ASSIGN; - } else { - if (verbose) { - dhcpmsg(LOG_INFO, "Database write unnecessary for " - "BOOTP client: %1$s, %2$s\n", - pcd->cidbuf, cipbuf); - } - log = L_REPLY; - } - - if (write_error == DSVC_SUCCESS) { - if (send_reply(ifp, rep_pktp, pkt_len, &no_ip) != 0) { - dhcpmsg(LOG_ERR, - "Reply to BOOTP client %1$s with %2$s failed.\n", - pcd->cidbuf, cipbuf); - } else { - /* Note that the conversation has completed. */ - pcd->state = ACK; - - (void) update_offer(pcd, &dnlp, 0, &no_ip, B_TRUE); - existing_offer = B_TRUE; - } - - logtrans(P_BOOTP, log, ndn.dn_lease, no_ip, server_ip, plp); - } - -leave_bootp: - if (rep_pktp != NULL) - free(rep_pktp); - if (dncp != NULL) - dhcp_free_dd_list(pnd->dh, dncp); - if (dnip != NULL) - dhcp_free_dd_list(pnd->dh, dnip); - if (dnlp != NULL && !existing_offer) - dhcp_free_dd_list(pnd->dh, dnlp); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/dhcp-server.xml b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/dhcp-server.xml deleted file mode 100644 index fd60d587e4..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/dhcp-server.xml +++ /dev/null @@ -1,133 +0,0 @@ -<?xml version='1.0'?> -<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> -<!-- - Copyright 2009 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License (the "License"). - You may not use this file except in compliance with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - NOTE: This service manifest is not editable; its contents will - be overwritten by package or patch operations, including - operating system upgrade. Make customizations in a different - file. - - Service manifest for the SunOS DHCP service. ---> - -<service_bundle type='manifest' name='SUNWdhcsr:dhcp-server'> - -<service - name='network/dhcp-server' - type='service' - version='1'> - - <create_default_instance enabled='false' /> - - <single_instance/> - - <!-- - We historically ran only in run-level 3, so depend on the - equivalent milestone to level 2. We restart on refresh in - order to handle any changes to nameservice or filesystem - or other service configuration which may affect DHCP service. - --> - <dependency - name='multi-user' - grouping='require_all' - restart_on='refresh' - type='service'> - <service_fmri value='svc:/milestone/multi-user' /> - </dependency> - - <dependency - name='config_data' - grouping='require_all' - restart_on='restart' - type='path'> - <service_fmri value='file:///etc/inet/dhcpsvc.conf' /> - </dependency> - - <dependent - name='dhcp_multi-user-server' - grouping='optional_all' - restart_on='none'> - <service_fmri value='svc:/milestone/multi-user-server' /> - </dependent> - - <exec_method - type='method' - name='start' - exec='/usr/lib/inet/in.dhcpd' - timeout_seconds='60' > - <method_context> - <method_credential - user='root' - group='root' - privileges='zone,net_icmpaccess,sys_ip_config' - /> - </method_context> - </exec_method> - - <exec_method - type='method' - name='stop' - exec=':kill' - timeout_seconds='60' /> - - <exec_method - type='method' - name='refresh' - exec=':kill -HUP' - timeout_seconds='60' /> - - <property_group name='firewall_context' type='com.sun,fw_definition'> - <propval name='name' type='astring' value='bootps' /> - </property_group> - - <property_group name='firewall_config' type='com.sun,fw_configuration'> - <propval name='policy' type='astring' value='use_global' /> - <propval name='apply_to' type='astring' value='' /> - <propval name='exceptions' type='astring' value='' /> - <propval name='value_authorization' type='astring' - value='solaris.smf.value.firewall.config' /> - </property_group> - - <stability value='Unstable' /> - - <template> - <common_name> - <loctext xml:lang='C'> - DHCP server - </loctext> - </common_name> - <description> - <loctext xml:lang='C'> -The SunOS DHCP server, which provides DHCP and BOOTP -protocol services to DHCP and BOOTP clients. - </loctext> - </description> - <documentation> - <manpage title='in.dhcpd' section='1M' - manpath='/usr/share/man' /> - </documentation> - </template> -</service> - -</service_bundle> diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/dhcp.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/dhcp.c deleted file mode 100644 index 8426b39326..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/dhcp.c +++ /dev/null @@ -1,2925 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <alloca.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/sysmacros.h> -#include <assert.h> -#include <sys/socket.h> -#include <sys/byteorder.h> -#include <string.h> -#include <time.h> -#include <sys/socket.h> -#include <syslog.h> -#include <sys/errno.h> -#include <net/if.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -#include <netinet/dhcp.h> -#include <dhcp_symbol.h> -#include <nss_dbdefs.h> -#include <dlfcn.h> -#include "dhcpd.h" -#include "per_dnet.h" -#include "interfaces.h" -#include <locale.h> -#include <resolv.h> - -static void dhcp_offer(dsvc_clnt_t *, PKT_LIST *); -static void dhcp_req_ack(dsvc_clnt_t *, PKT_LIST *); -static void dhcp_dec_rel(dsvc_clnt_t *, PKT_LIST *, int); -static void dhcp_inform(dsvc_clnt_t *, PKT_LIST *); -static PKT *gen_reply_pkt(dsvc_clnt_t *, PKT_LIST *, int, uint_t *, - uchar_t **, struct in_addr *); -static void set_lease_option(ENCODE **, lease_t); -static int config_lease(PKT_LIST *, dn_rec_t *, ENCODE **, lease_t, boolean_t); -static int is_option_requested(PKT_LIST *, ushort_t); -static void add_request_list(IF *, PKT_LIST *, ENCODE **, struct in_addr *); -static char *disp_clnt_msg(PKT_LIST *, char *, int); -static void add_dnet_cache(dsvc_dnet_t *, dn_rec_list_t *); -static void purge_dnet_cache(dsvc_dnet_t *, dn_rec_t *); - -static boolean_t addr_avail(dsvc_dnet_t *, dsvc_clnt_t *, dn_rec_list_t **, - struct in_addr, boolean_t); -static boolean_t name_avail(char *, dsvc_clnt_t *, PKT_LIST *, - dn_rec_list_t **, ENCODE *, struct in_addr **); -static boolean_t entry_available(dsvc_clnt_t *, dn_rec_t *); -static boolean_t do_nsupdate(struct in_addr, ENCODE *, PKT_LIST *); - -extern int dns_puthostent(struct hostent *, time_t); - -/* - * Offer cache. - * - * The DHCP server maintains a cache of DHCP OFFERs it has extended to DHCP - * clients. It does so because: - * a) Subsequent requests get the same answer, and the same IP address - * isn't offered to a different client. - * - * b) No ICMP validation is required the second time through, nor is a - * database lookup required. - * - * c) If the client accepts the OFFER and sends a REQUEST, we can simply - * lookup the record by client IP address, the one field guaranteed to - * be unique within the dhcp network table. - * - * We don't explicitly delete entries from the offer cache. We let them time - * out on their own. This is done to ensure the server responds correctly when - * many pending client requests are queued (duplicates). We don't want to ICMP - * validate an IP address we just allocated. - * - * The offer cache (and any database records cached in select_offer()) will - * diverge from the database for the length of the D_OFFER lifetime. - * SIGHUP flushes the offer cache, allowing management tools to inform the - * server of changes in a timely manner. - */ - -/* - * Dispatch the DHCP packet based on its type. - */ -void -dhcp(dsvc_clnt_t *pcd, PKT_LIST *plp) -{ - if (plp->opts[CD_DHCP_TYPE]->len != 1) { - dhcpmsg(LOG_ERR, - "Garbled DHCP Message type option from client: %s\n", - pcd->cidbuf); - return; - } - - pcd->state = *plp->opts[CD_DHCP_TYPE]->value; - switch (pcd->state) { - case DISCOVER: -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, "dhcp() - processing OFFER...\n"); -#endif /* DEBUG */ - dhcp_offer(pcd, plp); -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, "dhcp() - processed OFFER.\n"); -#endif /* DEBUG */ - break; - case REQUEST: -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, "dhcp() - processing REQUEST...\n"); -#endif /* DEBUG */ - dhcp_req_ack(pcd, plp); -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, "dhcp() - processed REQUEST.\n"); -#endif /* DEBUG */ - break; - case DECLINE: -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, "dhcp() - processing DECLINE...\n"); -#endif /* DEBUG */ - dhcp_dec_rel(pcd, plp, DECLINE); -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, "dhcp() - processed DECLINE.\n"); -#endif /* DEBUG */ - break; - case RELEASE: -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, "dhcp() - processing RELEASE...\n"); -#endif /* DEBUG */ - dhcp_dec_rel(pcd, plp, RELEASE); -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, "dhcp() - processed RELEASE.\n"); -#endif /* DEBUG */ - break; - case INFORM: -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, "dhcp() - processing INFORM...\n"); -#endif /* DEBUG */ - dhcp_inform(pcd, plp); -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, "dhcp() - processed INFORM.\n"); -#endif /* DEBUG */ - break; - default: - dhcpmsg(LOG_INFO, - "Unexpected DHCP message type: %d from client: %s.\n", - pcd->state, pcd->cidbuf); - break; - } -} - -/* - * Responding to a DISCOVER message. icmp echo check (if done) is synchronous. - * Previously known requests are in the OFFER cache. - */ -static void -dhcp_offer(dsvc_clnt_t *pcd, PKT_LIST *plp) -{ - IF *ifp = pcd->ifp; - boolean_t result; - struct in_addr nsip, ncip; - dsvc_dnet_t *pnd = pcd->pnd; - uint_t replen; - int used_pkt_len; - PKT *rep_pktp = NULL; - uchar_t *optp; - ENCODE *ecp, *vecp, *macro_ecp, *macro_vecp, - *class_ecp, *class_vecp, - *cid_ecp, *cid_vecp, - *net_ecp, *net_vecp; - MACRO *net_mp, *pkt_mp, *class_mp, *cid_mp; - char *class_id; - time_t now = time(NULL); - lease_t newlease, oldlease = 0; - int err = 0; - boolean_t existing_allocation = B_FALSE; - boolean_t existing_offer = B_FALSE; - char sipstr[INET_ADDRSTRLEN], cipstr[INET_ADDRSTRLEN]; - char class_idbuf[DSYM_CLASS_SIZE]; - dn_rec_t *dnp, dn, ndn; - uint32_t query; - dn_rec_list_t *dncp = NULL, *dnlp = NULL; - boolean_t unreserve = B_FALSE; - - class_id = get_class_id(plp, class_idbuf, sizeof (class_idbuf)); - - /* - * Purge offers when expired or the database has been re-read. - * - * Multi-threading: to better distribute garbage collection - * and data structure aging tasks, each thread must actively - * implement policy, rather then specialized, non-scalable - * threads which halt the server and update all data - * structures. - * - * The test below checks whether the offer has expired, - * due to aging, or re-reading of the dhcptab, via timeout - * or explicit signal. - */ - if (pcd->off_ip.s_addr != htonl(INADDR_ANY) && - PCD_OFFER_TIMEOUT(pcd, now)) - purge_offer(pcd, B_TRUE, B_TRUE); - - if (pcd->off_ip.s_addr != htonl(INADDR_ANY)) { - /* - * We've already validated this IP address in the past, and - * due to the OFFER hash table, we would not have offered this - * IP address to another client, so use the offer-cached record. - */ - existing_offer = B_TRUE; - dnlp = pcd->dnlp; - dnp = dnlp->dnl_rec; - ncip.s_addr = htonl(dnp->dn_cip.s_addr); - } else { - /* Try to find an existing usable entry for the client. */ - DSVC_QINIT(query); - DSVC_QEQ(query, DN_QCID); - (void) memcpy(dn.dn_cid, pcd->cid, pcd->cid_len); - dn.dn_cid_len = pcd->cid_len; - - /* No bootp records, thank you. */ - DSVC_QNEQ(query, DN_QFBOOTP_ONLY); - dn.dn_flags = DN_FBOOTP_ONLY; - - /* - * We don't limit this search by SIP, because this client - * may be owned by another server, and we need to detect this - * since that record may be MANUAL. - */ - dncp = NULL; - dnlp = dhcp_lookup_dd_classify(pcd->pnd, B_FALSE, query, - -1, &dn, (void **)&dncp, S_CID); - - while (dnlp != NULL) { - - dnp = dnlp->dnl_rec; - if (match_ownerip(htonl(dnp->dn_sip.s_addr)) == NULL) { - /* - * An IP address, but not ours! It's up to the - * primary to respond to DISCOVERs on this - * address. - */ - if (verbose) { - char *m1, *m2; - - if (dnp->dn_flags & DN_FMANUAL) { - m1 = "MANUAL"; - m2 = " No other IP address " - "will be allocated."; - } else { - m1 = "DYNAMIC"; - m2 = ""; - } - - nsip.s_addr = htonl(dnp->dn_sip.s_addr); - (void) inet_ntop(AF_INET, &nsip, sipstr, - sizeof (sipstr)); - ncip.s_addr = htonl(dnp->dn_cip.s_addr); - (void) inet_ntop(AF_INET, &ncip, cipstr, - sizeof (cipstr)); - dhcpmsg(LOG_INFO, "Client: %1$s has " - "%2$s %3$s owned by server: " - "%4$s.%5$s\n", pcd->cidbuf, - m1, cipstr, sipstr, m2); - } - - /* We give up if that IP address is manual */ - if (dnp->dn_flags & DN_FMANUAL) - goto leave_offer; - } else { - uint_t bits = DN_FUNUSABLE | DN_FMANUAL; - if ((dnp->dn_flags & bits) == bits) { - ncip.s_addr = htonl(dnp->dn_cip.s_addr); - (void) inet_ntop(AF_INET, &ncip, cipstr, - sizeof (cipstr)); - dhcpmsg(LOG_WARNING, "Client: %1$s " - "MANUAL record %2$s is UNUSABLE. " - "No other IP address will be " - "allocated.\n", pcd->cidbuf, - cipstr); - goto leave_offer; - } else - break; /* success */ - } - - free_dnrec_list(dnlp); - dnlp = detach_dnrec_from_list(NULL, dncp, &dncp); - } - - if (dnlp == NULL) { - /* - * select_offer() ONLY selects IP addresses owned - * by us. Only log a notice if we own any IP addresses - * at all. Otherwise, this is an informational server. - */ - if (!select_offer(pnd, plp, pcd, &dnlp)) { - if (pnd->naddrs > 0) { - dhcpmsg(LOG_NOTICE, - "No more IP addresses on %1$s " - "network (%2$s)\n", pnd->network, - pcd->cidbuf); - } - goto leave_offer; - } - dnp = dnlp->dnl_rec; - } else - existing_allocation = B_TRUE; - - ncip.s_addr = htonl(dnp->dn_cip.s_addr); - (void) inet_ntop(AF_INET, &ncip, cipstr, sizeof (cipstr)); - - /* - * ICMP echo validate the address. - */ - if (!noping) { - /* - * If icmp echo validation fails, let the plp fall by - * the wayside. - */ - if (icmp_echo_check(&ncip, &result) != 0) { - dhcpmsg(LOG_ERR, "ICMP ECHO check cannot be " - "registered for: %s, ignoring\n", cipstr); - unreserve = B_TRUE; - goto leave_offer; - } - if (result) { - dhcpmsg(LOG_WARNING, - "ICMP ECHO reply to OFFER candidate: " - "%s, disabling.\n", cipstr); - - ndn = *dnp; /* struct copy */ - ndn.dn_flags |= DN_FUNUSABLE; - - if ((err = dhcp_modify_dd_entry(pnd->dh, dnp, - &ndn)) != DSVC_SUCCESS) { - dhcpmsg(LOG_ERR, - "ICMP ECHO reply to OFFER " - "candidate: %1$s. No " - "modifiable dhcp network " - "record. (%2$s)\n", cipstr, - dhcpsvc_errmsg(err)); - } else { - /* Keep the cached entry current. */ - *dnp = ndn; /* struct copy */ - } - - logtrans(P_DHCP, L_ICMP_ECHO, 0, ncip, - server_ip, plp); - - unreserve = B_TRUE; - - goto leave_offer; - } - } - } - - /* - * At this point, we've ICMP validated (if requested) the IP - * address, and can go about producing an OFFER for the client. - */ - - ecp = vecp = NULL; - net_vecp = net_ecp = NULL; - macro_vecp = macro_ecp = NULL; - class_vecp = class_ecp = NULL; - cid_vecp = cid_ecp = NULL; - if (!no_dhcptab) { - open_macros(); - - /* - * Macros are evaluated this way: First apply parameters from - * a client class macro (if present), then apply those from the - * network macro (if present), then apply those from the - * dhcp network macro (if present), and finally apply those - * from a client id macro (if present). - */ - - /* - * First get a handle on network, dhcp network table macro, - * and client id macro values. - */ - if ((net_mp = get_macro(pnd->network)) != NULL) - net_ecp = net_mp->head; - if ((pkt_mp = get_macro(dnp->dn_macro)) != NULL) - macro_ecp = pkt_mp->head; - if ((cid_mp = get_macro(pcd->cidbuf)) != NULL) - cid_ecp = cid_mp->head; - - if (class_id != NULL) { - /* Get a handle on the class id macro (if it exists). */ - if ((class_mp = get_macro(class_id)) != NULL) { - /* - * Locate the ENCODE list for encapsulated - * options associated with our class id within - * the class id macro. - */ - class_vecp = vendor_encodes(class_mp, class_id); - class_ecp = class_mp->head; - } - - /* - * Locate the ENCODE list for encapsulated options - * associated with our class id within the network, - * dhcp network, and client macros. - */ - if (net_mp != NULL) - net_vecp = vendor_encodes(net_mp, class_id); - if (pkt_mp != NULL) - macro_vecp = vendor_encodes(pkt_mp, class_id); - if (cid_mp != NULL) - cid_vecp = vendor_encodes(cid_mp, class_id); - - /* - * Combine the encapsulated option encode lists - * associated with our class id in the order defined - * above (class, net, dhcp network, client id) - */ - vecp = combine_encodes(class_vecp, net_vecp, ENC_COPY); - vecp = combine_encodes(vecp, macro_vecp, ENC_DONT_COPY); - vecp = combine_encodes(vecp, cid_vecp, ENC_DONT_COPY); - } - - /* - * Combine standard option encode lists in the order defined - * above (class, net, dhcp network, and client id). - */ - if (class_ecp != NULL) - ecp = combine_encodes(class_ecp, net_ecp, ENC_COPY); - else - ecp = dup_encode_list(net_ecp); - - ecp = combine_encodes(ecp, macro_ecp, ENC_DONT_COPY); - ecp = combine_encodes(ecp, cid_ecp, ENC_DONT_COPY); - - /* If dhcptab configured to return hostname, do so. */ - if (find_encode(ecp, DSYM_INTERNAL, CD_BOOL_HOSTNAME) != NULL) { - struct hostent h, *hp; - char hbuf[NSS_BUFLEN_HOSTS]; - ENCODE *hecp; - hp = gethostbyaddr_r((char *)&ncip, sizeof (ncip), - AF_INET, &h, hbuf, sizeof (hbuf), &err); - if (hp != NULL) { - hecp = make_encode(DSYM_STANDARD, - CD_HOSTNAME, strlen(hp->h_name), - hp->h_name, ENC_COPY); - replace_encode(&ecp, hecp, ENC_DONT_COPY); - } - } - - /* If dhcptab configured to echo client class, do so. */ - if (plp->opts[CD_CLASS_ID] != NULL && - find_encode(ecp, DSYM_INTERNAL, CD_BOOL_ECHO_VCLASS) != - NULL) { - ENCODE *echo_ecp; - DHCP_OPT *op = plp->opts[CD_CLASS_ID]; - echo_ecp = make_encode(DSYM_STANDARD, CD_CLASS_ID, - op->len, op->value, ENC_COPY); - replace_encode(&ecp, echo_ecp, ENC_DONT_COPY); - } - } - - if ((ifp->flags & IFF_NOARP) == 0) - (void) set_arp(ifp, &ncip, NULL, 0, DHCP_ARP_DEL); - - /* - * For OFFERs, we don't check the client's lease nor LeaseNeg, - * regardless of whether the client has an existing allocation - * or not. Lease expiration (w/o LeaseNeg) only occur during - * RENEW/REBIND or INIT-REBOOT client states, not SELECTing state. - */ - if (existing_allocation) { - if (dnp->dn_lease == DHCP_PERM || - (dnp->dn_flags & DN_FAUTOMATIC)) { - oldlease = DHCP_PERM; - } else { - if ((lease_t)dnp->dn_lease < (lease_t)now) - oldlease = (lease_t)0; - else { - oldlease = (lease_t)dnp->dn_lease - - (lease_t)now; - } - } - } - - /* First get a generic reply packet. */ - rep_pktp = gen_reply_pkt(pcd, plp, OFFER, &replen, &optp, &ifp->addr); - - /* Set the client's IP address */ - rep_pktp->yiaddr.s_addr = htonl(dnp->dn_cip.s_addr); - - /* Calculate lease time. */ - newlease = config_lease(plp, dnp, &ecp, oldlease, B_TRUE); - - /* - * Client is requesting specific options. let's try and ensure it - * gets what it wants, if at all possible. - */ - if (plp->opts[CD_REQUEST_LIST] != NULL) - add_request_list(ifp, plp, &ecp, &ncip); - - /* Now load all the asked for / configured options */ - used_pkt_len = load_options(DHCP_DHCP_CLNT | DHCP_SEND_LEASE, plp, - rep_pktp, replen, optp, ecp, vecp); - - free_encode_list(ecp); - free_encode_list(vecp); - if (!no_dhcptab) - close_macros(); - - if (used_pkt_len < sizeof (PKT)) - used_pkt_len = sizeof (PKT); - - if (send_reply(ifp, rep_pktp, used_pkt_len, &ncip) == 0) { - if (newlease == DHCP_PERM) - newlease = htonl(newlease); - else - newlease = htonl(now + newlease); - (void) update_offer(pcd, &dnlp, newlease, NULL, B_TRUE); - existing_offer = B_TRUE; - } else { - unreserve = B_TRUE; - } - -leave_offer: - if (unreserve) - purge_offer(pcd, B_FALSE, B_TRUE); - if (rep_pktp != NULL) - free(rep_pktp); - if (dncp != NULL) - dhcp_free_dd_list(pnd->dh, dncp); - if (dnlp != NULL && !existing_offer) - dhcp_free_dd_list(pnd->dh, dnlp); -} - -/* - * Responding to REQUEST message. - * - * Very similar to dhcp_offer(), except that we need to be more - * discriminating. - * - * The ciaddr field is TRUSTED. A INIT-REBOOTing client will place its - * notion of its IP address in the requested IP address option. INIT - * clients will place the value in the OFFERs yiaddr in the requested - * IP address option. INIT-REBOOT packets are differentiated from INIT - * packets in that the server id option is missing. ciaddr will only - * appear from clients in the RENEW/REBIND states. - * - * Error messages may be generated. Database write failures are no longer - * fatal, since we'll only respond to the client if the write succeeds. - */ -static void -dhcp_req_ack(dsvc_clnt_t *pcd, PKT_LIST *plp) -{ - dn_rec_t dn, ndn, *dnp; - struct in_addr serverid, ciaddr, claddr, nreqaddr, cipaddr, - ncipaddr, sipaddr; - struct in_addr dest_in; - dsvc_dnet_t *pnd = pcd->pnd; - uint_t replen; - int actual_len; - int pkt_type = ACK; - DHCP_MSG_CATEGORIES log; - PKT *rep_pktp = NULL; - uchar_t *optp; - ENCODE *ecp, *vecp, - *class_ecp, *class_vecp, - *net_ecp, *net_vecp, - *macro_ecp, *macro_vecp, - *cid_ecp, *cid_vecp; - MACRO *class_mp, *pkt_mp, *net_mp, *cid_mp; - char *class_id; - char nak_mesg[DHCP_SCRATCH]; - time_t now; - lease_t newlease, oldlease; - boolean_t negot; - int err = 0; - int write_error = DSVC_SUCCESS, clnt_state; - ushort_t boot_secs; - char ntoaa[INET_ADDRSTRLEN], ntoab[INET_ADDRSTRLEN], - ntoac[INET_ADDRSTRLEN]; - char class_idbuf[DSYM_CLASS_SIZE]; - boolean_t hostname_update = B_FALSE; - dn_rec_list_t *nlp, *dncp = NULL, *dnlp = NULL; - uint32_t query; - IF *ifp = pcd->ifp; - boolean_t existing_offer = B_FALSE; - - ciaddr.s_addr = plp->pkt->ciaddr.s_addr; - boot_secs = ntohs(plp->pkt->secs); - now = time(NULL); - - class_id = get_class_id(plp, class_idbuf, sizeof (class_idbuf)); - - /* Determine type of REQUEST we've got. */ - if (plp->opts[CD_SERVER_ID] != NULL) { - if (plp->opts[CD_SERVER_ID]->len != sizeof (struct in_addr)) { - dhcpmsg(LOG_ERR, "Garbled DHCP Server ID option from " - "client: '%1$s'. Len is %2$d, when it should be " - "%3$d \n", pcd->cidbuf, - plp->opts[CD_SERVER_ID]->len, - sizeof (struct in_addr)); - goto leave_ack; - } - - /* - * Request in response to an OFFER. ciaddr must not - * be set. Requested IP address option will hold address - * we offered the client. - */ - clnt_state = INIT_STATE; - (void) memcpy((void *)&serverid, - plp->opts[CD_SERVER_ID]->value, sizeof (struct in_addr)); - - if (plp->opts[CD_REQUESTED_IP_ADDR] == NULL) { - if (verbose) { - dhcpmsg(LOG_NOTICE, "%1$s: REQUEST on %2$s is " - "missing requested IP option.\n", - pcd->cidbuf, pcd->pnd->network); - } - goto leave_ack; - } - if (plp->opts[CD_REQUESTED_IP_ADDR]->len != - sizeof (struct in_addr)) { - dhcpmsg(LOG_ERR, "Garbled Requested IP option from " - "client: '%1$s'. Len is %2$d, when it should be " - "%3$d \n", - pcd->cidbuf, plp->opts[CD_REQUESTED_IP_ADDR]->len, - sizeof (struct in_addr)); - goto leave_ack; - } - (void) memcpy((void *)&nreqaddr, - plp->opts[CD_REQUESTED_IP_ADDR]->value, - sizeof (struct in_addr)); - - if (serverid.s_addr != ifp->addr.s_addr) { - /* - * Another server address was selected. - * - * If the server address is handled by another - * thread of our process, do nothing in the - * hope that the other thread will eventually - * receive a REQUEST with its server address. - * - * If a server address was selected which is - * not handled by this process, see if we made - * an offer, and clear it if we did. If offer - * expired before client responded, then no - * need to do anything. - */ - if (is_our_address(serverid.s_addr)) { - if (verbose) { - dhcpmsg(LOG_INFO, - "Client: %1$s chose %2$s from " - "server: %3$s, which is being " - "handled by another thread\n", - pcd->cidbuf, - inet_ntop(AF_INET, &nreqaddr, ntoaa, - sizeof (ntoaa)), - inet_ntop(AF_INET, &serverid, ntoab, - sizeof (ntoab))); - } - } else { - purge_offer(pcd, B_FALSE, B_TRUE); - if (verbose) { - dhcpmsg(LOG_INFO, - "Client: %1$s chose %2$s from " - "server: %3$s, not %4$s\n", - pcd->cidbuf, - inet_ntop(AF_INET, &nreqaddr, ntoaa, - sizeof (ntoaa)), - inet_ntop(AF_INET, &serverid, ntoab, - sizeof (ntoab)), - inet_ntop(AF_INET, &ifp->addr, - ntoac, sizeof (ntoac))); - } - } - goto leave_ack; - } - - /* - * See comment at the top of the file for description of - * OFFER cache. - * - * If the offer expires before the client got around to - * requesting, and we can't confirm the address is still free, - * we'll silently ignore the client, until it drops back and - * tries to discover again. We will print a message in - * verbose mode however. If the Offer hasn't timed out, we - * bump it up again in case we have a bounce of queued up - * INIT requests to respond to. - */ - if (pcd->off_ip.s_addr == htonl(INADDR_ANY) || - PCD_OFFER_TIMEOUT(pcd, now)) { - /* - * Hopefully, the timeout value is fairly long to - * prevent this. - */ - purge_offer(pcd, B_TRUE, B_TRUE); - if (verbose) { - dhcpmsg(LOG_INFO, - "Offer on %1$s expired for client: %2$s\n", - pcd->pnd->network, pcd->cidbuf); - } - goto leave_ack; - } else - (void) update_offer(pcd, NULL, 0, NULL, B_TRUE); - - /* - * The client selected us. Create a ACK, and send - * it off to the client, commit to permanent - * storage the new binding. - */ - existing_offer = B_TRUE; - dnlp = pcd->dnlp; - dnp = dnlp->dnl_rec; - ndn = *dnp; /* struct copy */ - ndn.dn_lease = pcd->lease; - ncipaddr.s_addr = htonl(dnp->dn_cip.s_addr); - - /* - * If client thinks we offered it a different address, then - * ignore it. - */ - if (memcmp((char *)&ncipaddr, - plp->opts[CD_REQUESTED_IP_ADDR]->value, - sizeof (struct in_addr)) != 0) { - if (verbose) { - dhcpmsg(LOG_INFO, "Client %1$s believes " - "offered IP address %2$s is different than " - "what was offered.\n", pcd->cidbuf, - inet_ntop(AF_INET, &ncipaddr, ntoab, - sizeof (ntoab))); - } - goto leave_ack; - } - - /* - * Clear out any temporary ARP table entry we may have - * created during the offer. - */ - if ((ifp->flags & IFF_NOARP) == 0) - (void) set_arp(ifp, &ncipaddr, NULL, 0, DHCP_ARP_DEL); - } else { - /* - * Either a client in the INIT-REBOOT state, or one in - * either RENEW or REBIND states. The latter will have - * ciaddr set, whereas the former will place its concept - * of its IP address in the requested IP address option. - */ - if (ciaddr.s_addr == htonl(INADDR_ANY)) { - clnt_state = INIT_REBOOT_STATE; - /* - * Client isn't sure of its IP address. It's - * attempting to verify its address, thus requested - * IP option better be present, and correct. - */ - if (plp->opts[CD_REQUESTED_IP_ADDR] == NULL) { - dhcpmsg(LOG_ERR, - "Client: %s REQUEST is missing " - "requested IP option.\n", pcd->cidbuf); - goto leave_ack; - } - if (plp->opts[CD_REQUESTED_IP_ADDR]->len != - sizeof (struct in_addr)) { - dhcpmsg(LOG_ERR, "Garbled Requested IP option " - "from client: '%1$s'. Len is %2$d, when it " - "should be %3$d \n", pcd->cidbuf, - plp->opts[CD_REQUESTED_IP_ADDR]->len, - sizeof (struct in_addr)); - goto leave_ack; - } - (void) memcpy(&claddr, - plp->opts[CD_REQUESTED_IP_ADDR]->value, - sizeof (struct in_addr)); - - DSVC_QINIT(query); - DSVC_QEQ(query, DN_QCID); - (void) memcpy(dn.dn_cid, pcd->cid, pcd->cid_len); - dn.dn_cid_len = pcd->cid_len; - - /* No bootp records, thank you. */ - DSVC_QNEQ(query, DN_QFBOOTP_ONLY); - dn.dn_flags = DN_FBOOTP_ONLY; - - } else { - clnt_state = RENEW_REBIND_STATE; - /* - * Client knows its IP address. It is trying to - * RENEW/REBIND (extend its lease). We trust ciaddr, - * and use it to locate the client's record. If we - * can't find the client's record, then we keep - * silent. If the client id of the record doesn't - * match this client, then the database is - * inconsistent, and we'll ignore it. - */ - DSVC_QINIT(query); - DSVC_QEQ(query, DN_QCID|DN_QCIP); - (void) memcpy(dn.dn_cid, pcd->cid, pcd->cid_len); - dn.dn_cid_len = pcd->cid_len; - dn.dn_cip.s_addr = ntohl(ciaddr.s_addr); - - /* No bootp records, thank you. */ - DSVC_QNEQ(query, DN_QFBOOTP_ONLY); - dn.dn_flags = DN_FBOOTP_ONLY; - - claddr.s_addr = ciaddr.s_addr; - } - - dncp = NULL; - dnlp = dhcp_lookup_dd_classify(pcd->pnd, B_FALSE, query, - -1, &dn, (void **)&dncp, S_CID); - - if (dnlp != NULL) { - dnp = dnlp->dnl_rec; - if (dnp->dn_flags & DN_FUNUSABLE) - goto leave_ack; - - sipaddr.s_addr = htonl(dnp->dn_sip.s_addr); - cipaddr.s_addr = htonl(dnp->dn_cip.s_addr); - - /* - * If this address is not owned by this server and - * the client is trying to verify the address, then - * ignore the client. If the client is simply trying - * to rebind, then don't respond until after - * renog_secs passes, to give the server that *OWNS* - * the address time to respond first. - */ - if (match_ownerip(sipaddr.s_addr) == NULL) { - if (clnt_state == INIT_REBOOT_STATE) { - if (verbose) { - dhcpmsg(LOG_NOTICE, "Client: " - "%1$s is requesting " - "verification of %2$s " - "owned by %3$s\n", - pcd->cidbuf, - inet_ntop(AF_INET, &cipaddr, - ntoab, sizeof (ntoab)), - inet_ntop(AF_INET, &sipaddr, - ntoac, sizeof (ntoac))); - } - goto leave_ack; - } else { - /* RENEW/REBIND - wait for primary */ - if (boot_secs < (ushort_t)renog_secs) - goto leave_ack; - } - - } - if (claddr.s_addr != htonl(dnp->dn_cip.s_addr)) { - /* - * Client has the wrong IP address. Nak. - */ - (void) snprintf(nak_mesg, sizeof (nak_mesg), - "Incorrect IP address."); - pkt_type = NAK; - } else { - if (!(dnp->dn_flags & DN_FAUTOMATIC) && - (lease_t)dnp->dn_lease < (lease_t)now) { - (void) snprintf(nak_mesg, - sizeof (nak_mesg), - "Lease has expired."); - pkt_type = NAK; - } - } - } else { - if (clnt_state == RENEW_REBIND_STATE) { - dhcpmsg(LOG_ERR, "Client: %1$s is trying to " - "renew %2$s, an IP address it has not " - "leased.\n", pcd->cidbuf, inet_ntop(AF_INET, - &ciaddr, ntoab, sizeof (ntoab))); - goto leave_ack; - } - /* - * There is no such client registered for this - * address. Check if their address is on the correct - * net. If it is, then we'll assume that some other, - * non-database sharing DHCP server knows about this - * client. If the client is on the wrong net, NAK'em. - */ - if ((claddr.s_addr & pnd->subnet.s_addr) == - pnd->net.s_addr) { - /* Right net, but no record of client. */ - if (verbose) { - dhcpmsg(LOG_INFO, - "Client: %1$s is trying to verify " - "unrecorded address: %2$s, " - "ignored.\n", pcd->cidbuf, - inet_ntop(AF_INET, &claddr, - ntoab, sizeof (ntoab))); - } - goto leave_ack; - } else { - if (ciaddr.s_addr == 0L) { - (void) snprintf(nak_mesg, - sizeof (nak_mesg), - "No valid configuration exists on " - "network: %s", pnd->network); - pkt_type = NAK; - } else { - if (verbose) { - dhcpmsg(LOG_INFO, - "Client: %1$s is not " - "recorded as having " - "address: %2$s\n", - pcd->cidbuf, - inet_ntop(AF_INET, &ciaddr, - ntoab, sizeof (ntoab))); - } - goto leave_ack; - } - } - } - } - - /* - * Produce the appropriate response. - */ - if (pkt_type == NAK) { - rep_pktp = gen_reply_pkt(pcd, plp, NAK, &replen, &optp, - &ifp->addr); - /* - * Setting yiaddr to the client's ciaddr abuses the - * semantics of yiaddr, So we set this to 0L. - * - * We twiddle the broadcast flag to force the - * server/relay agents to broadcast the NAK. - * - * Exception: If a client's lease has expired, and it - * is still trying to renegotiate its lease, AND ciaddr - * is set, AND ciaddr is on a "remote" net, unicast the - * NAK. Gross, huh? But SPA could make this happen with - * super short leases. - */ - rep_pktp->yiaddr.s_addr = 0L; - if (ciaddr.s_addr != 0L && - (ciaddr.s_addr & pnd->subnet.s_addr) != pnd->net.s_addr) { - dest_in.s_addr = ciaddr.s_addr; - } else { - rep_pktp->flags |= htons(BCAST_MASK); - dest_in.s_addr = INADDR_BROADCAST; - } - - *optp++ = CD_MESSAGE; - *optp++ = (uchar_t)strlen(nak_mesg); - (void) memcpy(optp, nak_mesg, strlen(nak_mesg)); - optp += strlen(nak_mesg); - *optp = CD_END; - actual_len = BASE_PKT_SIZE + (uint_t)(optp - rep_pktp->options); - if (actual_len < sizeof (PKT)) - actual_len = sizeof (PKT); - - (void) send_reply(ifp, rep_pktp, actual_len, &dest_in); - - logtrans(P_DHCP, L_NAK, 0, dest_in, server_ip, plp); - } else { - rep_pktp = gen_reply_pkt(pcd, plp, ACK, &replen, &optp, - &ifp->addr); - - /* Set the client's IP address */ - rep_pktp->yiaddr.s_addr = htonl(dnp->dn_cip.s_addr); - dest_in.s_addr = htonl(dnp->dn_cip.s_addr); - - /* - * Macros are evaluated this way: First apply parameters - * from a client class macro (if present), then apply - * those from the network macro (if present), then apply - * those from the server macro (if present), and finally - * apply those from a client id macro (if present). - */ - ecp = vecp = NULL; - class_vecp = class_ecp = NULL; - net_vecp = net_ecp = NULL; - macro_vecp = macro_ecp = NULL; - cid_vecp = cid_ecp = NULL; - - if (!no_dhcptab) { - open_macros(); - if ((net_mp = get_macro(pnd->network)) != NULL) - net_ecp = net_mp->head; - if ((pkt_mp = get_macro(dnp->dn_macro)) != NULL) - macro_ecp = pkt_mp->head; - if ((cid_mp = get_macro(pcd->cidbuf)) != NULL) - cid_ecp = cid_mp->head; - if (class_id != NULL) { - if ((class_mp = get_macro(class_id)) != NULL) { - class_vecp = vendor_encodes(class_mp, - class_id); - class_ecp = class_mp->head; - } - if (net_mp != NULL) { - net_vecp = vendor_encodes(net_mp, - class_id); - } - if (pkt_mp != NULL) - macro_vecp = vendor_encodes(pkt_mp, - class_id); - if (cid_mp != NULL) { - cid_vecp = vendor_encodes(cid_mp, - class_id); - } - vecp = combine_encodes(class_vecp, net_vecp, - ENC_COPY); - vecp = combine_encodes(vecp, macro_vecp, - ENC_DONT_COPY); - vecp = combine_encodes(vecp, cid_vecp, - ENC_DONT_COPY); - } - if (class_ecp != NULL) { - ecp = combine_encodes(class_ecp, net_ecp, - ENC_COPY); - } else - ecp = dup_encode_list(net_ecp); - - ecp = combine_encodes(ecp, macro_ecp, ENC_DONT_COPY); - ecp = combine_encodes(ecp, cid_ecp, ENC_DONT_COPY); - - ncipaddr.s_addr = htonl(dnp->dn_cip.s_addr); - /* - * If the server is configured to do host name updates - * and the REQUEST packet contains a hostname request, - * see whether we can honor it. - * - * First, determine (via name_avail()) whether the host - * name is unassigned or belongs to an unleased IP - * address under our control. If not, we won't do a - * host name update on behalf of the client. - * - * Second, if we own the IP address and it is in the - * correct network table, see whether an update is - * necessary (or, in the lucky case, whether the name - * requested already belongs to that address), in which - * case we need do nothing more than return the option. - */ - if ((nsutimeout_secs != DHCP_NO_NSU) && - (plp->opts[CD_HOSTNAME] != NULL)) { - char hname[MAXHOSTNAMELEN + 1]; - int hlen; - struct in_addr ia, *iap = &ia; - - /* turn hostname option into a string */ - hlen = plp->opts[CD_HOSTNAME]->len; - hlen = MIN(hlen, MAXHOSTNAMELEN); - (void) memcpy(hname, - plp->opts[CD_HOSTNAME]->value, hlen); - hname[hlen] = '\0'; - - nlp = NULL; - if (name_avail(hname, pcd, plp, &nlp, ecp, - &iap)) { - ENCODE *hecp; - - /* - * If we pass this test, it means either - * no address is currently associated - * with the requested host name (iap is - * NULL) or the address doesn't match - * the one to be leased; in either case - * an update attempt is needed. - * - * Otherwise (in the else case), we need - * only send the response - the name and - * address already match. - */ - if ((iap == NULL) || (iap->s_addr != - dnp->dn_cip.s_addr)) { - if (do_nsupdate(dnp->dn_cip, - ecp, plp)) { - hecp = make_encode( - DSYM_STANDARD, - CD_HOSTNAME, - strlen(hname), - hname, - ENC_COPY); - replace_encode(&ecp, - hecp, - ENC_DONT_COPY); - hostname_update = - B_TRUE; - } - } else { - hecp = make_encode( - DSYM_STANDARD, - CD_HOSTNAME, - strlen(hname), hname, - ENC_COPY); - replace_encode(&ecp, hecp, - ENC_DONT_COPY); - hostname_update = B_TRUE; - } - if (nlp != NULL) - dhcp_free_dd_list(pnd->dh, nlp); - } - } - - /* - * If dhcptab configured to return hostname, do so. - */ - if ((hostname_update == B_FALSE) && - (find_encode(ecp, DSYM_INTERNAL, - CD_BOOL_HOSTNAME) != NULL)) { - struct hostent h, *hp; - ENCODE *hecp; - char hbuf[NSS_BUFLEN_HOSTS]; - hp = gethostbyaddr_r((char *)&ncipaddr, - sizeof (struct in_addr), AF_INET, &h, hbuf, - sizeof (hbuf), &err); - if (hp != NULL) { - hecp = make_encode(DSYM_STANDARD, - CD_HOSTNAME, strlen(hp->h_name), - hp->h_name, ENC_COPY); - replace_encode(&ecp, hecp, - ENC_DONT_COPY); - } - } - - /* - * If dhcptab configured to echo client class, do so. - */ - if (plp->opts[CD_CLASS_ID] != NULL && - find_encode(ecp, DSYM_INTERNAL, - CD_BOOL_ECHO_VCLASS) != NULL) { - ENCODE *echo_ecp; - DHCP_OPT *op = plp->opts[CD_CLASS_ID]; - echo_ecp = make_encode(DSYM_STANDARD, - CD_CLASS_ID, op->len, op->value, - ENC_COPY); - replace_encode(&ecp, echo_ecp, ENC_DONT_COPY); - } - } - - if (dnp->dn_flags & DN_FAUTOMATIC || dnp->dn_lease == DHCP_PERM) - oldlease = DHCP_PERM; - else { - if (plp->opts[CD_SERVER_ID] != NULL) { - /* - * Offered absolute Lease time is cached - * in the lease field of the record. If - * that's expired, then they'll get the - * policy value again here. Must have been - * LONG time between DISC/REQ! - */ - if ((lease_t)dnp->dn_lease < (lease_t)now) - oldlease = (lease_t)0; - else - oldlease = dnp->dn_lease - now; - } else - oldlease = dnp->dn_lease - now; - } - - if (find_encode(ecp, DSYM_INTERNAL, CD_BOOL_LEASENEG) != - NULL) - negot = B_TRUE; - else - negot = B_FALSE; - - /* - * Modify changed fields in new database record. - */ - ndn = *dnp; /* struct copy */ - (void) memcpy(ndn.dn_cid, pcd->cid, pcd->cid_len); - ndn.dn_cid_len = pcd->cid_len; - - /* - * This is a little longer than we offered (not taking into - * account the secs field), but since I trust the UNIX - * clock better than the PC's, it is a good idea to give - * the PC a little more time than it thinks, just due to - * clock slop on PC's. - */ - newlease = config_lease(plp, &ndn, &ecp, oldlease, negot); - - if (newlease != DHCP_PERM) - ndn.dn_lease = now + newlease; - else - ndn.dn_lease = DHCP_PERM; - - - /* - * It is critical to write the database record if the - * client is in the INIT state, so we don't reply to the - * client if this fails. However, if the client is simply - * trying to verify its address or extend its lease, then - * we'll reply regardless of the status of the write, - * although we'll return the old lease time. - * - * If the client is in the INIT_REBOOT state, and the - * lease time hasn't changed, we don't bother with the - * write, since nothing has changed. - */ - if (clnt_state == INIT_STATE || oldlease != newlease) { - - write_error = dhcp_modify_dd_entry(pnd->dh, dnp, &ndn); - - /* Keep state of the cached entry current. */ - if (write_error == DSVC_SUCCESS) { - *dnp = ndn; /* struct copy */ - } - } else { - if (verbose) { - dhcpmsg(LOG_INFO, - "Database write unnecessary for " - "DHCP client: " - "%1$s, %2$s\n", pcd->cidbuf, - inet_ntop(AF_INET, &ncipaddr, - ntoab, sizeof (ntoab))); - } - } - if (write_error == DSVC_SUCCESS || - clnt_state == INIT_REBOOT_STATE) { - - if (write_error != DSVC_SUCCESS) - set_lease_option(&ecp, oldlease); - else { - /* Note that the conversation has completed. */ - pcd->state = ACK; - } - - if (plp->opts[CD_REQUEST_LIST]) - add_request_list(ifp, plp, &ecp, &ncipaddr); - - /* Now load all the asked for / configured options */ - actual_len = load_options(DHCP_DHCP_CLNT | - DHCP_SEND_LEASE, plp, rep_pktp, replen, optp, ecp, - vecp); - - if (actual_len < sizeof (PKT)) - actual_len = sizeof (PKT); - if (verbose) { - dhcpmsg(LOG_INFO, - "Client: %1$s maps to IP: %2$s\n", - pcd->cidbuf, - inet_ntop(AF_INET, &ncipaddr, - ntoab, sizeof (ntoab))); - } - (void) send_reply(ifp, rep_pktp, actual_len, &dest_in); - - if (clnt_state == INIT_STATE) - log = L_ASSIGN; - else - log = L_REPLY; - - logtrans(P_DHCP, log, ndn.dn_lease, ncipaddr, - server_ip, plp); - } - - free_encode_list(ecp); - free_encode_list(vecp); - if (!no_dhcptab) - close_macros(); - } - -leave_ack: - if (rep_pktp != NULL) - free(rep_pktp); - if (dncp != NULL) - dhcp_free_dd_list(pnd->dh, dncp); - if (dnlp != NULL && !existing_offer) - dhcp_free_dd_list(pnd->dh, dnlp); -} - -/* Reacting to a client's DECLINE or RELEASE. */ -static void -dhcp_dec_rel(dsvc_clnt_t *pcd, PKT_LIST *plp, int type) -{ - char *fmtp; - dn_rec_t *dnp, dn, ndn; - dsvc_dnet_t *pnd; - struct in_addr ip; - int err = 0; - DHCP_MSG_CATEGORIES log; - dn_rec_list_t *dncp, *dnlp = NULL; - uint32_t query; - char ipb[INET_ADDRSTRLEN]; - char clnt_msg[DHCP_MAX_OPT_SIZE]; - - pnd = pcd->pnd; - - if (type == DECLINE) { - if (plp->opts[CD_REQUESTED_IP_ADDR] && - plp->opts[CD_REQUESTED_IP_ADDR]->len == - sizeof (struct in_addr)) { - (void) memcpy((char *)&ip, - plp->opts[CD_REQUESTED_IP_ADDR]->value, - sizeof (struct in_addr)); - } - } else - ip.s_addr = plp->pkt->ciaddr.s_addr; - - (void) inet_ntop(AF_INET, &ip, ipb, sizeof (ipb)); - - /* Look for a matching IP address and Client ID */ - - DSVC_QINIT(query); - DSVC_QEQ(query, DN_QCID|DN_QCIP); - (void) memcpy(dn.dn_cid, pcd->cid, pcd->cid_len); - dn.dn_cid_len = pcd->cid_len; - dn.dn_cip.s_addr = ntohl(ip.s_addr); - - dncp = NULL; - dnlp = dhcp_lookup_dd_classify(pcd->pnd, B_FALSE, query, -1, - &dn, (void **)&dncp, S_CID); - assert(dncp == NULL); - - if (dnlp == NULL) { - if (verbose) { - if (type == DECLINE) { - fmtp = "Unregistered client: %1$s is " - "DECLINEing address: %2$s.\n"; - } else { - fmtp = "Unregistered client: %1$s is " - "RELEASEing address: %2$s.\n"; - } - dhcpmsg(LOG_INFO, fmtp, pcd->cidbuf, ipb); - } - return; - } - - dnp = dnlp->dnl_rec; - ndn = *dnp; /* struct copy */ - - /* If the entry is not one of ours, then give up. */ - if (match_ownerip(htonl(ndn.dn_sip.s_addr)) == NULL) { - if (verbose) { - if (type == DECLINE) { - fmtp = "Client: %1$s is DECLINEing: " - "%2$s not owned by this server.\n"; - } else { - fmtp = "Client: %1$s is RELEASEing: " - "%2$s not owned by this server.\n"; - } - dhcpmsg(LOG_INFO, fmtp, pcd->cidbuf, ipb); - } - goto leave_dec_rel; - } - - if (type == DECLINE) { - log = L_DECLINE; - dhcpmsg(LOG_ERR, "Client: %1$s DECLINED address: %2$s.\n", - pcd->cidbuf, ipb); - if (plp->opts[CD_MESSAGE]) { - dhcpmsg(LOG_ERR, "DECLINE: client message: %s\n", - disp_clnt_msg(plp, clnt_msg, sizeof (clnt_msg))); - } - ndn.dn_flags |= DN_FUNUSABLE; - } else { - log = L_RELEASE; - if (ndn.dn_flags & DN_FMANUAL) { - dhcpmsg(LOG_ERR, - "Client: %1$s is trying to RELEASE manual " - "address: %2$s\n", pcd->cidbuf, ipb); - goto leave_dec_rel; - } - if (verbose) { - dhcpmsg(LOG_INFO, - "Client: %1$s RELEASED address: %2$s\n", - pcd->cidbuf, ipb); - if (plp->opts[CD_MESSAGE]) { - dhcpmsg(LOG_INFO, - "RELEASE: client message: %s\n", - disp_clnt_msg(plp, clnt_msg, - sizeof (clnt_msg))); - } - } - } - - /* Clear out the cid and lease fields */ - if (!(ndn.dn_flags & DN_FMANUAL)) { - ndn.dn_cid[0] = '\0'; - ndn.dn_cid_len = 1; - ndn.dn_lease = (lease_t)0; - } - - /* Ignore write errors. */ - err = dhcp_modify_dd_entry(pnd->dh, dnp, &ndn); - if (err != DSVC_SUCCESS) { - dhcpmsg(LOG_NOTICE, - "%1$s: ERROR modifying database: %2$s for client %3$s\n", - log == L_RELEASE ? "RELEASE" : "DECLINE", - dhcpsvc_errmsg(err), ipb); - } else { - if (type == RELEASE) { - /* - * performance: save select_offer() lots of work by - * caching this perfectly good ip address in freerec. - */ - *(dnlp->dnl_rec) = ndn; /* struct copy */ - add_dnet_cache(pnd, dnlp); - dnlp = NULL; - } - } - - logtrans(P_DHCP, log, ndn.dn_lease, ip, server_ip, plp); - -leave_dec_rel: - - if (dnlp != NULL) - dhcp_free_dd_list(pnd->dh, dnlp); -} - -/* - * Responding to an INFORM message. - * - * INFORM messages are received from clients that already have their network - * parameters (such as IP address and subnet mask), but wish to receive - * other configuration parameters. The server will not check for an existing - * lease as clients may have obtained their network parameters by some - * means other than DHCP. Similarly, the DHCPACK generated in response to - * the INFORM message will not include lease time information. All other - * configuration parameters are returned. - */ -static void -dhcp_inform(dsvc_clnt_t *pcd, PKT_LIST *plp) -{ - uint_t replen; - int used_pkt_len; - PKT *rep_pktp = NULL; - uchar_t *optp; - ENCODE *ecp, *vecp, *class_ecp, *class_vecp, - *cid_ecp, *cid_vecp, *net_ecp, *net_vecp; - MACRO *net_mp, *class_mp, *cid_mp; - dsvc_dnet_t *pnd; - char *class_id; - char class_idbuf[DSYM_CLASS_SIZE]; - IF *ifp = pcd->ifp; - - pnd = pcd->pnd; - class_id = get_class_id(plp, class_idbuf, sizeof (class_idbuf)); - - /* - * Macros are evaluated this way: First apply parameters from - * a client class macro (if present), then apply those from the - * network macro (if present), and finally apply those from a - * client id macro (if present). - */ - ecp = vecp = NULL; - net_vecp = net_ecp = NULL; - class_vecp = class_ecp = NULL; - cid_vecp = cid_ecp = NULL; - - if (!no_dhcptab) { - open_macros(); - if ((net_mp = get_macro(pnd->network)) != NULL) - net_ecp = net_mp->head; - if ((cid_mp = get_macro(pcd->cidbuf)) != NULL) - cid_ecp = cid_mp->head; - if (class_id != NULL) { - if ((class_mp = get_macro(class_id)) != NULL) { - class_vecp = vendor_encodes(class_mp, - class_id); - class_ecp = class_mp->head; - } - if (net_mp != NULL) - net_vecp = vendor_encodes(net_mp, class_id); - if (cid_mp != NULL) - cid_vecp = vendor_encodes(cid_mp, class_id); - vecp = combine_encodes(class_vecp, net_vecp, - ENC_COPY); - vecp = combine_encodes(vecp, cid_vecp, ENC_DONT_COPY); - } - - ecp = combine_encodes(class_ecp, net_ecp, ENC_COPY); - ecp = combine_encodes(ecp, cid_ecp, ENC_DONT_COPY); - } - - /* First get a generic reply packet. */ - rep_pktp = gen_reply_pkt(pcd, plp, ACK, &replen, &optp, &ifp->addr); - - /* - * Client is requesting specific options. let's try and ensure it - * gets what it wants, if at all possible. - */ - if (plp->opts[CD_REQUEST_LIST] != NULL) - add_request_list(ifp, plp, &ecp, &plp->pkt->ciaddr); - - /* - * Explicitly set the ciaddr to be that which the client gave - * us. - */ - rep_pktp->ciaddr.s_addr = plp->pkt->ciaddr.s_addr; - - /* - * Now load all the asked for / configured options. DON'T send - * any lease time info! - */ - used_pkt_len = load_options(DHCP_DHCP_CLNT, plp, rep_pktp, replen, optp, - ecp, vecp); - - free_encode_list(ecp); - free_encode_list(vecp); - if (!no_dhcptab) - close_macros(); - - if (used_pkt_len < sizeof (PKT)) - used_pkt_len = sizeof (PKT); - - (void) send_reply(ifp, rep_pktp, used_pkt_len, &plp->pkt->ciaddr); - - logtrans(P_DHCP, L_INFORM, 0, plp->pkt->ciaddr, server_ip, plp); - -leave_inform: - if (rep_pktp != NULL) - free(rep_pktp); -} - -static char * -disp_clnt_msg(PKT_LIST *plp, char *bufp, int len) -{ - uchar_t tlen; - - bufp[0] = '\0'; /* null string */ - - if (plp && plp->opts[CD_MESSAGE]) { - tlen = ((uchar_t)len < plp->opts[CD_MESSAGE]->len) ? - (len - 1) : plp->opts[CD_MESSAGE]->len; - (void) memcpy(bufp, plp->opts[CD_MESSAGE]->value, tlen); - bufp[tlen] = '\0'; - } - return (bufp); -} - -/* - * serverip expected in host order - */ -static PKT * -gen_reply_pkt(dsvc_clnt_t *pcd, PKT_LIST *plp, int type, uint_t *len, - uchar_t **optpp, struct in_addr *serverip) -{ - PKT *reply_pktp; - uint16_t plen; - - /* - * We need to determine the packet size. Perhaps the client has told - * us? - */ - if (plp->opts[CD_MAX_DHCP_SIZE]) { - if (plp->opts[CD_MAX_DHCP_SIZE]->len != sizeof (uint16_t)) { - dhcpmsg(LOG_ERR, "Garbled MAX DHCP message size option " - "from\nclient: '%1$s'. Len is %2$d, when it should " - "be %3$d. Defaulting to %4$d.\n", - pcd->cidbuf, - plp->opts[CD_MAX_DHCP_SIZE]->len, - sizeof (uint16_t), DHCP_DEF_MAX_SIZE); - plen = DHCP_DEF_MAX_SIZE; - } else { - (void) memcpy(&plen, plp->opts[CD_MAX_DHCP_SIZE]->value, - sizeof (uint16_t)); - plen = ntohs(plen); - if (plen < DHCP_DEF_MAX_SIZE) - plen = DHCP_DEF_MAX_SIZE; - } - } else { - /* - * Define size to be a fixed length. Too hard to add up all - * possible class id, macro, and hostname/lease time options - * without doing just about as much work as constructing the - * whole reply packet. - */ - plen = DHCP_MAX_REPLY_SIZE; - } - - /* Generate a generically initialized BOOTP packet */ - reply_pktp = gen_bootp_pkt(plen, plp->pkt); - - reply_pktp->op = BOOTREPLY; - *optpp = reply_pktp->options; - - /* - * Set pkt type. - */ - *(*optpp)++ = (uchar_t)CD_DHCP_TYPE; - *(*optpp)++ = (uchar_t)1; - *(*optpp)++ = (uchar_t)type; - - /* - * All reply packets have server id set. - */ - *(*optpp)++ = (uchar_t)CD_SERVER_ID; - *(*optpp)++ = (uchar_t)4; -#if defined(_LITTLE_ENDIAN) - *(*optpp)++ = (uchar_t)(serverip->s_addr & 0xff); - *(*optpp)++ = (uchar_t)((serverip->s_addr >> 8) & 0xff); - *(*optpp)++ = (uchar_t)((serverip->s_addr >> 16) & 0xff); - *(*optpp)++ = (uchar_t)((serverip->s_addr >> 24) & 0xff); -#else - *(*optpp)++ = (uchar_t)((serverip->s_addr >> 24) & 0xff); - *(*optpp)++ = (uchar_t)((serverip->s_addr >> 16) & 0xff); - *(*optpp)++ = (uchar_t)((serverip->s_addr >> 8) & 0xff); - *(*optpp)++ = (uchar_t)(serverip->s_addr & 0xff); -#endif /* _LITTLE_ENDIAN */ - - *len = plen; - return (reply_pktp); -} - -/* - * If the client requests it, and either it isn't currently configured - * or hasn't already been added, provide the option now. Will also work - * for NULL ENCODE lists, but initializing them to point to the requested - * options. - * - * If nsswitch contains host name services which hang, big problems occur - * with dhcp server, since the main thread hangs waiting for that name - * service's timeout. - * - * NOTE: this function should be called only after all other parameter - * merges have taken place (combine_encode). - */ -static void -add_request_list(IF *ifp, PKT_LIST *plp, ENCODE **ecp, struct in_addr *ip) -{ - ENCODE *ep, *ifecp, *end_ecp = NULL; - struct hostent h, *hp; - char hbuf[NSS_BUFLEN_HOSTS]; - int herrno; - - /* Find the end. */ - if (*ecp) { - for (ep = *ecp; ep->next; ep = ep->next) - /* null */; - end_ecp = ep; - } - - /* HOSTNAME */ - if (is_option_requested(plp, CD_HOSTNAME) && - (find_encode(*ecp, DSYM_STANDARD, CD_HOSTNAME) == NULL) && - (find_encode(*ecp, DSYM_INTERNAL, CD_BOOL_HOSTNAME) == NULL)) { - hp = gethostbyaddr_r((char *)ip, sizeof (struct in_addr), - AF_INET, &h, hbuf, sizeof (hbuf), &herrno); - if (hp != NULL) { - if (end_ecp) { - end_ecp->next = make_encode(DSYM_STANDARD, - CD_HOSTNAME, strlen(hp->h_name), - hp->h_name, ENC_COPY); - end_ecp = end_ecp->next; - } else { - end_ecp = make_encode(DSYM_STANDARD, - CD_HOSTNAME, strlen(hp->h_name), - hp->h_name, ENC_COPY); - } - } - } - - /* - * all bets off for the following if thru a relay agent. - */ - if (plp->pkt->giaddr.s_addr != 0L) - return; - - /* SUBNET MASK */ - if (is_option_requested(plp, CD_SUBNETMASK) && find_encode(*ecp, - DSYM_STANDARD, CD_SUBNETMASK) == NULL) { - ifecp = find_encode(ifp->ecp, DSYM_STANDARD, CD_SUBNETMASK); - if (end_ecp) { - end_ecp->next = dup_encode(ifecp); - end_ecp = end_ecp->next; - } else - end_ecp = dup_encode(ifecp); - } - - /* BROADCAST ADDRESS */ - if (is_option_requested(plp, CD_BROADCASTADDR) && find_encode(*ecp, - DSYM_STANDARD, CD_BROADCASTADDR) == NULL) { - ifecp = find_encode(ifp->ecp, DSYM_STANDARD, - CD_BROADCASTADDR); - if (end_ecp) { - end_ecp->next = dup_encode(ifecp); - end_ecp = end_ecp->next; - } else - end_ecp = dup_encode(ifecp); - } - - /* IP MTU */ - if (is_option_requested(plp, CD_MTU) && find_encode(*ecp, - DSYM_STANDARD, CD_MTU) == NULL) { - ifecp = find_encode(ifp->ecp, DSYM_STANDARD, CD_MTU); - if (end_ecp) { - end_ecp->next = dup_encode(ifecp); - end_ecp = end_ecp->next; - } else - end_ecp = dup_encode(ifecp); - } - - if (*ecp == NULL) - *ecp = end_ecp; -} - -/* - * Is a specific option requested? Returns True if so, False otherwise. - */ -static int -is_option_requested(PKT_LIST *plp, ushort_t code) -{ - uchar_t c, *tp; - DHCP_OPT *cp = plp->opts[CD_REQUEST_LIST]; - - for (c = 0, tp = (uchar_t *)cp->value; c < cp->len; c++, tp++) { - if (*tp == (uchar_t)code) - return (B_TRUE); - } - return (B_FALSE); -} - -/* - * Locates lease option, if possible, otherwise allocates an encode and - * appends it to the end. Changes current lease setting. - * - * TODO: ugh. We don't address the case where the Lease time changes, but - * T1 and T2 don't. We don't want T1 or T2 to be greater than the lease - * time! Perhaps T1 and T2 should be a percentage of lease time... Later.. - */ -static void -set_lease_option(ENCODE **ecpp, lease_t lease) -{ - ENCODE *ep, *prev_ep, *lease_ep; - - lease = htonl(lease); - - if (ecpp != NULL && (lease_ep = find_encode(*ecpp, DSYM_STANDARD, - CD_LEASE_TIME)) != NULL && lease_ep->len == sizeof (lease_t)) { - (void) memcpy(lease_ep->data, (void *)&lease, sizeof (lease_t)); - } else { - if (*ecpp != NULL) { - for (prev_ep = ep = *ecpp; ep != NULL; ep = ep->next) - prev_ep = ep; - prev_ep->next = make_encode(DSYM_STANDARD, - CD_LEASE_TIME, sizeof (lease_t), &lease, ENC_COPY); - } else { - *ecpp = make_encode(DSYM_STANDARD, CD_LEASE_TIME, - sizeof (lease_t), &lease, ENC_COPY); - (*ecpp)->next = NULL; - } - } -} -/* - * Sets appropriate option in passed ENCODE list for lease. Returns - * calculated relative lease time. - */ -static int -config_lease(PKT_LIST *plp, dn_rec_t *dnp, ENCODE **ecpp, lease_t oldlease, - boolean_t negot) -{ - lease_t newlease, rel_current; - ENCODE *lease_ecp; - - if (ecpp != NULL && (lease_ecp = find_encode(*ecpp, DSYM_STANDARD, - CD_LEASE_TIME)) != NULL && lease_ecp->len == sizeof (lease_t)) { - (void) memcpy((void *)&rel_current, lease_ecp->data, - sizeof (lease_t)); - rel_current = htonl(rel_current); - } else - rel_current = (lease_t)DEFAULT_LEASE; - - if (dnp->dn_flags & DN_FAUTOMATIC || !negot) { - if (dnp->dn_flags & DN_FAUTOMATIC) - newlease = ntohl(DHCP_PERM); - else { - /* sorry! */ - if (oldlease) - newlease = oldlease; - else - newlease = rel_current; - } - } else { - /* - * lease is not automatic and is negotiable! - * If the dhcp-network lease is bigger than the current - * policy value, then let the client benefit from this - * situation. - */ - if (oldlease > rel_current) - rel_current = oldlease; - - if (plp->opts[CD_LEASE_TIME] && - plp->opts[CD_LEASE_TIME]->len == sizeof (lease_t)) { - /* - * Client is requesting a lease renegotiation. - */ - (void) memcpy((void *)&newlease, - plp->opts[CD_LEASE_TIME]->value, sizeof (lease_t)); - - newlease = ntohl(newlease); - - /* - * Note that this comparison handles permanent - * leases as well. Limit lease to configured value. - */ - if (newlease > rel_current) - newlease = rel_current; - } else - newlease = rel_current; - } - - set_lease_option(ecpp, newlease); - - return (newlease); -} - -/* - * If a packet has the classid set, return the value, else return null. - */ -char * -get_class_id(PKT_LIST *plp, char *bufp, int len) -{ - uchar_t *ucp, ulen; - char *retp; - - if (plp->opts[CD_CLASS_ID]) { - /* - * If the class id is set, see if there is a macro by this - * name. If so, then "OR" the ENCODE settings of the class - * macro with the packet macro. Settings in the packet macro - * OVERRIDE settings in the class macro. - */ - ucp = plp->opts[CD_CLASS_ID]->value; - ulen = plp->opts[CD_CLASS_ID]->len; - if (len < ulen) - ulen = len; - (void) memcpy(bufp, ucp, ulen); - bufp[ulen] = '\0'; - - retp = bufp; - } else - retp = NULL; - - return (retp); -} - -/* - * Checks whether an offer ip address in the per net inet address - * cache. - * - * pnd - per net structure - * reservep - address to check, in network order. - */ -static boolean_t -check_offer(dsvc_dnet_t *pnd, struct in_addr *reservep) -{ - dsvc_clnt_t tpcd; - - tpcd.off_ip.s_addr = reservep->s_addr; - - return (hash_Lookup(pnd->itable, reservep, sizeof (struct in_addr), - clnt_netcmp, &tpcd, B_FALSE) == NULL ? B_TRUE : B_FALSE); -} - -/* - * Adds or updates an offer to the per client data structure. The client - * struct is hashed by clientid into the per net ctable hash table, and - * by offer address in the itable hash table, which is used to reserve the - * ip address. Lease time is expected to be set by caller. - * Will update existing OFFER if already provided. - * - * This implementation does not consider the fact that an offer can be - * sent out via more than one interface, so dsvc_clnt_t.ifp should - * really be a list or the itable's entries should be lists of - * dsvc_clnt_ts. As long as we don't change this, we assume that the - * client will eventually REQUEST the last offer we have sent out - * because when we receive the same DISCOVER via multiple interfaces, - * we always update the same offer cache entry so its ifp is always - * the interface we received the last DISCOVER on. - * - * pcd - per client data struct. - * dnlp - pointer to pointer to current container entry. Performance: caching - * reduces datastore activity, structure copying. - * nlease - new lease time. - * reservep - new offer address (expected in network order). - * purge_cache - Multithreading: avoid redundant cache purging in - * select_offer(). - */ -boolean_t -update_offer(dsvc_clnt_t *pcd, dn_rec_list_t **dnlp, lease_t nlease, - struct in_addr *reservep, boolean_t purge_cache) -{ - char ntoab[INET_ADDRSTRLEN]; - boolean_t insert = B_TRUE; - boolean_t update = B_FALSE; - boolean_t offer = B_FALSE; - dsvc_dnet_t *pnd = pcd->pnd; - IF *ifp = pcd->ifp; - dn_rec_t *dnp = NULL; - struct in_addr off_ip; - - /* Save the original datastore record. */ - if (dnlp != NULL && *dnlp != NULL) { - if (pcd->dnlp != NULL && pcd->dnlp != *dnlp) - dhcp_free_dd_list(pnd->dh, pcd->dnlp); - pcd->dnlp = *dnlp; - } - if (pcd->dnlp != NULL) - dnp = pcd->dnlp->dnl_rec; - - /* Determine the offer address. */ - if (reservep == NULL && dnp != NULL) - off_ip.s_addr = htonl(dnp->dn_cip.s_addr); - else if (reservep != NULL) - off_ip.s_addr = reservep->s_addr; - else { - dhcpmsg(LOG_DEBUG, - "Neither offer IP nor IP to reserve present\n"); - assert(B_FALSE); - return (B_FALSE); - } - - /* If updating, release the old offer address. */ - if (pcd->off_ip.s_addr == htonl(INADDR_ANY)) { - offer = B_TRUE; - } else { - update = B_TRUE; - if (pcd->off_ip.s_addr != off_ip.s_addr) { - purge_offer(pcd, B_FALSE, purge_cache); - offer = B_TRUE; - } else - insert = B_FALSE; - } - - if (nlease != 0) - pcd->lease = nlease; - - /* Prepare to insert pcd into the offer hash table. */ - pcd->mtime = reinit_time; - - pcd->off_ip.s_addr = off_ip.s_addr; - - assert(pcd->off_ip.s_addr != htonl(INADDR_ANY)); - - if (insert) { - if ((pcd->ihand = hash_Insert(pnd->itable, &pcd->off_ip, - sizeof (struct in_addr), clnt_netcmp, pcd, pcd)) == NULL) { - if (reservep == NULL) { - dhcpmsg(LOG_WARNING, "Duplicate offer of %1$s " - "to client: %2$s\n", - inet_ntop(AF_INET, &pcd->off_ip, ntoab, - sizeof (ntoab)), pcd->cidbuf); - } - pcd->off_ip.s_addr = htonl(INADDR_ANY); - dhcp_free_dd_list(pnd->dh, pcd->dnlp); - if (dnlp != NULL && *dnlp != NULL && - pcd->dnlp == *dnlp) { - *dnlp = NULL; - } - pcd->dnlp = NULL; - return (B_FALSE); - } - } else - hash_Dtime(pcd->ihand, time(NULL) + off_secs); - - if (offer) { - (void) mutex_lock(&ifp->ifp_mtx); - ifp->offers++; - (void) mutex_unlock(&ifp->ifp_mtx); - } - - if (debug) { - if (reservep != NULL) { - dhcpmsg(LOG_INFO, "Reserved offer: %s\n", - inet_ntop(AF_INET, &pcd->off_ip, - ntoab, sizeof (ntoab))); - } else if (update) { - dhcpmsg(LOG_INFO, "Updated offer: %s\n", - inet_ntop(AF_INET, &pcd->off_ip, - ntoab, sizeof (ntoab))); - } else { - dhcpmsg(LOG_INFO, "Added offer: %s\n", - inet_ntop(AF_INET, &pcd->off_ip, - ntoab, sizeof (ntoab))); - } - } - return (B_TRUE); -} - -/* - * Deletes an offer. - * - * pcd - per client struct - * expired - has offer expired, or been purged - * purge_cache - Multi-threading: avoid redundant cache purging in - * select_offer(). - */ -void -purge_offer(dsvc_clnt_t *pcd, boolean_t expired, boolean_t purge_cache) -{ - char ntoab[INET_ADDRSTRLEN]; - dsvc_dnet_t *pnd = pcd->pnd; - IF *ifp = pcd->ifp; - - if (pcd->off_ip.s_addr != htonl(INADDR_ANY)) { - if (debug) { - if (expired == B_TRUE) - dhcpmsg(LOG_INFO, "Freeing offer: %s\n", - inet_ntop(AF_INET, &pcd->off_ip, - ntoab, sizeof (ntoab))); - else - dhcpmsg(LOG_INFO, "Purging offer: %s\n", - inet_ntop(AF_INET, &pcd->off_ip, - ntoab, sizeof (ntoab))); - } - - /* - * The offer cache ensures that recently granted offer - * addresses won't attempt to be reused from the dnet - * caches. When purging one of these offers, be sure to - * remove the associated record from the dnet cache, - * to avoid collisions. - */ - if (pcd->state == ACK && pcd->dnlp != NULL) { - if (purge_cache) - purge_dnet_cache(pnd, pcd->dnlp->dnl_rec); - dhcp_free_dd_list(pnd->dh, pcd->dnlp); - pcd->dnlp = NULL; - } - - - /* Prepare to delete pcd from the offer hash table. */ - (void) hash_Delete(pnd->itable, &pcd->off_ip, - sizeof (struct in_addr), clnt_netcmp, pcd, NULL); - - pcd->off_ip.s_addr = htonl(INADDR_ANY); - - (void) mutex_lock(&ifp->ifp_mtx); - if (ifp->offers > 0) - ifp->offers--; - if (expired) - ifp->expired++; - (void) mutex_unlock(&ifp->ifp_mtx); - } -} - -/* - * Allocate a new entry in the dhcp-network db for the cid, taking into - * account requested IP address. Verify address. - * - * The network portion of the address doesn't have to be the same as ours, - * just owned by us. We also make sure we don't select a record which is - * currently in use, by reserving the address in the offer cache. Database - * records are cached up to the D_OFFER lifetime to improve performance. - * - * Returns: 1 if there's a usable entry for the client, 0 - * if not. Places the record in the dn_rec_list_t structure - * pointer handed in. - */ -/*ARGSUSED*/ -boolean_t -select_offer(dsvc_dnet_t *pnd, PKT_LIST *plp, dsvc_clnt_t *pcd, - dn_rec_list_t **dnlpp) -{ - struct in_addr req_ip, *req_ipp = &req_ip, tip; - boolean_t found = B_FALSE; - time_t now; - dn_rec_t dn, *dnp; - dn_rec_list_t *dncp, *dnsp, *tlp; - int nrecords; - uint32_t query; - int retry; - boolean_t io_done, is_bootp; - struct in_addr *oip; - - if (plp->opts[CD_DHCP_TYPE] == NULL) - is_bootp = B_TRUE; - else - is_bootp = B_FALSE; - - *dnlpp = NULL; - if (!is_bootp) { - /* - * Is the DHCP client requesting a specific address? Is so, and - * we can satisfy him, do so. - */ - if (plp->opts[CD_REQUESTED_IP_ADDR] != NULL) { - (void) memcpy((void *)&req_ip, - plp->opts[CD_REQUESTED_IP_ADDR]->value, - sizeof (struct in_addr)); - - if ((req_ip.s_addr & pnd->subnet.s_addr) == - pnd->net.s_addr) - found = B_TRUE; - - } else if (plp->opts[CD_HOSTNAME] != NULL) { - char hname[MAXHOSTNAMELEN + 1]; - int hlen; - - /* turn hostname option into a string */ - hlen = plp->opts[CD_HOSTNAME]->len; - hlen = MIN(hlen, MAXHOSTNAMELEN); - (void) memcpy(hname, plp->opts[CD_HOSTNAME]->value, - hlen); - hname[hlen] = '\0'; - - dhcpmsg(LOG_DEBUG, - "select_offer: hostname request for %s\n", hname); - if (name_avail(hname, pcd, plp, dnlpp, NULL, - &req_ipp) && req_ipp) { - if ((req_ip.s_addr & pnd->subnet.s_addr) == - pnd->net.s_addr) { - found = B_TRUE; - } else if (*dnlpp != NULL) { - dhcp_free_dd_list(pnd->dh, *dnlpp); - *dnlpp = NULL; - } - dhcpmsg(LOG_DEBUG, "select_offer: hostname %s " - "available, req_ip %x\n", hname, - ntohl(req_ip.s_addr)); - } else - dhcpmsg(LOG_DEBUG, "select_offer: name_avail " - "false or no address for %s\n", hname); - } - } - - /* - * Check the offer list and table entry. - */ - if (found && *dnlpp == NULL) - found = addr_avail(pnd, pcd, dnlpp, req_ip, B_FALSE); - - if (!found) { - /* - * Try to find a free entry. Look for an AVAILABLE entry - * (cid == 0x00, len == 1), owned by us. - * The outer loop runs through the server ips owned by us. - * - * Multi-threading: to improve performance, the following - * algorithm coordinates accesses to the underlying table, - * so only one thread is initiating lookups per network. - * This is crucial, as lookup operations are expensive, - * and not sufficiently malleable to allow partitioned - * lookups (e.g. all that can be asked for are n free or - * server-owned entries, multiple threads will retrieve - * the same records). - * - * The three iterations through the inner loop attempt to use - * - * 1) the next cached entry - * 2) all cached entries - * 3) all free or per-server entries in the underlying table - * - * Since many threads are consuming the cached entries, - * any thread may find itself in the role of having to - * refresh the cache. We always read at least enough - * entries to satisfy all current threads. Reading all - * records is prohibitively expensive, and should only - * be done as a last resort. - * - * As always, to better distribute garbage - * collection and data structure aging tasks, each - * thread must actively implement policy, checking - * for offer expiration (which invalidates the cache). - */ - - for (oip = owner_ip; oip->s_addr != INADDR_ANY; oip++) { - /* - * Initialize query. - */ - DSVC_QINIT(query); - DSVC_QEQ(query, DN_QCID|DN_QSIP); - dn.dn_cid[0] = '\0'; - dn.dn_cid_len = 1; - dn.dn_sip.s_addr = ntohl(oip->s_addr); - - /* - * Decide whether a bootp record is required. - */ - dn.dn_flags = 0; - DSVC_QEQ(query, DN_QFBOOTP_ONLY); - if (is_bootp) - dn.dn_flags = DN_FBOOTP_ONLY; - - /* - * These flags are used counter-intuitively. - * This says that the setting of the bit - * (off) in the dn.dn_flags matches the - * setting in the record (off). - */ - DSVC_QEQ(query, DN_QFUNUSABLE|DN_QFMANUAL); - - for (retry = 0; !found && retry < 3; retry++) { - now = time(NULL); - (void) mutex_lock(&pnd->thr_mtx); - nrecords = pnd->nthreads < DHCP_MIN_RECORDS ? - DHCP_MIN_RECORDS : pnd->nthreads; - (void) mutex_unlock(&pnd->thr_mtx); - - /* - * Purge cached records when expired or database - * re-read. - */ - - (void) mutex_lock(&pnd->free_mtx); - dncp = pnd->freerec; - if (dncp != NULL && - PND_FREE_TIMEOUT(pnd, now)) { - pnd->freerec = NULL; - dhcp_free_dd_list(pnd->dh, dncp); - dncp = NULL; - } - - if (dncp != NULL) { - if (retry == 0) { - /* Try the next cached record */ - pnd->freerec = dncp->dnl_next; - dncp->dnl_next = NULL; - } else if (retry == 1) { - /* - * Try all remaining cached - * records - */ - pnd->freerec = NULL; - } - } - if (retry > 1) { - /* Try all possible records in datastore. */ - pnd->freerec = NULL; - nrecords = -1; - if (dncp != NULL) { - dhcp_free_dd_list( - pnd->dh, dncp); - dncp = NULL; - } - } - (void) mutex_unlock(&pnd->free_mtx); - - io_done = (dncp == NULL); - *dnlpp = dhcp_lookup_dd_classify(pcd->pnd, - nrecords == -1 ? B_FALSE : B_TRUE, query, - nrecords, &dn, (void **)&dncp, - S_CID | S_FREE); - if (*dnlpp != NULL) { - dnp = (*dnlpp)->dnl_rec; - tip.s_addr = htonl(dnp->dn_cip.s_addr); - (void) update_offer(pcd, NULL, 0, - &tip, B_TRUE); - found = B_TRUE; - } - - (void) mutex_lock(&pnd->free_mtx); - if (io_done) { - /* - * Note time when records were read. - */ - if (dncp != NULL) { - now = time(NULL); - pnd->free_mtime = reinit_time; - pnd->free_stamp = now + - cache_secs; - } - } - - /* Save any leftover records for later use. */ - if (dncp != NULL) { - for (tlp = dncp; - tlp != NULL && tlp->dnl_next; - tlp = tlp->dnl_next) - /* null statement */; - tlp->dnl_next = pnd->freerec; - pnd->freerec = dncp; - } - (void) mutex_unlock(&pnd->free_mtx); - } - } - } - - if (!found && !is_bootp) { - /* - * Struck out. No usable available addresses. Let's look for - * the LRU expired address. Only makes sense for dhcp - * clients. First we'll try the next record from - * the lru list (this assumes lru database search capability). - * Next we'll try all records. Finally we'll go get all - * free records. - * - * Multi-threading: to improve performance, the following - * algorithm coordinates accesses to the underlying table, - * so only one thread is initiating lookups per network. - * This is crucial, as lookup operations are expensive, - * and not sufficiently malleable to allow partitioned - * lookups (e.g. all that can be asked for are n free or - * server-owned entries, multiple threads will retrieve - * the same records). - * - * We only consider clients owned by us. - * The outer loop runs through the server ips owned by us - * - * The three iterations through the inner loop attempt to use - * - * 1) the next cached entry - * 2) all cached entries - * 3) all free or per-server entries in the underlying table - * - * Since many threads are consuming the cached entries, - * any thread may find itself in the role of having to - * refresh the cache. We always read at least enough - * entries to satisfy all current threads. Reading all - * records is prohibitively expensive, and should only - * be done as a last resort. - * - * As always, to better distribute garbage - * collection and data structure aging tasks, each - * thread must actively implement policy, checking - * for offer expiration (which invalidates the cache). - */ - - for (oip = owner_ip; oip->s_addr != INADDR_ANY; oip++) { - /* - * Initialize query. - */ - DSVC_QINIT(query); - DSVC_QEQ(query, DN_QSIP); - dn.dn_sip.s_addr = ntohl(oip->s_addr); - - /* - * These flags are used counter-intuitively. - * This says that the setting of the bit - * (off) in the dn.dn_flags matches the - * setting in the record (off). - */ - DSVC_QEQ(query, DN_QFBOOTP_ONLY| - DN_QFMANUAL|DN_QFUNUSABLE); - dn.dn_flags = 0; - - for (retry = 0; !found && retry < 3; retry++) { - now = time(NULL); - (void) mutex_lock(&pnd->thr_mtx); - nrecords = pnd->nthreads < DHCP_MIN_RECORDS ? - DHCP_MIN_RECORDS : pnd->nthreads; - (void) mutex_unlock(&pnd->thr_mtx); - - /* - * Purge cached records when expired or database - * re-read. - */ - - (void) mutex_lock(&pnd->lru_mtx); - dnsp = pnd->lrurec; - if (dnsp != NULL && PND_LRU_TIMEOUT(pnd, now)) { - pnd->lrurec = NULL; - dhcp_free_dd_list(pnd->dh, dnsp); - dnsp = NULL; - } - - if (dnsp != NULL) { - if (retry == 0) { - /* Try the next cached record */ - pnd->lrurec = dnsp->dnl_next; - dnsp->dnl_next = NULL; - } else if (retry == 1) { - /* - * Try all remaining cached - * records - */ - pnd->lrurec = NULL; - } - } - if (retry > 1) { - /* Try all possible records */ - pnd->lrurec = NULL; - nrecords = -1; - if (dnsp != NULL) { - dhcp_free_dd_list(pnd->dh, - dnsp); - dnsp = NULL; - } - } - (void) mutex_unlock(&pnd->lru_mtx); - - io_done = (dnsp == NULL); - *dnlpp = dhcp_lookup_dd_classify(pcd->pnd, - nrecords == -1 ? B_FALSE : B_TRUE, query, - nrecords, &dn, (void **)&dnsp, S_LRU); - if (*dnlpp != NULL) { - dnp = (*dnlpp)->dnl_rec; - tip.s_addr = htonl(dnp->dn_cip.s_addr); - (void) update_offer(pcd, NULL, 0, &tip, - B_TRUE); - found = B_TRUE; - } - - (void) mutex_lock(&pnd->lru_mtx); - if (io_done) { - if (dnsp != NULL) { - now = time(NULL); - pnd->lru_mtime = reinit_time; - pnd->lru_stamp = now + - cache_secs; - } - } - - /* - * Save any leftover records for possible - * later use - */ - if (dnsp != NULL) { - for (tlp = dnsp; - tlp != NULL && tlp->dnl_next; - tlp = tlp->dnl_next) - /* null statement */; - tlp->dnl_next = pnd->lrurec; - pnd->lrurec = dnsp; - } - (void) mutex_unlock(&pnd->lru_mtx); - } - } - } - - return (found); -} - -/* - * purge_dnet_cache() - remove conflicting entries from the - * free and lru dnet caches when records are modified. Expensive - * but necessary. - * - * pnd - per net struct - * dnp - pointer to cached/modified entry - */ -static void -purge_dnet_cache(dsvc_dnet_t *pnd, dn_rec_t *dnp) -{ - dn_rec_list_t *tlp; - dn_rec_list_t *plp; - - (void) mutex_lock(&pnd->free_mtx); - - for (plp = tlp = pnd->freerec; tlp != NULL; tlp = tlp->dnl_next) { - if (tlp->dnl_rec->dn_cip.s_addr == dnp->dn_cip.s_addr) { - if (tlp == plp) { - pnd->freerec = tlp->dnl_next; - } else { - plp->dnl_next = tlp->dnl_next; - } - tlp->dnl_next = NULL; - break; - } - plp = tlp; - } - (void) mutex_unlock(&pnd->free_mtx); - if (tlp != NULL) - dhcp_free_dd_list(pnd->dh, tlp); - - (void) mutex_lock(&pnd->lru_mtx); - for (plp = tlp = pnd->lrurec; tlp != NULL; tlp = tlp->dnl_next) { - if (tlp->dnl_rec->dn_cip.s_addr == dnp->dn_cip.s_addr) { - if (tlp == plp) { - pnd->lrurec = tlp->dnl_next; - } else { - plp->dnl_next = tlp->dnl_next; - } - tlp->dnl_next = NULL; - break; - } - plp = tlp; - } - (void) mutex_unlock(&pnd->lru_mtx); - if (tlp != NULL) - dhcp_free_dd_list(pnd->dh, tlp); -} - -/* - * add_dnet_cache() - add a free entry back to the free dnet cache. - * - * Performance: this can greatly reduce the amount of work select_offer() - * must perform. - * - * pnd - per net struct - * dnlp - pointer to cached/modified entry. - */ -static void -add_dnet_cache(dsvc_dnet_t *pnd, dn_rec_list_t *dnlp) -{ - (void) mutex_lock(&pnd->free_mtx); - dnlp->dnl_next = pnd->freerec; - pnd->freerec = dnlp; - (void) mutex_unlock(&pnd->free_mtx); -} - -static char unowned_net[] = "the DHCP server believes the IP address that" - " corresponds to the requested host name belongs to a network not" - " managed by the DHCP server.\n"; -static char unowned_addr[] = "the DHCP server believes the IP address that" - " corresponds to the requested host name is not managed by the DHCP" - " server.\n"; - -/* - * Determine whether the requested IP address is available to the requesting - * client. To be so, its IP address must be managed by us, be on the ``right'' - * network and neither currently leased nor currently under offer to another - * client. - */ -static boolean_t -addr_avail(dsvc_dnet_t *pnd, dsvc_clnt_t *pcd, dn_rec_list_t **dnlpp, - struct in_addr req_ip, boolean_t isname) -{ - dn_rec_t dn; - dn_rec_list_t *dnip; - uint32_t query; - - *dnlpp = NULL; - /* - * first, check the ICMP list or offer list. - */ - if (isname) { - if (pcd->off_ip.s_addr != req_ip.s_addr && - check_offer(pnd, &req_ip) == B_FALSE) { - /* Offered to someone else. Sorry. */ - dhcpmsg(LOG_DEBUG, "name_avail(F):" - " check_offer failed\n"); - return (B_FALSE); - } - } else { - if (update_offer(pcd, NULL, 0, &req_ip, B_TRUE) == B_FALSE) { - /* Offered to someone else. Sorry. */ - if (isname) { - dhcpmsg(LOG_DEBUG, "name_avail(F):" - " check_other_offers failed\n"); - } - return (B_FALSE); - } - } - - /* - * entry_available() searches for owner_ips - * query on DN_QCIP will suffice here - */ - DSVC_QINIT(query); - DSVC_QEQ(query, DN_QCIP); - dn.dn_cip.s_addr = ntohl(req_ip.s_addr); - - dnip = NULL; - *dnlpp = dhcp_lookup_dd_classify(pnd, B_FALSE, query, -1, &dn, - (void **)&dnip, 0); - dhcp_free_dd_list(pnd->dh, dnip); - if (*dnlpp != NULL) { - /* - * Ok, the requested IP exists. But is it available? - */ - if (!entry_available(pcd, (*dnlpp)->dnl_rec)) { - dhcp_free_dd_list(pnd->dh, *dnlpp); - *dnlpp = NULL; - purge_offer(pcd, B_FALSE, B_TRUE); - return (B_FALSE); - } - } else { - if (isname) - dhcpmsg(LOG_DEBUG, "name_avail(F): %s", unowned_addr); - else - purge_offer(pcd, B_FALSE, B_TRUE); - return (B_FALSE); - } - return (B_TRUE); -} - -/* - * Determine whether "name" is available. To be so, it must either not have - * a corresponding IP address, or its IP address must be managed by us and - * neither currently leased nor currently under offer to a client. - * - * To determine this, we first attempt to translate the name to an address. - * If no name-to-address translation exists, it's automatically available. - * Otherwise, we next check for any outstanding offers. Finally, we look - * at the flags in the corresponding per-network table to see whether the - * address is currently leased. - * - * Upon successful completion, we also return the vetted IP address as a - * value result parameter. - */ -static boolean_t -name_avail(char *name, dsvc_clnt_t *pcd, PKT_LIST *plp, dn_rec_list_t **dnlpp, - ENCODE *ecp, struct in_addr **iap) -{ - struct hostent h, *hp, *owner_hp; - char hbuf[NSS_BUFLEN_HOSTS]; - char fqname [NS_MAXDNAME+1]; - char owner [NS_MAXDNAME+1]; - int err, ho_len; - struct in_addr ia, ma; - dsvc_dnet_t *pnd; - boolean_t isopen = B_FALSE; - ENCODE *ep; - - *dnlpp = NULL; - /* - * If possible, use a fully-qualified name to do the name-to- - * address query. The complication is that the domain name - * with which to qualify the client's host name resides in a - * dhcptab macro unavailable at the time of the DHCPOFFER. - * ecp will be non-NULL if we may have the means to fully-qualify - * the name given. - */ - if (strchr(name, '.') != NULL) { - (void) strlcpy(fqname, name, sizeof (fqname)); - if (fqname[(strlen(fqname))-1] != '.') - (void) strcat(fqname, "."); - } else { - /* - * Append '.' domain-name '.' to hostname. - * Note the use of the trailing '.' to avoid any surprises - * because of the ndots value (see resolv.conf(4) for more - * information about the latter). - * - * First see whether we can dredge up domain-name from the - * ENCODE list. - */ - if ((ecp != NULL) && ((ep = find_encode(ecp, - DSYM_STANDARD, CD_DNSDOMAIN)) != NULL)) { - DHCP_OPT *ho = plp->opts[CD_HOSTNAME]; - - /* - * name_avail() should never be called unless the - * CD_HOSTNAME option is present in the client's - * packet. - */ - assert(ho != NULL); - ho_len = ho->len; - if (ho->value[ho_len - 1] == '\0') { - /* null at end of the hostname */ - ho_len = strlen((char *)ho->value); - } - - if (qualify_hostname(fqname, (char *)ho->value, - (char *)ep->data, ho_len, ep->len) == -1) - return (B_FALSE); - - dhcpmsg(LOG_DEBUG, "name_avail: unqualified name\n" - "found CD_DNSDOMAIN and qualified: %s\n", fqname); - } else { - /* - * No DNS domain in the ENCODE list, have to use - * local domain name. - */ - if ((resolv_conf.defdname == NULL) || - (qualify_hostname(fqname, name, - resolv_conf.defdname, - strlen(name), - strlen(resolv_conf.defdname)) == -1)) - return (B_FALSE); - - dhcpmsg(LOG_DEBUG, - "name_avail: unqualified name\n" - "qualified with local domain: %s\n", fqname); - } - } - - /* - * Try a forward lookup on the requested name. - * Consider the name available if we get a definitive - * ``name doesn't exist'' indication. - */ - hp = gethostbyname_r(fqname, &h, hbuf, sizeof (hbuf), &err); - if (hp == NULL) - if ((err == HOST_NOT_FOUND) || (err == NO_DATA)) { - *iap = NULL; - dhcpmsg(LOG_DEBUG, - "name_avail(T): gethostbyname_r failed\n"); - return (B_TRUE); - } else { - dhcpmsg(LOG_DEBUG, - "name_avail(F): gethostbyname_r failed, err %d\n", - err); - return (B_FALSE); - } - - /* - * Check that the address has not been leased to someone else. - * Bear in mind that there may be inactive A records in the DNS - * (since we don't delete them when a lease expires or is released). - * Try a reverse lookup on the address returned in hp. - * If the owner of this address is different to the requested name - * we can infer that owner is a stale A record. - */ - - (void) memcpy(&ia, hp->h_addr, sizeof (struct in_addr)); - owner_hp = gethostbyaddr_r((char *)&ia, sizeof (struct in_addr), - AF_INET, &h, hbuf, sizeof (hbuf), &err); - - if (owner_hp == NULL) { - /* If there's no PTR record the address can't be in use */ - if ((err == HOST_NOT_FOUND) || (err == NO_DATA)) { - *iap = NULL; - dhcpmsg(LOG_DEBUG, - "name_avail(T): gethostbyaddr_r failed\n"); - return (B_TRUE); - } else { - dhcpmsg(LOG_DEBUG, - "name_avail(F): gethostbyaddr_r failed\n"); - return (B_FALSE); - } - } - - /* If name returned is not a FQDN, qualify with local domain name */ - - if (strchr(owner_hp->h_name, '.') != NULL) { - (void) strlcpy(owner, owner_hp->h_name, sizeof (owner)); - if (owner[(strlen(owner))-1] != '.') - (void) strcat(owner, "."); - } else { - if ((resolv_conf.defdname == NULL) || - (qualify_hostname(owner, owner_hp->h_name, - resolv_conf.defdname, - strlen(owner_hp->h_name), - strlen(resolv_conf.defdname)) == -1)) - return (B_FALSE); - - dhcpmsg(LOG_DEBUG, - "name_avail: address owner qualified with %s\n", - resolv_conf.defdname); - } - - if ((strncmp(owner, fqname, NS_MAXDNAME)) != 0) { - /* Forward lookup found an inactive record - ignore it */ - *iap = NULL; - dhcpmsg(LOG_DEBUG, "name_avail(T): 'A' record inactive: %s\n", - owner); - return (B_TRUE); - } - - /* Get pnd of the current client */ - pnd = pcd->pnd; - get_netmask(&ia, &ma); - if (pnd->net.s_addr != (ia.s_addr & ma.s_addr)) { - /* get pnd of previous owner of the hostname */ - if (open_dnet(&pnd, &ia, &ma) != DSVC_SUCCESS) { - /* we must not manage the net containing this address */ - dhcpmsg(LOG_DEBUG, "name_avail(F): %s", unowned_net); - return (B_FALSE); - } - isopen = B_TRUE; - } - - /* - * Test that the address has not been offered to someone else. - */ - if (!addr_avail(pnd, pcd, dnlpp, ia, B_TRUE)) { - if (isopen) { - close_dnet(pnd, B_FALSE); - } - return (B_FALSE); - } - if (isopen) - close_dnet(pnd, B_FALSE); - - /* LINTED */ - **iap = *((struct in_addr *)hp->h_addr); - dhcpmsg(LOG_DEBUG, "name_avail(T)\n"); - return (B_TRUE); -} - -static boolean_t -entry_available(dsvc_clnt_t *pcd, dn_rec_t *dnp) -{ - char ntoab[INET_ADDRSTRLEN]; - boolean_t isme = dnp->dn_cid_len == pcd->cid_len && - memcmp(pcd->cid, dnp->dn_cid, pcd->cid_len) == 0; - (void) inet_ntop(AF_INET, &(dnp->dn_sip), ntoab, sizeof (ntoab)); - - if ((dnp->dn_flags & (DN_FMANUAL|DN_FUNUSABLE)) != 0) { - dhcpmsg(LOG_DEBUG, "entry_available():" - " %s is manually allocated or not usable\n", - ntoab); - return (B_FALSE); - } - - if (dnp->dn_cid_len != 0 && isme == B_FALSE && - (dnp->dn_flags & (DN_FAUTOMATIC|DN_FBOOTP_ONLY))) { - dhcpmsg(LOG_DEBUG, "entry_available():" - " %s is a permanent address or reserved for BOOTP\n", - ntoab); - return (B_FALSE); - } - - if (dnp->dn_cid_len != 0 && isme == B_FALSE && - (lease_t)time(NULL) < (lease_t)ntohl(dnp->dn_lease)) { - dhcpmsg(LOG_DEBUG, "entry_available():" - " lease on %s has not expired\n", - ntoab); - return (B_FALSE); - } - - if (match_ownerip(htonl(dnp->dn_sip.s_addr)) == NULL) { - dhcpmsg(LOG_DEBUG, "entry_available():" - " %s does not match owner_ip\n", - ntoab); - return (B_FALSE); - } - - /* Input IP is good. */ - return (B_TRUE); -} - -static char msft_classid[] = "MSFT "; -static char no_domain[] = "name service update on behalf of client with ID" -" %s failed because requested name was not fully-qualified and no DNS" -" domain name was specified for this client in the dhcptab\n"; - -/* - * Given a host name and IP address, try to do a host name update. - */ -static boolean_t -do_nsupdate(struct in_addr ia, ENCODE *ecp, PKT_LIST *plp) -{ - struct hostent *hp; - DHCP_OPT *ho; - ENCODE *ep; - char class_idbuf[DSYM_CLASS_SIZE]; - int puthostent_ret; - - /* - * hostent information is dynamically allocated so that threads spawned - * by dns_puthostent() will have access to it after the calling thread - * has returned. - */ - hp = (struct hostent *)smalloc(sizeof (struct hostent)); - hp->h_addr_list = (char **)smalloc(2 * sizeof (char **)); - hp->h_addr_list[1] = NULL; - hp->h_addr = smalloc(sizeof (struct in_addr)); - hp->h_aliases = NULL; - hp->h_addrtype = AF_INET; - hp->h_length = sizeof (struct in_addr); - /* - * Convert address to network order, as that's what hostent's are - * expected to be. - */ - /* LINTED */ - ((struct in_addr *)hp->h_addr)->s_addr = htonl(ia.s_addr); - - /* - * Is the host name unqualified? If so, try to qualify it. If that - * can't be done, explain why the update won't be attempted. - */ - ho = plp->opts[CD_HOSTNAME]; - if (memchr(ho->value, '.', ho->len) == NULL) { - /* - * See whether we can dredge up the DNS domain from the - * ENCODE list. - */ - if ((ep = find_encode(ecp, DSYM_STANDARD, CD_DNSDOMAIN)) != - NULL) { - char *fqname; - int ho_len = ho->len; - - /* - * We need room for - * - * hostname len + - * strlen(".") + - * domainname len + - * strlen(".") + - * trailing '\0' - * - * Note the use of the trailing '.' to avoid any - * surprises because of the ndots value (see - * resolv.conf(4) for more information about - * the latter). - */ - if (ho->value[ho_len - 1] == '\0') { - ho_len = strlen((char *)ho->value); - } - fqname = smalloc(ho_len + ep->len + 1 + 1 + 1); - /* first copy host name, ... */ - (void) memcpy(fqname, ho->value, ho_len); - /* then '.', ... */ - (void) memcpy(fqname + ho_len, ".", 1); - /* ... then domain name, */ - (void) memcpy(fqname + ho_len + 1, ep->data, ep->len); - /* then a trailing '.', ... */ - (void) memcpy(fqname + ho_len + ep->len + 1, ".", 1); - /* no need to null-terminate - smalloc() did it */ - - hp->h_name = fqname; - dhcpmsg(LOG_DEBUG, "do_nsupdate: unqualified name\n" - "found CD_DNSDOMAIN and qualified: %s\n", fqname); - } else { - char cidbuf[BUFSIZ]; - - (void) disp_cid(plp, cidbuf, sizeof (cidbuf)); - dhcpmsg(LOG_INFO, no_domain, cidbuf); - } - } else { - hp->h_name = smalloc(ho->len + 1); - (void) memcpy(hp->h_name, ho->value, ho->len); - dhcpmsg(LOG_DEBUG, "do_nsupdate: fully qualified name: %s\n", - hp->h_name); - } - - /* returns -1 or the number of name service updates done */ - puthostent_ret = dns_puthostent(hp, nsutimeout_secs); - dhcpmsg(LOG_DEBUG, "do_nsupdate: dns_puthostent returned %d\n", - puthostent_ret); - if (puthostent_ret == -1) { - return (B_FALSE); - } else if (puthostent_ret == 0) { - /* - * dns_puthostent() didn't see any errors occur, - * but no updates were done; Microsoft clients - * (i.e. clients with a Microsoft class ID) expect - * it to succeed, so we lie to them. - */ - if (((get_class_id(plp, class_idbuf, - sizeof (class_idbuf))) != NULL) && - (strncmp(msft_classid, class_idbuf, - sizeof (msft_classid)) == 0)) { - dhcpmsg(LOG_DEBUG, "do_nsupdate: class ID \"%s\"\n", - class_idbuf); - return (B_TRUE); - } else - return (B_FALSE); - } else { - return (B_TRUE); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/dhcpd.h b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/dhcpd.h deleted file mode 100644 index 79fc5331a9..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/dhcpd.h +++ /dev/null @@ -1,227 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. - */ - -#ifndef _DHCPD_H -#define _DHCPD_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * dhcpd.h -- common header file for all the modules of the in.dhcpd program. - */ - -#include <dhcp_svc_confopt.h> -#include <dhcp_svc_private.h> -#include <dhcp_svc_public.h> -#include <dhcp_impl.h> -#include <dhcp_symbol.h> -#include <libinetutil.h> -#include "hash.h" -#include "per_dnet.h" - -/* - * Raw encoded packet data. The final state. Note that 'code' not only - * describes options: predefined: 1-60, site: 128-254, vendor: 42(*), - * but it also defines packet fields for packet data as well. - * Note that due to overlap of codes between various DSYM categories, - * category must be used to distinguish (see libdhcputil). - */ -typedef struct encoded { - uchar_t category; /* Option category */ - ushort_t code; /* Option code: 1--254, pkt loc */ - uchar_t len; /* len of data */ - uchar_t *data; /* Encoded DHCP packet field / option */ - struct encoded *prev; /* previous in list */ - struct encoded *next; /* next in list */ -} ENCODE; - -typedef struct { - char class[DSYM_CLASS_SIZE + 1]; /* client class */ - ENCODE *head; /* options of this class */ -} VNDLIST; - -typedef struct { - char nm[DN_MAX_CID_LEN + 1]; /* Macro name */ - ENCODE *head; /* head of encoded opts */ - int classes; /* num of client classes */ - VNDLIST **list; /* table of client classes */ -} MACRO; - -/* logging message categories */ -typedef enum { - L_ASSIGN = 0, /* New assignment */ - L_REPLY = 1, /* respond to existing client */ - L_RELEASE = 2, /* client released IP */ - L_DECLINE = 3, /* client declined IP */ - L_INFORM = 4, /* client requested information only */ - L_NAK = 5, /* client NAK'ed */ - L_ICMP_ECHO = 6, /* Server detected IP in use */ - L_RELAY_REQ = 7, /* Relay request to server(s) */ - L_RELAY_REP = 8 /* Relay reply to client */ -} DHCP_MSG_CATEGORIES; - -typedef enum { - P_BOOTP = 0, /* BOOT Protocol */ - P_DHCP = 1 /* DHC Protocol */ -} DHCP_PROTO; - -#define DHCPD "in.dhcpd" /* daemon's name */ -#define DAEMON_VERS "3.5" /* daemon's version number */ -#define ENC_COPY 0 /* Copy encode list */ -#define ENC_DONT_COPY 1 /* don't copy encode list */ -#define DHCP_MAX_REPLY_SIZE 8192 /* should be big enough */ -#define DHCP_MIN_RECORDS 32 /* should be big enough */ -#define DHCP_ICMP_ATTEMPTS 1 /* Number of ping attempts */ -#define DHCP_ICMP_TIMEOUT 1000 /* Wait # millisecs for resp */ -#define DHCP_ARP_ADD 0 /* Add an ARP table entry */ -#define DHCP_ARP_DEL 1 /* Del an ARP table entry */ -#define DHCP_SCRATCH 128 /* scratch buffer size */ -#define NEW_DHCPTAB 0 /* load initial dhcptab */ -#define PRESERVE_DHCPTAB 1 /* preserve previous dhcptab */ -#define DEFAULT_LEASE 3600 /* Default if not specified */ -#define DHCP_RDCOP_RETRIES 3 /* Attempts to read options */ -#define HASHTABLESIZE 257 /* must be a prime number */ -#define DHCP_RESCAN_SCALE 60L /* scale rescan_interval */ - -#define DHCP_MIN_CLIENTS 32 /* minimum client structs */ -#define DHCP_DEFAULT_CLIENTS 1024 /* default client structs */ -#define DHCP_MINFREE_CLIENTS 8 /* minimum free clients */ -#define DHCP_NSS_LWP 32 /* free lwps for nss lib use */ -#define DHCP_NSS_TIME 3 /* name service cache time */ -#define DHCP_NO_NSU (-1) /* No Name service updates */ - -/* load option flags */ -#define DHCP_DHCP_CLNT 1 /* It's a DHCP client */ -#define DHCP_SEND_LEASE 2 /* Send lease parameters */ -#define DHCP_NON_RFC1048 4 /* non-rfc1048 magic cookie */ -#define DHCP_OVRLD_CLR ((uchar_t)0x00) /* SNAME/FILE clear */ -#define DHCP_OVRLD_FILE ((uchar_t)0x01) /* FILE in use */ -#define DHCP_OVRLD_SNAME ((uchar_t)0x02) /* SNAME in use */ -#define DHCP_OVRLD_ALL ((uchar_t)0x03) /* All overload space in use */ - -/* dhcp_lookup_dd_classify search flags */ -#define S_CID 0x01 /* find a client match */ -#define S_FREE 0x02 /* find a free record */ -#define S_LRU 0x04 /* find an lru record */ - -/* DHCP client states */ -#define INIT_STATE 1 -#define INIT_REBOOT_STATE 2 -#define RENEW_REBIND_STATE 3 - -extern int debug; -extern boolean_t verbose; -extern boolean_t noping; -extern boolean_t no_dhcptab; -extern boolean_t server_mode; -extern boolean_t be_automatic; -extern uchar_t max_hops; -extern int log_local; -extern int icmp_tries; -extern time_t off_secs; -extern time_t cache_secs; -extern time_t renog_secs; -extern time_t min_lru; -extern time_t icmp_timeout; -extern time_t nsutimeout_secs; -extern boolean_t time_to_go; -extern struct in_addr server_ip; -extern struct in_addr *owner_ip; -extern dsvc_datastore_t datastore; -extern int max_threads; /* maximum number of threads per net */ -extern int max_clients; /* maximum number of clients per net */ -extern ushort_t port_offset; /* offset to port for multiple server */ -extern int net_thresh; /* secs to keep pernet reference */ -extern int clnt_thresh; /* secs to keep client reference */ -extern time_t reinit_time; /* reinitialization time */ -extern struct __res_state resolv_conf; -#ifdef DEBUG -extern char *dbg_net; /* simulated debug net (see misc.c) */ -#endif /* DEBUG */ - -extern void *reinitialize(void *); -extern PKT *gen_bootp_pkt(int, PKT *); -extern int initmtab(void); -extern int initntab(void); -extern int checktab(void); -extern int readtab(int); -extern void resettab(boolean_t); -extern int relay_agent_init(char *); -extern void dhcpmsg(int, const char *, ...); -extern void *smalloc(unsigned); -extern void *srealloc(void *, uint_t); -extern struct in_addr *match_ownerip(in_addr_t); -extern void *stack_create(unsigned int); -extern ENCODE *combine_encodes(ENCODE *, ENCODE *, int); -extern void open_macros(void); -extern void close_macros(void); -extern MACRO *get_macro(char *); -extern ENCODE *find_encode(ENCODE *, uchar_t, ushort_t); -extern ENCODE *dup_encode(ENCODE *); -extern ENCODE *make_encode(uchar_t, ushort_t, uchar_t, void *, int); -extern ENCODE *dup_encode_list(ENCODE *); -extern void free_encode_list(ENCODE *); -extern void free_encode(ENCODE *); -extern void replace_encode(ENCODE **, ENCODE *, int); -extern ENCODE *vendor_encodes(MACRO *, char *); -extern char *disp_cid(PKT_LIST *, char *, int); -extern void get_clnt_id(PKT_LIST *, uchar_t *, int, uchar_t *); -extern char *get_class_id(PKT_LIST *, char *, int); -extern int load_options(int, PKT_LIST *, PKT *, int, uchar_t *, ENCODE *, - ENCODE *); -extern void free_plp(PKT_LIST *); -extern void logtrans(DHCP_PROTO, DHCP_MSG_CATEGORIES, time_t, - struct in_addr, struct in_addr, PKT_LIST *); -extern int icmp_echo_check(struct in_addr *, boolean_t *); -extern void *monitor_client(void *); - -extern void dhcp(dsvc_clnt_t *, PKT_LIST *); -boolean_t update_offer(dsvc_clnt_t *, dn_rec_list_t **, lease_t, - struct in_addr *, boolean_t); -extern void bootp(dsvc_clnt_t *, PKT_LIST *); -extern void get_netmask(struct in_addr *, struct in_addr *); -extern boolean_t select_offer(dsvc_dnet_t *dbp, PKT_LIST *, dsvc_clnt_t *, - dn_rec_list_t **); - -extern int dhcp_open_dd(dsvc_handle_t *, dsvc_datastore_t *, dsvc_contype_t, - const char *, uint_t); -extern int dhcp_close_dd(dsvc_handle_t *); -extern int dhcp_modify_dd_entry(dsvc_handle_t, const void *, void *); -extern void dhcp_free_dd_list(dsvc_handle_t, void *); - -extern void *dhcp_lookup_dd_classify(dsvc_dnet_t *, boolean_t, uint_t, int, - const dn_rec_t *, void **, int); - -extern dn_rec_list_t *detach_dnrec_from_list(dn_rec_list_t *, dn_rec_list_t *, - dn_rec_list_t **); - -extern int qualify_hostname(char *, const char *, const char *, int, int); - -#ifdef __cplusplus -} -#endif - -#endif /* _DHCPD_H */ diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/dhcptab.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/dhcptab.c deleted file mode 100644 index db7d2ce975..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/dhcptab.c +++ /dev/null @@ -1,1313 +0,0 @@ -/* - * Routines and structures which are used from CMU's 2.2 bootp implementation - * are labelled as such. Code not labelled is: - * - * Copyright 1997-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Copyright 1988, 1991 by Carnegie Mellon University - * - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Carnegie Mellon University not be used - * in advertising or publicity pertaining to distribution of the software - * without specific, written prior permission. - * - * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. - * IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF - * THIS SOFTWARE. - */ - -/* - * in.dhcpd configuration file reading code. - * - * The routines in this file deal with reading, interpreting, and storing - * the information found in the in.dhcpd configuration file (usually - * /etc/dhcptab). - */ - -/* - * TODO: What's missing: Symbol code is very generic, but doesn't allow - * per symbol granularity checking - ie, using goodname() to check the - * hostname, for example. Perhaps each symbol should have a verifier - * function possibly associated with it (null is ok), which would return - * B_TRUE if ok, B_FALSE if not, and print out a nasty message. - * - * Option overload. If set, then NO BOOTFILE or SNAME values can exist. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> -#include <errno.h> -#include <assert.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/byteorder.h> -#include <sys/stat.h> -#include <sys/file.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <net/if.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <syslog.h> -#include <dhcp_inittab.h> -#include <dhcp_symbol.h> -#include "netinet/dhcp.h" -#include "hash.h" -#include "dhcpd.h" -#include <locale.h> - -/* - * Local constants - */ -#define OP_ADDITION 1 /* Operations on tags */ -#define OP_DELETION 2 -#define OP_BOOLEAN 3 - -#define MAXENTRYLEN 3072 /* Max size of an entire entry */ -#define MAX_ITEMS 16 /* Max number of items in entry */ -#define MAX_MACRO_NESTING 20 /* Max number of nested includes */ - -#define DB_DHCP_MAC 'm' /* Like TBL_DHCP_{MACRO,SYMBOL} */ -#define DB_DHCP_SYM 's' /* But not strings! */ - -static time_t mtable_time; /* load time of hash table */ - -static uint_t nentries; /* Total number of entries */ -static int include_nest; /* macro nesting counter */ -static dt_rec_list_t **newtbl; /* reordered Tbl. */ -static dt_rec_list_t **oldtbl; /* The original tbl. */ -static hash_tbl *mtable; -static mutex_t mtable_mtx; /* Reinitialization mutex */ -static cond_t mtable_cv; /* Reinitialization cv */ -static int mtable_refcnt; /* Current reference count */ -static int mtable_closing; /* macros are going away */ - -#define INCLUDE_SYM "Include" /* symbol for macro include */ - -/* - * Forward declarations. - */ -static dhcp_symbol_t *sym_list; -static size_t sym_num_items; -static int check_includes(int, char *); -static MACRO *process_entry(dt_rec_list_t *); -static int eval_symbol(char **, MACRO *); -static char *get_string(char **, char *, uchar_t *); -static void adjust(char **); -static void eat_whitespace(char **); -static int first_macro_row(dt_rec_list_t **); -static void get_sym_name(char *, char **); -static void print_error_msg(int, uchar_t); -static boolean_t define_symbol(char **, char *); -static int scan_include(char **, char *); -static boolean_t free_macro(MACRO *, boolean_t); -static int macro_cmp(MACRO *, MACRO *); -static void add_vndlist(ENCODE *, MACRO *, dhcp_symbol_t *); - -/* - * Initialize the hash table. - */ -int -initmtab(void) -{ - /* - * Allocate hash table - */ - mtable = hash_Init(0, NULL, 0, B_FALSE); - - assert(mtable != NULL); - - (void) mutex_init(&mtable_mtx, USYNC_THREAD, NULL); - (void) cond_init(&mtable_cv, USYNC_THREAD, 0); - - return (0); -} - -/* - * Check presence/access to dhcptab database file. - */ -int -checktab(void) -{ - int err; - dsvc_handle_t dh; - - err = open_dd(&dh, &datastore, DSVC_DHCPTAB, DT_DHCPTAB, DSVC_READ); - switch (err) { - case DSVC_SUCCESS: - (void) close_dd(&dh); - break; - case DSVC_ACCESS: - dhcpmsg(LOG_ERR, - "No permission to access dhcptab in %s (%s)\n", - datastore.d_resource, datastore.d_location); - err = EACCES; - break; - case DSVC_NOENT: - case DSVC_NO_TABLE: - dhcpmsg(LOG_INFO, - "Dhcptab table does not exist in %s (%s)\n", - datastore.d_resource, datastore.d_location); - err = ENOENT; - break; - default: - dhcpmsg(LOG_ERR, - "Error checking status of dhcptab in %s (%s)\n", - datastore.d_resource, datastore.d_location); - } - return (err); -} - -/* - * Read dhcptab database file. - */ -int -readtab(int preserve) -{ - int err = 0, first_mac; - MACRO *mc; - uint32_t query; - dt_rec_t dt; - dt_rec_list_t **dhcptab = NULL; - dt_rec_list_t *dhcptab_list = NULL; - dt_rec_list_t *dtep; - int i; - int ind; - uint_t records; - timestruc_t tm; - dsvc_handle_t dh; - boolean_t tab_open = B_FALSE; - - (void) mutex_lock(&mtable_mtx); - - /* - * Wait for any current thread(s) to complete using macros. - */ - mtable_closing = 1; - while (mtable_refcnt > 0) { - tm.tv_sec = 1; - tm.tv_nsec = 0; - (void) cond_reltimedwait(&mtable_cv, &mtable_mtx, &tm); - } - - /* Get the *entire* dhcptab. */ - while ((err = open_dd(&dh, &datastore, DSVC_DHCPTAB, DT_DHCPTAB, - DSVC_READ)) != DSVC_SUCCESS) { - if (err == DSVC_BUSY) { - continue; - } - if (err == DSVC_NOENT) { - dhcpmsg(LOG_INFO, "Empty dhcptab macro database.\n"); - err = 0; /* not a "real" error */ - } else - dhcpmsg(LOG_ERR, "Error opening macro database: %s\n", - dhcpsvc_errmsg(err)); - goto leave_readtab; - } - - tab_open = B_TRUE; - - DSVC_QINIT(query); - (void) memset(&dt, 0, sizeof (dt_rec_t)); - - dhcptab_list = NULL; - nentries = 0; - err = lookup_dd(dh, B_FALSE, query, -1, (const void *)&dt, - (void **)&dhcptab_list, &nentries); - if (err != DSVC_SUCCESS) { - if (verbose && err == DSVC_NOENT) { - dhcpmsg(LOG_INFO, "Error access macro database: %s\n", - dhcpsvc_errmsg(err)); - } - goto leave_readtab; - } else - err = 0; - if (nentries == 0) { - dhcpmsg(LOG_INFO, "Empty dhcptab macro database.\n"); - err = 0; /* not a "real" error */ - goto leave_readtab; - } - - /* - * Because libdhcpsvc doesn't guarantee any order, we need to - * preprocess the macro list to guarantee that macros which are - * included in other macro definitions are already defined prior - * to their use. This means that macro processing is a two step process. - */ - dhcptab = (dt_rec_list_t **)smalloc((nentries + 1) * - sizeof (dt_rec_list_t *)); - - /* Extract symbols first. */ - ind = 0; - for (i = 0, dtep = dhcptab_list; dtep != NULL; - i++, dtep = dtep->dtl_next) { - if (dtep->dtl_rec->dt_type == DT_SYMBOL) { - dhcptab[ind++] = dtep; - } - } - /* Copy macros */ - for (i = 0, dtep = dhcptab_list; dtep != NULL; - i++, dtep = dtep->dtl_next) { - if (dtep->dtl_rec->dt_type == DT_MACRO) { - dhcptab[ind++] = dtep; - } - } - - first_mac = first_macro_row(dhcptab); - include_nest = 0; - if (first_mac >= 0) { - oldtbl = dhcptab; - newtbl = (dt_rec_list_t **)smalloc((nentries + 1) * - sizeof (dt_rec_list_t *)); - for (i = 0; i < first_mac; i++) - newtbl[i] = oldtbl[i]; /* copy symdefs */ - for (i = first_mac; i < nentries; i++) { - if ((err = check_includes(first_mac, - oldtbl[i]->dtl_rec->dt_key)) != 0) - break; - } - if (err != 0) { - free(newtbl); - free(dhcptab); - goto leave_readtab; - } else { - free(dhcptab); - dhcptab = newtbl; - } - } - - resettab(B_FALSE); - - /* - * Now table is reordered. process as usual. - */ - records = 0; - for (i = 0; i < nentries; i++) { - - if ((mc = process_entry(dhcptab[i])) == (MACRO *)NULL) - continue; - - if (hash_Insert(mtable, mc->nm, strlen(mc->nm), macro_cmp, - mc->nm, mc) == NULL) { - dhcpmsg(LOG_WARNING, - "Duplicate macro definition: %s\n", mc->nm); - continue; - } - records++; - } - - mtable_time = time(NULL); - - if (verbose) { - dhcpmsg(LOG_INFO, - "Read %d entries from DHCP macro database on %s", - records, ctime(&mtable_time)); - } - - free(dhcptab); - -leave_readtab: - - if (dhcptab_list != NULL) - free_dd_list(dh, dhcptab_list); - - if (tab_open) - (void) close_dd(&dh); - - if (preserve && err != 0) { - dhcpmsg(LOG_WARNING, - "DHCP macro database rescan failed %d, using scan: %s", - err, ctime(&mtable_time)); - err = 0; - } - - mtable_closing = 0; - (void) mutex_unlock(&mtable_mtx); - return (err); -} - -/* - * Reset the dhcptab hash table, free any dynamic symbol definitions. - */ -void -resettab(boolean_t lck) -{ - int i; - dhcp_symbol_t tmp; - timestruc_t tm; - - if (lck == B_TRUE) - (void) mutex_lock(&mtable_mtx); - - /* - * Wait for any current thread(s) to complete using macros. - */ - if (mtable_closing == 0) { - mtable_closing = 1; - while (mtable_refcnt > 0) { - tm.tv_sec = 1; - tm.tv_nsec = 0; - (void) cond_reltimedwait(&mtable_cv, &mtable_mtx, &tm); - } - } - - /* Entirely erase all hash tables. */ - hash_Reset(mtable, free_macro); - - /* - * Dump any dynamically defined symbol definitions, and reinitialize. - */ - if (sym_list != NULL) { - - /* - * Free class resources for each symbol. - */ - for (i = 0; i < sym_num_items; i++) { - dsym_free_classes(&sym_list[i].ds_classes); - } - - free(sym_list); - sym_list = NULL; - } - - if (time_to_go) { - if (lck == B_TRUE) { - (void) mutex_unlock(&mtable_mtx); - (void) mutex_destroy(&mtable_mtx); - (void) cond_destroy(&mtable_cv); - } - return; - } - - /* Allocate the inittab and class tables */ - sym_list = inittab_load(ITAB_CAT_STANDARD|ITAB_CAT_FIELD| - ITAB_CAT_INTERNAL|ITAB_CAT_VENDOR, - ITAB_CONS_SERVER, &sym_num_items); - /* - * Allocate the internal INCLUDE_SYM macro include symbol. - * Since this is not part of inittab, it must be added - * manually to the list. - */ - sym_list = (dhcp_symbol_t *)realloc(sym_list, - (sym_num_items + 1) * sizeof (dhcp_symbol_t)); - - if (sym_num_items == 0 || sym_list == NULL) { - dhcpmsg(LOG_ERR, "Cannot allocate inittab, exiting\n"); - (void) exit(1); - } - - (void) memset(&sym_list[sym_num_items], 0, sizeof (dhcp_symbol_t)); - (void) strcpy(sym_list[sym_num_items].ds_name, INCLUDE_SYM); - sym_list[sym_num_items].ds_type = DSYM_INCLUDE; - sym_list[sym_num_items].ds_max = 32; - sym_num_items++; - - /* Verify the inittab entries */ - for (i = 0; i < sym_num_items; i++) { - if (inittab_verify(&sym_list[i], &tmp) == ITAB_FAILURE) { - print_error_msg(ITAB_SYNTAX_ERROR, i); - (void) memcpy(&sym_list[i], &tmp, - sizeof (dhcp_symbol_t)); - } - } - - mtable_closing = 0; - if (lck == B_TRUE) - (void) mutex_unlock(&mtable_mtx); -} - -/* - * Given an value field pptr, return the first INCLUDE_SYM value found in - * include, updating pptr along the way. Returns nonzero if no INCLUDE_SYM - * symbol is found (pptr is still updated). - */ -static int -scan_include(char **cpp, char *include) -{ - char t_sym[DSVC_MAX_MACSYM_LEN + 1]; - uchar_t ilen; - - while (*cpp && **cpp != '\0') { - eat_whitespace(cpp); - get_sym_name(t_sym, cpp); - if (strcmp(t_sym, INCLUDE_SYM) == 0) { - ilen = DHCP_SCRATCH; - if (**cpp == '=') - (*cpp)++; - (void) get_string(cpp, include, &ilen); - include[ilen] = '\0'; - return (0); - } else - adjust(cpp); - } - return (1); -} - -/* - * Return the first macro row in dhcptab. Returns -1 if no macros exist. - */ -static int -first_macro_row(dt_rec_list_t **tblp) -{ - int i; - - for (i = 0; i < nentries; i++) { - if (tolower(tblp[i]->dtl_rec->dt_type) == (int)DT_MACRO) - return (i); - } - return (-1); -} - -/* - * RECURSIVE function: Scans for included macros, and reorders Tbl to - * ensure macro definitions occur in the correct order. - * - * Returns 0 for success, nonzero otherwise. - */ -static int -check_includes(int first, char *mname) -{ - char include[DHCP_SCRATCH + 1]; - int m, err = 0; - dt_rec_list_t *current_rowp = NULL; - char *cp; - - include_nest++; - - if (include_nest > MAX_MACRO_NESTING) { - dhcpmsg(LOG_ERR, - "Circular macro definition using: %s\n", mname); - err = -1; - goto leave_check_include; - } - - for (m = first; m < nentries; m++) { - if (newtbl[m] != NULL && - strcmp(newtbl[m]->dtl_rec->dt_key, mname) == 0) { - err = 0; /* already processed */ - goto leave_check_include; - } - } - - /* - * is it defined someplace? - */ - for (m = first; m < nentries; m++) { - if (strcmp(oldtbl[m]->dtl_rec->dt_key, mname) == 0) { - current_rowp = oldtbl[m]; - break; - } - } - - if (current_rowp == NULL) { - dhcpmsg(LOG_ERR, "Undefined macro: %s\n", mname); - err = -1; - goto leave_check_include; - } - - /* - * Scan value field, looking for includes. - */ - cp = current_rowp->dtl_rec->dt_value; - while (cp) { - adjust(&cp); - if (scan_include(&cp, include) != 0) { - /* find a free entry */ - for (m = first; m < nentries; m++) { - if (newtbl[m] == NULL) - break; - } - if (m >= nentries) { - dhcpmsg(LOG_ERR, - "Macro expansion (Include=%s) error!\n", - mname); - err = -1; - } else { - newtbl[m] = current_rowp; - err = 0; - } - break; - } - - if (*include == '\0') { - /* - * Null value for macro name. We can safely ignore - * this entry. An error message will be generated - * later during encode processing. - */ - continue; - } - - if (strcmp(mname, include) == 0) { - dhcpmsg(LOG_ERR, - "Circular macro definition using: %s\n", mname); - err = -1; - break; - } - - /* Recurse. */ - if ((err = check_includes(first, include)) != 0) - break; - } - -leave_check_include: - include_nest--; - return (err); -} - -/* - * open_macros: open reference to macro table. - */ -void -open_macros(void) { - (void) mutex_lock(&mtable_mtx); - mtable_refcnt++; - (void) mutex_unlock(&mtable_mtx); -} - -/* - * close_macros: close reference to macro table. - */ -void -close_macros(void) { - (void) mutex_lock(&mtable_mtx); - mtable_refcnt--; - (void) cond_signal(&mtable_cv); - (void) mutex_unlock(&mtable_mtx); -} - -/* - * Given a macro name, look it up in the hash table. - * Returns ptr to MACRO structure, NULL if error occurs. - */ -MACRO * -get_macro(char *mnamep) -{ - if (mnamep == (char *)NULL) - return ((MACRO *)NULL); - - return ((MACRO *)hash_Lookup(mtable, mnamep, strlen(mnamep), macro_cmp, - mnamep, B_FALSE)); -} - -/*ARGSUSED*/ -static boolean_t -free_macro(MACRO *mp, boolean_t force) -{ - int i; - - if (mp) { - free_encode_list(mp->head); - for (i = 0; i < mp->classes; i++) { - if (mp->list[i]->head != NULL) - free_encode_list(mp->list[i]->head); - free(mp->list[i]); - } - free(mp->list); - free(mp); - } - return (B_TRUE); -} - -static int -macro_cmp(MACRO *m1, MACRO *m2) -{ - if (!m1 || !m2) - return (B_FALSE); - - if (strcmp(m1->nm, m2->nm) == 0) - return (B_TRUE); - else - return (B_FALSE); -} - -/* - * Parse out all the various tags and parameters in the row entry pointed - * to by "src". - * - * Returns 0 for success, nozero otherwise. - */ -static MACRO * -process_entry(dt_rec_list_t *src) -{ - char *cp; - MACRO *mc, *retval = NULL; - - assert(src != NULL); - - if (strlen(src->dtl_rec->dt_key) > DSVC_MAX_MACSYM_LEN) { - dhcpmsg(LOG_ERR, - "Token: %s is too long. Limit: %d characters.\n", - src->dtl_rec->dt_key, DSVC_MAX_MACSYM_LEN); - return (retval); - } - - switch (tolower(src->dtl_rec->dt_type)) { - case DT_SYMBOL: - /* New Symbol definition */ - cp = src->dtl_rec->dt_value; - if (!define_symbol(&cp, src->dtl_rec->dt_key)) - dhcpmsg(LOG_ERR, - "Bad Runtime symbol definition: %s\n", - src->dtl_rec->dt_key); - /* Success. Treat new symbol like the predefines. */ - break; - case DT_MACRO: - /* Macro definition */ - - mc = (MACRO *)smalloc(sizeof (MACRO)); - (void) strcpy(mc->nm, src->dtl_rec->dt_key); - - cp = src->dtl_rec->dt_value; - adjust(&cp); - while (*cp != '\0') { - if (eval_symbol(&cp, mc) != 0) { - dhcpmsg(LOG_ERR, - "Error processing macro: %s\n", mc->nm); - (void) free_macro(mc, B_TRUE); - return (NULL); - } - adjust(&cp); - eat_whitespace(&cp); - } - retval = mc; - break; - default: - dhcpmsg(LOG_ERR, "Unrecognized token: %s.\n", - src->dtl_rec->dt_key); - break; - } - return (retval); -} - -/* - * This function processes the parameter name pointed to by "symbol" and - * updates the appropriate ENCODE structure in data if one already exists, - * or allocates a new one for this parameter. - */ -static int -eval_symbol(char **symbol, MACRO *mc) -{ - int index, optype, i, j, err = 0; - dhcp_symbol_t *sp; - char **clp; - ENCODE *tmp; - VNDLIST **mpp, **ipp; - MACRO *ic; - char *cp; - uchar_t ilen; - uint16_t len; - char t_sym[DSVC_MAX_MACSYM_LEN + 1]; - char include[DHCP_SCRATCH + 1]; - /* - * The following buffer must be aligned on a int64_t boundary. - */ - uint64_t scratch[(UCHAR_MAX + sizeof (int64_t) - 1) / - sizeof (int64_t)]; - - if ((*symbol)[0] == ':') - return (0); - - eat_whitespace(symbol); - get_sym_name(t_sym, symbol); - - for (index = 0; index < sym_num_items; index++) { - if (strcmp(t_sym, sym_list[index].ds_name) == 0) - break; - } - if (index >= sym_num_items) { - dhcpmsg(LOG_ERR, "Unrecognized symbol name: '%s'\n", t_sym); - return (-1); - } else { - sp = &sym_list[index]; - clp = sp->ds_classes.dc_names; - } - /* - * Determine the type of operation to be done on this symbol - */ - switch (**symbol) { - case '=': - optype = OP_ADDITION; - (*symbol)++; - break; - case '@': - optype = OP_DELETION; - (*symbol)++; - break; - case ':': - case '\0': - optype = OP_BOOLEAN; - break; - default: - dhcpmsg(LOG_ERR, "Syntax error: symbol: '%s' in macro: %s\n", - t_sym, mc->nm); - return (-1); - } - - switch (optype) { - case OP_ADDITION: - switch (sp->ds_type) { - case DSYM_BOOL: - err = -1; - break; - - case DSYM_INCLUDE: - /* - * If symbol type is INCLUDE, then walk the encode - * list, replacing any previous encodes with those - * from the INCLUDed macro. Vendor options are also - * merged, if their class and vendor codes match. - */ - ilen = DHCP_SCRATCH; - (void) get_string(symbol, include, &ilen); - include[ilen] = '\0'; - ic = get_macro(include); - if (ic == (MACRO *)NULL) { - dhcpmsg(LOG_ERR, "WARNING: No macro: '%1$s' \ -defined for 'Include' symbol in macro: %2$s\n", - include, mc->nm); - adjust(symbol); - return (0); - } - - mc->head = combine_encodes(mc->head, ic->head, - ENC_DONT_COPY); - - if (ic->list == NULL && mc->list == NULL) - break; - - /* Vendor options. */ - if (mc->list == NULL) { - /* - * No combining necessary. Just duplicate - * ic's vendor options - all classes. - */ - mc->list = (VNDLIST **)smalloc( - sizeof (VNDLIST **) * ic->classes); - for (i = 0; i < ic->classes; i++) { - mc->list[i] = (VNDLIST *)smalloc( - sizeof (VNDLIST)); - (void) strcpy(mc->list[i]->class, - ic->list[i]->class); - mc->list[i]->head = dup_encode_list( - ic->list[i]->head); - } - mc->classes = ic->classes; - } else { - /* Class and vendor code must match. */ - for (i = 0, ipp = ic->list; - ipp && i < ic->classes; i++) { - for (j = 0, mpp = mc->list; - j < mc->classes; j++) { - if (strcmp(mpp[j]->class, - ipp[i]->class) == 0) { - mpp[j]->head = - combine_encodes( - mpp[j]->head, - ipp[i]->head, - ENC_DONT_COPY); - break; - } - } - } - } - break; - - default: - /* - * Get encode associated with symbol value. - */ - tmp = (ENCODE *)smalloc(sizeof (ENCODE)); - - if (sp->ds_type == DSYM_ASCII) { - if (sp->ds_max) - ilen = sp->ds_max; - else - ilen = UCHAR_MAX; - (void) get_string(symbol, (char *)scratch, - &ilen); - include[ilen] = '\0'; - - tmp->data = inittab_encode_e(sp, - (char *)scratch, &len, B_TRUE, &err); - } else { - - if ((cp = strchr(*symbol, ':')) != NULL) - *cp = '\0'; - - tmp->data = inittab_encode_e(sp, *symbol, &len, - B_TRUE, &err); - /* - * Advance symbol pointer to next encode. - */ - if (cp != NULL) { - *cp = ':'; - *symbol = cp; - } else { - while (*symbol != '\0') - symbol++; - } - } - - tmp->len = len; - tmp->category = sp->ds_category; - tmp->code = sp->ds_code; - - if (err != 0 || tmp->data == NULL) { - if (err == 0) - err = -1; - free_encode(tmp); - } else { - /* - * Find/replace/add encode. - */ - if (sp->ds_category != DSYM_VENDOR) { - replace_encode(&mc->head, tmp, - ENC_DONT_COPY); - } else - add_vndlist(tmp, mc, sp); - } - break; - } - break; - - case OP_DELETION: - if (sp->ds_type == DSYM_INCLUDE) - return (-1); - - if (sp->ds_category != DSYM_VENDOR) { - tmp = find_encode(mc->head, sp->ds_category, - sp->ds_code); - if (tmp != (ENCODE *)NULL) { - if (tmp->prev != (ENCODE *)NULL) - tmp->prev->next = tmp->next; - else - mc->head = mc->head->next; - free_encode(tmp); - } - } else { - for (i = 0; i < sp->ds_classes.dc_cnt; i++) { - for (j = 0; mc->list && j < mc->classes; - j++) { - if (strcmp(clp[i], - mc->list[j]->class) == 0) { - tmp = find_encode( - mc->list[j]->head, - sp->ds_category, - sp->ds_code); - if (tmp == NULL) - continue; - if (tmp->prev != NULL) { - tmp->prev->next = - tmp->next; - } else { - mc->list[j]->head = - mc->list[j]-> - head->next; - } - free_encode(tmp); - } - } - } - } - - err = 0; - break; - - case OP_BOOLEAN: - if (sp->ds_type == DSYM_INCLUDE) - return (-1); - /* - * True signified by existence, false by omission. - */ - if (sp->ds_category != DSYM_VENDOR) { - tmp = find_encode(mc->head, sp->ds_category, - sp->ds_code); - if (tmp == (ENCODE *)NULL) { - tmp = make_encode(sp->ds_category, sp->ds_code, - 0, NULL, ENC_DONT_COPY); - replace_encode(&mc->head, tmp, - ENC_DONT_COPY); - } - } else { - for (i = 0; i < sp->ds_classes.dc_cnt; i++) { - for (j = 0; mc->list && j < mc->classes; - j++) { - if (strcmp((const char *)clp[i], - mc->list[j]->class) == 0) { - tmp = find_encode( - mc->list[j]->head, - sp->ds_category, - sp->ds_code); - if (tmp == NULL) { - tmp = make_encode( - sp->ds_category, - sp->ds_code, 0, - NULL, - ENC_DONT_COPY); - replace_encode( - &mc->list[j]-> - head, tmp, - ENC_DONT_COPY); - } - } - } - } - } - - err = 0; - break; - } - if (err) - print_error_msg(ITAB_SYNTAX_ERROR, index); - return (err); -} - -/* - * Find/add option to appropriate client classes. - */ -static void -add_vndlist(ENCODE *vp, MACRO *mp, dhcp_symbol_t *sp) -{ - int i, j, class_exists, copy; - VNDLIST **tmp; - char **cp = sp->ds_classes.dc_names; - - copy = ENC_DONT_COPY; - for (i = 0; i < sp->ds_classes.dc_cnt; i++) { - class_exists = 0; - for (j = 0; mp->list && j < mp->classes; j++) { - if (strcmp(cp[i], mp->list[j]->class) == 0) { - class_exists = 1; - replace_encode(&mp->list[j]->head, vp, copy); - if (copy == ENC_DONT_COPY) - copy = ENC_COPY; - } - } - if (!class_exists) { - tmp = (VNDLIST **)realloc(mp->list, - sizeof (VNDLIST **) * (j + 1)); - if (tmp != NULL) - mp->list = tmp; - else { - dhcpmsg(LOG_ERR, "Warning: ran out of \ -memory adding vendor class: '%1$s' for symbol: '%2$s'\n", - cp[i], sp->ds_name); - break; - } - mp->list[j] = (VNDLIST *)smalloc(sizeof (VNDLIST)); - (void) strcpy(mp->list[j]->class, cp[i]); - if (copy == ENC_DONT_COPY) { - mp->list[j]->head = vp; - copy = ENC_COPY; - } else - mp->list[j]->head = dup_encode(vp); - mp->classes++; - } - } -} - -/* - * CMU 2.2 routine. - * - * Read a string from the buffer indirectly pointed to through "src" and - * move it into the buffer pointed to by "dest". A pointer to the maximum - * allowable length of the string (including null-terminator) is passed as - * "length". The actual length of the string which was read is returned in - * the unsigned integer pointed to by "length". This value is the same as - * that which would be returned by applying the strlen() function on the - * destination string (i.e the terminating null is not counted as a - * character). Trailing whitespace is removed from the string. For - * convenience, the function returns the new value of "dest". - * - * The string is read until the maximum number of characters, an unquoted - * colon (:), or a null character is read. The return string in "dest" is - * null-terminated. - */ -static char * -get_string(char **src, char *dest, uchar_t *length) -{ - int n = 0, len, quoteflag; - - quoteflag = B_FALSE; - len = *length - 1; - while ((n < len) && (**src)) { - if (quoteflag == B_FALSE && (**src == ':')) - break; - if (**src == '"') { - (*src)++; - quoteflag = !quoteflag; - continue; - } - if (**src == '\\') { - (*src)++; - if (!**src) - break; - } - *dest++ = *(*src)++; - n++; - } - - /* - * Remove that troublesome trailing whitespace. . . - */ - while ((n > 0) && isspace(*(char *)(dest - 1))) { - dest--; - n--; - } - - *dest = '\0'; - *length = n; - return (dest); -} - -/* - * This function adjusts the caller's pointer to point just past the - * first-encountered colon. If it runs into a null character, it leaves - * the pointer pointing to it. - */ -static void -adjust(char **s) -{ - char *t; - - t = *s; - while (*t && (*t != ':')) - t++; - - if (*t) - t++; - *s = t; -} - -/* - * This function adjusts the caller's pointer to point to the first - * non-whitespace character. If it runs into a null character, it leaves - * the pointer pointing to it. - */ -static void -eat_whitespace(char **s) -{ - char *t; - - t = *s; - while (*t && isspace(*t)) - t++; - *s = t; -} - -/* - * Copy symbol name into buffer. Sym ends up pointing to the end of the - * token. - */ -static void -get_sym_name(char *buf, char **sym) -{ - int i; - - for (i = 0; i < DSVC_MAX_MACSYM_LEN; i++) { - if (**sym == ':' || **sym == '=' || **sym == '@' || - **sym == '\0') - break; - *buf++ = *(*sym)++; - } - *buf = '\0'; -} - -static void -print_error_msg(int error, uchar_t index) -{ - switch (error) { - case ITAB_BAD_IPADDR: - dhcpmsg(LOG_ERR, "Error processing Internet address \ -value(s) for symbol: '%s'\n", sym_list[index].ds_name); - break; - case ITAB_BAD_STRING: - dhcpmsg(LOG_ERR, "Error processing ASCII string value for \ -symbol: '%s'\n", sym_list[index].ds_name); - break; - case ITAB_BAD_OCTET: - dhcpmsg(LOG_ERR, "Error processing OCTET string value for \ -symbol: '%s'\n", sym_list[index].ds_name); - break; - case ITAB_BAD_NUMBER: - dhcpmsg(LOG_ERR, "Error processing NUMBER value for \ -symbol: '%s'\n", sym_list[index].ds_name); - break; - case ITAB_BAD_BOOLEAN: - dhcpmsg(LOG_ERR, - "Error processing BOOLEAN value for symbol: '%s'\n", - sym_list[index].ds_name); - break; - case ITAB_SYNTAX_ERROR: - /* FALLTHRU */ - default: - dhcpmsg(LOG_ERR, - "Syntax error found processing value for symbol: '%s'\n", - sym_list[index].ds_name); - break; - } -} - -/* - * Define new symbols for things like site-wide and vendor options. - */ -static boolean_t -define_symbol(char **ptr, char *name) -{ - - dhcp_symbol_t sym; - char **fields; - int last = 0; - dsym_errcode_t ret = DSYM_SUCCESS; - ushort_t min; - ushort_t max; - int i; - - /* - * Only permit new symbol definitions, not old ones. I suppose we - * could allow the administrator to redefine symbols, but what if - * they redefine subnetmask to be a new brownie recipe? Let's stay - * out of that rat hole for now. - */ - for (i = 0; i < sym_num_items; i++) { - if (strcmp(name, sym_list[i].ds_name) == 0) { - dhcpmsg(LOG_ERR, "Symbol: %s already defined. New " - "definition ignored.\n", name); - adjust(ptr); - return (0); - } - } - - ret = dsym_init_parser(name, *ptr, &fields, &sym); - if (ret != DSYM_SUCCESS) { - switch (ret) { - case DSYM_NULL_FIELD: - dhcpmsg(LOG_ERR, - "Item is missing in symbol definition: '%s'\n", - name); - break; - - case DSYM_TOO_MANY_FIELDS: - dhcpmsg(LOG_ERR, - "Too many items exist in symbol definition: %s\n", - name); - break; - case DSYM_NO_MEMORY: - dhcpmsg(LOG_ERR, - "Ran out of memory processing symbol: '%s'\n", - name); - break; - default: - dhcpmsg(LOG_ERR, - "Internal error processing symbol: '%s'\n", - name); - break; - - } - return (B_FALSE); - } - - ret = dsym_parser(fields, &sym, &last, B_FALSE); - if (ret != DSYM_SUCCESS) { - switch (ret) { - case DSYM_SYNTAX_ERROR: - dhcpmsg(LOG_ERR, - "Syntax error parsing symbol definition: '%s'\n", - name); - break; - - case DSYM_CODE_OUT_OF_RANGE: - (void) dsym_get_code_ranges(fields[DSYM_CAT_FIELD], - &min, &max, B_TRUE); - dhcpmsg(LOG_ERR, "Out of range (%d-%d) option code: " - "%d in symbol definition: '%s'\n", - min, max, sym.ds_code, name); - break; - - case DSYM_VALUE_OUT_OF_RANGE: - dhcpmsg(LOG_ERR, - "Bad item, %s, in symbol definition: '%s'\n", - fields[last], name); - break; - - case DSYM_INVALID_CAT: - dhcpmsg(LOG_ERR, "Missing/Incorrect Site/Vendor flag " - "in symbol definition: '%s'\n", name); - break; - - case DSYM_INVALID_TYPE: - dhcpmsg(LOG_ERR, "Unrecognized value descriptor: %s " - "in symbol definition: '%s'\n", - fields[DSYM_TYPE_FIELD], name); - break; - - case DSYM_EXCEEDS_CLASS_SIZE: - dhcpmsg(LOG_ERR, "Client class is too " - "long for vendor symbol: '%s'. Must be " - "less than: %d\n", name, DSYM_CLASS_SIZE); - break; - - case DSYM_EXCEEDS_MAX_CLASS_SIZE: - dhcpmsg(LOG_ERR, "Client class is too long for " - "vendor symbol: '%s'. Must be less than: %d\n", - name, DSYM_MAX_CLASS_SIZE); - break; - - case DSYM_NO_MEMORY: - dhcpmsg(LOG_ERR, - "Ran out of memory processing symbol: '%s'\n", - name); - break; - - default: - dhcpmsg(LOG_ERR, - "Internal error processing symbol: '%s'\n", - name); - break; - } - dsym_close_parser(fields, &sym); - return (B_FALSE); - } - - /* - * Don't free the symbol structure resources, we need those. - * Just free the fields memory. We will free the symbol structure - * resources later. - */ - dsym_free_fields(fields); - - /* - * Now add it to the existing definitions, reallocating - * the dynamic symbol list. - */ - sym_list = (dhcp_symbol_t *)realloc(sym_list, - (sym_num_items + 1) * sizeof (dhcp_symbol_t)); - if (sym_list != (dhcp_symbol_t *)NULL) { - sym_num_items++; - (void) memcpy(&sym_list[sym_num_items - 1], &sym, - sizeof (dhcp_symbol_t)); - } else { - dhcpmsg(LOG_ERR, - "Cannot extend symbol table, using predefined table.\n"); - resettab(B_FALSE); - } - - return (B_TRUE); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/encode.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/encode.c deleted file mode 100644 index e25e6849fd..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/encode.c +++ /dev/null @@ -1,248 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <stdarg.h> -#include <sys/types.h> -#include <errno.h> -#include <assert.h> -#include <string.h> -#include <sys/syslog.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netinet/dhcp.h> -#include "hash.h" -#include "dhcpd.h" -#include "per_dnet.h" - -/* - * This file contains the code which creates, manipulates, and frees encode - * structures. - */ - -/* - * Free an individual encode structure, including data. - */ -void -free_encode(ENCODE *ecp) -{ - if (ecp != NULL) { - if (ecp->data) - free(ecp->data); - free(ecp); - } -} - -/* - * Dump an entire encode list, including data. - */ -void -free_encode_list(ENCODE *ecp) -{ - ENCODE *tmp; - - while (ecp != NULL) { - tmp = ecp; - ecp = ecp->next; - free_encode(tmp); - } -} - -/* - * Allocate an ENCODE structure, and fill it in with the passed data. - * - * Doesn't copy data if copy_flag is not set. - * - * Returns: ptr for success. Doesn't return if a failure occurs. - */ -ENCODE * -make_encode(uchar_t cat, ushort_t code, uchar_t len, void *data, - int copy_flag) -{ - ENCODE *ecp; - - ecp = (ENCODE *)smalloc(sizeof (ENCODE)); - - ecp->category = cat; - ecp->code = code; - ecp->len = len; - - if (data != NULL && len != 0) { - if (copy_flag == ENC_COPY) { - ecp->data = (uchar_t *)smalloc(len); - (void) memcpy(ecp->data, data, len); - } else - ecp->data = data; - } - return (ecp); -} - -/* - * Find a specific code in the ENCODE list. Doesn't consider class. - * - * Returns: ptr if successful, NULL otherwise. - */ -ENCODE * -find_encode(ENCODE *eclp, uchar_t cat, ushort_t code) -{ - for (; eclp != NULL; eclp = eclp->next) { - if (eclp->category == cat && eclp->code == code) - return (eclp); - } - return (NULL); -} - -/* - * Duplicate the passed encode structure. - */ -ENCODE * -dup_encode(ENCODE *ecp) -{ - assert(ecp != NULL); - return (make_encode(ecp->category, ecp->code, ecp->len, ecp->data, - ENC_COPY)); -} - -/* - * Duplicate an encode list. May be called with NULL as a convenience. - */ -ENCODE * -dup_encode_list(ENCODE *ecp) -{ - ENCODE *pp, *np, *headp; - - if (ecp == NULL) - return (NULL); - - /* - * Note: pp/np are used as placeholders in parallel list. - */ - pp = headp = NULL; - for (; ecp != NULL; ecp = ecp->next) { - np = dup_encode(ecp); - if (pp == NULL) { - headp = np; - np->prev = NULL; - } else { - pp->next = np; - np->prev = pp; - } - pp = np; - } - return (headp); -} - -/* - * Given two ENCODE lists, produce NEW ENCODE list by "OR"ing the first - * encode list with the second. Note that the settings in the second encode - * list override any identical code settings in the first encode list. - * - * The primary list is copied if flags argument is ENC_COPY. Class is not - * considered. - * - * Returns a ptr to the merged list for success, NULL ptr otherwise. - */ -ENCODE * -combine_encodes(ENCODE *first_ecp, ENCODE *second_ecp, int flags) -{ - ENCODE *ep; - - if (first_ecp != NULL) { - if (flags == ENC_COPY) - first_ecp = dup_encode_list(first_ecp); - - for (ep = second_ecp; ep != NULL; ep = ep->next) - replace_encode(&first_ecp, ep, ENC_COPY); - } else { - first_ecp = dup_encode_list(second_ecp); - } - return (first_ecp); -} - -/* - * Replace/add the encode matching the code value of the second ENCODE - * parameter in the list represented by the first ENCODE parameter. - */ -void -replace_encode(ENCODE **elistpp, ENCODE *rp, int flags) -{ - ENCODE *wp; - - assert(elistpp != NULL && rp != NULL); - - if (flags == ENC_COPY) - rp = dup_encode(rp); - - if (*elistpp == NULL) { - *elistpp = rp; - return; - } - wp = find_encode(*elistpp, rp->category, rp->code); - - if (wp == NULL) { - rp->next = *elistpp; - rp->next->prev = rp; - *elistpp = rp; - rp->prev = NULL; - } else { - if (wp->prev == NULL) { - rp->next = wp->next; - *elistpp = rp; - rp->prev = NULL; - } else { - rp->next = wp->next; - rp->prev = wp->prev; - wp->prev->next = rp; - } - if (wp->next != NULL) - wp->next->prev = rp; - free_encode(wp); - } -} - -/* - * Given a MACRO and a class name, return the ENCODE list for - * that class name, or null if a ENCODE list by that class doesn't exist. - */ -ENCODE * -vendor_encodes(MACRO *mp, char *class) -{ - VNDLIST **tvpp; - int i; - - assert(mp != NULL && class != NULL); - - for (tvpp = mp->list, i = 0; tvpp != NULL && i < mp->classes; i++) { - if (strcmp(tvpp[i]->class, class) == 0) - return (tvpp[i]->head); - } - return (NULL); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/generic.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/generic.c deleted file mode 100644 index 3d3165944b..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/generic.c +++ /dev/null @@ -1,670 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * This file contains routines that are shared between the DHCP server - * implementation and BOOTP server compatibility. - */ - - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <assert.h> -#include <sys/types.h> -#include <stdarg.h> -#include <errno.h> -#include <alloca.h> -#include <sys/socket.h> -#include <sys/sockio.h> -#include <net/if.h> -#include <sys/syslog.h> -#include <string.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -#include <netinet/dhcp.h> -#include <search.h> -#include <dhcp_symbol.h> -#include "dhcpd.h" -#include "per_dnet.h" -#include "interfaces.h" -#include <locale.h> -#include <resolv.h> - -/* - * Get the client id. Sets cid and len. - */ -void -get_clnt_id(PKT_LIST *plp, uchar_t *cid, int cidlen, uchar_t *len) -{ - DHCP_OPT *optp = plp->opts[CD_CLIENT_ID]; - - /* - * If the DHCP client specified the client id option, use that, - * otherwise use the client's hardware type and hardware address. - */ - if (plp->opts[CD_DHCP_TYPE] != NULL && optp != NULL) { - /* DHCP client w/ client id */ - if (cidlen < optp->len) - *len = (uchar_t)cidlen; - else - *len = optp->len; - (void) memcpy(cid, optp->value, *len); - } else { - /* BOOTP client or DHCP client w/o client id. */ - *cid++ = plp->pkt->htype; - *len = plp->pkt->hlen + 1; - if (cidlen < *len) - *len = cidlen; - (void) memcpy(cid, plp->pkt->chaddr, *len); - } -} - -/* - * Return a string representing an ASCII version of the client_id. - */ -char * -disp_cid(PKT_LIST *plp, char *bufp, int len) -{ - DHCP_OPT *optp = plp->opts[CD_CLIENT_ID]; - uchar_t *cp; - uchar_t cplen; - uint_t tlen; - - if (optp != (DHCP_OPT *)0) { - cp = optp->value; - cplen = optp->len; - } else { - cp = plp->pkt->chaddr; - cplen = plp->pkt->hlen; - } - - tlen = len; - (void) octet_to_hexascii(cp, cplen, bufp, &tlen); - return (bufp); -} - -/* - * Based on the contents of the PKT_LIST structure for an incoming - * packet, determine the net address and subnet mask identifying the - * dhcp-network database. This centralizes choices that were formerly - * made in the specific protocol routines. - */ -void -determine_network(IF *ifp, PKT_LIST *plp, struct in_addr *netp, - struct in_addr *subp) -{ - /* - * For BOOTP, REQUEST, RELEASE, and INFORM packets, trust client's - * notion of IP address if ciaddr is set. Use it to figure out correct - * dhcp-network. - */ - netp->s_addr = plp->pkt->ciaddr.s_addr; - if (netp->s_addr != htonl(INADDR_ANY) && - (plp->opts[CD_DHCP_TYPE] == NULL || - (*plp->opts[CD_DHCP_TYPE]->value == REQUEST || - *plp->opts[CD_DHCP_TYPE]->value == RELEASE || - *plp->opts[CD_DHCP_TYPE]->value == INFORM))) { - /* - * Calculate client's default net mask, consult netmasks - * database to see if net is further subnetted. Use resulting - * subnet mask with client's address to produce dhcp-network - * database name. - */ - get_netmask(netp, subp); - } else - netp->s_addr = htonl(INADDR_ANY); - - /* - * If no trusted IP address, examine giaddr. - */ - if (netp->s_addr == htonl(INADDR_ANY)) { - if (plp->pkt->giaddr.s_addr != htonl(INADDR_ANY)) { - netp->s_addr = plp->pkt->giaddr.s_addr; - /* - * Packet received thru a relay agent. Calculate the - * net's address using subnet mask and giaddr. - */ - get_netmask(netp, subp); - } else { - /* Locally connected net. */ - netp->s_addr = ifp->addr.s_addr; - subp->s_addr = ifp->mask.s_addr; - } - } -} - -struct netmask_node; - -typedef struct netmask_node { - struct in_addr net; /* cached network */ - struct in_addr mask; /* cached netmask */ -} NNODE; - -static void *nroot; /* root of netmask tree */ -static time_t nroot_mtime; /* time for dynamic free */ -static time_t nroot_stamp; /* time for dynamic free */ -static rwlock_t nroot_rwlock; /* synchronization variable */ - -/* - * nm_cmp() - determine whether key n1 is within range of net/mask n2 - */ -static int -nm_cmp(const void *n1, const void *n2) -{ - void *v1 = (void *) (((NNODE *)n1)->net.s_addr & - ((NNODE *)n2)->mask.s_addr); - void *v2 = (void *) ((NNODE *)n2)->net.s_addr; - - return (memcmp(&v1, &v2, sizeof (struct in_addr))); -} - -/* - * Given a network-order address, calculate client's default net mask. - * Consult local cache, then netmasks database to see if net is further - * subnetted. We'll only snag the first netmask that matches our criteria. - */ -void -get_netmask(struct in_addr *n_addrp, struct in_addr *s_addrp) -{ - NNODE key; - NNODE *node; - NNODE **ret; - struct in_addr haddr; - - assert(n_addrp != NULL && s_addrp != NULL); - - /* - * First check locally maintained, incomplete cache. - */ - (void) rw_rdlock(&nroot_rwlock); - if (nroot != NULL) { - /* Delete expired tree. */ - if (nroot_mtime != reinit_time || nroot_stamp < time(NULL)) { - (void) rw_unlock(&nroot_rwlock); - (void) rw_wrlock(&nroot_rwlock); - while ((ret = (NNODE **)nroot) != NULL) { - node = *ret; - (void) tdelete(node, &nroot, nm_cmp); - free(node); - } - nroot_mtime = reinit_time; - nroot_stamp = time(NULL) + DHCP_NSS_TIME; - } else { - key.net.s_addr = ntohl(n_addrp->s_addr); - key.mask.s_addr = INADDR_ANY; - if ((ret = (NNODE **)tfind((void *)&key, - (void * const *)&nroot, nm_cmp)) != NULL) { - s_addrp->s_addr = htonl((*ret)->mask.s_addr); - (void) rw_unlock(&nroot_rwlock); - return; - } - } - } - - /* - * Note: workaround for 4336124: single-thread access to - * nss search routines to avoid getting incorrect results. - */ - node = (NNODE *)smalloc(sizeof (NNODE)); - - /* Convert to and from host order. */ - haddr.s_addr = ntohl(n_addrp->s_addr); - get_netmask4(&haddr, s_addrp); - node->mask.s_addr = s_addrp->s_addr; - node->net.s_addr = haddr.s_addr & node->mask.s_addr; - s_addrp->s_addr = htonl(s_addrp->s_addr); - - /* While inserting check that another insert has not occurred. */ - ret = (NNODE **)tsearch((void *)node, &nroot, nm_cmp); - if (ret != NULL && *ret != node) - free(node); - - (void) rw_unlock(&nroot_rwlock); -} - -/* - * This function is charged with loading the options field with the - * configured and/or asked for options. Note that if the packet is too - * small to fit the options, then option overload is enabled. - * - * Note that the caller is expected to free any allocated ENCODE lists, - * with the exception of locally-allocated lists in the case where ecp is - * NULL, but vecp is not. In this case, the resultant ecp list (ecp == tvep) - * is freed locally. - * - * Returns: The actual size of the utilized packet buffer. - */ - -int -load_options(int flags, PKT_LIST *c_plp, PKT *r_pktp, int replen, uchar_t *optp, - ENCODE *ecp, ENCODE *vecp) -{ - ENCODE *ep, *prevep, *tvep = NULL; - ENCODE *router_ecp = NULL; - PKT *c_pktp = c_plp->pkt; - uchar_t cat; - ushort_t code; - uint_t vend_len; - uchar_t len, *vp, *vdata, *data, *endp, *main_optp, *opt_endp; - uchar_t overload = DHCP_OVRLD_CLR; - uchar_t using_overload = DHCP_OVRLD_CLR; - boolean_t srv_using_file = B_FALSE, clnt_ovrld_file = B_FALSE; - boolean_t echo_clnt_file; - - if (c_plp->opts[CD_OPTION_OVERLOAD] != NULL && - *c_plp->opts[CD_OPTION_OVERLOAD]->value & DHCP_OVRLD_FILE) - clnt_ovrld_file = B_TRUE; - - opt_endp = (uchar_t *)((uint_t)r_pktp->options + replen - - BASE_PKT_SIZE); - endp = opt_endp; - - /* - * We handle vendor options by fabricating an ENCODE of type - * CD_VENDOR_SPEC, and setting its datafield equal to vecp. - * - * We assume we've been handed the proper class list. - */ - if (vecp != NULL && (flags & DHCP_NON_RFC1048) == 0) { - vend_len = 0; - for (ep = vecp, vend_len = 0; ep != NULL; ep = ep->next) - vend_len += (ep->len + 2); - - if (vend_len != 0) { - if (vend_len > (uint_t)0xff) { - dhcpmsg(LOG_WARNING, - "Warning: Too much vendor data (> 255) to " - "encapsulate within option %d.\n", - CD_VENDOR_SPEC); - vend_len = (uint_t)0xff; - } - vdata = (uchar_t *)smalloc(vend_len); - - for (vp = vdata, tvep = vecp; tvep != NULL && - (uchar_t *)(vp + tvep->len + 2) <= &vdata[vend_len]; - tvep = tvep->next) { - *vp++ = tvep->code; - *vp++ = tvep->len; - (void) memcpy(vp, tvep->data, tvep->len); - vp += tvep->len; - } - - /* this make_encode *doesn't* copy data */ - tvep = make_encode(DSYM_VENDOR, CD_VENDOR_SPEC, - vend_len, vdata, ENC_DONT_COPY); - - /* Tack it on the end of standard list. */ - for (ep = prevep = ecp; ep != NULL; ep = ep->next) - prevep = ep; - if (prevep != NULL) - prevep->next = tvep; - else - ecp = tvep; - } - } - - /* - * Scan the options first to determine if we could potentially - * option overload. - */ - if (flags & DHCP_DHCP_CLNT) { - for (ep = ecp; ep != NULL; ep = ep->next) { - if (ep->category == DSYM_FIELD) - switch (ep->code) { - case CD_SNAME: - overload |= DHCP_OVRLD_SNAME; - break; - case CD_BOOTFILE: - overload |= DHCP_OVRLD_FILE; - srv_using_file = B_TRUE; - break; - } - } - } else { - /* BOOTP uses these fields for fixed parameters, no overload */ - overload = DHCP_OVRLD_ALL; - } - - if (c_pktp->file[0] != '\0' && !clnt_ovrld_file && !srv_using_file) { - /* - * simply echo back client's boot file, and don't overload. - * if CD_BOOTPATH is set, we'll simply rewrite the r_pktp - * file field to include it along with the client's requested - * name during the load pass through the internal options. - * Here we let the overload code know we're not to overload - * the file field. - */ - (void) memcpy(r_pktp->file, c_pktp->file, - sizeof (r_pktp->file)); - overload |= DHCP_OVRLD_FILE; - echo_clnt_file = B_TRUE; - } else - echo_clnt_file = B_FALSE; - - /* Now actually load the options! */ - for (ep = ecp; ep != NULL; ep = ep->next) { - cat = ep->category; - code = ep->code; - len = ep->len; - data = ep->data; - - /* - * non rfc1048 clients can only get packet fields and - * the CD_BOOTPATH internal pseudo opt, which only potentially - * affects the file field. - */ - if ((flags & DHCP_NON_RFC1048) && - !(cat == DSYM_FIELD || (cat == DSYM_INTERNAL && - code == CD_BOOTPATH))) { - continue; - } - - if ((flags & DHCP_SEND_LEASE) == 0 && - cat == DSYM_STANDARD && - (code == CD_T1_TIME || code == CD_T2_TIME || - code == CD_LEASE_TIME)) { - continue; - } - - /* standard and site options */ - if (cat == DSYM_STANDARD || cat == DSYM_SITE || - cat == DSYM_VENDOR) { - - uchar_t *need_optp; - - /* - * This horrible kludge is necessary because the DHCP - * options RFCs require that the subnet option MUST - * precede the router option. To accomplish this, we - * - * inspect each of the standard options, waiting - * for CD_ROUTER to turn up (if it never does, - * no special handling is needed) - * - * search the remaining options for CD_SUBNETMASK - * If it occurs, we - * set router_ecp to indicate where to find - * the router option's values that we have - * not yet emitted - * - * reinitialize code, len, and data to emit - * the CD_SUBNETMASK option now - * - * when CD_SUBNETMASK is encountered, we - * reinitialize code, len, and data to emit - * the CD_ROUTER option - */ - if ((cat == DSYM_STANDARD) && (code == CD_ROUTER)) { - ENCODE *tp; - - for (tp = ep->next; tp != NULL; tp = tp->next) - if ((tp->category == DSYM_STANDARD) && - (tp->code == CD_SUBNETMASK)) { - router_ecp = ep; - code = CD_SUBNETMASK; - len = tp->len; - data = tp->data; - } - } else if ((cat == DSYM_STANDARD) && - (code == CD_SUBNETMASK) && (router_ecp != NULL)) { - code = CD_ROUTER; - len = router_ecp->len; - data = router_ecp->data; - } - - /* - * Keep an eye on option field. Option overload. Note - * that we need to keep track of the space necessary - * to place the Overload option in the options section - * (that's the 3 octets below.) The 2 octets cover the - * necessary code and len portion of the payload. - */ - if (using_overload == DHCP_OVRLD_CLR) { - /* 2 for code/len, 3 for overload option */ - need_optp = &optp[len + 2 + 3]; - } else { - /* Just need 2 for code/len */ - need_optp = &optp[len + 2]; - } - if (need_optp > endp) { - /* - * If overload is not possible, we will - * keep going, hoping to find an option - * that will fit in the remaining space, - * rather than just give up. - */ - if (overload != DHCP_OVRLD_ALL) { - if (using_overload == DHCP_OVRLD_CLR) { - *optp++ = CD_OPTION_OVERLOAD; - *optp++ = 1; - main_optp = optp; - } else { - if (optp < endp) - *optp = CD_END; - overload |= using_overload; - } - } - switch (overload) { - case DHCP_OVRLD_CLR: - /* great, can use both */ - /* FALLTHRU */ - case DHCP_OVRLD_FILE: - /* Can use sname. */ - optp = r_pktp->sname; - endp = r_pktp->file; - using_overload |= DHCP_OVRLD_SNAME; - break; - case DHCP_OVRLD_SNAME: - /* Using sname, can use file. */ - optp = r_pktp->file; - endp = r_pktp->cookie; - using_overload |= DHCP_OVRLD_FILE; - break; - } - } - /* Skip the option if it's too long to fit */ - if (len < (endp - optp - 1)) { - /* Load options. */ - *optp++ = (uchar_t)code; - *optp++ = len; - (void) memcpy(optp, data, len); - optp += len; - } - } else if (cat == DSYM_FIELD) { - /* packet field pseudo options */ - switch (code) { - case CD_SIADDR: - /* - * Configuration includes Boot server addr - */ - (void) memcpy((void *)&r_pktp->siaddr, data, - len); - break; - case CD_SNAME: - /* - * Configuration includes Boot server name - */ - (void) memcpy(r_pktp->sname, data, len); - break; - case CD_BOOTFILE: - /* - * Configuration includes boot file. - * Always authoritative. - */ - (void) memset(r_pktp->file, 0, - sizeof (r_pktp->file)); - (void) memcpy(r_pktp->file, data, len); - break; - default: - dhcpmsg(LOG_ERR, - "Unsettable DHCP packet field: %d\n", code); - break; - } - } else if (cat == DSYM_INTERNAL) { - /* Internal server pseudo options */ - switch (code) { - case CD_BOOTPATH: - /* - * Prefix for boot file. Only used if - * client provides bootfile and server doesn't - * specify one. Prepended on client's bootfile - * value. Otherwise ignored. - */ - if (echo_clnt_file) { - uchar_t alen, flen; - - alen = sizeof (c_pktp->file); - flen = alen - 1; - if (c_pktp->file[flen] != '\0') - flen++; - else - flen = strlen( - (char *)c_pktp->file); - - if ((len + flen + 1) > alen) { - char *bp = alloca(alen + 1); - char *bf = alloca(alen + 1); - (void) memcpy(bp, data, len); - bp[len] = '\0'; - (void) memcpy(bf, c_pktp->file, - flen); - bf[flen] = '\0'; - dhcpmsg(LOG_ERR, - "BootPath(%1$s) + " - "BootFile(%2$s) too " - "long: %3$d > %4$d\n", - bp, bf, (len + flen), alen); - } else { - (void) memcpy(r_pktp->file, - data, len); - r_pktp->file[len] = '/'; - (void) memcpy( - &r_pktp->file[len + 1], - c_pktp->file, flen); - } - } - break; - case CD_BOOL_HOSTNAME: - /* FALLTHRU */ - case CD_BOOL_LEASENEG: - /* FALLTHRU */ - case CD_BOOL_ECHO_VCLASS: - /* - * These pseudo opts have had their - * affect elsewhere, such as dhcp.c. - */ - break; - default: - dhcpmsg(LOG_ERR, - "Unknown Internal pseudo opt: %d\n", code); - break; - } - } else { - dhcpmsg(LOG_ERR, - "Unrecognized option with code: %d %d\n", cat, - code); - } - } - - if (using_overload != DHCP_OVRLD_CLR) { - *main_optp++ = using_overload; - if (optp < endp) - *optp = CD_END; - } else - main_optp = optp; /* no overload */ - - if (main_optp < opt_endp) - *main_optp++ = CD_END; - - if (ecp == tvep) - free_encode_list(ecp); - - return (BASE_PKT_SIZE + (uint_t)(main_optp - r_pktp->options)); -} - -/* - * Reinitialize the dhcptab database, as a result of timeout or - * user signal. Note: if_head_mtx cannot be held by caller. - */ -void * -reinitialize(void *arg) -{ - int totpkts; - IF *ifp; - thread_t *tp = (thread_t *)arg; - int err; - - /* - * Got a signal to reinitialize - */ - - if (verbose) - dhcpmsg(LOG_INFO, "Reinitializing server\n"); - - if (!no_dhcptab) { - if (checktab() != 0) { - dhcpmsg(LOG_WARNING, - "WARNING: Cannot access dhcptab.\n"); - } else { - if ((err = readtab(PRESERVE_DHCPTAB)) != 0) { - dhcpmsg(LOG_ERR, - "Error reading dhcptab.\n"); - return ((void *)err); - } - } - } - - /* - * Drop all pending offers, display interface statistics. - */ - if (verbose) { - (void) mutex_lock(&if_head_mtx); - for (ifp = if_head, totpkts = 0; ifp != NULL; ifp = ifp->next) { - (void) mutex_lock(&ifp->ifp_mtx); - disp_if_stats(ifp); - totpkts += ifp->received; - (void) mutex_unlock(&ifp->ifp_mtx); - } - (void) mutex_unlock(&if_head_mtx); - - dhcpmsg(LOG_INFO, - "Total Packets received on all interfaces: %d\n", totpkts); - dhcpmsg(LOG_INFO, "Server reinitialized.\n"); - } - - /* Default domain may have changed */ - if (res_ninit(&resolv_conf) == -1) - dhcpmsg(LOG_ERR, "Cannot acquire resolver configuration.\n"); - - /* Release reinitialization thread */ - reinit_time = time(NULL); - *tp = NULL; - thr_exit(NULL); - - return (NULL); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/hash.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/hash.c deleted file mode 100644 index 0e44430bee..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/hash.c +++ /dev/null @@ -1,579 +0,0 @@ -/* - * Copyright (c) 1993-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Copyright 1988, 1991 by Carnegie Mellon University - * - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Carnegie Mellon University not be used - * in advertising or publicity pertaining to distribution of the software - * without specific, written prior permission. - * - * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. - * IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF - * THIS SOFTWARE. - */ - -/* - * Generalized hash table ADT - * - * Provides multiple, dynamically-allocated, variable-sized hash tables on - * various data and keys. - * - * This package attempts to follow some of the coding conventions suggested - * by Bob Sidebotham and the AFS Clean Code Committee of the - * Information Technology Center at Carnegie Mellon. - * - * Additions for per bucket locking, and configurable dynamic free of - * unused entries. - */ - -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/param.h> -#include <sys/sysmacros.h> -#include <stdarg.h> -#include <stddef.h> -#include <assert.h> -#include <synch.h> -#include "dhcpd.h" -#include "hash.h" - -/* - * Hash table size calculation routine. - * - * Estimate the size of a hash table based on the expected number of - * entries, up to a maximum of HASHTABLESIZE. - */ -static unsigned -hashi_Hsize(unsigned hint) -{ - unsigned f; - - if (hint == 0) /* Default size. */ - hint = HASHTABLESIZE; - else if (hint < 16) /* Minimal size. */ - hint = 16; - - hint /= 4; - for (f = 2; f * f <= hint; f++) { /* Find next largest prime. */ - if (hint % f == 0) { - f = 1; - hint++; - } - } - return (MIN(HASHTABLESIZE, hint)); -} - -/* - * Frees an entire linked list of bucket members (used in the - * open hashing scheme). Does nothing if the passed pointer is NULL. - * - * Returns B_FALSE and members which could not be freed in bucketptr, when - * force variable is set to B_FALSE, and free_data routine indicates - * free did not occur. - */ -static boolean_t -hashi_FreeMember(hash_member **bucketptr, boolean_t (*free_data)(), - boolean_t force) -{ - hash_member *prev, *next, *unfree = NULL; - boolean_t ret = B_TRUE; - - if (bucketptr) { - for (prev = *bucketptr; prev; prev = next) { - next = prev->next; - prev->next = NULL; - if (free_data != NULL) { - if ((*free_data)(prev->data, force) == - B_FALSE) { - ret = B_FALSE; - prev->next = unfree; - unfree = prev; - } else { - free(prev); - } - } else - free(prev); - } - *bucketptr = unfree; - } - return (ret); -} - -/* - * Dynamic free initialization. - */ -static void -hashi_Dinit(hash_tbl *hashtable, hash_member *memberptr) -{ - (void) mutex_init(&memberptr->h_mtx, USYNC_THREAD, NULL); - memberptr->h_time = time(NULL) + hashtable->dfree_time; - memberptr->h_count = 1; -} - -/* - * Dynamic free reference count increment. - */ -static void -hashi_Dhold(hash_member *memberptr) -{ - (void) mutex_lock(&memberptr->h_mtx); - memberptr->h_count++; - (void) mutex_unlock(&memberptr->h_mtx); -} - -/* - * Dynamic free expired data. Return NULL if memberptr is successfully - * dynamically freed, otherwise return memberptr. - */ -static hash_member * -hashi_Dfree(hash_member *memberptr, boolean_t (*free_data)()) -{ - hash_member *next; - - next = memberptr->next; - memberptr->next = NULL; - if (hashi_FreeMember(&memberptr, free_data, B_FALSE) == B_TRUE) - memberptr = NULL; - else - memberptr->next = next; - return (memberptr); -} - -/* - * Hash table initialization routine. - * - * This routine creates and intializes a hash table of size "tablesize" - * entries. Successful calls return a pointer to the hash table (which must - * be passed to other hash routines to identify the hash table). Failed - * calls return NULL. - */ -hash_tbl * -hash_Init(unsigned tablesize, boolean_t (*dfree_data)(), time_t dtime, - boolean_t lck) -{ - hash_tbl *hashtblptr; - unsigned totalsize; - unsigned i; - - tablesize = hashi_Hsize(tablesize); - - totalsize = sizeof (hash_tbl) + (sizeof (hash_bucket) * - (tablesize - 1)); - - hashtblptr = (hash_tbl *)smalloc(totalsize); - - hashtblptr->size = tablesize; /* Success! */ - hashtblptr->bucketnum = 0; - hashtblptr->dfree_data = dfree_data; - hashtblptr->dfree_lck = lck; - hashtblptr->dfree_time = dtime; - hashtblptr->table = &hashtblptr->data[0]; - for (i = 0; i < tablesize; i++) { - hashtblptr->table[i].table = hashtblptr; - if (lck == B_TRUE) { - (void) rwlock_init(&(hashtblptr->table[i].rwlock), - USYNC_THREAD, NULL); - } - } - - return (hashtblptr); /* NULL if failure */ -} - -/* - * Generic hash function to calculate a hash code from the given string. - * - * For each byte of the string, this function left-shifts the value in an - * accumulator and then adds the byte into the accumulator. The contents of - * the accumulator is returned after the entire string has been processed. - * It is assumed that this result will be used as the "hashcode" parameter in - * calls to other functions in this package. These functions automatically - * adjust the hashcode for the size of each hashtable. - * - * This algorithm probably works best when the hash table size is a prime - * number. - * - * Hopefully, this function is better than the previous one which returned - * the sum of the squares of all the bytes. I'm still open to other - * suggestions for a default hash function. The programmer is more than - * welcome to supply his/her own hash function as that is one of the design - * features of this package. - */ -static unsigned -hashi_HashFunction(unsigned char *string, unsigned len) -{ - unsigned accum; - - /* - * Special case: allow hash_Delete() to iterate over buckets. - */ - if (string == NULL) - return (len); - - for (accum = 0; len != 0; len--) { - accum <<= 1; - accum += (unsigned)(*string++ & 0xFF); - } - return (accum); -} - -/* - * This routine re-initializes the hash table. It frees all the allocated - * memory and resets all bucket pointers to NULL. For the macro hash - * table, the table will be reused. Other tables (with bucket locks) - * will be destroyed. - */ -void -hash_Reset(hash_tbl *hashtable, boolean_t (*free_data)()) -{ - hash_bucket *bucketptr; - unsigned i; - - bucketptr = &((hashtable->table)[0]); - for (i = 0; i < hashtable->size; i++) { - if (hashtable->dfree_lck == B_TRUE) - (void) rw_wrlock(&bucketptr->rwlock); - /* - * Unequivocally free member, using the force parameter. - */ - (void) hashi_FreeMember(&bucketptr->next, free_data, B_TRUE); - bucketptr->next = NULL; - if (hashtable->dfree_lck == B_TRUE) { - (void) rw_unlock(&bucketptr->rwlock); - (void) rwlock_destroy(&(bucketptr->rwlock)); - } - bucketptr++; - } - hashtable->bucketnum = 0; -} - -/* - * Returns B_TRUE if at least one entry for the given key exists; B_FALSE - * otherwise. Dynamically free expired data as searched. - */ -static int -hashi_Exists(hash_bucket *bucketptr, int (*compare)(), hash_datum *key, - boolean_t (*free_data)(), hash_member **prev) -{ - hash_member *prevptr = (hash_member *)bucketptr; - hash_member *memberptr = bucketptr->next; - hash_tbl *hashtable = bucketptr->table; - hash_member *next; - boolean_t ret = B_FALSE; - time_t now = time(NULL); - - while (memberptr != NULL) { - /* - * Dynamically free expired data. - */ - if (free_data != NULL && hashtable->dfree_data != NULL && - memberptr->h_time < now) { - next = memberptr->next; - if ((memberptr = hashi_Dfree(memberptr, free_data)) == - NULL) { - prevptr->next = memberptr = next; - continue; - } - } - - /* - * Entry exists, or we are randomly selecting any - * element (compare function is NULL). - */ - if (compare == NULL || (*compare)(key, memberptr->data)) { - ret = B_TRUE; - break; - } else - prevptr = memberptr; - memberptr = memberptr->next; - } - - if (prev != NULL) - *prev = prevptr; - return (ret); -} - -/* - * Returns number of Dynamically freed expired entries. - */ -static int -hashi_Expire(hash_bucket *bucketptr, boolean_t (*free_data)()) -{ - hash_member *prevptr = (hash_member *)bucketptr; - hash_member *memberptr = bucketptr->next; - hash_tbl *hashtable = bucketptr->table; - hash_member *next; - int rcount = 0; - time_t now = time(NULL); - - while (memberptr) { - /* - * Dynamically free expired data. - */ - if (free_data != NULL && hashtable->dfree_data != NULL && - memberptr->h_time < now) { - next = memberptr->next; - if ((memberptr = hashi_Dfree(memberptr, free_data)) == - NULL) { - rcount++; - prevptr->next = memberptr = next; - continue; - } - } - prevptr = memberptr; - memberptr = memberptr->next; - } - return (rcount); -} - -/* - * Insert the data item "element" into the hash table using "hashcode" - * to determine the bucket number, and "compare" and "key" to determine - * its uniqueness. - * - * If the insertion is successful the element is returned. If a matching entry - * already exists in the given bucket of the hash table, then NULL is returned, - * signifying that the entry is already in the table. This happens when some - * other thread has already inserted the entry. - */ -void * -hash_Insert(hash_tbl *hashtable, void *hashdata, unsigned hashlen, - int (*compare)(), hash_datum *key, hash_datum *element) -{ - hash_member *temp = NULL; - hash_bucket *bucketptr; - hash_member *prev = NULL; - unsigned hashcode = hashi_HashFunction(hashdata, hashlen); - - bucketptr = &((hashtable->table)[hashcode % hashtable->size]); - if (hashtable->dfree_lck) - (void) rw_wrlock(&bucketptr->rwlock); - - if (hashi_Exists(bucketptr, compare, key, hashtable->dfree_data, - &prev)) { - /* Some other thread got there first, so just return */ - if (hashtable->dfree_lck) - (void) rw_unlock(&bucketptr->rwlock); - return (NULL); - } - - temp = (hash_member *)smalloc(sizeof (hash_member)); - - prev->next = temp; - temp->data = element; - temp->next = NULL; - - /* - * Dynamic free initialization. - */ - if (hashtable->dfree_data != NULL) - hashi_Dinit(hashtable, temp); - - if (hashtable->dfree_lck) - (void) rw_unlock(&bucketptr->rwlock); - - return ((void *)temp); -} - -/* - * Release the reference count on an item. Performance: if item is to be - * deleted, mark for future dynamic free. - */ -void -hash_Rele(void *hashp, boolean_t delete) -{ - hash_member *memberptr = (hash_member *)hashp; - - (void) mutex_lock(&memberptr->h_mtx); - memberptr->h_count--; - assert(memberptr->h_count >= 0); - if (delete == B_TRUE) - memberptr->h_time = 0; - (void) mutex_unlock(&memberptr->h_mtx); -} - -/* - * Report the reference count on an item. - */ -int -hash_Refcount(void *hashp) -{ - hash_member *memberptr = (hash_member *)hashp; - int ret; - - (void) mutex_lock(&memberptr->h_mtx); - ret = memberptr->h_count; - (void) mutex_unlock(&memberptr->h_mtx); - return (ret); -} - -/* - * Report the dynamic free time on an item. - */ -int -hash_Htime(void *hashp) -{ - hash_member *memberptr = (hash_member *)hashp; - int ret; - - (void) mutex_lock(&memberptr->h_mtx); - ret = memberptr->h_time; - (void) mutex_unlock(&memberptr->h_mtx); - return (ret); -} - -/* - * Increase the dynamic free time on an item. - */ -void -hash_Age(void *hashp) -{ - hash_member *memberptr = (hash_member *)hashp; - - (void) mutex_lock(&memberptr->h_mtx); - memberptr->h_time++; - (void) mutex_unlock(&memberptr->h_mtx); -} - -/* - * Set the dynamic free time on an item. - */ -void -hash_Dtime(void *hashp, time_t tm) -{ - hash_member *memberptr = (hash_member *)hashp; - - (void) mutex_lock(&memberptr->h_mtx); - memberptr->h_time = tm; - (void) mutex_unlock(&memberptr->h_mtx); -} - -/* - * Delete a data item from the hash table using "hashcode" - * to determine the bucket number, and "compare" and "key" to determine - * its uniqueness. - * - * If the deletion is successful 0 is returned. If a matching entry - * does not exist in the given bucket of the hash table, or some other error - * occurs, -1 is returned and the insertion is not done. - */ -boolean_t -hash_Delete(hash_tbl *hashtable, void *hashdata, unsigned hashlen, - int (*compare)(), hash_datum *key, boolean_t (*free_data)()) -{ - hash_member *prev = NULL; - hash_member *temp; - hash_bucket *bucketptr; - unsigned hashcode = hashi_HashFunction(hashdata, hashlen); - - bucketptr = &((hashtable->table)[hashcode % hashtable->size]); - if (hashtable->dfree_lck == B_TRUE) - (void) rw_wrlock(&bucketptr->rwlock); - - if (hashi_Exists(bucketptr, compare, key, free_data, &prev) == - B_FALSE || prev == NULL) { - if (hashtable->dfree_lck == B_TRUE) - (void) rw_unlock(&bucketptr->rwlock); - return (B_FALSE); /* Entry does not exist */ - } - - temp = prev->next; - if (temp) { - prev->next = temp->next; - temp->next = NULL; - (void) hashi_FreeMember(&temp, free_data, B_TRUE); - } else - prev->next = NULL; - if (hashtable->dfree_lck == B_TRUE) - (void) rw_unlock(&bucketptr->rwlock); - return (B_TRUE); -} - -/* - * Locate and return the data entry associated with the given key. - * - * If the data entry is found, a pointer to it is returned. Otherwise, - * NULL is returned. - */ -hash_datum * -hash_Lookup(hash_tbl *hashtable, void *hashdata, unsigned hashlen, - int (*compare)(), hash_datum *key, boolean_t hold) -{ - hash_datum *ret = NULL; - hash_bucket *bucketptr; - hash_member *prev = NULL; - unsigned hashcode = hashi_HashFunction(hashdata, hashlen); - - bucketptr = &((hashtable->table)[hashcode % hashtable->size]); - if (hashtable->dfree_lck == B_TRUE) - (void) rw_wrlock(&bucketptr->rwlock); - - if (hashi_Exists(bucketptr, compare, key, hashtable->dfree_data, - &prev) == B_TRUE) { - /* - * Dynamic free increment reference. - */ - if (hold) - hashi_Dhold(prev->next); - ret = prev->next->data; - - } - if (hashtable->dfree_lck == B_TRUE) - (void) rw_unlock(&bucketptr->rwlock); - return (ret); -} - -/* - * Reap expired data items, or a random data item from the hash table. - */ -void -hash_Reap(hash_tbl *hashtable, boolean_t (*free_data)()) -{ - hash_bucket *bucketptr; - int rcount; - unsigned i; - - bucketptr = &((hashtable->table)[0]); - rcount = 0; - - /* - * Walk the buckets, reaping expired clients. - */ - for (i = 0; i < hashtable->size; i++) { - if (hashtable->dfree_lck == B_TRUE) - (void) rw_wrlock(&bucketptr->rwlock); - rcount += hashi_Expire(bucketptr, hashtable->dfree_data); - if (hashtable->dfree_lck == B_TRUE) - (void) rw_unlock(&bucketptr->rwlock); - bucketptr++; - } - - /* - * Nothing to be reaped, delete a random element. Note that - * the unhash_data routine will wait for current references - * before deletion. - */ - if (rcount == 0) { - for (i = 0; i < hashtable->size; i++) { - if (hash_Delete(hashtable, NULL, i, NULL, NULL, - free_data) == B_TRUE) { - break; - } - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/hash.h b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/hash.h deleted file mode 100644 index 6cd659a550..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/hash.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 1993-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -/* - * Copyright 1988, 1991 by Carnegie Mellon University - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Carnegie Mellon University not be used - * in advertising or publicity pertaining to distribution of the software - * without specific, written prior permission. - * - * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. - * IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF - * THIS SOFTWARE. - */ - -#ifndef _HASH_H -#define _HASH_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Generalized hash table ADT - * - * Provides multiple, dynamically-allocated, variable-sized hash tables on - * various data and keys. - * - * This package attempts to follow some of the coding conventions suggested - * by Bob Sidebotham and the AFS Clean Code Committee. - */ - -/* - * The user must supply the following: - * - * 1. A comparison function which is declared as: - * - * int compare(data1, data2) - * hash_datum *data1, *data2; - * - * This function must compare the desired fields of data1 and - * data2 and return B_TRUE (1) if the data should be considered - * equivalent (i.e. have the same key value) or B_FALSE (0) - * otherwise. This function is called through a pointer passed to - * the various hashtable functions (thus pointers to different - * functions may be passed to effect different tests on different - * hash tables). - * - * Internally, all the functions of this package always call the - * compare function with the "key" parameter as the first parameter, - * and a full data element as the second parameter. Thus, the key - * and element arguments to functions such as hash_Lookup() may - * actually be of different types and the programmer may provide a - * compare function which compares the two different object types - * as desired. - * - * Example: - * - * int compare(key, element) - * char *key; - * struct some_complex_structure *element; - * { - * return !strcmp(key, element->name); - * } - * - * key = "John C. Doe" - * element = &some_complex_structure - * hash_Lookup(table, hashptr, hashlen, compare, key, free_rec, B_TRUE); - * - * 2. A hash function yielding an unsigned integer value to be used - * as the hashcode (index into the hashtable). Thus, the user - * may hash on whatever data is desired and may use several - * different hash functions for various different hash tables. - * The actual hash table index will be the passed hashcode modulo - * the hash table size. - * - * A generalized hash function, hash_HashFunction(), is included - * with this package to make things a little easier. It is not - * guarenteed to use the best hash algorithm in existence. . . . - * - * 3. An ability to garbage collect data has been added. Timed garbage - * collection of hash members is provided to relieve the interface and worker - * threads of explicit data structure management. Expired data structures - * are pruned during hash insertion and deletion, or by explicit calls - * to Delete and Reap functions. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Various hash table definitions - */ - -/* - * Define "hash_datum" as a universal data type - */ -typedef void hash_datum; -typedef void *hash_handle; - -typedef struct hash_memberstruct hash_member; -typedef struct hash_bucketstruct hash_bucket; -typedef struct hash_tblstruct hash_tbl; -typedef struct hash_tblstruct_hdr hash_tblhdr; - -struct hash_memberstruct { - hash_member *next; /* hash next pointer */ - hash_datum *data; /* hash data */ - time_t h_time; /* hash dynamic free time */ - int h_count; /* hash reference count */ - mutex_t h_mtx; /* hash mutex */ -}; - -struct hash_tblstruct; -struct hash_bucketstruct { - hash_member *next; - struct hash_tblstruct *table; - rwlock_t rwlock; -}; - -struct hash_tblstruct_hdr { - unsigned size; - unsigned bucketnum; - hash_member *member; -}; - -struct hash_tblstruct { - unsigned size; - unsigned bucketnum; - hash_member *member; /* Used for linear dump */ - boolean_t (*dfree_data)(); /* Used for dynamic free */ - boolean_t dfree_lck; /* Use for dynamic free locking */ - time_t dfree_time; /* Unused time to dynamically free */ - hash_bucket *table; /* Dynamically Extend */ - hash_bucket data[1]; -}; - -extern unsigned hash_Size(unsigned int); -extern hash_tbl *hash_Init(unsigned, boolean_t (*)(), time_t, boolean_t); -extern void hash_Reset(hash_tbl *, boolean_t (*)()); -extern void *hash_Insert(hash_tbl *, void *, unsigned, int (*)(), - hash_datum *, hash_datum *); -extern hash_datum *hash_Lookup(hash_tbl *, void *, unsigned, int (*)(), - hash_datum *, boolean_t); -extern boolean_t hash_Delete(hash_tbl *, void *, unsigned, int (*)(), - hash_datum *, boolean_t (*)()); -extern void hash_Reap(hash_tbl *, boolean_t (*)()); -extern void hash_Age(void *); -extern void hash_Dtime(void *, time_t); -extern int hash_Refcount(void *); -extern int hash_Htime(void *); -extern void hash_Rele(void *, boolean_t); - -#ifdef __cplusplus -} -#endif - -#endif /* _HASH_H */ diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/icmp.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/icmp.c deleted file mode 100644 index f29119cbb8..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/icmp.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1993-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <stdarg.h> -#include <sys/types.h> -#include <fcntl.h> -#include <errno.h> -#include <syslog.h> -#include <string.h> -#include <time.h> -#include <thread.h> -#include <sys/socket.h> -#include <net/if.h> -#include <netinet/in_systm.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netinet/ip.h> -#include <netinet/ip_icmp.h> -#include <netinet/udp.h> -#include <netinet/dhcp.h> -#include "dhcpd.h" -#include "per_dnet.h" -#include "interfaces.h" -#include <v4_sum_impl.h> -#include <locale.h> - -#define ICMP_ECHO_SIZE (sizeof (struct icmp) + 36) - -/* - * An implementation of ICMP ECHO for use in detecting addresses already - * in use. Address argument expected in network order. Result is set to - * B_TRUE if a ICMP ECHO reply is received, B_FALSE if not. Returns 0 if - * no errors were encountered, nonzero otherwise. - * - * NOTES: Not interface specific. We use our routing tables to route the - * messages correctly, and collect responses. This may mean that we - * receive an ICMP ECHO reply thru an interface the daemon has not been - * directed to watch. However, I believe that *ANY* echo reply means - * trouble, regardless of the route taken! - * - * 'cip' is expected in network order. - */ - -int -icmp_echo_check(struct in_addr *cip, boolean_t *result) -{ - struct icmp *icp; - struct ip *ipp; - int sequence = 0, i, s, s_cnt, r_cnt, - icmp_identifier, error = 0; - socklen_t fromlen; - ushort_t ip_hlen; - hrtime_t recv_intrvl; - struct sockaddr_in to, from; - struct pollfd pfd; - char ntoab[INET_ADDRSTRLEN]; - ulong_t outpack[DHCP_SCRATCH/sizeof (ulong_t)]; - ulong_t inpack[DHCP_SCRATCH/sizeof (ulong_t)]; - - *result = B_FALSE; - - (void) inet_ntop(AF_INET, cip, ntoab, sizeof (ntoab)); - - if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) { - error = errno; - dhcpmsg(LOG_ERR, - "Error opening raw socket for ICMP (ping %s).\n", ntoab); - return (error); - } - - if (fcntl(s, F_SETFL, O_NDELAY) == -1) { - error = errno; - dhcpmsg(LOG_ERR, - "Error setting ICMP socket to no delay. (ping %s)\n", - ntoab); - (void) close(s); - return (error); - } - - pfd.fd = s; - pfd.events = POLLIN | POLLPRI; - pfd.revents = 0; - - icmp_identifier = (int)thr_self() & (ushort_t)-1; - (void) memset((void *)outpack, 0, sizeof (outpack)); - outpack[10] = 0x12345678; - icp = (struct icmp *)outpack; - icp->icmp_code = 0; - icp->icmp_type = ICMP_ECHO; - icp->icmp_id = icmp_identifier; - - (void) memset((void *)&to, 0, sizeof (struct sockaddr_in)); - to.sin_family = AF_INET; - to.sin_addr.s_addr = cip->s_addr; - - /* - * We make icmp_tries attempts to contact the target. We - * wait the same length of time for a response in both cases. - */ - for (i = 0; i < icmp_tries; i++) { - icp->icmp_seq = sequence++; - icp->icmp_cksum = 0; - icp->icmp_cksum = ipv4cksum((uint16_t *)icp, ICMP_ECHO_SIZE); - - /* Deliver our ECHO. */ - s_cnt = sendto(s, (char *)outpack, ICMP_ECHO_SIZE, 0, - (struct sockaddr *)&to, sizeof (struct sockaddr)); - - if (s_cnt < 0 || s_cnt != ICMP_ECHO_SIZE) { - error = errno; - dhcpmsg(LOG_ERR, - "Error sending ICMP message. (ping %s).\n", - ntoab); - (void) close(s); - return (error); - } - - /* Collect replies. */ - recv_intrvl = gethrtime() + - (hrtime_t)(icmp_timeout) * 1000000; - - while (gethrtime() < recv_intrvl) { - if (poll(&pfd, (nfds_t)1, icmp_timeout) < 0 || - pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { - /* EINTR is masked - must be serious */ - error = errno; - dhcpmsg(LOG_ERR, "Poll: ICMP reply for %s.\n", - ntoab); - (void) close(s); - return (error); - } - - if (!pfd.revents) { - continue; /* no data, timeout */ - } - - fromlen = sizeof (from); - if ((r_cnt = recvfrom(s, (char *)inpack, - sizeof (inpack), 0, (struct sockaddr *)&from, - &fromlen)) < 0) { - error = errno; - if (error == EAGAIN) { - error = 0; - continue; - } - /* EINTR is masked - must be serious */ - dhcpmsg(LOG_ERR, - "recvfrom: ICMP reply for %s.\n", - ntoab); - (void) close(s); - return (error); - } - - if (from.sin_addr.s_addr != cip->s_addr) - continue; /* Not from the IP of interest */ - /* - * We know we got an ICMP message of some type from - * the IP of interest. Be conservative and - * consider it in use. The following logic is just - * for identifying problems in the response. - */ - *result = B_TRUE; - - if (!debug) - break; - - ipp = (struct ip *)inpack; - if (r_cnt != ntohs(ipp->ip_len)) { - /* bogus IP header */ - dhcpmsg(LOG_NOTICE, "Malformed ICMP message " - "received from host %s: len %d != %d\n", - ntoab, r_cnt, ntohs(ipp->ip_len)); - break; - } - ip_hlen = ipp->ip_hl << 2; - if (r_cnt < (int)(ip_hlen + ICMP_MINLEN)) { - dhcpmsg(LOG_NOTICE, "ICMP message received " - "from host %s is too small.\n", ntoab); - break; - } - icp = (struct icmp *)((uint_t)inpack + ip_hlen); - if (ipv4cksum((uint16_t *)icp, - ntohs(ipp->ip_len) - ip_hlen) != 0) { - dhcpmsg(LOG_NOTICE, "Bad checksum on incoming " - "ICMP echo reply. (ping %s)\n", ntoab); - } - if (icp->icmp_type != ICMP_ECHOREPLY) { - dhcpmsg(LOG_NOTICE, - "Unexpected ICMP type %d from %s.\n", - icp->icmp_type, ntoab); - } - if (icp->icmp_id != icmp_identifier) { - dhcpmsg(LOG_NOTICE, - "ICMP message id mismatch (from %s).\n", - ntoab); - } - if (icp->icmp_seq != (sequence - 1)) { - dhcpmsg(LOG_NOTICE, "ICMP sequence mismatch: " - "%d != %d (ping %s)\n", icp->icmp_seq, - sequence - 1, ntoab); - } - break; - } - } - (void) close(s); - - return (error); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/in.dhcpd.xcl b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/in.dhcpd.xcl deleted file mode 100644 index f4ddaa112a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/in.dhcpd.xcl +++ /dev/null @@ -1,152 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -msgid "XXX_XXX_XXX_XXX" -msgid ":" -msgid "," -msgid "Subnet" -msgid "UTCoffst" -msgid "Router" -msgid "Timeserv" -msgid "IEN116ns" -msgid "DNSserv" -msgid "Logserv" -msgid "Cookie" -msgid "Lprserv" -msgid "Impress" -msgid "Resource" -msgid "Hostname" -msgid "Bootsize" -msgid "Dumpfile" -msgid "DNSdmain" -msgid "Swapserv" -msgid "Rootpath" -msgid "ExtendP" -msgid "IpFwdF" -msgid "NLrouteF" -msgid "PFilter" -msgid "MaxIpSiz" -msgid "IpTTL" -msgid "PathTO" -msgid "PathTbl" -msgid "MTU" -msgid "SameMtuF" -msgid "Broadcst" -msgid "MaskDscF" -msgid "MaskSupF" -msgid "RDiscvyF" -msgid "RSolictS" -msgid "StaticRt" -msgid "TrailerF" -msgid "ArpTimeO" -msgid "EthEncap" -msgid "TcpTTL" -msgid "TcpKaInt" -msgid "TcpKaGbF" -msgid "NISdmain" -msgid "NISservs" -msgid "NTPservs" -msgid "NetBNms" -msgid "NetBDsts" -msgid "NetBNdT" -msgid "NetBScop" -msgid "XFontSrv" -msgid "XDispMgr" -msgid "LeaseTim" -msgid "Message" -msgid "T1Time" -msgid "T2Time" -msgid "NW_dmain" -msgid "NWIPOpts" -msgid "NIS+dom" -msgid "NIS+serv" -msgid "TFTPsrvN" -msgid "OptBootF" -msgid "MblIPAgt" -msgid "SMTPserv" -msgid "POP3serv" -msgid "NNTPserv" -msgid "WWWservs" -msgid "Fingersv" -msgid "IRCservs" -msgid "STservs" -msgid "STDAservs" -msgid "BootFile" -msgid "BootSrvA" -msgid "BootSrvN" -msgid "LeaseNeg" -msgid "EchoVC" -msgid "BootPath" -msgid "Include" -msgid "files" -msgid "nisplus" -msgid "Vendor" -msgid "Site" -msgid "Extend" -msgid "ASCII" -msgid "OCTET" -msgid "IP" -msgid "NUMBER" -msgid "BOOL" -msgid " \t\n" -msgid "dlinfoack" -msgid "dlattachreq" -msgid "dldetachreq" -msgid "dlbindack" -msgid "dlunbindack" -msgid "/tftpboot" -msgid "inetboot" -msgid ".PREP" -msgid "%s/%s" -msgid "NOENT" -msgid "PENDING" -msgid "AVAILABLE" -msgid "IN_USE" -msgid "FAILED" -msgid "DONTCARE" -msgid "UNKNOWN" -msgid "/dev/ip" -msgid "pfmod" -msgid "0123456789" -msgid "/dev/" -msgid "SOCKET" -msgid "DLPI" -msgid "BIND: %s\n" -msgid "I_PUSH: %s, on %s\n" -msgid "SENDTO: %s.\n" -msgid "in.dhcpd" -msgid "denvh:o:r:b:i:t:" -msgid "automatic" -msgid "manual" -msgid "/etc/default/dhcp" -msgid "/dev/null" -msgid "3.1" -msgid "files" -msgid "nisplus" -msgid "NIS_PATH" -msgid "none" -msgid "(errno: %d)" -msgid "%s %s" -msgid "%s" -msgid "(%%m) %s" -msgid "%02u" -msgid "%ld" -msgid "%ld_%ld_%ld_%ld" diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/inc.flg b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/inc.flg deleted file mode 100644 index 6303961989..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/inc.flg +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 1999-2000 by Sun Microsystems, Inc. -# All rights reserved. -# - -echo_file usr/src/cmd/cmd-inet/usr.lib/Makefile.lib -find_files "s.*" usr/src/common/net/dhcp diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/interfaces.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/interfaces.c deleted file mode 100644 index 8d7030faae..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/interfaces.c +++ /dev/null @@ -1,1462 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/time.h> -#include <fcntl.h> -#include <errno.h> -#include <assert.h> -#include <string.h> -#include <sys/socket.h> -#include <sys/sockio.h> -#include <net/if.h> -#include <net/if_arp.h> -#include <netinet/in_systm.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netinet/if_ether.h> -#include <netinet/ip.h> -#include <netinet/udp.h> -#include <stropts.h> -#include <stdio.h> -#include <ctype.h> -#include <syslog.h> -#include <netinet/dhcp.h> -#include <dhcp_symbol.h> -#include "dhcpd.h" -#include "per_dnet.h" -#include "interfaces.h" -#include <v4_sum_impl.h> -#include <locale.h> - -static int socksize = 64 * 1024; /* large socket window size for data */ -static const uchar_t magic_cookie[] = BOOTMAGIC; -static void disp_if(IF *); - -/* - * Network interface configuration. This file contains routines which - * handle the input side of the DHCP/BOOTP/Relay agent. Multiple interfaces - * are handled by identifying explicitly each interface, and creating a - * stream for each. If only one usable interface exists, then a "normal" - * UDP socket is used for simplicity's sake. - */ - -IF *if_head; /* head of interfaces list */ -mutex_t if_head_mtx; /* mutex for adding/deleting IF list entries */ -char *interfaces; /* user specified interfaces */ -static int num_interfaces; /* # of usable interfaces on the system */ - -static char * -dsrvr_socktype(dsrvr_socktype_t stype) -{ - char *rp; - - switch (stype) { - case DSRVR_LBCAST: - rp = "limited broadcast"; - break; - case DSRVR_DBCAST: - rp = "directed broadcast"; - break; - case DSRVR_UCAST: - rp = "unicast"; - break; - } - return (rp); -} - -/* - * Given two packets, match them based on BOOTP header operation, packet len, - * hardware type, flags, ciaddr, DHCP type, client id, or chaddr. - * Returns B_TRUE if they match, B_FALSE otherwise. - */ -static boolean_t -match_plp(PKT_LIST *alp, PKT_LIST *blp) -{ - DHCP_OPT *a, *b; - - assert(alp != NULL && blp != NULL); - - if (alp->pkt->op != blp->pkt->op || - alp->len != alp->len || - alp->pkt->htype != blp->pkt->htype || - alp->pkt->flags != blp->pkt->flags || - alp->pkt->ciaddr.s_addr != blp->pkt->ciaddr.s_addr) - return (B_FALSE); /* not even the same BOOTP type. */ - -#ifdef DEBUG - if (alp->pkt->giaddr.s_addr != blp->pkt->giaddr.s_addr) { - dhcpmsg(LOG_DEBUG, - "%04d match_plp: giaddr mismatch on 0x%x, 0x%x\n", - thr_self()); - } -#endif /* DEBUG */ - - a = alp->opts[CD_DHCP_TYPE]; - b = blp->opts[CD_DHCP_TYPE]; - if (a == NULL && b == NULL) { - /* bootp */ - if (memcmp(alp->pkt->chaddr, blp->pkt->chaddr, - alp->pkt->hlen) == 0) - return (B_TRUE); - } else if (a != NULL && b != NULL) { - if (a->value[0] == b->value[0]) { - /* dhcp - packet types match. */ - a = alp->opts[CD_CLIENT_ID]; - b = blp->opts[CD_CLIENT_ID]; - if (a != NULL && b != NULL) { - if (memcmp(a->value, b->value, a->len) == 0) - return (B_TRUE); - } else { - if (memcmp(alp->pkt->chaddr, blp->pkt->chaddr, - alp->pkt->hlen) == 0) - return (B_TRUE); - } - } - } - return (B_FALSE); -} - -/* - * Given a packet, searches for a later packet in the - * interface's client list. If the search is successful, the argument - * packet is deleted, and the later packet is returned with the appropriate - * fields/options modified. - * - * Matches are based on match_plp(). The list is scanned until the final packet - * which "matches" is found. The last match replaces - * the argument plp. Duplicates are deleted. - * - * General Notes: After the first candidate is found, the list is checked to - * the tail of the list for other matches. For each packet which is deleted. - * the duplicate statistic is incremented for each one. If no candidate is - * found, then the argument plp is returned. - * - * Caveats: What about length and contents of packets? By definition, a - * client is not supposed to be altering this between frames, so we should - * be ok. Since the argument plp may be destroyed, it is assumed to be - * detached. - */ -PKT_LIST * -refresh_pktlist(dsvc_clnt_t *pcd, PKT_LIST *plp) -{ - PKT_LIST *wplp, *tplp, *retplp = NULL; - IF *ifp = pcd->ifp; - - assert(MUTEX_HELD(&pcd->pkt_mtx)); - - wplp = pcd->pkthead; - while (wplp != NULL) { - if (match_plp(plp, wplp)) { - pcd->pending--; - - (void) mutex_lock(&ifp->ifp_mtx); - ifp->duplicate++; - (void) mutex_unlock(&ifp->ifp_mtx); - - /* - * Note that tplp, retplp can be synonyms for - * wplp. The synonyms are used because moldy plp's - * will be nuked, and the plp to return will be - * detached. - */ - tplp = wplp; - wplp = wplp->next; - - if (retplp != NULL) { - /* moldy duplicates */ - free_plp(retplp); - } - retplp = tplp; - detach_plp(pcd, retplp); - } else { - wplp = wplp->next; - } - } - - if (retplp == NULL) - retplp = plp; - else { - if (debug) { - dhcpmsg(LOG_DEBUG, - "%04d: Refreshed (0x%p) to (0x%p)\n", - thr_self(), (void *)plp, (void *)retplp); - } - free_plp(plp); - } - - return (retplp); -} - -/* - * Queries the IP transport layer for configured interfaces. Those that - * are acceptable for use by our daemon have these characteristics: - * - * Not loopback - * Is UP - * - * Sets num_interfaces global to number of valid, selected interfaces. - * - * Returns: 0 for success, the appropriate errno on fatal failure. - * - * Notes: Code gleaned from the in.rarpd, solaris 2.2. - */ -static int -find_interfaces(void) -{ - int i, k, ip, reqsize, numifs; - boolean_t found; - ushort_t mtu_tmp; - struct ifreq *reqbuf, *ifr; - struct ifconf ifconf; - IF *ifp, *if_tail; - struct sockaddr_in *sin; - char **user_if; - ENCODE *hecp; - - if ((ip = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - dhcpmsg(LOG_ERR, "Error opening socket: %s\n", - strerror(errno)); - return (1); - } - - if (ioctl(ip, SIOCGIFNUM, &numifs) < 0) { - dhcpmsg(LOG_WARNING, - "Error discovering number of network interfaces: %s\n", - strerror(errno)); - (void) close(ip); - return (1); - } - - reqsize = numifs * sizeof (struct ifreq); - reqbuf = (struct ifreq *)smalloc(reqsize); - - ifconf.ifc_len = reqsize; - ifconf.ifc_buf = (caddr_t)reqbuf; - - if (ioctl(ip, SIOCGIFCONF, &ifconf) < 0) { - dhcpmsg(LOG_ERR, - "Error getting network interface information: %s\n", - strerror(errno)); - free(reqbuf); - (void) close(ip); - return (1); - } - - /* - * Verify that user specified interfaces are valid. - */ - user_if = (char **)smalloc(numifs * sizeof (char *)); - if (interfaces != NULL) { - for (i = 0; i < numifs; i++) { - user_if[i] = strtok(interfaces, ","); - if (user_if[i] == NULL) - break; /* we're done */ - interfaces = NULL; /* for next call to strtok() */ - - for (found = B_FALSE, ifr = ifconf.ifc_req; - ifr < &ifconf.ifc_req[ifconf.ifc_len / - sizeof (struct ifreq)]; ifr++) { - if (strcmp(user_if[i], ifr->ifr_name) == 0) { - found = B_TRUE; - break; - } - } - if (!found) { - dhcpmsg(LOG_ERR, - "Invalid network interface: %s\n", - user_if[i]); - free(reqbuf); - free(user_if); - (void) close(ip); - return (1); - } - } - if (i < numifs) - user_if[i] = NULL; - } else - user_if[0] = NULL; - - /* - * For each interface, build an interface structure. Ignore any - * LOOPBACK or down interfaces. - */ - if_tail = if_head = NULL; - for (ifr = ifconf.ifc_req; - ifr < &ifconf.ifc_req[ifconf.ifc_len / sizeof (struct ifreq)]; - ifr++) { - if (ioctl(ip, SIOCGIFFLAGS, ifr) < 0) { - dhcpmsg(LOG_ERR, -"Error encountered getting interface: %s flags: %s\n", - ifr->ifr_name, strerror(errno)); - continue; - } - if ((ifr->ifr_flags & IFF_LOOPBACK) || - !(ifr->ifr_flags & IFF_UP)) - continue; - - num_interfaces++; /* all possible interfaces counted */ - - /* - * If the user specified a list of interfaces, - * we'll only consider the ones specified. - */ - if (user_if[0] != NULL) { - for (i = 0; i < numifs; i++) { - if (user_if[i] == NULL) - break; /* skip this interface */ - if (strcmp(user_if[i], ifr->ifr_name) == 0) - break; /* user wants this one */ - } - if (i == numifs || user_if[i] == NULL) - continue; /* skip this interface */ - } else if (strchr(ifr->ifr_name, ':') != NULL) - continue; /* skip virtual interfaces */ - - ifp = (IF *)smalloc(sizeof (IF)); - (void) strcpy(ifp->nm, ifr->ifr_name); - - ifp->ifceno = if_nametoindex(ifp->nm); - ifp->flags = ifr->ifr_flags; - for (k = 0; k < DSRVR_NUM_DESC; k++) - ifp->descs[k] = -1; - - /* - * Broadcast address. Not valid for POINTOPOINT - * connections. - */ - if ((ifp->flags & IFF_POINTOPOINT) == 0) { - if (ifp->flags & IFF_BROADCAST) { - if (ioctl(ip, SIOCGIFBRDADDR, ifr) < 0) { - dhcpmsg(LOG_ERR, "Error encountered \ -getting interface: %s broadcast address: %s\n", ifp->nm, strerror(errno)); - free(ifp); - num_interfaces--; - continue; - } - /* LINTED [alignment ok] */ - sin = (struct sockaddr_in *)&ifr->ifr_addr; - ifp->bcast = sin->sin_addr; - } else - ifp->bcast.s_addr = htonl(INADDR_ANY); - - hecp = make_encode(DSYM_STANDARD, CD_BROADCASTADDR, - sizeof (struct in_addr), &ifp->bcast, - ENC_COPY); - replace_encode(&ifp->ecp, hecp, ENC_DONT_COPY); - } - - /* Subnet mask */ - if (ioctl(ip, SIOCGIFNETMASK, ifr) < 0) { - dhcpmsg(LOG_ERR, "Error encountered getting \ -interface: %s netmask: %s\n", ifp->nm, strerror(errno)); - free_encode_list(ifp->ecp); - free(ifp); - num_interfaces--; - continue; - } - /* LINTED [alignment ok] */ - sin = (struct sockaddr_in *)&ifr->ifr_addr; - ifp->mask = sin->sin_addr; - hecp = make_encode(DSYM_STANDARD, CD_SUBNETMASK, - sizeof (struct in_addr), &ifp->mask, ENC_COPY); - replace_encode(&ifp->ecp, hecp, ENC_DONT_COPY); - - /* Address */ - if (ioctl(ip, SIOCGIFADDR, ifr) < 0) { - dhcpmsg(LOG_ERR, "Error encountered getting \ -interface: %s address: %s\n", ifp->nm, strerror(errno)); - free_encode_list(ifp->ecp); - free(ifp); - num_interfaces--; - continue; - } - /* LINTED [alignment ok] */ - sin = (struct sockaddr_in *)&ifr->ifr_addr; - ifp->addr = sin->sin_addr; - - /* MTU */ - if (ioctl(ip, SIOCGIFMTU, ifr) < 0) { - dhcpmsg(LOG_ERR, "Error encountered getting \ -interface: %s MTU: %s\n", ifp->nm, strerror(errno)); - free_encode_list(ifp->ecp); - free(ifp); - num_interfaces--; - continue; - } - - ifp->mtu = ifr->ifr_metric; - mtu_tmp = htons(ifp->mtu); - hecp = make_encode(DSYM_STANDARD, CD_MTU, 2, - &mtu_tmp, ENC_COPY); - replace_encode(&ifp->ecp, hecp, ENC_DONT_COPY); - - /* Attach to interface list */ - if (!if_tail) { - (void) mutex_init(&if_head_mtx, USYNC_THREAD, 0); - (void) mutex_lock(&if_head_mtx); - if_tail = if_head = ifp; - (void) mutex_unlock(&if_head_mtx); - } else { - (void) mutex_lock(&if_head_mtx); - if_tail->next = ifp; - if_tail = ifp; - (void) mutex_unlock(&if_head_mtx); - } - } - - free(reqbuf); - free(user_if); - (void) close(ip); - - if (if_head == NULL) { - num_interfaces = 0; - dhcpmsg(LOG_ERR, "Cannot find any valid interfaces.\n"); - (void) mutex_destroy(&if_head_mtx); - return (EINVAL); - } - return (0); -} - -/* - * Destroy an *uninitialized* IF structure - returns next ifp. - */ -static IF * -zap_ifp(IF **ifp_prevpp, IF *ifp) -{ - IF *tifp; - - assert(MUTEX_HELD(&if_head_mtx)); - - if (*ifp_prevpp == ifp) { - if_head = ifp->next; - *ifp_prevpp = if_head; - } else - (*ifp_prevpp)->next = ifp->next; - - tifp = ifp->next; - - free(ifp); - - return (tifp); -} - -/* - * Monitor thread function. Poll on interface descriptors. Add valid BOOTP - * packets to interfaces PKT_LIST. - * - * Because the buffer will potentially contain the ip/udp headers, we flag - * this by setting the 'offset' field to the length of the two headers so that - * free_plp() can "do the right thing" - * - * Monitor the given interface. Signals are handled by sig_client thread. - * - * We make some attempt to deal with marginal interfaces as follows. We - * keep track of system errors (errors) and protocol errors (ifp->errors). - * If we encounter more than DHCP_MON_SYSERRS in DHCP_MON_ERRINTVL, - * then the interface thread will put itself to sleep for DHCP_MON_SLEEP - * minutes. - * - * MT SAFE - */ -static void * -monitor_interface(void *argp) -{ - PKT_LIST *plp, *tplp; - IF *ifp = (IF *)argp; - int errors, err, i; - uint_t verify_len; - struct pollfd pfd[DSRVR_NUM_DESC]; - struct strbuf data; - char cbuf[DN_MAX_CID_LEN], ntoab[INET_ADDRSTRLEN]; - time_t err_interval; - dn_rec_t dn; - dsvc_dnet_t *pnd; - dsvc_clnt_t *pcd; - struct in_addr netaddr, subnetaddr; - dsvc_pendclnt_t *workp; - int open_ret; - dsvc_thr_t *freep; - thread_t tid; - boolean_t existing_allocation; - - if (debug) { - dhcpmsg(LOG_DEBUG, "Monitor (%04d/%s) started...\n", - ifp->if_thread, ifp->nm); - } - - if (verbose) - disp_if(ifp); - - pfd[DSRVR_LBCAST].fd = ifp->descs[DSRVR_LBCAST]; - pfd[DSRVR_LBCAST].events = POLLIN | POLLPRI; - pfd[DSRVR_DBCAST].fd = ifp->descs[DSRVR_DBCAST]; - pfd[DSRVR_DBCAST].events = POLLIN | POLLPRI; - pfd[DSRVR_UCAST].fd = ifp->descs[DSRVR_UCAST]; - pfd[DSRVR_UCAST].events = POLLIN | POLLPRI; - - err_interval = time(NULL) + DHCP_MON_ERRINTVL; - errors = 0; - while (time_to_go == 0) { - if (errors > DHCP_MON_SYSERRS) { - if (time(NULL) < err_interval) { - dhcpmsg(LOG_WARNING, -"Monitor (%04d/%s): Too many system errors (%d), pausing for %d minute(s)...\n", - ifp->if_thread, ifp->nm, errors, - DHCP_MON_SYSERRS); - (void) sleep(DHCP_MON_SLEEP); - err_interval = time(NULL) + DHCP_MON_ERRINTVL; - } - errors = 0; - } - pfd[DSRVR_LBCAST].revents = 0; - pfd[DSRVR_DBCAST].revents = 0; - pfd[DSRVR_UCAST].revents = 0; - if (poll(&pfd[0], (nfds_t)DSRVR_NUM_DESC, INFTIM) < 0) { - dhcpmsg(LOG_ERR, - "Monitor (%04d/%s) Polling error: (%s).\n", - ifp->if_thread, ifp->nm, strerror(errno)); - errors++; - continue; - } - /* - * See if we are to exit. We can't be holding any locks... - */ - (void) mutex_lock(&ifp->ifp_mtx); - if (ifp->thr_exit) { - if (debug) { - dhcpmsg(LOG_DEBUG, - "Monitor (%04d/%s): exiting.\n", - ifp->if_thread, ifp->nm); - } - (void) mutex_unlock(&ifp->ifp_mtx); - break; - } - (void) mutex_unlock(&ifp->ifp_mtx); - - /* examine each socket for packets in turn */ - for (i = 0; i < DSRVR_NUM_DESC; i++) { - if (pfd[i].revents == 0) - continue; - if (pfd[i].revents & (POLLERR | POLLHUP | POLLNVAL)) { - dhcpmsg(LOG_ERR, "Network interface " - "error on device: %s(%s)\n", ifp->nm, - dsrvr_socktype(i)); - errors++; - continue; - } - if (!(pfd[i].revents & (POLLIN | POLLRDNORM))) { - dhcpmsg(LOG_INFO, "Unsupported event " - "on device %s(%s): %d\n", ifp->nm, - dsrvr_socktype(i), - pfd[i].revents); - errors++; - continue; - } - data.buf = smalloc(ifp->mtu); - data.len = recv(ifp->descs[i], data.buf, ifp->mtu, 0); - if (data.len < 0) { - dhcpmsg(LOG_ERR, "Error: %s receiving UDP " - "datagrams on %s(%s)\n", - strerror(errno), ifp->nm, - dsrvr_socktype(i)); - free(data.buf); - errors++; - continue; - } else - verify_len = data.len; - - if (debug) { - dhcpmsg(LOG_INFO, - "Datagram received on network device: " - "%s(%s)\n", ifp->nm, dsrvr_socktype(i)); - } - - (void) mutex_lock(&ifp->ifp_mtx); - ifp->received++; - (void) mutex_unlock(&ifp->ifp_mtx); - - if (verify_len < BASE_PKT_SIZE) { - if (verbose) { - dhcpmsg(LOG_INFO, "Short packet %d < " - "%d on %s(%s) ignored\n", - verify_len, sizeof (PKT), - ifp->nm, dsrvr_socktype(i)); - } - free(data.buf); - (void) mutex_lock(&ifp->ifp_mtx); - ifp->errors++; - (void) mutex_unlock(&ifp->ifp_mtx); - continue; - } - - plp = (PKT_LIST *)smalloc(sizeof (PKT_LIST)); - plp->offset = 0; - plp->len = data.len; - /* LINTED [alignment ok] */ - plp->pkt = (PKT *)data.buf; - - if (plp->pkt->hops >= max_hops + 1) { - if (verbose) { - dhcpmsg(LOG_INFO, "%s(%s): Packet " - "dropped: too many hops: %d\n", - ifp->nm, dsrvr_socktype(i), - plp->pkt->hops); - } - free_plp(plp); - (void) mutex_lock(&ifp->ifp_mtx); - ifp->errors++; - (void) mutex_unlock(&ifp->ifp_mtx); - continue; - } - - /* validate hardware len */ - if (plp->pkt->hlen > sizeof (plp->pkt->chaddr)) - plp->pkt->hlen = sizeof (plp->pkt->chaddr); - - if (debug && plp->pkt->giaddr.s_addr != 0L && - plp->pkt->giaddr.s_addr != ifp->addr.s_addr) { - dhcpmsg(LOG_INFO, "%s(%s): Packet received " - "from relay agent: %s\n", ifp->nm, - dsrvr_socktype(i), inet_ntop(AF_INET, - &plp->pkt->giaddr, ntoab, sizeof (ntoab))); - } - - if (!server_mode) { - /* - * Relay agent mode. No further processing - * required ; we'll handle it here. - */ - (void) mutex_lock(&if_head_mtx); - err = relay_agent(ifp, plp); - (void) mutex_unlock(&if_head_mtx); - if (err != 0) { - dhcpmsg(LOG_ERR, "Relay agent mode " - "failed: %d (%s) on: %s(%s)\n", - err, (plp->pkt->op == BOOTREPLY) ? - "reply" : "request", ifp->nm, - dsrvr_socktype(i)); - errors++; /* considered system error */ - } else { - /* update statistics */ - (void) mutex_lock(&ifp->ifp_mtx); - ifp->processed++; - ifp->received++; - (void) mutex_unlock(&ifp->ifp_mtx); - } - free_plp(plp); - continue; - } - -/* ============ Packets destined for bootp and dhcp server modules ========== */ - - /* - * Allow packets without RFC1048 magic cookies. - * Just don't do an options scan on them, - * thus we treat them as plain BOOTP packets. - * The BOOTP server can deal with requests of - * this type. - */ - if (memcmp(plp->pkt->cookie, magic_cookie, - sizeof (magic_cookie)) != 0) { - if (verbose) { - dhcpmsg(LOG_INFO, "%s(%s): Client: %s " - "using non-RFC1048 BOOTP cookie.\n", - ifp->nm, dsrvr_socktype(i), - disp_cid(plp, cbuf, sizeof (cbuf))); - } - plp->rfc1048 = B_FALSE; - } else { - /* - * Scan the options in the packet and fill in - * the opts and vs fields in the * clientlist - * structure. If there's a DHCP message type - * in the packet then it's a DHCP packet; - * otherwise it's a BOOTP packet. Standard - * options are RFC1048 style. - */ - if (dhcp_options_scan(plp, B_FALSE) != 0) { - dhcpmsg(LOG_ERR, "Garbled DHCP/BOOTP " - "packet received on: %s(%s)\n", - ifp->nm, dsrvr_socktype(i)); - free_plp(plp); - (void) mutex_lock(&ifp->ifp_mtx); - ifp->errors++; - (void) mutex_unlock(&ifp->ifp_mtx); - continue; - } - plp->rfc1048 = B_TRUE; - } - - /* - * Link the new packet to the list of packets - * for this network/client. No need to lock plp, - * since it isn't visible outside this function yet. - */ - if (plp->pkt->op != BOOTREQUEST) { - dhcpmsg(LOG_ERR, "Unexpected packet received " - "on %s(%s), BOOTP server port. Ignored.\n", - ifp->nm, dsrvr_socktype(i)); - free_plp(plp); - (void) mutex_lock(&ifp->ifp_mtx); - ifp->errors++; - (void) mutex_unlock(&ifp->ifp_mtx); - continue; - } - - determine_network(ifp, plp, &netaddr, &subnetaddr); - if ((err = open_dnet(&pnd, &netaddr, &subnetaddr)) != - DSVC_SUCCESS) { - if (verbose && err == DSVC_NO_TABLE) { - netaddr.s_addr &= subnetaddr.s_addr; - dhcpmsg(LOG_INFO, "%s(%s): There is no " - "%s dhcp-network table for DHCP " - "client's network.\n", ifp->nm, - dsrvr_socktype(i), - inet_ntop(AF_INET, &netaddr, - ntoab, sizeof (ntoab))); - } - free_plp(plp); - continue; - } - - /* Find client */ - get_clnt_id(plp, (uchar_t *)dn.dn_cid, - sizeof (dn.dn_cid), &dn.dn_cid_len); - open_ret = open_clnt(pnd, &pcd, dn.dn_cid, - dn.dn_cid_len, B_FALSE); - - if (pcd == NULL) { - free_plp(plp); - close_dnet(pnd, B_FALSE); - continue; - } - - /* - * DOS via Packet flooding: ensure that each client's - * PKT_LIST never exceeds DHCP_MON_THRESHOLD pkts in - * length. If it does, we prune it from the head of - * the list, dropping sequential packets. Note that - * since DHCP is a multi-transaction protocol, we would - * like to be sure not to discard a REQUEST for an OFFER - * we've extended. - * - * TODO: we are still vulnerable to flooding attacks - * where bogus client ids are presented. This can be - * manually controlled via the MAX_CLIENTS and - * MAX_THREADS config file knobs. - */ - (void) mutex_lock(&pcd->pkt_mtx); - if (pcd->pending > DHCP_MON_THRESHOLD) { - if ((tplp = pcd->pkthead) != NULL) { - detach_plp(pcd, tplp); - free_plp(tplp); - pcd->pending--; - } - } - - if (pcd->pkthead == NULL) - pcd->pkthead = plp; - else { - pcd->pkttail->next = plp; - plp->prev = pcd->pkttail; - } - pcd->pkttail = plp; - pcd->pending++; - (void) mutex_unlock(&pcd->pkt_mtx); - - /* - * Manage worker threads and deferred thread work list. - */ - (void) mutex_lock(&pcd->pcd_mtx); - pcd->ifp = ifp; - if (pcd->clnt_thread == NULL && - (pcd->flags & DHCP_PCD_CLOSING) == 0) { - existing_allocation = B_FALSE; - (void) mutex_lock(&pnd->thr_mtx); - if ((freep = pnd->thrhead) != NULL) { - existing_allocation = B_TRUE; - /* - * Restart a suspended thread. - */ - pnd->thrhead = freep->thr_next; - if (pnd->thrhead == NULL) - pnd->thrtail = NULL; - (void) mutex_unlock(&pnd->thr_mtx); - - (void) mutex_lock(&freep->thr_mtx); - freep->thr_flags &= ~DHCP_THR_LIST; - freep->thr_next = NULL; - freep->thr_pcd = pcd; - (void) mutex_unlock(&freep->thr_mtx); - pcd->clnt_thread = freep; - } else if (max_threads != -1 && - pnd->nthreads >= max_threads) { - /* - * Add client once to deferred work - * list, to keep track of future work. - */ - if ((pcd->flags & DHCP_PCD_WORK) == 0) { - pcd->flags |= DHCP_PCD_WORK; - workp = (dsvc_pendclnt_t *) - smalloc( - sizeof (dsvc_pendclnt_t)); - get_clnt_id(plp, - (uchar_t *)workp->pnd_cid, - sizeof (workp->pnd_cid), - &workp->pnd_cid_len); - if (pnd->workhead == NULL) - pnd->workhead = workp; - else { - pnd->worktail-> - pnd_next = workp; - } - pnd->worktail = workp; - } - (void) mutex_unlock(&pnd->thr_mtx); - (void) mutex_unlock(&pcd->pcd_mtx); - if (open_ret == DSVC_SUCCESS) - close_clnt(pcd, B_FALSE); - close_dnet(pnd, B_FALSE); - continue; - } - if (pcd->clnt_thread == NULL) { - pnd->nthreads++; - (void) mutex_unlock(&pnd->thr_mtx); - freep = pcd->clnt_thread = - (dsvc_thr_t *) - smalloc(sizeof (dsvc_thr_t)); - (void) mutex_init(&freep->thr_mtx, - USYNC_THREAD, 0); - freep->thr_pcd = pcd; - - /* Fire up a client thread. */ - if (thr_create(NULL, 0, monitor_client, - freep, THR_BOUND | THR_SUSPENDED | - THR_DETACHED, &freep->thr_tid) != - 0) { - dhcpmsg(LOG_ERR, "%s(%s): " - "Error %s starting client " - "monitor thread.\n", - ifp->nm, dsrvr_socktype(i), - strerror(errno)); - (void) mutex_lock( - &pnd->thr_mtx); - pnd->nthreads--; - (void) mutex_unlock( - &pnd->thr_mtx); - free(freep); - freep = pcd->clnt_thread = NULL; - } - } - if (freep != NULL) { - /* - * Continue the new or reused thread. - * Let it close the client. - */ - open_ret = DSVC_BUSY; - tid = freep->thr_tid; - (void) mutex_unlock(&pcd->pcd_mtx); - pcd = NULL; - if (existing_allocation) { - (void) cond_signal( - &freep->thr_cv); - } else { - (void) thr_continue(tid); - } - } - } - if (pcd != NULL) { - (void) mutex_unlock(&pcd->pcd_mtx); - if (open_ret == DSVC_SUCCESS) - close_clnt(pcd, B_FALSE); - } - close_dnet(pnd, B_FALSE); - } - } - return (NULL); -} - -/* - * close interface sockets - */ -static void -close_sockets(IF *ifp) { - int i; - - for (i = 0; i < DSRVR_NUM_DESC; i++) { - if (ifp->descs[i] == -1) - continue; - (void) close(ifp->descs[i]); - ifp->descs[i] = -1; - } -} - -/* - * initialize interface sockets. - * - * Returns: 0 for success, -1 otherwise. - */ -static int -init_sockets(IF *ifp) -{ - int i, soptbuf = 1; - struct sockaddr_in sin; - - sin.sin_family = AF_INET; - sin.sin_port = htons((short)IPPORT_BOOTPS + port_offset); - - ifp->descs[DSRVR_LBCAST] = -1; - ifp->descs[DSRVR_DBCAST] = -1; - ifp->descs[DSRVR_UCAST] = -1; - - for (i = 0; i < DSRVR_NUM_DESC; i++) { - ifp->descs[i] = socket(AF_INET, SOCK_DGRAM, 0); - if (ifp->descs[i] < 0) { - dhcpmsg(LOG_ERR, "Error opening socket on %s(%s) for " - "receiving UDP datagrams: %s\n", - ifp->nm, dsrvr_socktype(i), strerror(errno)); - return (-1); - } - - if (setsockopt(ifp->descs[i], SOL_SOCKET, SO_REUSEADDR, - &soptbuf, (int)sizeof (soptbuf)) < 0) { - dhcpmsg(LOG_DEBUG, "Setting socket option on %s(%s) " - "to allow reuse on send descriptor failed: %s\n", - ifp->nm, dsrvr_socktype(i), strerror(errno)); - close_sockets(ifp); - return (-1); - } - - (void) setsockopt(ifp->descs[i], SOL_SOCKET, SO_RCVBUF, - &socksize, sizeof (socksize)); - (void) setsockopt(ifp->descs[i], SOL_SOCKET, SO_SNDBUF, - &socksize, sizeof (socksize)); - - switch (i) { - case DSRVR_LBCAST: - if (setsockopt(ifp->descs[i], IPPROTO_IP, - IP_BOUND_IF, &ifp->ifceno, - (int)sizeof (char *)) < 0) { - dhcpmsg(LOG_ERR, - "Bind to index failed on %s: %s\n", - ifp->nm, strerror(errno)); - close_sockets(ifp); - return (-1); - } - sin.sin_addr.s_addr = htonl(INADDR_BROADCAST); - break; - case DSRVR_DBCAST: - sin.sin_addr.s_addr = - ifp->addr.s_addr & ifp->mask.s_addr; - break; - case DSRVR_UCAST: - /* We send out the unicast socket */ - if (setsockopt(ifp->descs[i], SOL_SOCKET, - SO_BROADCAST, &soptbuf, - (int)sizeof (soptbuf)) < 0) { - dhcpmsg(LOG_ERR, "Setting socket " - "option on %s to allow broadcast " - "on send descriptor failed: %s\n", - ifp->nm, strerror(errno)); - close_sockets(ifp); - return (-1); - } - sin.sin_addr.s_addr = ifp->addr.s_addr; - break; - } - if (bind(ifp->descs[i], - (struct sockaddr *)&sin, sizeof (sin)) < 0) { - dhcpmsg(LOG_ERR, - "Error binding to UDP socket on %s(%s): %s\n", - ifp->nm, dsrvr_socktype(i), strerror(errno)); - close_sockets(ifp); - return (-1); - } - } - return (0); -} - -/* - * Based on the list generated by find_interfaces(), possibly modified by - * user arguments, open a stream for each valid / requested interface. - * - * If: - * - * 1) Only one interface exists, open a standard bidirectional UDP - * socket. Note that this is different than if only ONE - * interface is requested (but more exist). - * - * 2) If more than one valid interface exists, then attach to the - * datalink layer, push on the packet filter and buffering - * modules, and wait for fragment 0 IP packets that contain - * UDP packets with port 67 (server port). - * - * Comments: - * Using DLPI to identify the interface thru which BOOTP - * packets pass helps in providing the correct response. - * Note that I will open a socket for use in transmitting - * responses, suitably specifying the destination relay agent - * or host. Note that if I'm unicasting to the client (broadcast - * flag not set), that somehow I have to clue the IP layer about - * the client's hw address. The only way I can see doing this is - * making the appropriate ARP table entry. - * - * The only remaining unknown is dealing with clients that - * require broadcasting, and multiple interfaces exist. I assume - * that if I specify the interface's source address when - * opening the socket, that a limited broadcast will be - * directed to the correct net, and only the correct net. - * - * Returns: 0 for success, non-zero for failure. - */ -int -open_interfaces(void) -{ - int inum, err = 0; - IF *ifp, *ifp_prevp; - - /* Uncover list of valid, user-selected interfaces to monitor */ - if ((err = find_interfaces()) != 0) - return (err); - - (void) mutex_lock(&if_head_mtx); - - /* - * Setup valid interfaces. - */ - ifp = ifp_prevp = if_head; - err = inum = 0; - while (ifp != NULL) { - if (init_sockets(ifp) < 0) { - ifp = zap_ifp(&ifp_prevp, ifp); - num_interfaces--; - continue; - } - - /* Accounting */ - ifp->transmit = ifp->received = 0; - ifp->duplicate = ifp->dropped = 0; - ifp->processed = 0; - - /* ifp structure lock */ - (void) mutex_init(&ifp->ifp_mtx, USYNC_THREAD, 0); - ifp->thr_exit = 0; - - /* fire up monitor thread */ - if (thr_create(NULL, 0, monitor_interface, ifp, - THR_BOUND, &ifp->if_thread) != 0) { - dhcpmsg(LOG_ERR, -"Interface: %s - Error %s starting monitor thread.\n", ifp->nm, - strerror(errno)); - close_sockets(ifp); - (void) mutex_destroy(&ifp->ifp_mtx); - ifp = zap_ifp(&ifp_prevp, ifp); - num_interfaces--; - continue; - } - inum++; - ifp_prevp = ifp; - ifp = ifp->next; - } - (void) mutex_unlock(&if_head_mtx); - - /* - * We must succeed in configuring at least one interface - * to be considered successful. - */ - if (num_interfaces == 0) { - err = EINVAL; - dhcpmsg(LOG_ERR, "Cannot configure any interfaces.\n"); - } - return (err); -} - -/* - * Detach the referenced plp from the client list. - */ -void -detach_plp(dsvc_clnt_t *pcd, PKT_LIST *plp) -{ - assert(MUTEX_HELD(&pcd->pkt_mtx)); - - if (plp->prev == NULL) { - pcd->pkthead = plp->next; - if (pcd->pkthead != NULL) - pcd->pkthead->prev = NULL; - } else - plp->prev->next = plp->next; - - if (plp->next != NULL) - plp->next->prev = plp->prev; - else { - pcd->pkttail = plp->prev; - if (pcd->pkttail != NULL) - pcd->pkttail->next = NULL; - } - plp->prev = plp->next = NULL; -} - -/* - * Write a packet to an interface. - * - * Returns 0 on success otherwise non-zero. - */ -int -write_interface(IF *ifp, PKT *clientp, int len, struct sockaddr_in *to) -{ - int err; - - to->sin_family = AF_INET; - - if ((err = sendto(ifp->descs[DSRVR_UCAST], clientp, len, 0, - (struct sockaddr *)to, sizeof (struct sockaddr))) < 0) { - dhcpmsg(LOG_ERR, "SENDTO: %s.\n", strerror(errno)); - return (err); - } - - (void) mutex_lock(&ifp->ifp_mtx); - ifp->transmit++; - (void) mutex_unlock(&ifp->ifp_mtx); - - return (0); -} - -/* - * Pop any packet filters, buffering modules, close stream, free encode - * list, terminate monitor thread, free ifp. Return ifp next ptr. - */ -static IF * -close_interface(IF *ifp) -{ - int err; - IF *tifp; - - assert(ifp != NULL); - - assert(MUTEX_HELD(&if_head_mtx)); - - (void) mutex_lock(&ifp->ifp_mtx); - ifp->thr_exit = 1; - - close_sockets(ifp); /* thread will exit poll ... */ - (void) mutex_unlock(&ifp->ifp_mtx); - - /* - * Wait for the thread to exit. We release the if_head_mtx - * lock, since the monitor thread(s) need to acquire it to traverse - * the list - and we don't want to deadlock. Once the monitor thread - * notices the thr_exit flag, it'll be gone anyway. Note that if_head - * is changing (in close_interfaces()). At this point, only monitor - * threads that haven't been reaped could be walking the interface - * list. They will "see" the change in if_head. - */ - (void) mutex_unlock(&if_head_mtx); - if ((err = thr_join(ifp->if_thread, NULL, NULL)) != 0) { - dhcpmsg(LOG_ERR, - "Error %d while waiting for monitor %d of %s\n", - err, ifp->if_thread, ifp->nm); - } - (void) mutex_lock(&if_head_mtx); - - /* - * Note: clients and their associated packet lists are freed prior - * to interfaces being closed. - */ - - /* free encode list */ - free_encode_list(ifp->ecp); - - /* display statistics */ - disp_if_stats(ifp); - - ifp->received = ifp->processed = 0; - - (void) mutex_unlock(&ifp->ifp_mtx); - (void) mutex_destroy(&ifp->ifp_mtx); - tifp = ifp->next; - free(ifp); - return (tifp); -} - -/* - * Close all interfaces, freeing up associated resources. - * This should only be called from main() during final exit. - */ -void -close_interfaces(void) -{ - (void) mutex_lock(&if_head_mtx); - for (; if_head != NULL; if_head = close_interface(if_head)) { - if (verbose) { - dhcpmsg(LOG_INFO, "Closing interface: %s\n", - if_head->nm); - } - } - (void) mutex_unlock(&if_head_mtx); - (void) mutex_destroy(&if_head_mtx); -} - -/* - * display IF info. Must be MT Safe - called from monitor threads. - */ -static void -disp_if(IF *ifp) -{ - char ntoab[INET_ADDRSTRLEN]; - - dhcpmsg(LOG_INFO, "Thread Id: %04d - Monitoring Interface: %s *****\n", - ifp->if_thread, ifp->nm); - dhcpmsg(LOG_INFO, "MTU: %d\tType: %s\n", ifp->mtu, "SOCKET"); - if ((ifp->flags & IFF_POINTOPOINT) == 0) - dhcpmsg(LOG_INFO, "Broadcast: %s\n", - inet_ntop(AF_INET, &ifp->bcast, ntoab, sizeof (ntoab))); - dhcpmsg(LOG_INFO, "Netmask: %s\n", - inet_ntop(AF_INET, &ifp->mask, ntoab, sizeof (ntoab))); - dhcpmsg(LOG_INFO, "Address: %s\n", - inet_ntop(AF_INET, &ifp->addr, ntoab, sizeof (ntoab))); -} - -/* - * Display IF statistics. - */ -void -disp_if_stats(IF *ifp) -{ - dhcpmsg(LOG_INFO, "Interface statistics for: %s **************\n", - ifp->nm); - - dhcpmsg(LOG_INFO, "Pending DHCP offers: %d\n", ifp->offers); - dhcpmsg(LOG_INFO, "Total Packets Transmitted: %d\n", ifp->transmit); - dhcpmsg(LOG_INFO, "Total Packets Received: %d\n", ifp->received); - dhcpmsg(LOG_INFO, "Total Packet Duplicates: %d\n", ifp->duplicate); - dhcpmsg(LOG_INFO, "Total Packets Dropped: %d\n", ifp->dropped); - dhcpmsg(LOG_INFO, "Total Packets Processed: %d\n", ifp->processed); - dhcpmsg(LOG_INFO, "Total Protocol Errors: %d\n", ifp->errors); -} - -/* - * Setup the arp cache so that IP address 'ia' will be temporarily - * bound to hardware address 'ha' of length 'len'. 'ia' is expected in - * network order. - * - * Returns: 0 if the arp entry was made, 1 otherwise. - */ -int -set_arp(IF *ifp, struct in_addr *ia, uchar_t *ha, int len, uchar_t flags) -{ - struct sockaddr_in *si; - struct xarpreq arpreq; - int err = 0; - char scratch[DHCP_SCRATCH]; - uint_t scratch_len; - char ntoab[INET_ADDRSTRLEN]; - - (void) memset((caddr_t)&arpreq, 0, sizeof (arpreq)); - - arpreq.xarp_ha.sdl_family = AF_LINK; - - si = (struct sockaddr_in *)&arpreq.xarp_pa; - si->sin_family = AF_INET; - si->sin_addr = *ia; /* struct copy */ - - switch (flags) { - case DHCP_ARP_ADD: - if (debug) { - scratch_len = sizeof (scratch); - if (octet_to_hexascii(ha, len, scratch, - &scratch_len) != 0) { - dhcpmsg(LOG_DEBUG, "Cannot convert ARP \ -request to ASCII: %s: len: %d\n", - inet_ntop(AF_INET, ia, - ntoab, sizeof (ntoab)), - len); - } else { - dhcpmsg(LOG_DEBUG, - "Adding ARP entry: %s == %s\n", - inet_ntop(AF_INET, ia, - ntoab, sizeof (ntoab)), - scratch); - } - } - arpreq.xarp_flags = ATF_INUSE | ATF_COM; - (void) memcpy(LLADDR(&arpreq.xarp_ha), ha, len); - arpreq.xarp_ha.sdl_alen = len; - - if (ioctl(ifp->descs[DSRVR_UCAST], SIOCSXARP, &arpreq) < 0) { - dhcpmsg(LOG_ERR, - "ADD: Cannot modify ARP table to add: %s\n", - inet_ntop(AF_INET, ia, ntoab, sizeof (ntoab))); - err = 1; - } - break; - case DHCP_ARP_DEL: - /* give it a good effort, but don't worry... */ - (void) ioctl(ifp->descs[DSRVR_UCAST], SIOCDXARP, &arpreq); - break; - default: - err = 1; - break; - } - - return (err); -} - -/* - * Address and send a BOOTP reply packet appropriately. Does right thing - * based on BROADCAST flag. Also checks if giaddr field is set, and - * WE are the relay agent... - * - * Returns: 0 for success, nonzero otherwise (fatal) - */ -int -send_reply(IF *ifp, PKT *pp, int len, struct in_addr *dstp) -{ - int local = B_FALSE; - struct sockaddr_in to; - struct in_addr if_in, cl_in; - char ntoab[INET_ADDRSTRLEN]; - - if (pp->giaddr.s_addr != 0L && ifp->addr.s_addr != - pp->giaddr.s_addr) { - /* Going thru a relay agent */ - to.sin_addr.s_addr = pp->giaddr.s_addr; - to.sin_port = htons(IPPORT_BOOTPS + port_offset); - } else { - to.sin_port = htons(IPPORT_BOOTPC + port_offset); - - if (ntohs(pp->flags) & BCAST_MASK) { - /* - * TODO - what should we do if broadcast - * flag is set, but ptp connection? - */ - if (debug) - dhcpmsg(LOG_INFO, - "Sending datagram to broadcast address.\n"); - to.sin_addr.s_addr = INADDR_BROADCAST; - } else { - /* - * By default, we assume unicast! - */ - to.sin_addr.s_addr = dstp->s_addr; - - if (debug) { - dhcpmsg(LOG_INFO, - "Unicasting datagram to %s address.\n", - inet_ntop(AF_INET, dstp, - ntoab, sizeof (ntoab))); - } - if (ifp->addr.s_addr == pp->giaddr.s_addr) { - /* - * No doubt a reply packet which we, as - * the relay agent, are supposed to deliver. - * Local Delivery! - */ - local = B_TRUE; - } else { - /* - * We can't use the giaddr field to - * determine whether the client is local - * or remote. Use the client's address, - * our interface's address, and our - * interface's netmask to make this - * determination. - */ - if_in.s_addr = ntohl(ifp->addr.s_addr); - if_in.s_addr &= ntohl(ifp->mask.s_addr); - cl_in.s_addr = ntohl(dstp->s_addr); - cl_in.s_addr &= ntohl(ifp->mask.s_addr); - if (if_in.s_addr == cl_in.s_addr) - local = B_TRUE; - } - - if (local) { - /* - * Local delivery. If we can make an - * ARP entry we'll unicast. But only in - * cases when we do have the chaddr handy. - * RFC2855 and IPoIB are cases that do not - * send chaddr and set hlen = 0. Identify - * such media by their htype, and rely on - * in-kernel ARP for them. - */ - if ((ifp->flags & IFF_NOARP) == 0 && - ((pp->htype == ARPHRD_IB) || - (set_arp(ifp, dstp, pp->chaddr, pp->hlen, - DHCP_ARP_ADD) == 0))) { - to.sin_addr.s_addr = dstp->s_addr; - } else { - to.sin_addr.s_addr = INADDR_BROADCAST; - } - } - } - } - return (write_interface(ifp, pp, len, &to)); -} - -/* - * Free pkts - */ -void -free_pktlist(dsvc_clnt_t *pcd) -{ - PKT_LIST *plp, *plp_next; - IF *ifp = pcd->ifp; - - assert(MUTEX_HELD(&pcd->pcd_mtx)); - - plp = pcd->pkthead; - while (plp != NULL) { - plp_next = plp; - plp = plp->next; - free_plp(plp_next); - ifp->dropped++; - pcd->pending--; - } - pcd->pkthead = NULL; -} - -/* Check if address is one of the addresses we are listening on */ -boolean_t -is_our_address(in_addr_t addr) -{ - IF *ifp; - boolean_t found = B_FALSE; - - (void) mutex_lock(&if_head_mtx); - for (ifp = if_head; ifp != NULL; ifp = ifp->next) { - if (ifp->addr.s_addr == addr) { - found = B_TRUE; - break; - } - } - (void) mutex_unlock(&if_head_mtx); - return (found); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/interfaces.h b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/interfaces.h deleted file mode 100644 index 3faedebe16..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/interfaces.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _INTERFACES_H -#define _INTERFACES_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define DSRVR_NUM_DESC 3 /* Number of socket descriptors */ -typedef enum { - DSRVR_LBCAST = 0, /* Limited broadcast recv descriptor */ - DSRVR_DBCAST = 1, /* Directed broadcast recv descriptor */ - DSRVR_UCAST = 2 /* Unicast send/recv descriptor */ -} dsrvr_socktype_t; - -typedef struct interfaces { - char nm[IFNAMSIZ]; /* Interface name */ - unsigned int ifceno; /* Interface index */ - short mtu; /* MTU of interface */ - int descs[DSRVR_NUM_DESC]; /* recv/send sockets */ - uint_t flags; /* interface flags */ - struct in_addr bcast; /* interface broadcast */ - struct in_addr mask; /* interface netmask */ - struct in_addr addr; /* interface IP addr */ - ENCODE *ecp; /* IF specific options */ - uint_t transmit; /* # of transmitted pkts */ - uint_t received; /* # of received pkts */ - uint_t duplicate; /* # of duplicate pkts */ - uint_t dropped; /* # of dropped pkts */ - uint_t expired; /* # of expired pkts */ - uint_t errors; /* # of protocol errors */ - uint_t processed; /* # of processed pkts */ - uint_t offers; /* # of pending offers */ - thread_t if_thread; /* rcv service thread */ - int thr_exit; /* sent when time to exit */ - mutex_t ifp_mtx; /* mutex lock on this struct */ - struct interfaces *next; -} IF; - -#define DHCP_MON_SYSERRS 30 /* Max allowable interface errors */ -#define DHCP_MON_ERRINTVL 1 /* Time interval for IF errors (secs) */ -#define DHCP_MON_THRESHOLD 6 /* Max allowable pending pkts pcd */ - -/* - * Pause interval (mins) if IF error threshold reached. - */ -#define DHCP_MON_SLEEP 5 - -extern IF *if_head; /* head of monitored interfaces */ -extern mutex_t if_head_mtx; /* lock to protect interfaces list */ -extern char *interfaces; /* list of user-requested interfaces. */ -extern int open_interfaces(void); -extern int write_interface(IF *, PKT *, int, struct sockaddr_in *); -extern void close_interfaces(void); -extern void detach_plp(dsvc_clnt_t *, PKT_LIST *); -extern void free_pktlist(dsvc_clnt_t *); -extern PKT_LIST *refresh_pktlist(dsvc_clnt_t *, PKT_LIST *); -extern int set_arp(IF *, struct in_addr *, uchar_t *, int, uchar_t); - -extern int send_reply(IF *, PKT *, int, struct in_addr *); -extern void disp_if_stats(IF *); - -extern int relay_agent(IF *, PKT_LIST *); -extern void determine_network(IF *, PKT_LIST *, struct in_addr *, - struct in_addr *); -extern boolean_t is_our_address(in_addr_t); - - -#ifdef __cplusplus -} -#endif - -#endif /* _INTERFACES_H */ diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/logging.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/logging.c deleted file mode 100644 index 36cbe79fe3..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/logging.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> -#include <syslog.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <net/if.h> -#include <netinet/in.h> -#include <netinet/if_ether.h> -#include <arpa/inet.h> -#include <netinet/dhcp.h> -#include <netdb.h> -#include "dhcpd.h" - -static char *dhcp_msg_cats[] = { - /* L_ASSIGN */ "ASSIGN", - /* L_REPLY */ "EXTEND", - /* L_RELEASE */ "RELEASE", - /* L_DECLINE */ "DECLINE", - /* L_INFORM */ "INFORM", - /* L_NAK */ "NAK", - /* L_ICMP_ECHO */ "ICMP-ECHO", - /* L_RELAY_REQ */ "RELAY-SRVR", - /* L_RELAY_REP */ "RELAY-CLNT" -}; - -static char *protos[] = { - /* P_BOOTP */ "BOOTP", - /* P_DHCP */ "DHCP" -}; - -/* - * Transaction logging. Note - if we're in debug mode, the transactions - * are logged to the console! - * - * 'cip' and 'sip' are expected in network order. - */ -void -logtrans(DHCP_PROTO p, DHCP_MSG_CATEGORIES type, time_t lease, - struct in_addr cip, struct in_addr sip, PKT_LIST *plp) -{ - char *cat, *proto, *t, *class_id; - uint_t maclen; - char class_idbuf[DHCP_MAX_OPT_SIZE]; - char cidbuf[DHCP_MAX_OPT_SIZE]; - char ntoabc[INET_ADDRSTRLEN], ntoabs[INET_ADDRSTRLEN]; - char macbuf[(sizeof (((PKT *)NULL)->chaddr) * 2) + 1]; - - if (log_local < 0) - return; - - proto = protos[p]; - cat = dhcp_msg_cats[type]; - - (void) disp_cid(plp, cidbuf, sizeof (cidbuf)); - - class_id = get_class_id(plp, class_idbuf, sizeof (class_idbuf)); - - /* convert white space in class id into periods (.) */ - if (class_id != NULL) { - for (t = class_id; *t != '\0'; t++) { - if (isspace(*t)) - *t = '.'; - } - } else - class_id = "N/A"; - - maclen = sizeof (macbuf); - macbuf[0] = '\0'; - (void) octet_to_hexascii(plp->pkt->chaddr, plp->pkt->hlen, macbuf, - &maclen); - - dhcpmsg(log_local | LOG_NOTICE, "%s %s %010ld %010ld %s %s %s %s %s\n", - proto, cat, time(NULL), lease, - inet_ntop(AF_INET, &cip, ntoabc, sizeof (ntoabc)), - inet_ntop(AF_INET, &sip, ntoabs, sizeof (ntoabs)), - cidbuf, class_id, macbuf); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/main.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/main.c deleted file mode 100644 index d79be1e0e0..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/main.c +++ /dev/null @@ -1,1361 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. - */ - -/* - * This file contains the argument parsing routines of the dhcpd daemon. - * It corresponds to the START state as spec'ed. - */ - -/* - * Multithreading Notes: - * ===================== - * - * For Enterprise DHCP scalability, libdhcpsvc has been made reentrant, - * and the server has been organized with a worker thread per client. - * - * There is a thread per configured interface which reads requests, - * determines if they are for this server, and appends them to the - * interface's PKT list. This thread spawns worker threads as needed - * to service incoming clients. - * - * The main thread creates a thread to handle signals. All subsequent threads - * (and the main thread) mask out all signals. - * - * The signal thread will deal with the -t option. This is done by - * waiting in sigtimedwait() for the timeout period, then spawning - * a reinitialization thread. - * - * dhcp: each client worker thread moves through the multi-packet - * state machine inline, performing icmp_echo_check() as needed. - * We prevent multiple threads from registering the same address for ICMP - * validation due to multiple DISCOVERS by reserving addresses in - * select_offer() to ensure we don't offer IP addresses currently - * undergoing ICMP validation. - * - * bootp: If automatic allocation is in effect, - * bootp behaves in the same fashion as dhcp_offer. - * - * Summary: - * - * Threads: - * 1) Main thread: Handles startup and shutdown chores. - * - * 2) Signal thread: The main thread creates this thread, and - * then masks out all signals. The signal thread waits on - * sigwait(), and processes all signals. It notifies the - * main thread of EINTR or ETERM via a global variable, which - * the main thread checks upon the exit to cond_wait. - * This thread is on it's own LWP, and is DETACHED | DAEMON. - * The thread function is sig_handle(). - * - * 3) Interface threads: Each interface structure has a thread - * associated with it (created in open_interfaces) which is - * responsible for polling the interface, validating bootp - * packets received, and placing them on the client's - * PKT_LIST. The thread function is monitor_interface(). - * When notified by the main thread via the thr_exit flag, - * the thread prints interface statistics for the interface, - * and then exits. - * - * 4) Client threads: Created as needed when the interface - * thread processes each incoming packet. These threads are - * created DETACHED and SUSPENDED by the interface thread, - * which then places each plp structure on the client's - * PKT_LIST, then continues the thread. A client thread exits - * when it has processed all incoming packets, and no - * deferred client work is queued. See per_dnet.h for - * more information on client locks. - * - * Locks: - * 1) if_head_mtx - Locks the global interface list. - * - * 2) ifp_mtx - Locks contents of the enclosed - * interface (IF) structure, including - * such things as thr_exit flag and - * statistics counters. - * - * 3) pkt_mtx - Locks PKT_LIST head list within the - * enclosed client (dsvc_clnt_t) struct. - */ - -#include <stdio.h> -#include <stdio_ext.h> -#include <stdlib.h> -#include <unistd.h> -#include <ctype.h> -#include <string.h> -#include <syslog.h> -#include <signal.h> -#include <time.h> -#include <limits.h> -#include <sys/resource.h> -#include <sys/fcntl.h> -#include <stdarg.h> -#include <sys/types.h> -#include <assert.h> -#include <fcntl.h> -#include <sys/resource.h> -#include <sys/stat.h> -#include <sys/systeminfo.h> -#include <sys/socket.h> -#include <sys/sockio.h> -#include <net/if.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <errno.h> -#include <netinet/dhcp.h> -#include <synch.h> -#include <sys/param.h> -#include <sys/sysmacros.h> -#include <netdb.h> -#include <dhcp_svc_confkey.h> -#include "dhcpd.h" -#include "per_dnet.h" -#include "interfaces.h" -#include <locale.h> -#include <mtmalloc.h> -#include <resolv.h> - -extern int optind, opterr; -extern char *optarg; - -typedef struct dhcp_cops { - char *cop_name; /* opt name */ - boolean_t cop_present; /* opt present? */ - boolean_t (*cop_vinit)(struct dhcp_cops *, const char *); - union { - char *ucop_str; - boolean_t ucop_bool; - int ucop_num; - } dhcp_cops_un; -#define cop_bool dhcp_cops_un.ucop_bool /* opt val: boolean_t */ -#define cop_num dhcp_cops_un.ucop_num /* opt val: int */ -#define cop_str dhcp_cops_un.ucop_str /* opt val: string */ -} DHCP_COP; - -static boolean_t bool_v(DHCP_COP *, const char *); -static boolean_t uchar_v(DHCP_COP *, const char *); -static boolean_t int_v(DHCP_COP *, const char *); -static boolean_t uint_v(DHCP_COP *, const char *); -static boolean_t str_v(DHCP_COP *, const char *); -static boolean_t bootp_v(DHCP_COP *, const char *); -static boolean_t logging_v(DHCP_COP *, const char *); -static boolean_t runmode_v(DHCP_COP *, const char *); -static int collect_options(int, char **); -static void usage(void); -static void local_closelog(void); -static void *sig_handle(void *); - -#define C_RUNMODE 0 -#define C_DEBUG 1 -#define C_VERBOSE 2 -#define C_HOPS 3 -#define C_LOGGING 4 -#define C_IF 5 -#define C_OFFER 6 -#define C_ICMP 7 -#define C_RESCAN 8 -#define C_BOOTP 9 -#define C_CLIENT 10 -#define C_THREADS 11 -#define C_MINLRU 12 -#define C_RELAY 13 -#define C_NSUPDATE 14 -#define C_CACHE 15 - -#define C_DBGPORT 16 -#define C_RENOG 17 -#define C_OWNER 18 -#ifdef DEBUG -#define C_DBGNET 19 -#define C_LAST C_DBGNET -#else /* DEBUG */ -#define C_LAST C_OWNER -#endif /* DEBUG */ - - -static DHCP_COP options[C_LAST + 1] = { -/* name Present? Verify func Value */ -/* ==== ======== =========== ===== */ - /* Run mode / BOOTP relay agent selection option */ -{ DSVC_CK_RUN_MODE, B_FALSE, runmode_v, DSVC_CV_SERVER }, - /* Generic daemon options */ -{ "DEBUG", B_FALSE, bool_v, B_FALSE }, -{ DSVC_CK_VERBOSE, B_FALSE, bool_v, B_FALSE }, -{ DSVC_CK_RELAY_HOPS, B_FALSE, uchar_v, (char *)DSVC_CV_HOPS }, -{ DSVC_CK_LOGGING_FACILITY, B_FALSE, logging_v, 0 }, -{ DSVC_CK_INTERFACES, B_FALSE, str_v, NULL }, - /* DHCP server run mode options */ -{ DSVC_CK_OFFER_CACHE_TIMEOUT, B_FALSE, uint_v, (char *)DSVC_CV_OFFER_TTL }, -{ DSVC_CK_ICMP_VERIFY, B_FALSE, bool_v, (char *)B_TRUE }, -{ DSVC_CK_RESCAN_INTERVAL, B_FALSE, int_v, 0 }, -{ DSVC_CK_BOOTP_COMPAT, B_FALSE, bootp_v, NULL }, -{ DSVC_CK_MAX_CLIENTS, B_FALSE, int_v, (char *)0 }, -{ DSVC_CK_MAX_THREADS, B_FALSE, int_v, (char *)0 }, -{ DSVC_CK_LEASE_MIN_LRU, B_FALSE, int_v, (char *)DSVC_CV_MIN_LRU }, - /* BOOTP relay agent options */ -{ DSVC_CK_RELAY_DESTINATIONS, B_FALSE, str_v, NULL }, - /* Name service update timeout */ -{ DSVC_CK_NSU_TIMEOUT, B_FALSE, uint_v, (char *)DSVC_CV_NSU_TO }, -{ DSVC_CK_CACHE_TIMEOUT, B_FALSE, int_v, (char *)DSVC_CV_CACHE_TTL }, -{ DSVC_CK_DBG_PORT_OFFSET, B_FALSE, int_v, 0 }, -{ DSVC_CK_RENOG_INTERVAL, B_FALSE, uint_v, (char *)DSVC_CV_RENOG_INT }, -{ DSVC_CK_OWNER_IP, B_FALSE, str_v, NULL }, -#ifdef DEBUG -{ DSVC_CK_DBG_MEMORY_NET, B_FALSE, str_v, NULL } -#endif /* DEBUG */ -}; - -#define DHCPCOP_NAME(x) (options[x].cop_name) -#define DHCPCOP_PRES(x) (options[x].cop_present) -#define DHCPCOP_VINIT(x, y) (options[x].cop_vinit(&options[x], y)) -#define DHCPCOP_BOOL(x) (options[x].cop_bool) -#define DHCPCOP_NUM(x) (options[x].cop_num) -#define DHCPCOP_STR(x) (options[x].cop_str) - -int debug; -boolean_t verbose; -boolean_t noping; /* Always ping before offer by default */ -boolean_t no_dhcptab; /* set if no dhcptab exists */ -boolean_t server_mode; /* set if running in server mode */ -static boolean_t bootp_compat; /* bootp compatibility */ -boolean_t be_automatic; /* set if bootp server should allocate IPs */ -uchar_t max_hops; /* max relay hops before discard */ -int log_local; /* syslog local facility number */ -int icmp_tries = DHCP_ICMP_ATTEMPTS; /* Number of attempts @ icmp_timeout */ -time_t off_secs; /* def ttl of an offer */ -time_t cache_secs; /* def ttl of netmask and table caches */ -time_t renog_secs; /* def wait time for secondary server timeout */ -time_t min_lru; /* def minimum lru of a reclaimed lease */ -time_t icmp_timeout = DHCP_ICMP_TIMEOUT; /* milliseconds to wait for response */ -time_t nsutimeout_secs; /* seconds to wait for a name service up date */ -struct in_addr server_ip; /* IP address of server's primary interface */ -struct in_addr *owner_ip; /* owner IP address list */ -static dhcp_confopt_t *dsp; /* Confopt for datastore access */ -dsvc_datastore_t datastore; /* Datastore for container access */ -int max_threads; /* maximum number of worker threads per net */ -int max_clients; /* maximum number of active clients per net */ -ushort_t port_offset = 0; /* offset to port for multiple server */ -int net_thresh = DHCP_NET_THRESHOLD; /* secs to keep pernet reference */ -int clnt_thresh = DHCP_CLIENT_THRESHOLD; /* secs to keep client reference */ -struct __res_state resolv_conf; /* DNS resolver data, includes domain-name */ -static int rescan_scale = DHCP_RESCAN_SCALE; /* secs to scale */ -#ifdef DEBUG -char *dbg_net; /* Simulated debug net (see misc.c) */ -#endif /* DEBUG */ - -static time_t rescan_interval; /* dhcptab rescan interval */ - - -/* - * This global is set by the signal handler when the main thread (and thus - * the daemon) should exit. We only use the mutex in this file, since we make - * the main thread wait on it becoming true using a condition variable. - */ -boolean_t time_to_go = B_FALSE; -static mutex_t ttg_mtx; -static cond_t ttg_cv; - -/* local syslog facilities */ -static int log_facilities[] = { - LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, - LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7 -}; - -time_t reinit_time; /* reinitialization time */ -static thread_t init_thread; /* reinitialization thread */ - -int -main(int argc, char *argv[]) -{ - sigset_t set; - int i, ns, err = 0; - struct rlimit rl; - struct hostent *hp; - thread_t sigthread; - int nss_lwp = 0; - int32_t ncpus; - char scratch[MAXHOSTNAMELEN + 1]; - char ntoab[INET_ADDRSTRLEN]; - char *ownerip_args, *sip, *lasts; - int np = 1; - struct in_addr *oip; - -#ifdef DEBUG - mallocctl(MTDEBUGPATTERN, 1); - mallocctl(MTINITBUFFER, 1); -#endif /* DEBUG */ - - (void) setlocale(LC_ALL, ""); - -#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ -#define TEXT_DOMAIN "SYS_TEXT" -#endif /* ! TEXT_DOMAIN */ - - (void) textdomain(TEXT_DOMAIN); - - if (geteuid() != (uid_t)0) { - (void) fprintf(stderr, gettext("Must be 'root' to run %s.\n"), - DHCPD); - return (EPERM); - } - - if ((err = collect_options(argc, argv)) != 0) { - if (errno == EAGAIN) { - (void) fprintf(stderr, gettext("DHCP daemon config " - "file locked.\n")); - err = EAGAIN; - } else { - usage(); - err = EINVAL; - } - return (err); - } - - /* Deal with run mode generic options first */ - debug = DHCPCOP_BOOL(C_DEBUG); - verbose = DHCPCOP_BOOL(C_VERBOSE); - max_hops = DHCPCOP_NUM(C_HOPS); - interfaces = DHCPCOP_STR(C_IF); - bootp_compat = DHCPCOP_PRES(C_BOOTP); /* present then yes */ - max_clients = DHCPCOP_NUM(C_CLIENT); - max_threads = DHCPCOP_NUM(C_THREADS); - log_local = DHCPCOP_PRES(C_LOGGING) ? - log_facilities[DHCPCOP_NUM(C_LOGGING)] : -1; - - server_mode = (strcasecmp(DHCPCOP_STR(C_RUNMODE), DSVC_CV_SERVER) == 0); - if (server_mode) { - - if (bootp_compat) { - be_automatic = (strcasecmp(DHCPCOP_STR(C_BOOTP), - DSVC_CV_AUTOMATIC) == 0); - } - - if (DHCPCOP_BOOL(C_ICMP) == B_FALSE) { - (void) fprintf(stderr, gettext("\nWARNING: Disabling \ -duplicate IP address detection!\n\n")); - noping = B_TRUE; - } else { - noping = B_FALSE; - } - - off_secs = DHCPCOP_NUM(C_OFFER); - cache_secs = DHCPCOP_NUM(C_CACHE); - renog_secs = DHCPCOP_NUM(C_RENOG); - min_lru = DHCPCOP_NUM(C_MINLRU); - port_offset = DHCPCOP_NUM(C_DBGPORT); /* Private debug flag */ -#ifdef DEBUG - dbg_net = DHCPCOP_STR(C_DBGNET); -#endif /* DEBUG */ - nsutimeout_secs = DHCPCOP_PRES(C_NSUPDATE) ? - DHCPCOP_NUM(C_NSUPDATE) : DHCP_NO_NSU; - - if ((rescan_interval = DHCPCOP_NUM(C_RESCAN)) != 0) { - rescan_interval *= rescan_scale; - } - - /* Load current datastore, if any. */ - if (dsp == NULL) - return (1); - if ((i = confopt_to_datastore(dsp, &datastore)) != - DSVC_SUCCESS) { - (void) fprintf(stderr, gettext( - "WARNING: Invalid datastore: %s\n"), - dhcpsvc_errmsg(i)); - return (1); - } - free_dsvc_conf(dsp); - - ns = status_dd(&datastore); - if (ns != DSVC_SUCCESS) { - (void) fprintf(stderr, gettext( - "Datastore status error: %s\n"), - dhcpsvc_errmsg(ns)); - return (1); - } - } else { - if (!DHCPCOP_PRES(C_RELAY)) { - (void) fprintf(stderr, gettext("Missing BOOTP " - "relay destinations (%s)\n"), - DSVC_CK_RELAY_DESTINATIONS); - return (1); - } - if ((err = relay_agent_init(DHCPCOP_STR(C_RELAY))) != 0) - return (err); - } - - if (!debug) { - /* Daemon (background, detach from controlling tty). */ - switch (fork()) { - case -1: - (void) fprintf(stderr, - gettext("Daemon cannot fork(): %s\n"), - strerror(errno)); - return (errno); - case 0: - /* child */ - break; - default: - /* parent */ - return (0); - } - - closefrom(0); /* close all open files */ - errno = 0; /* clean up benign bad file no error */ - (void) open("/dev/null", O_RDONLY, 0); - (void) dup2(0, 1); - (void) dup2(0, 2); - - /* Detach console */ - (void) setsid(); - - (void) openlog(DHCPD, LOG_PID, LOG_DAEMON); - } - - /* set NOFILE to unlimited */ - rl.rlim_cur = rl.rlim_max = RLIM_INFINITY; - if ((err = setrlimit(RLIMIT_NOFILE, &rl)) < 0) { - dhcpmsg(LOG_ERR, "Cannot set open file limit: %s\n", - strerror(errno)); - return (err); - } - (void) enable_extended_FILE_stdio(-1, -1); - - if (verbose) - dhcpmsg(LOG_INFO, "Daemon started.\n"); - - /* - * Block all signals in main thread - threads created will also - * ignore signals. - */ - (void) sigfillset(&set); - - (void) sigdelset(&set, SIGABRT); /* allow for user abort */ - - (void) thr_sigsetmask(SIG_SETMASK, &set, NULL); - - /* - * Create signal handling thread. - * Due to threads library limitations, the main program - * thread currently cannot function as the signal thread, and - * must be a bound thread. - */ - if ((err = thr_create(NULL, 0, sig_handle, NULL, THR_NEW_LWP | - THR_DAEMON | THR_BOUND | THR_DETACHED, &sigthread)) != 0) { - (void) fprintf(stderr, - gettext("Cannot start signal handling thread, error: %d\n"), - err); - return (err); - } -#ifdef DEBUG - (void) fprintf(stderr, - gettext("Started signal handling thread: %d\n"), sigthread); -#endif /* DEBUG */ - - /* Save away the IP address associated with our HOSTNAME. */ - -#ifdef DEBUG - /* Debugging: allow shared use of difficult to create databases. */ - if (getenv("DHCP_HOSTNAME") != NULL) - (void) strcpy(scratch, getenv("DHCP_HOSTNAME")); - else -#endif /* DEBUG */ - (void) sysinfo(SI_HOSTNAME, scratch, MAXHOSTNAMELEN + 1); - - if ((hp = gethostbyname(scratch)) != NULL && - hp->h_addrtype == AF_INET && - hp->h_length == sizeof (struct in_addr)) { - (void) memcpy((char *)&server_ip, hp->h_addr_list[0], - sizeof (server_ip)); - /* - * server_ip is supplemented by owner_ip list - * the first in the list of owner_ips always = server_ip - */ - owner_ip = smalloc((sizeof (struct in_addr)) * (np + 1)); - (void) memcpy(owner_ip, &server_ip, sizeof (server_ip)); - - if (DHCPCOP_PRES(C_OWNER)) { - ownerip_args = DHCPCOP_STR(C_OWNER); - sip = strtok_r(ownerip_args, ",", &lasts); - while (sip != NULL) { - owner_ip = srealloc(owner_ip, - (sizeof (struct in_addr)) * (np + 2)); - oip = owner_ip + np; - if (inet_pton(AF_INET, sip, oip) == 0 || - oip->s_addr == INADDR_ANY) { - dhcpmsg(LOG_ERR, - "Invalid OWNER IP address %s\n", - sip); - sip = strtok_r(NULL, ",", &lasts); - continue; - } - np++; - sip = strtok_r(NULL, ",", &lasts); - } - } - oip = owner_ip + np; - oip->s_addr = INADDR_ANY; - } else { - dhcpmsg(LOG_ERR, - "Cannot determine server hostname/IP address.\n"); - local_closelog(); - return (1); - } - (void) memset(&resolv_conf, 0, sizeof (resolv_conf)); - if (res_ninit(&resolv_conf) == -1) { - dhcpmsg(LOG_ERR, "Cannot acquire resolver configuration.\n"); - } - i = 0; - if (server_mode) { - /* - * Calculate limits to maximum concurrency. Special values: - * If max_{threads,clients} == 0, calculate limits - * based on cpu and memory. - * Else if max_{threads,clients} is set to -1, run without - * concurrency limits. - * Else use supplied limits. - */ - if ((ncpus = sysconf(_SC_NPROCESSORS_CONF)) < 0) - ncpus = 1; - - if (max_clients == 0) - max_clients = DHCP_DEFAULT_CLIENTS * ncpus; - - /* Require a minimum number of client structs. */ - if (max_clients != -1 && max_clients < DHCP_MIN_CLIENTS) { - max_clients = DHCP_MIN_CLIENTS; - dhcpmsg(LOG_ERR, "Warning: adjusting MAX_CLIENTS" - " to minimum value %d\n", max_clients); - } - - if (max_threads == 0) - max_threads = max_clients/4; - - /* - * 4321342: Alloc additional lwps for unbound library threads. - * Remove this performance workaround when bug fixed. - */ - if (max_clients != 0) - nss_lwp = max_clients/8; - if (nss_lwp <= 0 || nss_lwp > DHCP_NSS_LWP) - nss_lwp = DHCP_NSS_LWP; - i = thr_setconcurrency(nss_lwp); - } - - if (verbose) { - if (i != 0) - dhcpmsg(LOG_ERR, "Error setting concurrency %d: %s\n", - max_threads, strerror(i)); - dhcpmsg(LOG_INFO, "Daemon Version: %s\n", DAEMON_VERS); - dhcpmsg(LOG_INFO, "Maximum relay hops: %d\n", max_hops); - if (log_local > -1) { - dhcpmsg(LOG_INFO, - "Transaction logging to %s enabled.\n", - debug ? "console" : "syslog"); - } - if (server_mode) { - dhcpmsg(LOG_INFO, "Run mode is: DHCP Server Mode.\n"); - dhcpmsg(LOG_INFO, "Datastore resource: %s\n", - datastore.d_resource ? - datastore.d_resource : ""); - dhcpmsg(LOG_INFO, "Location: %s\n", - datastore.d_location ? - datastore.d_location : ""); - dhcpmsg(LOG_INFO, "DHCP offer TTL: %ld\n", off_secs); - if (bootp_compat) - dhcpmsg(LOG_INFO, - "BOOTP compatibility enabled.\n"); - if (rescan_interval != 0) { - dhcpmsg(LOG_INFO, - "Dhcptab rescan interval: %ld minutes.\n", - rescan_interval / rescan_scale); - } - dhcpmsg(LOG_INFO, "ICMP validation timeout: %ld " - "milliseconds, Attempts: %d.\n", icmp_timeout, - icmp_tries); - if (nsutimeout_secs != DHCP_NO_NSU) { - dhcpmsg(LOG_INFO, "Name service update " - "enabled, timeout: %ld seconds\n", - nsutimeout_secs); - } - for (oip = owner_ip; oip->s_addr != INADDR_ANY; oip++) - dhcpmsg(LOG_INFO, "Owner IP address: %s\n", - inet_ntop(AF_INET, oip, ntoab, - sizeof (ntoab))); - dhcpmsg(LOG_INFO, "Maximum concurrent clients: %d\n", - max_clients); - dhcpmsg(LOG_INFO, "Maximum threads: %d\n", max_threads); - } else - dhcpmsg(LOG_INFO, "Run mode is: Relay Agent Mode.\n"); - } - - (void) mutex_init(&ttg_mtx, USYNC_THREAD, 0); - (void) cond_init(&ttg_cv, USYNC_THREAD, 0); - - if (server_mode) { - - if (initntab() != 0) { - dhcpmsg(LOG_ERR, "Cannot allocate per network hash " - "table.\n"); - local_closelog(); - (void) mutex_destroy(&ttg_mtx); - (void) cond_destroy(&ttg_cv); - res_ndestroy(&resolv_conf); - return (1); - } - - if (initmtab() != 0) { - dhcpmsg(LOG_ERR, "Cannot allocate macro hash table.\n"); - local_closelog(); - (void) mutex_destroy(&ttg_mtx); - (void) cond_destroy(&ttg_cv); - res_ndestroy(&resolv_conf); - return (1); - } - - if ((err = checktab()) != 0 || - (err = readtab(NEW_DHCPTAB)) != 0) { - if (err == ENOENT) { - no_dhcptab = B_TRUE; - } else { - dhcpmsg(LOG_ERR, - "Error reading macro table.\n"); - local_closelog(); - (void) mutex_destroy(&ttg_mtx); - (void) cond_destroy(&ttg_cv); - res_ndestroy(&resolv_conf); - return (err); - } - } else - no_dhcptab = B_FALSE; - } - - if ((err = open_interfaces()) != 0) { - local_closelog(); - (void) mutex_destroy(&ttg_mtx); - (void) cond_destroy(&ttg_cv); - res_ndestroy(&resolv_conf); - return (err); - } - - /* - * While forever, handle signals and dispatch them. - */ - while (!time_to_go) { - (void) mutex_lock(&ttg_mtx); - while (!time_to_go) - (void) cond_wait(&ttg_cv, &ttg_mtx); - (void) mutex_unlock(&ttg_mtx); - } - - /* Daemon terminated. */ - if (server_mode) { - resettab(B_TRUE); - close_clnts(); /* reaps client threads */ - } - - close_interfaces(); /* reaps monitor threads */ - local_closelog(); - (void) fflush(NULL); - (void) mutex_destroy(&ttg_mtx); - (void) cond_destroy(&ttg_cv); - res_ndestroy(&resolv_conf); - return (err); -} - -/* - * Signal handler routine. All signals handled by calling thread. - */ -/* ARGSUSED */ -static void * -sig_handle(void *arg) -{ - int err; - int sig; - sigset_t set; - char buf[SIG2STR_MAX]; - timespec_t ts; - siginfo_t si; - - (void) sigfillset(&set); /* catch all signals */ - - ts.tv_sec = rescan_interval == 0 ? DEFAULT_LEASE : rescan_interval; - ts.tv_nsec = 0L; - - /* wait for a signal */ - while (!time_to_go) { - switch (sig = sigtimedwait(&set, &si, &ts)) { - case -1: - if (rescan_interval == 0 || errno != EAGAIN) - break; - /*FALLTHRU*/ - case SIGHUP: - /* - * Create reinitialization thread. - */ - if (init_thread != NULL) - break; - - if ((err = thr_create(NULL, 0, reinitialize, - &init_thread, THR_BOUND | THR_DETACHED, - &init_thread)) != 0) { - (void) fprintf(stderr, gettext( - "Cannot start reinit thread, error: %d\n"), - err); - } - break; - case SIGTERM: - /* FALLTHRU */ - case SIGINT: - (void) sig2str(sig, buf); - dhcpmsg(LOG_NOTICE, "Signal: %s received...Exiting\n", - buf); - time_to_go = B_TRUE; - break; - default: - if (verbose) { - (void) sig2str(sig, buf); - dhcpmsg(LOG_INFO, - "Signal: %s received...Ignored\n", - buf); - } - break; - } - if (time_to_go) { - (void) mutex_lock(&ttg_mtx); - (void) cond_signal(&ttg_cv); - (void) mutex_unlock(&ttg_mtx); - break; - } - } - return ((void *)sig); /* NOTREACHED */ -} - -static void -usage(void) -{ - (void) fprintf(stderr, gettext( - "%s:\n\n\tCommon: [-d] [-v] [-i interface, ...] " - "[-h hops] [-l local_facility]\n\n\t" - "Server: [-n] [-t rescan_interval] [-o DHCP_offer_TTL]\n\t\t" - "[ -b automatic | manual]\n\n\t" - "Relay Agent: -r IP | hostname, ...\n"), DHCPD); -} - -static void -local_closelog(void) -{ - dhcpmsg(LOG_INFO, "Daemon terminated.\n"); - if (!debug) - closelog(); -} - -/* - * Given a received BOOTP packet, generate an appropriately sized, - * and generically initialized BOOTP packet. - */ -PKT * -gen_bootp_pkt(int size, PKT *srcpktp) -{ - PKT *pkt = (PKT *)smalloc(size); - - pkt->htype = srcpktp->htype; - pkt->hlen = srcpktp->hlen; - pkt->xid = srcpktp->xid; - pkt->secs = srcpktp->secs; - pkt->flags = srcpktp->flags; - pkt->giaddr.s_addr = srcpktp->giaddr.s_addr; - (void) memcpy(pkt->cookie, srcpktp->cookie, 4); - (void) memcpy(pkt->chaddr, srcpktp->chaddr, srcpktp->hlen); - - return (pkt); -} - -/* - * Points field serves to identify those packets whose allocated size - * and address is not represented by the address in pkt. - */ -void -free_plp(PKT_LIST *plp) -{ - char *tmpp; - -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, -"%04d: free_plp(0x%x)pkt(0x%x)len(%d)next(0x%x)prev(0x%x)\n", - thr_self(), plp, plp->pkt, plp->len, - plp->next, plp->prev); -#endif /* DEBUG */ - if (plp->pkt) { - if (plp->offset != 0) - tmpp = (char *)((uint_t)plp->pkt - plp->offset); - else - tmpp = (char *)plp->pkt; - free(tmpp); - } - free(plp); - plp = NULL; -} - -/* - * Validate boolean is "B_TRUE" or "B_FALSE". - * Returns B_TRUE if successful, B_FALSE otherwise. - */ -static boolean_t -bool_v(DHCP_COP *dp, const char *option) -{ - boolean_t i; - - assert(dp != NULL && option != NULL); - - if (strcasecmp(option, DSVC_CV_TRUE) == 0) { - i = B_TRUE; - } else if (strcasecmp(option, DSVC_CV_FALSE) == 0) { - i = B_FALSE; - } else { - return (B_FALSE); /* huh? */ - } - dp->cop_bool = i; - return (B_TRUE); -} - -/* - * Validate uchar data. - * Returns B_TRUE if successful, B_FALSE otherwise. - */ -static boolean_t -uchar_v(DHCP_COP *dp, const char *option) -{ - if (dp == NULL || option == NULL || !isdigit(*option)) - return (B_FALSE); - dp->cop_num = strtoul(option, 0L, 0L); - if (dp->cop_num < 0 || dp->cop_num > 0xFF) - return (B_FALSE); - return (B_TRUE); -} - -/* - * Validate integer data. - * Returns B_TRUE if successful, B_FALSE otherwise. - */ -static boolean_t -int_v(DHCP_COP *dp, const char *option) -{ - if (dp != NULL && option != NULL) { - errno = 0; - dp->cop_num = strtol(option, NULL, 0L); - if (errno == 0) - return (B_TRUE); - } - return (B_FALSE); -} - -/* - * Validate unsigned integer data. - * Returns B_TRUE if successful, B_FALSE otherwise. - */ -static boolean_t -uint_v(DHCP_COP *dp, const char *option) -{ - if (dp != NULL && option != NULL) { - errno = 0; - dp->cop_num = strtoul(option, NULL, 0L); - if (errno == 0) - return (B_TRUE); - } - return (B_FALSE); -} - -/* - * Check if value is a string. - * Returns B_TRUE if successful, B_FALSE otherwise - */ -static boolean_t -str_v(DHCP_COP *dp, const char *option) -{ - if (dp == NULL || option == NULL || - (dp->cop_str = strdup(option)) == NULL) { - return (B_FALSE); - } - return (B_TRUE); -} - -/* - * Validate bootp compatibility options. Must be "automatic" or - * "manual". - * Returns B_TRUE if successful, B_FALSE otherwise. - */ -static boolean_t -bootp_v(DHCP_COP *dp, const char *option) -{ - if (dp == NULL || option == NULL) - return (B_FALSE); - - if ((strcasecmp(option, DSVC_CV_AUTOMATIC) == 0 || - strcasecmp(option, DSVC_CV_MANUAL) == 0) && - (dp->cop_str = strdup(option)) != NULL) { - return (B_TRUE); - } - return (B_FALSE); -} - -/* - * Validate logging facility. Must be a number between 0 and 7 inclusive. - * Returns B_TRUE if successful, B_FALSE otherwise. - */ -static boolean_t -logging_v(DHCP_COP *dp, const char *option) -{ - if (uint_v(dp, option) && dp->cop_num <= 7) - return (B_TRUE); - - (void) fprintf(stderr, gettext("Syslog local facility must be in the " - "range of 0 through 7.\n")); - return (B_FALSE); -} - -/* - * Validate run mode. Must be "server" or "relay". - * Returns B_TRUE if successful, B_FALSE otherwise - */ -static boolean_t -runmode_v(DHCP_COP *dp, const char *option) -{ - if (dp == NULL || option == NULL) - return (B_FALSE); - if ((strcasecmp(option, DSVC_CV_SERVER) == 0 || - strcasecmp(option, DSVC_CV_RELAY) == 0) && - (dp->cop_str = strdup(option)) != NULL) { - return (B_TRUE); - } - return (B_FALSE); -} - -/* - * Initialize options table based upon config file settings or command - * line flags. Handle all option inter-dependency checking here. No value - * checking is done here. - * - * Returns 0 if successful, nonzero otherwise. - */ -static int -collect_options(int count, char **args) -{ - int c, i, j; - char *mode; - - /* First, load the configuration options from the file, if present. */ - for (errno = 0, i = 0; i < DHCP_RDCOP_RETRIES && - read_dsvc_conf(&dsp) < 0; i++) { - (void) fprintf(stderr, gettext( - "WARNING: DHCP daemon config file: %s\n"), - strerror(errno)); - if (errno == EAGAIN) { - /* file's busy, wait one second and try again */ - (void) sleep(1); - } else - break; - } - if (errno == EAGAIN) - return (EAGAIN); - - /* set default RUN_MODE to server if it wasn't found in the file */ - if (query_dsvc_conf(dsp, DSVC_CK_RUN_MODE, &mode) < 0) { - if (errno == ENOENT) { - if (add_dsvc_conf(&dsp, DSVC_CK_RUN_MODE, - DSVC_CV_SERVER) != 0) - return (errno); - } - } else - free(mode); - - /* - * Second, pick up the user's preferences from the command line, - * which modify the config file settings. - */ - while ((c = getopt(count, args, "dnvh:o:r:b:i:t:l:")) != -1) { - - boolean_t relay_mode = B_FALSE; - char *key = NULL, *value = NULL; - - switch (c) { - case 'd': - key = "DEBUG"; - value = DSVC_CV_TRUE; - break; - case 'n': - key = DSVC_CK_ICMP_VERIFY; - value = DSVC_CV_FALSE; - break; - case 'v': - key = DSVC_CK_VERBOSE; - value = DSVC_CV_TRUE; - break; - case 'r': - key = DSVC_CK_RELAY_DESTINATIONS; - value = optarg; - relay_mode = B_TRUE; - break; - case 'b': - key = DSVC_CK_BOOTP_COMPAT; - value = optarg; - break; - case 'h': - key = DSVC_CK_RELAY_HOPS; - value = optarg; - break; - case 'i': - key = DSVC_CK_INTERFACES; - value = optarg; - break; - case 'o': - key = DSVC_CK_OFFER_CACHE_TIMEOUT; - value = optarg; - break; - case 't': - key = DSVC_CK_RESCAN_INTERVAL; - value = optarg; - break; - case 'l': - key = DSVC_CK_LOGGING_FACILITY; - value = optarg; - break; - default: - (void) fprintf(stderr, gettext("Unknown option: %c\n"), - c); - return (EINVAL); - } - - /* - * Create parameters if they don't exist, or replace - * their value if they exist. - */ - if (replace_dsvc_conf(&dsp, key, value) < 0) - return (errno); - - if (relay_mode) { - if (replace_dsvc_conf(&dsp, DSVC_CK_RUN_MODE, - DSVC_CV_RELAY) < 0) - return (errno); - } - } - - if (optind < count) { - - /* get all unused arguments */ - (void) fprintf(stderr, "%s: unexpected argument(s) \"", - args[0]); - for (; optind < count; optind++) { - if (args[optind][0] != '-') - (void) fprintf(stderr, " %s", args[optind]); - else - break; - } - (void) fprintf(stderr, "\"; Aborting\n"); - return (EINVAL); - } - - /* load options table, validating value portions of present as we go */ - for (i = 0; dsp != NULL && dsp[i].co_key != NULL; i++) { - if (dsp[i].co_type != DHCP_KEY) - continue; /* comment */ - for (j = 0; j <= C_LAST; j++) { - if (strcasecmp(DHCPCOP_NAME(j), - dsp[i].co_key) == 0) { - DHCPCOP_PRES(j) = B_TRUE; - if (DHCPCOP_VINIT(j, dsp[i].co_value)) - break; - else { - (void) fprintf(stderr, gettext( - "Invalid value for option: %s\n"), - DHCPCOP_NAME(j)); - return (EINVAL); - } - } - } - } - - return (0); -} - -/* - * monitor_client: worker thread from pool created for each network. - * We loop through and process one packet. Relay agent tasks are handled by - * the per-interface threads, thus we should only be dealing with bootp/dhcp - * server bound packets here. - * - * The worker thread treats the client packet lists as - * "stacks", or FIFO objects. We do this so that we get - * the latest, equivalent request from the client before - * responding, thus keeping the chance of responding to - * moldy requests to an absolute minimum. - * - * Performance: a pool of threads are used, to avoid thread startup/teardown. - * Per-interface threads keep track of clients who cannot be serviced - * due to a lack of threads. After completing the current request, threads - * look for other work to do, before suspending and waiting to be - * continued when work is available. - */ -void * -monitor_client(void *arg) -{ - dsvc_thr_t *thrp = (dsvc_thr_t *)arg; - dsvc_clnt_t *pcd; - dsvc_dnet_t *pnd; - dsvc_pendclnt_t *workp; - IF *ifp; - PKT_LIST *plp = NULL; - int nclients; - boolean_t delete; - uint_t flags = 0; - - /* - * Initialize variables. - * - * Due to a possible race between suspend and continue, we must - * provide a positive indication that the thread has continued to - * the per-interface thread. - */ - (void) mutex_lock(&thrp->thr_mtx); - pcd = thrp->thr_pcd; - thrp->thr_pcd = NULL; - (void) mutex_unlock(&thrp->thr_mtx); - - ifp = pcd->ifp; - pnd = pcd->pnd; - - /* - * The per-interface thread leaves the client struct open, - * so it cannot be garbage-collected in the interim. - * Keep track of when we must release client structs. - */ - (void) mutex_lock(&pnd->thr_mtx); - nclients = pnd->nclients; - (void) mutex_unlock(&pnd->thr_mtx); - - for (; (flags & DHCP_THR_EXITING) == 0; ) { - if (pcd == NULL) { - /* - * No work. Place thread struct on free list - * if it isn't already, and suspend - * until new work is available. - */ - (void) mutex_lock(&thrp->thr_mtx); - if ((thrp->thr_flags & DHCP_THR_LIST) == 0) { - thrp->thr_flags |= DHCP_THR_LIST; - thrp->thr_pcd = NULL; - thrp->thr_next = NULL; - - (void) mutex_lock(&pnd->thr_mtx); - if (pnd->thrhead != NULL) { - pnd->thrtail->thr_next = thrp; - } else { - pnd->thrhead = thrp; - } - pnd->thrtail = thrp; - (void) mutex_unlock(&pnd->thr_mtx); - } - - /* Wait for new work. */ - (void) cond_wait(&thrp->thr_cv, &thrp->thr_mtx); - - /* - * Resume with new client if any. - */ - pcd = thrp->thr_pcd; - thrp->thr_pcd = NULL; - flags = thrp->thr_flags; - (void) mutex_unlock(&thrp->thr_mtx); - continue; - } - - (void) mutex_lock(&pcd->pkt_mtx); - /* - * Remove the first packet from the list - */ - plp = pcd->pkthead; - if (plp != NULL) { - - detach_plp(pcd, plp); - pcd->pending--; - - /* - * See if there's a later one - * exchanging this plp for that one. - */ - plp = refresh_pktlist(pcd, plp); - } - (void) mutex_unlock(&pcd->pkt_mtx); - - (void) mutex_lock(&pcd->pcd_mtx); - if (plp == NULL || (pcd->flags & DHCP_PCD_CLOSING) != 0) { - - if (plp) { - free_plp(plp); /* Free the packet. */ - plp = NULL; - } - - /* - * No work remaining for this client. Release, - * and check for other deferred clients on the - * per net work list. - */ - pcd->flags &= ~DHCP_PCD_WORK; - - /* - * Housekeeping: delete pcd immediately if above - * threshold and no offer has been made, or offer - * has been completed. Only perform deletion if no - * other thread has. - */ - delete = B_FALSE; - if (max_clients != -1 && - (pcd->flags & DHCP_PCD_CLOSING) == 0) { - if (nclients >= - max_clients - DHCP_MINFREE_CLIENTS && - pcd->off_ip.s_addr == htonl(INADDR_ANY)) { - - /* Remove clients without offers. */ - pcd->flags |= DHCP_PCD_CLOSING; - delete = B_TRUE; - - } else if (nclients > max_clients/2 && - (pcd->state == ACK || - (pcd->state == REQUEST && - pcd->off_ip.s_addr == htonl(INADDR_ANY)))) { - - /* Remove completed clients. */ - pcd->flags |= DHCP_PCD_CLOSING; - delete = B_TRUE; - - } else if (pcd->state == RELEASE || - pcd->state == DECLINE) { - - /* Remove freed clients. */ - pcd->flags |= DHCP_PCD_CLOSING; - delete = B_TRUE; - } - } - pcd->clnt_thread = NULL; - (void) mutex_unlock(&pcd->pcd_mtx); - - /* Close the client. */ - close_clnt(pcd, delete); - pcd = NULL; - - /* - * Remove next deferred work from list. - */ - workp = NULL; - (void) mutex_lock(&pnd->thr_mtx); - nclients = pnd->nclients; - workp = pnd->workhead; - if (workp && - (pnd->workhead = pnd->workhead->pnd_next) == NULL) - pnd->worktail = NULL; - (void) mutex_unlock(&pnd->thr_mtx); - - if (workp != NULL) { - /* See if the deferred client still exists. */ - if (open_clnt(pnd, &pcd, workp->pnd_cid, - workp->pnd_cid_len, B_TRUE) != DSVC_SUCCESS) - pcd = NULL; - if (pcd == NULL) { - free(workp); - continue; - } - - (void) mutex_lock(&pcd->pcd_mtx); - /* Check if it needs a worker thread. */ - if (pcd->clnt_thread == NULL && - (pcd->flags & DHCP_PCD_WORK) != 0 && - (pcd->flags & DHCP_PCD_CLOSING) == 0) { - /* Found a valid client. Restart. */ - pcd->clnt_thread = thrp; - (void) mutex_unlock(&pcd->pcd_mtx); - ifp = pcd->ifp; - free(workp); - continue; - } - (void) mutex_unlock(&pcd->pcd_mtx); - close_clnt(pcd, B_FALSE); - pcd = NULL; - free(workp); - } - continue; - } - (void) mutex_unlock(&pcd->pcd_mtx); - - /* - * Based on the packet type, process accordingly. - */ - if (plp->pkt->op == BOOTREQUEST) { - if (plp->opts[CD_DHCP_TYPE]) { - /* DHCP packet */ - dhcp(pcd, plp); - } else { - /* BOOTP packet */ - if (!bootp_compat) { - dhcpmsg(LOG_INFO, "BOOTP request " - "received on interface: %s " - "ignored.\n", ifp->nm); - } else { - bootp(pcd, plp); - } - } - } - if (plp != NULL) { - free_plp(plp); /* Free the packet. */ - plp = NULL; - } - - (void) mutex_lock(&ifp->ifp_mtx); - ifp->processed++; - (void) mutex_unlock(&ifp->ifp_mtx); - } - - /* Free the packet. */ - if (plp != NULL) - free_plp(plp); - - /* Release the client structure. */ - if (pcd != NULL) { - (void) mutex_lock(&pcd->pcd_mtx); - pcd->flags &= ~DHCP_PCD_WORK; - pcd->clnt_thread = NULL; - (void) mutex_unlock(&pcd->pcd_mtx); - - close_clnt(pcd, B_FALSE); - } - - /* Release the thread reference in pernet structure. */ - if (pnd != NULL) { - (void) mutex_lock(&pnd->thr_mtx); - pnd->nthreads--; - (void) cond_signal(&pnd->thr_cv); - (void) mutex_unlock(&pnd->thr_mtx); - } - - return (NULL); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/misc.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/misc.c deleted file mode 100644 index 2a0ed5d04c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/misc.c +++ /dev/null @@ -1,769 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <string.h> -#include <stdarg.h> -#include <syslog.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/sysmacros.h> -#include <time.h> -#include <locale.h> -#include <stdlib.h> -#include <unistd.h> -#include <errno.h> -#include <assert.h> -#include <sys/socket.h> -#include <net/if.h> -#include <netinet/in.h> -#include <netinet/if_ether.h> -#include <arpa/inet.h> -#include <netinet/dhcp.h> -#include <netdb.h> -#include <sys/mman.h> -#include <locale.h> -#include <tnf/probe.h> -#include <resolv.h> - -#include "dhcpd.h" -#include "per_dnet.h" -#include "interfaces.h" - -#ifdef DEBUG -/* - * Datastore debugging functions. - * - * A simple datastore simulation, using the magic DBG_MEMORY_NET network, - * is provided, to test the program with minimal datastore overhead. - * A concatenated reclist is used to speed record manipulation. - * Note that other networks continue to pass-thru to libdhcpsvc, to allow - * live comparison. - */ - -/* Simple datastore database. */ -typedef struct db { - lease_t dn_lease; - char dn_cid[128]; - char dn_macro[2]; - uchar_t dn_cid_len; - uchar_t dn_flags; -} dbg_t; - -typedef struct reclist { - dn_rec_list_t d_reclist; - dn_rec_t d_rec; -} dbg_rec_t; - -#define DBG_MAXTABLE 16 -static dsvc_handle_t dbg_handle[DBG_MAXTABLE]; /* simulated handle */ -static rwlock_t dbg_lock[DBG_MAXTABLE]; /* locks */ -static uint32_t dbg_size = 4096; /* table size */ -static uint32_t dbg_msize; /* mapped size */ -static uint32_t dbg_mask = 0xFFFF; /* table mask */ - -static uint32_t dbg_cid = 0; /* starting cid */ -static uint32_t dbg_flags = 0; /* starting flags */ -static uint32_t dbg_lease = 0; /* starting lease */ -static char dbg_macro = '1'; /* macro */ -#endif /* DEBUG */ - -int -dhcp_open_dd(dsvc_handle_t *handp, dsvc_datastore_t *ddp, dsvc_contype_t type, - const char *name, uint_t flags) -{ -#ifndef DEBUG - return (open_dd(handp, ddp, type, name, flags)); - -#else /* DEBUG */ - int ret; - int hind; - int net; - int pgmsk = sysconf(_SC_PAGESIZE) - 1; - - if (dbg_net && memcmp(name, dbg_net, strlen(dbg_net)) == 0) { - for (net = 0, hind = strlen(dbg_net); name[hind] != '.'; hind++) - net += (net * 10) + (name[hind] - '0'); - if (net > DBG_MAXTABLE) - return (DSVC_NO_TABLE); - - if (dbg_handle[net] == NULL) { - dbg_msize = (sizeof (dbg_t) * dbg_size + pgmsk) & - ~pgmsk; - /* LINTED [alignment ok] */ - dbg_handle[net] = (dsvc_handle_t)mmap(0, dbg_msize, - PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0); - if ((char *)dbg_handle[net] == MAP_FAILED) { - dbg_handle[net] = NULL; - return (DSVC_INVAL); - } - } - *handp = (void *)net; - ret = DSVC_SUCCESS; - } else - ret = open_dd(handp, ddp, type, name, flags); - - return (ret); -#endif /* DEBUG */ -} - -int -dhcp_close_dd(dsvc_handle_t *handp) -{ -#ifndef DEBUG - return (close_dd(handp)); - -#else /* DEBUG */ - int ret; - int hind = (int)*handp; - - if (dbg_net && hind >= 0 && hind < DBG_MAXTABLE) { - if (dbg_handle[hind] != NULL) { - (void) munmap((char *)dbg_handle[hind], dbg_msize); - dbg_handle[hind] = (dsvc_handle_t)NULL; - ret = DSVC_SUCCESS; - } - } else - ret = close_dd(handp); - - return (ret); -#endif /* DEBUG */ -} - -/* - * Detach the element from a list, and return it. If the list is empty, NULL is - * returned. - */ -dn_rec_list_t * -detach_dnrec_from_list(dn_rec_list_t *prevp, dn_rec_list_t *elemp, - dn_rec_list_t **listpp) -{ - if (prevp == NULL) { - if (elemp == *listpp && elemp != NULL) { - /* head of the list */ - *listpp = (*listpp)->dnl_next; - elemp->dnl_next = NULL; - } - } else if (prevp->dnl_next != NULL) { - /* somewhere in the middle */ - prevp->dnl_next = elemp->dnl_next; - elemp->dnl_next = NULL; - } else - assert(elemp == NULL); - - return (elemp); -} - -/* - * Attach an unattached element (elemp) to a list (*listpp). - */ -static void -attach_dnrec_to_list(dn_rec_list_t *elemp, dn_rec_list_t **listpp) -{ - if (*listpp != NULL) - elemp->dnl_next = *listpp; - *listpp = elemp; -} - -/* - * dhcp_lookup_dd: perform lookup_dd. - */ -static int -dhcp_lookup_dd(dsvc_handle_t hand, boolean_t partial, uint_t query, - int count, const void *targetp, void **recordsp, uint_t *nrecordsp) -{ -#ifndef DEBUG - return (lookup_dd(hand, partial, query, count, targetp, recordsp, - nrecordsp)); - -#else /* DEBUG */ - int ret; - int hind = (int)hand; - int ind; - dn_rec_t *inp; - dn_rec_list_t **outp = (dn_rec_list_t **)recordsp; - dbg_t *dbp; - dbg_t *endp; - dbg_rec_t *rp; - dn_rec_t *recp; - dn_rec_list_t *reclp; - dbg_t *dbg_db; - - if (dbg_net && hind >= 0 && hind < DBG_MAXTABLE) { - dbg_db = (dbg_t *)dbg_handle[hind]; - - if (outp) - *outp = NULL; - if (nrecordsp) - *nrecordsp = 0; - inp = (dn_rec_t *)targetp; - - (void) rw_rdlock(&dbg_lock[hind]); - /* - * Simple linear search, aided by the fact that - * the server currently checks flags. - */ - if (DSVC_QISEQ(query, DN_QCIP)) { - ind = inp->dn_cip.s_addr & dbg_mask; - dbp = &dbg_db[ind]; - endp = &dbg_db[ind + 1]; - } else { - ind = 0; - dbp = dbg_db; - endp = &dbg_db[dbg_size]; - } - for (; dbp < endp; dbp++, ind++) { - /* - * Initialize record. fields will be zero'd - * when initially mmap'd. - */ - if (dbp->dn_cid_len == 0) { - /* Skip server address to avoid arp issues. */ - if (ind == (ntohl(server_ip.s_addr) % 256)) - continue; - if (dbg_cid) - (void) snprintf(dbp->dn_cid, - sizeof (dbp->dn_cid), "%8X", - dbg_cid++); - dbp->dn_flags = dbg_flags; - dbp->dn_lease = dbg_lease; - dbp->dn_macro[0] = dbg_macro; - dbp->dn_macro[1] = '\0'; - dbp->dn_cid_len = 1; - } - if (DSVC_QISEQ(query, DN_QCID) && - (inp->dn_cid[0] != dbp->dn_cid[0] || - memcmp(dbp->dn_cid, inp->dn_cid, inp->dn_cid_len))) - continue; - - rp = (dbg_rec_t *)smalloc(sizeof (dbg_rec_t)); - reclp = &rp->d_reclist; - recp = &rp->d_rec; - - if (nrecordsp) - (*nrecordsp)++; - - reclp->dnl_rec = recp; - recp->dn_lease = dbp->dn_lease; - recp->dn_sip.s_addr = ntohl(owner_ip->s_addr); - recp->dn_cip.s_addr = 0xd000000 + (hind << 16) + ind; - recp->dn_cid_len = dbp->dn_cid_len; - recp->dn_flags = dbp->dn_flags; - recp->dn_macro[0] = dbp->dn_macro[0]; - recp->dn_macro[1] = '\0'; - if ((recp->dn_cid[0] = dbp->dn_cid[0]) != '\0') - (void) memcpy(recp->dn_cid, dbp->dn_cid, - dbp->dn_cid_len); - if (*outp == NULL) - *outp = reclp; - else { - reclp->dnl_next = *outp; - *outp = reclp; - } - if (count > 0 && nrecordsp && *nrecordsp >= count) - break; - } - (void) rw_unlock(&dbg_lock[hind]); - ret = DSVC_SUCCESS; - } else - ret = lookup_dd(hand, partial, query, count, targetp, - recordsp, nrecordsp); - - return (ret); -#endif /* DEBUG */ -} - -int -dhcp_modify_dd_entry(dsvc_handle_t hand, const void *origp, void *newp) -{ -#ifndef DEBUG - return (modify_dd_entry(hand, origp, newp)); - -#else /* DEBUG */ - int ret; - int hind = (int)hand; - int ind; - dn_rec_t *dnp; - dbg_t *dbp; - dbg_t *dbg_db; - - if (dbg_net && hind >= 0 && hind < DBG_MAXTABLE) { - dbg_db = (dbg_t *)dbg_handle[hind]; - - dnp = (dn_rec_t *)newp; - ind = dnp->dn_cip.s_addr & dbg_mask; - dbp = &dbg_db[ind]; - (void) rw_wrlock(&dbg_lock[hind]); - dbp->dn_lease = dnp->dn_lease; - dbp->dn_cid_len = dnp->dn_cid_len; - dbp->dn_flags = dnp->dn_flags; - /* - * Performance: avoid routine call when NULL string - * is being copied. - */ - if ((dbp->dn_cid[0] = dnp->dn_cid[0]) != '\0') - (void) memcpy(dbp->dn_cid, dnp->dn_cid, - dnp->dn_cid_len); - (void) rw_unlock(&dbg_lock[hind]); - ret = DSVC_SUCCESS; - } else - ret = modify_dd_entry(hand, origp, newp); - - return (ret); -#endif /* DEBUG */ -} - -void -dhcp_free_dd_list(dsvc_handle_t hand, void *listp) -{ -#ifndef DEBUG - free_dd_list(hand, listp); - -#else /* DEBUG */ - dn_rec_list_t *ptr; - int hind = (int)hand; - - if (dbg_net && hind >= 0 && hind < DBG_MAXTABLE) { - while ((ptr = listp) != NULL) { - listp = ptr->dnl_next; - free(ptr); - } - } else - free_dd_list(hand, listp); -#endif /* DEBUG */ -} - -/* - * cmp_lrusort: qsort() comparison routine to sort lru list. - */ -static int -cmp_lrusort(const void *a, const void *b) -{ - dn_rec_list_t *r1 = *(dn_rec_list_t **)a; - dn_rec_list_t *r2 = *(dn_rec_list_t **)b; - - if (r1->dnl_rec->dn_lease < r2->dnl_rec->dn_lease) - return (-1); - else if (r1->dnl_rec->dn_lease == r2->dnl_rec->dn_lease) - return (0); - else - return (1); -} - -/* - * get_lrusort: quick sort of eligible lru container entries. - */ -static dn_rec_list_t * -get_lrusort(dsvc_dnet_t *pnd, dn_rec_list_t *lrup, uint_t *lrecords) -{ - size_t nel; - size_t size = *lrecords * sizeof (dn_rec_list_t *); - dn_rec_list_t *from, **to, *next, *freerec = NULL; - dn_rec_list_t *lrupage; - dn_rec_t *rp; - time_t reuse_time = time(NULL) - min_lru; - uint_t records = 0; -#ifndef NDEBUG - int cnt = 0; -#endif /* !NDEBUG */ - - (void) mutex_lock(&pnd->lrupage_mtx); - if (pnd->lrupage == NULL || pnd->lrusize < size) { - if (pnd->lrupage != NULL) - free(pnd->lrupage); - pnd->lrupage = (dn_rec_list_t **)smalloc(size); - pnd->lrusize = size; - } - if ((to = pnd->lrupage) == NULL) { - pnd->lrusize = 0; - (void) mutex_unlock(&pnd->lrupage_mtx); - return (lrup); - } - - /* - * Build a list of entries, discarding those which are in use. - */ - *to = NULL; - for (from = lrup; from != NULL; from = next) { - next = from->dnl_next; - rp = from->dnl_rec; - if (rp->dn_lease > reuse_time || - (rp->dn_flags & DN_FAUTOMATIC) || - rp->dn_lease == DHCP_PERM) { - from->dnl_next = freerec; - freerec = from; - } else { - records++; - *(to++) = from; - } - assert(++cnt <= *lrecords); - } - - /* - * Sort any usable elements, and relink. - */ - nel = (int)(to - pnd->lrupage); - if (nel > 0) { - if (nel > 1) - qsort(pnd->lrupage, nel, sizeof (dn_rec_list_t *), - cmp_lrusort); - for (to = pnd->lrupage; nel > 0; to++, nel--) - (*to)->dnl_next = *(to + 1); - to--; - (*to)->dnl_next = NULL; - } - - /* - * Free any unusable elements, return any usable elements. - */ - if (freerec) - dhcp_free_dd_list(pnd->dh, freerec); - *lrecords = records; - - lrupage = *(pnd->lrupage); - (void) mutex_unlock(&pnd->lrupage_mtx); - return (lrupage); -} - -/* - * dhcp_lookup_dd_classify: perform lookup_dd(), or use existing records - * if supplied, and classify the results based on the type of search criteria - * being employed. Centralized policy for DN_FMANUAL and DN_FUNUSABLE flag - * processing are implemented here. Classification is specialized - * based on these specific search criteria: - * - * S_CID A CID match is requested. Perform DN_FMANUAL and - * DN_FUNUSABLE processing. - * S_FREE A search for free records. Only examine first - * matching record. - * S_LRU A search for lru records. Perform sort if needed, - * and only examine first matching record. - * - * A matching record is detached and returned if found (ok || - * manual + unusable). Other successful matches are returned in recordsp as - * a cache. - */ -void * -dhcp_lookup_dd_classify(dsvc_dnet_t *pnd, boolean_t partial, uint_t query, - int count, const dn_rec_t *targetp, void **recordsp, int searchtype) -{ - int err; - uint_t rec_cnt = 0, manual = 0; - dn_rec_t *dnp; - dn_rec_list_t *nlp = NULL, *dnlp = NULL; - dn_rec_list_t *unulp = NULL; /* list of unusables, !manual */ - dn_rec_list_t *unu_m_lp = NULL; /* list of unusable + manual */ - dn_rec_list_t *m_lp = NULL; /* list of manual records */ - dn_rec_list_t *cachep = NULL; /* match cache */ - struct in_addr swapaddr; - char ntoab[INET_ADDRSTRLEN]; - - /* - * Lookup records matching the specified criteria, or use - * records from a previous lookup supplied for classification. - */ - if (*recordsp == NULL) { - - TNF_PROBE_1_DEBUG(classify, "classify classify", - "classify_query%debug 'in func classify'", - tnf_long, query, query); - - err = dhcp_lookup_dd(pnd->dh, partial, query, count, targetp, - (void **)recordsp, &rec_cnt); - - TNF_PROBE_1_DEBUG(classify_cid_end, "classify classify_end", - "classify_end%debug 'in func classify'", - tnf_long, rec_cnt, rec_cnt); - - /* - * If any error occurs, mark the dsvc_dnet_t table - * for immediate close and reopen. Let the protocol - * perform recover, rather than attempting time-consuming - * in-place error recovery. - */ - if (err != DSVC_SUCCESS) { - (void) mutex_lock(&pnd->pnd_mtx); - pnd->flags |= DHCP_PND_ERROR; - hash_Dtime(pnd->hand, 0); - (void) mutex_unlock(&pnd->pnd_mtx); -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, "classify failure %s\n", - dhcpsvc_errmsg(err)); -#endif /* DEBUG */ - *recordsp = NULL; - return (NULL); - } - - /* - * For LRU classification, sort returned records based - * on dn_lease field. Discards records with valid lease - * times; adjusts rec_cnt accordingly. - */ - if (searchtype & S_LRU) - *recordsp = get_lrusort(pnd, *recordsp, &rec_cnt); - - } - - /* - * Record classification: scan through all records, performing - * DN_FUNUSABLE and DN_FMANUAL processing. Note that most of the - * work has been performed by the datastore query. Remove the matching - * entry from the singlely-linked record list, for return. Free any - * non-matching entries prior to the match. Pass back any additional - * entries after the match in the recordsp pointer for possible re-use - * by the caching code. - */ - - for (nlp = detach_dnrec_from_list(NULL, *recordsp, - (dn_rec_list_t **)recordsp); nlp != NULL; - nlp = detach_dnrec_from_list(NULL, *recordsp, - (dn_rec_list_t **)recordsp)) { - /* - * If we find that there is a DN_FMANUAL entry that is - * DN_FUNUSABLE, we fail the request, when performing a - * CID search, even though there may be other CID matches. In - * the CID case, those other CID matches are errors, because - * there should be one and only one record for a client if that - * record is marked as being DN_FMANUALly assigned. We tell - * the user how many of those CID matches there are. If there - * are no DN_FMANUAL records, the first matching record which - * is USABLE wins. - */ - dnp = nlp->dnl_rec; - if (dnp->dn_flags & DN_FUNUSABLE) { - if ((searchtype & (S_CID|S_FREE|S_LRU)) == S_CID) { - char cidbuf[DHCP_MAX_OPT_SIZE]; - uint_t blen = sizeof (cidbuf); - - (void) octet_to_hexascii(targetp->dn_cid, - targetp->dn_cid_len, - cidbuf, &blen); - - swapaddr.s_addr = htonl(dnp->dn_cip.s_addr); - - dhcpmsg(LOG_NOTICE, "(%1$s,%2$s) " - "currently marked as unusable.\n", cidbuf, - inet_ntop(AF_INET, &swapaddr, ntoab, - sizeof (ntoab))); - } - - /* build list of unusable records */ - if (dnp->dn_flags & DN_FMANUAL) { - attach_dnrec_to_list(nlp, &unu_m_lp); - manual++; - } else - attach_dnrec_to_list(nlp, &unulp); - } else { - if (dnp->dn_flags & DN_FMANUAL) { - attach_dnrec_to_list(nlp, &m_lp); - manual++; - } else - attach_dnrec_to_list(nlp, &cachep); - /* - * These searches do not require examining all - * matches. - */ - if (searchtype & (S_FREE|S_LRU)) - break; - } - } - - /* - * Warnings are printed for CID searches which end with - * DN_FUNUSABLE|DN_FMANUAL match(es). - */ - if (m_lp != NULL || unu_m_lp != NULL) { - if (manual > 1) { - char cidbuf[DHCP_MAX_OPT_SIZE]; - uint_t blen = sizeof (cidbuf); - - (void) octet_to_hexascii(targetp->dn_cid, - targetp->dn_cid_len, - cidbuf, &blen); - dhcpmsg(LOG_WARNING, - "Manual allocation (%1$s) has %2$d other MANUAL" - " records. It should have 0.\n", cidbuf, - manual - 1); - } - if (unu_m_lp != NULL) { - dnlp = detach_dnrec_from_list(NULL, unu_m_lp, - &unu_m_lp); - } else - dnlp = detach_dnrec_from_list(NULL, m_lp, &m_lp); - } - - /* Free any unusable entries */ - if (unulp != NULL) - dhcp_free_dd_list(pnd->dh, unulp); - - /* any other... */ - if (dnlp == NULL) - dnlp = detach_dnrec_from_list(NULL, cachep, &cachep); - - /* - * Return any unused elements for possible caching use. These are - * the additional manual + unusable (as punishment for having - * multiple items), manual, and and any others. - */ - if (cachep != NULL) - attach_dnrec_to_list(cachep, (dn_rec_list_t **)recordsp); - if (m_lp != NULL) - attach_dnrec_to_list(m_lp, (dn_rec_list_t **)recordsp); - if (unu_m_lp != NULL) - attach_dnrec_to_list(unu_m_lp, (dn_rec_list_t **)recordsp); - - /* - * Return one of the matching record(s). - */ - return (dnlp); -} - -/* - * Error message function. If debugging off, then logging goes to - * syslog. - * - * Must be MT SAFE - called by various threads as well as the main thread. - */ - -/*VARARGS2*/ -void -dhcpmsg(int errlevel, const char *fmtp, ...) -{ - char buff[BUFSIZ], errbuf[BUFSIZ]; - const char *f = buff; - va_list ap; - - if (debug < 0) - return; - - va_start(ap, fmtp); - - if (debug > 0) { - if (errlevel != LOG_ERR) - (void) snprintf(errbuf, sizeof (errbuf), - "%lx: ", time(NULL)); - else - (void) snprintf(errbuf, sizeof (errbuf), - "%lx: (%s)", time(NULL), strerror(errno)); - (void) snprintf(buff, sizeof (buff), "%s %s", errbuf, - gettext(fmtp)); - (void) vfprintf(stderr, f, ap); - } else if (debug == 0) - (void) vsyslog(errlevel, gettext(fmtp), ap); - - va_end(ap); -} - -/* - * smalloc() -- safe malloc() - * - * Always returns a valid pointer(if it returns at all). The allocated - * memory is initialized to all zeros. If malloc() returns an error, a - * message is printed using the syslog() function and the program aborts - * with a status of 1. - * - * Must be MT SAFE - called by threads other than the main thread. - */ -void * -smalloc(uint_t nbytes) -{ - char *retvalue; - - if ((retvalue = calloc(nbytes, sizeof (char))) == NULL) { - dhcpmsg(LOG_ERR, "Cannot allocate memory (%s), exiting\n", - strerror(errno)); - exit(1); - } - return (retvalue); -} - -/* - * srealloc() -- safe realloc() - * - * Always returns a valid pointer(if it returns at all). - * If realloc() returns an error, a message is printed using the syslog() - * function and the program aborts with a status of 1. - * Unlike smalloc(), does not initialize the buffer to all zeros. - * - * Must be MT SAFE - called by threads other than the main thread. - */ -void * -srealloc(void *arg, uint_t nbytes) -{ - if ((arg = realloc(arg, nbytes)) == NULL) { - dhcpmsg(LOG_ERR, "Cannot allocate memory (%s), exiting\n", - strerror(errno)); - exit(1); - } - return (arg); -} - -/* - * Matches the speficied ip address with our owner_ip addresses. - * Returns NULL if no match is found. - */ -struct in_addr * -match_ownerip(in_addr_t new) -{ - struct in_addr *oip = owner_ip; - - while (oip->s_addr != INADDR_ANY && oip->s_addr != new) - oip++; - return ((oip->s_addr != INADDR_ANY) ? oip : NULL); -} - -/* - * qualify_hostname() -- concatenate host "." domain "." NULL - */ -int -qualify_hostname(char *fqname, const char *host, const char *domain, - int host_length, int domain_length) -{ - char *fqptr; - - if (domain_length + host_length + 2 > NS_MAXDNAME) { - dhcpmsg(LOG_ERR, "qualify_hostname: FQDN too long\n"); - return (-1); - } - - fqptr = fqname; - - (void) memcpy(fqptr, host, host_length); - fqptr += host_length; - - *fqptr = '.'; - fqptr++; - - (void) memcpy(fqptr, domain, domain_length); - fqptr += domain_length; - - *fqptr = '.'; - *(fqptr+1) = '\0'; - - return (0); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/per_dnet.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/per_dnet.c deleted file mode 100644 index f3d40c3fd0..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/per_dnet.c +++ /dev/null @@ -1,639 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/sysmacros.h> -#include <assert.h> -#include <errno.h> -#include <syslog.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/mman.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <netinet/in_systm.h> -#include <arpa/inet.h> -#include <net/if.h> -#include <netinet/dhcp.h> -#include "dhcpd.h" -#include "interfaces.h" -#include <locale.h> - -/* - * This file contains the access routines for the dhcp databases. - */ - -static dsvc_dnet_t *get_dnet(struct in_addr *); -static boolean_t unhash_dnet(dsvc_dnet_t *, boolean_t); -static int dnet_cmp(dsvc_dnet_t *, dsvc_dnet_t *); -static dsvc_clnt_t *get_client(hash_tbl *, uchar_t *, uchar_t); -static int clnt_cmp(dsvc_clnt_t *, dsvc_clnt_t *); -static boolean_t unhash_clnt(dsvc_clnt_t *, boolean_t); -static boolean_t unhash_offer(dsvc_clnt_t *, boolean_t); - -static hash_tbl *ntable; /* global per net datastore table */ - -/* - * Initialize global per network hash table. - * - * Per-bucket rwlocks reduce lock contention between interface and - * client threads. - * - * Performance: dynamically calculate hash table size. - */ -int -initntab(void) -{ - char **listppp; - uint_t cnt = 0; - uint_t ind; - - if (list_dd(&datastore, DSVC_DHCPNETWORK, &listppp, &cnt) == - DSVC_SUCCESS) { - if (listppp) { - for (ind = 0; listppp[ind] != NULL && ind < cnt; - ind++) - free(listppp[ind]); - free(listppp); - } - } - ntable = hash_Init(cnt, unhash_dnet, MAX(net_thresh, clnt_thresh), - B_TRUE); - return (ntable == NULL ? -1 : 0); -} - -/* - * open_dnet: Open the appropriate dhcp database given a network address and - * a subnet mask. These in_addr's are expected in network order. - * - * Returns: DSVC_SUCCESS for success or dsvc error. - */ -int -open_dnet(dsvc_dnet_t **pndp, struct in_addr *net, struct in_addr *mask) -{ - int err; - dsvc_dnet_t *pnd; - struct in_addr datum; - int hsize = 0; - uint32_t query; - dn_rec_t dn; - uint_t count; - struct in_addr *oip; - - datum.s_addr = net->s_addr; - datum.s_addr &= mask->s_addr; - - *pndp = NULL; - /* Locate existing dnet. */ - if ((pnd = get_dnet(&datum)) != NULL) { - (void) mutex_lock(&pnd->pnd_mtx); - if ((pnd->flags & DHCP_PND_ERROR) != 0) { - (void) mutex_unlock(&pnd->pnd_mtx); - close_dnet(pnd, B_TRUE); - return (DSVC_INTERNAL); - } else if ((pnd->flags & DHCP_PND_CLOSING) != 0) { - (void) mutex_unlock(&pnd->pnd_mtx); - close_dnet(pnd, B_FALSE); - return (DSVC_BUSY); - } else { - (void) mutex_unlock(&pnd->pnd_mtx); - *pndp = pnd; - return (DSVC_SUCCESS); - } - } - - /* Allocate new dnet. */ - - pnd = (dsvc_dnet_t *)smalloc(sizeof (dsvc_dnet_t)); - pnd->net.s_addr = datum.s_addr; - pnd->subnet.s_addr = mask != 0 ? mask->s_addr : htonl(INADDR_ANY); - (void) inet_ntop(AF_INET, &datum, pnd->network, sizeof (pnd->network)); - - /* Allocate hash tables. */ - if (max_clients != -1) - hsize = max_clients; - if ((pnd->ctable = - hash_Init(hsize, unhash_clnt, MAX(off_secs, clnt_thresh), - B_TRUE)) == NULL) { - free(pnd); - return (DSVC_INTERNAL); - } - if ((pnd->itable = - hash_Init(hsize, unhash_offer, off_secs, B_TRUE)) == NULL) { - free(pnd->ctable); - free(pnd); - return (DSVC_INTERNAL); - } - - err = dhcp_open_dd(&pnd->dh, &datastore, DSVC_DHCPNETWORK, pnd->network, - DSVC_READ|DSVC_WRITE); - - if (err != DSVC_SUCCESS) { - free(pnd->ctable); - free(pnd->itable); - free(pnd); - return (err); - } - - /* Find out how many addresses the server owns in this datastore */ - - pnd->naddrs = 0; - for (oip = owner_ip; oip->s_addr != INADDR_ANY; oip++) { - - DSVC_QINIT(query); - DSVC_QEQ(query, DN_QSIP); - dn.dn_sip.s_addr = ntohl(oip->s_addr); - - err = lookup_dd(pnd->dh, B_FALSE, query, -1, &dn, NULL, &count); - - if (err != DSVC_SUCCESS) { - free(pnd->ctable); - free(pnd->itable); - free(pnd); - return (err); - } - - pnd->naddrs += count; - } - - if ((pnd->hand = hash_Insert(ntable, &pnd->net, sizeof (struct in_addr), - dnet_cmp, pnd, pnd)) == NULL) { - /* Another thread has begun work on this net. */ -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, "Duplicate network: %s\n", pnd->network); -#endif /* DEBUG */ - free(pnd->ctable); - free(pnd->itable); - free(pnd); - return (DSVC_BUSY); - } - - (void) mutex_init(&pnd->pnd_mtx, USYNC_THREAD, NULL); - (void) mutex_init(&pnd->thr_mtx, USYNC_THREAD, NULL); - (void) mutex_init(&pnd->free_mtx, USYNC_THREAD, NULL); - (void) mutex_init(&pnd->lru_mtx, USYNC_THREAD, NULL); - (void) mutex_init(&pnd->lrupage_mtx, USYNC_THREAD, NULL); - - *pndp = pnd; - return (DSVC_SUCCESS); -} - -/* - * close_dnet: Closes specified dhcp-network database. - * - * delete - immediately delete. - */ -void -close_dnet(dsvc_dnet_t *pnd, boolean_t delete) -{ - hash_Rele(pnd->hand, delete); -} - -/* - * get_dnet: Given a network name, look it up in the hash table. - * Returns ptr to dsvc_dnet_t structure, NULL if error occurs. - */ -static dsvc_dnet_t * -get_dnet(struct in_addr *netp) -{ - dsvc_dnet_t tpnd; - dsvc_dnet_t *pnd; - - tpnd.net.s_addr = netp->s_addr; - pnd = (dsvc_dnet_t *)hash_Lookup(ntable, netp, - sizeof (struct in_addr), dnet_cmp, &tpnd, B_TRUE); - - /* refresh pnd hash entry timer */ - if (pnd != NULL) - hash_Dtime(pnd->hand, time(NULL) + ntable->dfree_time); - return (pnd); -} - -/* - * unhash_dnet: Free a datastore reference. - * - * Aging in hash routines will trigger freeing of unused references. - */ -/*ARGSUSED*/ -static boolean_t -unhash_dnet(dsvc_dnet_t *pnd, boolean_t force) -{ - int err = 0; - dsvc_pendclnt_t *workp; - dsvc_thr_t *thrp; - timestruc_t tm; - int nthreads; - int refcnt; - - if (pnd == NULL) - return (B_FALSE); - - /* Mark as closing. */ - (void) mutex_lock(&pnd->pnd_mtx); - pnd->flags |= DHCP_PND_CLOSING; - (void) mutex_unlock(&pnd->pnd_mtx); - - /* - * Wait for any remaining thread(s) to exit. - */ - refcnt = hash_Refcount(pnd->hand); - - (void) mutex_lock(&pnd->thr_mtx); - nthreads = pnd->nthreads; - while (nthreads > 0 || refcnt > 0) { - /* - * Wait for 1ms to avoid stalling monitor threads. - * cond_wait() not used to avoid thread synchronization - * overhead. - */ - tm.tv_sec = 0; - tm.tv_nsec = 1000 * 10; - (void) cond_reltimedwait(&pnd->thr_cv, &pnd->thr_mtx, &tm); - nthreads = pnd->nthreads; - (void) mutex_unlock(&pnd->thr_mtx); - /* Threads will exit. */ - for (thrp = pnd->thrhead; thrp; thrp = thrp->thr_next) { - (void) mutex_lock(&thrp->thr_mtx); - thrp->thr_flags |= DHCP_THR_EXITING; - (void) mutex_unlock(&thrp->thr_mtx); - (void) cond_signal(&thrp->thr_cv); - } - refcnt = hash_Refcount(pnd->hand); - (void) mutex_lock(&pnd->thr_mtx); - } - - /* Free threads. */ - while ((thrp = pnd->thrhead) != NULL) { - pnd->thrhead = pnd->thrhead->thr_next; - (void) mutex_destroy(&thrp->thr_mtx); - free(thrp); - } - pnd->thrtail = NULL; - - /* Free deferred thread work. */ - while ((workp = pnd->workhead) != NULL) { - pnd->workhead = pnd->workhead->pnd_next; - free(workp); - } - pnd->worktail = NULL; - (void) mutex_unlock(&pnd->thr_mtx); - - /* Free clients. */ - if (pnd->ctable) { - hash_Reset(pnd->ctable, unhash_clnt); - free(pnd->ctable); - } - - /* Free cached datastore records. */ - (void) mutex_lock(&pnd->free_mtx); - if (pnd->freerec != NULL) - dhcp_free_dd_list(pnd->dh, pnd->freerec); - (void) mutex_unlock(&pnd->free_mtx); - - (void) mutex_lock(&pnd->lru_mtx); - if (pnd->lrurec != NULL) - dhcp_free_dd_list(pnd->dh, pnd->lrurec); - (void) mutex_unlock(&pnd->lru_mtx); - - if (pnd->itable) { - hash_Reset(pnd->itable, unhash_offer); - free(pnd->itable); - } - - (void) mutex_lock(&pnd->lrupage_mtx); - if (pnd->lrupage) { - free(pnd->lrupage); - pnd->lrupage = NULL; - } - (void) mutex_unlock(&pnd->lrupage_mtx); - - if (pnd->dh != NULL) { - if (dhcp_close_dd(&pnd->dh) != DSVC_SUCCESS) { - dhcpmsg(LOG_ERR, - "Error %d while closing for network %s\n", - err, pnd->network); - } - pnd->dh = NULL; - } - - (void) mutex_destroy(&pnd->pnd_mtx); - (void) mutex_destroy(&pnd->thr_mtx); - (void) mutex_destroy(&pnd->free_mtx); - (void) mutex_destroy(&pnd->lru_mtx); - (void) mutex_destroy(&pnd->lrupage_mtx); - free(pnd); - - return (B_TRUE); -} - -/* - * dnet_cmp: Compare datastore references by network address. - */ -static int -dnet_cmp(dsvc_dnet_t *m1, dsvc_dnet_t *m2) -{ - return (m1->net.s_addr == m2->net.s_addr); -} - -/* - * open_clnt: Open the appropriate dhcp client given a network - * database and client id. - * - * Returns: DSVC_SUCCESS for success or errno if an error occurs. - * - * pnd - per net struct - * pcdp - client struct returned here - * cid - clientid - * cid_len - cid length - * nocreate - if set, client struct must previously exist - */ -int -open_clnt(dsvc_dnet_t *pnd, dsvc_clnt_t **pcdp, uchar_t *cid, - uchar_t cid_len, boolean_t nocreate) -{ - dsvc_clnt_t *pcd; - time_t now; - uint_t blen; - - *pcdp = NULL; - - /* Network is closing. */ - if ((pnd->flags & DHCP_PND_CLOSING) != 0) - return (DSVC_BUSY); - - /* Locate existing client. */ - if ((pcd = get_client(pnd->ctable, cid, cid_len)) != NULL) { - (void) mutex_lock(&pcd->pcd_mtx); - /* Client is closing - temporarily busy. */ - if ((pcd->flags & DHCP_PCD_CLOSING) != 0) { - (void) mutex_unlock(&pcd->pcd_mtx); - close_clnt(pcd, B_FALSE); - return (DSVC_BUSY); - } - (void) mutex_unlock(&pcd->pcd_mtx); - *pcdp = pcd; - return (DSVC_SUCCESS); - } - if (nocreate == B_TRUE) - return (DSVC_NOENT); - - /* Allocate new client. */ - (void) mutex_lock(&pnd->thr_mtx); - if (max_clients != -1) { - now = time(NULL); - /* - * Performance/DOS: dsvc_clnt_t structs are normally - * freed when the protocol conversation completes, - * or when garbage collected (see hash.c). In - * certain error scenarios (e.g. DOS attacks, or - * network failures where large numbers of clients - * begin protocol conversations that never complete) - * the server will become unresponsive. To detect - * these scenarios, free slot time is observed, and - * after a grace period (2 * the offer time the currently - * allocated clients are allowed), clients are randomly - * deleted. - */ - if (pnd->nclients < max_clients) { - /* Keep track of last time there were free slots. */ - pnd->clnt_stamp = now; - (void) mutex_unlock(&pnd->thr_mtx); - } else if (pnd->clnt_stamp + off_secs > now) { - /* Wait for other clients to complete. */ - (void) mutex_unlock(&pnd->thr_mtx); - return (DSVC_INTERNAL); - } else { - /* Forcibly delete a client to free a slot. */ - pnd->clnt_stamp = now; - (void) mutex_unlock(&pnd->thr_mtx); - hash_Reap(pnd->ctable, unhash_clnt); - } - } else - (void) mutex_unlock(&pnd->thr_mtx); - - pcd = (dsvc_clnt_t *)smalloc(sizeof (dsvc_clnt_t)); - (void) mutex_init(&pcd->pcd_mtx, USYNC_THREAD, NULL); - (void) mutex_init(&pcd->pkt_mtx, USYNC_THREAD, NULL); - (void) mutex_lock(&pcd->pcd_mtx); - pcd->pkthead = pcd->pkttail = NULL; - pcd->pnd = pnd; - (void) memcpy(pcd->cid, cid, cid_len); - pcd->cid_len = cid_len; - blen = sizeof (pcd->cidbuf); - (void) octet_to_hexascii(cid, cid_len, pcd->cidbuf, &blen); - - if ((pcd->chand = hash_Insert(pnd->ctable, cid, cid_len, clnt_cmp, - pcd, pcd)) == NULL) { - /* Another thread has begun work on this client */ -#ifdef DEBUG - dhcpmsg(LOG_DEBUG, "Duplicate client\n"); -#endif /* DEBUG */ - (void) mutex_unlock(&pcd->pcd_mtx); - (void) mutex_destroy(&pcd->pcd_mtx); - (void) mutex_destroy(&pcd->pkt_mtx); - free(pcd); - return (DSVC_BUSY); - } - (void) mutex_unlock(&pcd->pcd_mtx); - (void) mutex_lock(&pnd->thr_mtx); - pnd->nclients++; - (void) mutex_unlock(&pnd->thr_mtx); - *pcdp = pcd; - return (DSVC_SUCCESS); -} - -/* - * close_clnt: Closes specified client. - * - * delete - immediately delete. - */ -void -close_clnt(dsvc_clnt_t *pcd, boolean_t delete) -{ - hash_Rele(pcd->chand, delete); -} - -/* - * get_client: Given a client name, look it up in the per client hash table. - * Returns ptr to dsvc_clnt_t structure, NULL if error occurs. - */ -static dsvc_clnt_t * -get_client(hash_tbl *table, uchar_t *cid, uchar_t cid_len) -{ - dsvc_clnt_t tpcd; - dsvc_clnt_t *pcd; - - (void) memcpy(tpcd.cid, cid, cid_len); - tpcd.cid_len = cid_len; - - pcd = (dsvc_clnt_t *)hash_Lookup(table, cid, cid_len, clnt_cmp, - &tpcd, B_TRUE); - - /* refresh client hash entry's timer */ - if (pcd != NULL) { - (void) mutex_lock(&pcd->pcd_mtx); - hash_Dtime(pcd->chand, time(NULL) + table->dfree_time); - (void) mutex_unlock(&pcd->pcd_mtx); - } - return (pcd); -} - -/* - * unhash_clnt: Free a client structure. - * - * Aging in hash routines will trigger freeing of unused references. - */ -/*ARGSUSED*/ -static boolean_t -unhash_clnt(dsvc_clnt_t *pcd, boolean_t force) -{ - dsvc_dnet_t *pnd = pcd->pnd; - timestruc_t tm; - int refcnt; - struct in_addr off_ip; - - - refcnt = hash_Refcount(pcd->chand); - - /* - * Wait for thread(s) accessing pcd to drop references. - */ - (void) mutex_lock(&pcd->pcd_mtx); - pcd->flags |= DHCP_PCD_CLOSING; /* client no longer usable... */ - while (pcd->clnt_thread != NULL || refcnt > 0) { - /* - * Wait for 1ms to avoid stalling monitor threads. - * cond_wait() not used to avoid thread synchronization - * overhead. - */ - tm.tv_sec = 0; - tm.tv_nsec = 1000 * 10; - (void) cond_reltimedwait(&pcd->pcd_cv, &pcd->pcd_mtx, &tm); - (void) mutex_unlock(&pcd->pcd_mtx); - refcnt = hash_Refcount(pcd->chand); - (void) mutex_lock(&pcd->pcd_mtx); - } - - if (pcd->pkthead != NULL) - free_pktlist(pcd); - - off_ip.s_addr = pcd->off_ip.s_addr; - (void) mutex_unlock(&pcd->pcd_mtx); - - if (off_ip.s_addr != htonl(INADDR_ANY)) - purge_offer(pcd, B_TRUE, B_FALSE); - - if (pcd->dnlp != NULL) - dhcp_free_dd_list(pnd->dh, pcd->dnlp); - - (void) mutex_destroy(&pcd->pcd_mtx); - (void) mutex_destroy(&pcd->pkt_mtx); - free(pcd); - - (void) mutex_lock(&pnd->thr_mtx); - pnd->nclients--; - (void) mutex_unlock(&pnd->thr_mtx); - - return (B_TRUE); -} - -/* - * unhash_offer: Free offer associated with a client structure. - * - * Aging in hash routines will trigger freeing of expired offers. - */ -static boolean_t -unhash_offer(dsvc_clnt_t *pcd, boolean_t force) -{ - IF *ifp = pcd->ifp; - boolean_t ret = B_TRUE; - char ntoab[INET_ADDRSTRLEN]; - - (void) mutex_lock(&pcd->pcd_mtx); - if (pcd->off_ip.s_addr != htonl(INADDR_ANY) && - PCD_OFFER_TIMEOUT(pcd, time(NULL))) { - if (pcd->clnt_thread == NULL) { - if (debug) - dhcpmsg(LOG_INFO, "Freeing offer: %s\n", - inet_ntop(AF_INET, &pcd->off_ip, - ntoab, sizeof (ntoab))); - pcd->off_ip.s_addr = htonl(INADDR_ANY); - (void) mutex_unlock(&pcd->pcd_mtx); - (void) mutex_lock(&ifp->ifp_mtx); - if (ifp->offers > 0) - ifp->offers--; - ifp->expired++; - (void) mutex_unlock(&ifp->ifp_mtx); - } else if (force == B_FALSE) { - /* - * Worker thread is currently active. To avoid - * unnecessary thread synchronization, defer - * freeing the offer until the worker thread has - * completed. - */ - (void) mutex_unlock(&pcd->pcd_mtx); - hash_Age(pcd->ihand); - ret = B_FALSE; - } else - (void) mutex_unlock(&pcd->pcd_mtx); - } else - (void) mutex_unlock(&pcd->pcd_mtx); - return (ret); -} - -/* - * clnt_cmp: Compare client structures by cid. - */ -static int -clnt_cmp(dsvc_clnt_t *m1, dsvc_clnt_t *m2) -{ - return (m1->cid_len == m2->cid_len && - memcmp((char *)m1->cid, (char *)m2->cid, m1->cid_len) == 0); -} - -/* - * clnt_netcmp Compare clients by network address. This is used to maintain - * the itable hash table of client addresses. - */ -int -clnt_netcmp(dsvc_clnt_t *d1, dsvc_clnt_t *d2) -{ - return (d1->off_ip.s_addr == d2->off_ip.s_addr); -} - -/* - * close_clnts: Free the ntable hash table and associated client structs. - * Table walk frees each per network and client struct. - */ -void -close_clnts(void) -{ - hash_Reset(ntable, unhash_dnet); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/per_dnet.h b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/per_dnet.h deleted file mode 100644 index 8672e86ad8..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/per_dnet.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _PER_DSTORE_H -#define _PER_DSTORE_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * per_dnet.h -- DHCP-datastore database definitions. - */ - -/* - * DHCP thread deferred work structure. One per deferred client thread. - * - * Track clients who cannot be immediately serviced due - * to a lack of available client threads. Locked by thr_mtx. - */ -typedef struct dsvc_pending { - uchar_t pnd_cid[DN_MAX_CID_LEN]; /* cid */ - uchar_t pnd_cid_len; /* cid length */ - struct dsvc_pending *pnd_next; /* next */ -} dsvc_pendclnt_t; - -/* - * DHCP thread structure. One per client thread. - * - * Performance: create and track each client thread, using - * thr_suspend/thr_resume, rather than slower thread creation - * and deletion. Locked by thr_mtx. - */ -struct clnt; -typedef struct dsvc_free { - thread_t thr_tid; /* thread id */ - cond_t thr_cv; /* suspend/resume cv */ - mutex_t thr_mtx; /* suspend/resume mutex */ - uint_t thr_flags; /* suspend/resume flags */ - struct clnt *thr_pcd; /* per client data struct */ - struct dsvc_free *thr_next; /* next */ -} dsvc_thr_t; - -/* - * DHCP thread structure flags - */ -#define DHCP_THR_LIST 0x1 /* Thread is on freelist */ -#define DHCP_THR_EXITING 0x2 /* Thread is exiting */ - -/* - * DHCP datastore table. One per active network or dhcptab datastore. - * - * Timestamps are used to age the datastore structure, and any cached - * datastore free or lru records managed in select_offer(). - * The number of threads and clients can be controlled via MAX_THREADS - * and MAX_CLIENTS server parameters. - * - * Client and offer hashes provide fast lookup/reservation. - * Per-bucket rwlocks implemented in the hash routines reduce - * lock contention between clients. - * - * To minimize expensive datastore activity, threads synchronize to - * manage cached free and lru datastore records, which have the - * same lifetime as cached offers, which can be controlled via - * the OFFER_CACHE_TIMEOUT server parameter. - */ -typedef struct dnet { - hash_handle hand; /* hash insertion handle */ - time_t free_mtime; /* macro table purge time */ - time_t free_stamp; /* D_OFFER freerec purge time */ - time_t lru_mtime; /* macro table purge time */ - time_t lru_stamp; /* D_OFFER lrurec purge time */ - time_t clnt_stamp; /* D_OFFER client purge time */ - uint_t flags; /* dnet flags */ - struct in_addr net; /* network */ - struct in_addr subnet; /* subnet mask */ - int naddrs; /* # addrs owned by server */ - int nthreads; /* number of active threads */ - int nclients; /* number of active clients */ - hash_tbl *ctable; /* per client hash table */ - hash_tbl *itable; /* per ipaddr hash table */ - dsvc_thr_t *thrhead; /* free thread list */ - dsvc_thr_t *thrtail; /* free thread list tail */ - dsvc_pendclnt_t *workhead; /* head of thread work list */ - dsvc_pendclnt_t *worktail; /* tail of thread work list */ - dn_rec_list_t *freerec; /* free records head */ - dn_rec_list_t *lrurec; /* lru records head */ - dn_rec_list_t **lrupage; /* lru records sort area */ - size_t lrusize; - - dsvc_handle_t dh; /* datastore handle */ - mutex_t pnd_mtx; /* open/close mutex */ - mutex_t free_mtx; /* lock for free records */ - mutex_t lru_mtx; /* lock for lru records */ - mutex_t lrupage_mtx; /* lock for lru page */ - mutex_t thr_mtx; /* lock for thread work list */ - cond_t thr_cv; /* cond var (nthreads == 0) */ - char network[INET_ADDRSTRLEN]; /* display buffer */ -} dsvc_dnet_t; - -/* - * DHCP datastore table flags - */ -#define DHCP_PND_CLOSING 0x1 /* Dstore is closing */ -#define DHCP_PND_ERROR 0x2 /* Dstore experienced error */ - -/* - * DHCP datastore table macros - */ -#define PND_FREE_TIMEOUT(pnd, now) ((pnd)->free_stamp < (now) || \ - (pnd)->free_mtime != reinit_time) -#define PND_LRU_TIMEOUT(pnd, now) ((pnd)->lru_stamp < (now) || \ - (pnd)->lru_mtime != reinit_time) - -struct interfaces; - -/* - * DHCP client. One per active client, per network. - * - * Timestamps are used to age the client structure, and any cached - * offer, which can be controlled via the OFFER_CACHE_TIMEOUT server - * parameter, and the -t option, and SIGHUP signal. - * - * The original datastore record is cached, along with offer information, - * for use if the datastore record is modified. - * - * The clnt struct may appear on the client hash table, and offer hash table, - * depending on the validity of the current offer. A different dsvc_clnt_t - * is used for each link, to allow independent aging of client and offer. - */ -typedef struct clnt { - hash_handle chand; /* hash insertion handle: client hash */ - hash_handle ihand; /* hash insertion handle: inet hash */ - time_t mtime; /* macro table offer purge time */ - uint_t flags; /* Client flags */ - uint_t state; /* Client DHCP state */ - struct in_addr off_ip; /* Offered address */ - struct interfaces *ifp; /* the ifp the packet arrived on */ - dsvc_dnet_t *pnd; /* the per network datastore */ - PKT_LIST *pkthead; /* head of client packet list */ - PKT_LIST *pkttail; /* tail of client packet list */ - uint_t pending; /* # of pkts on client packet list */ - lease_t lease; /* Offered lease time */ - dsvc_thr_t *clnt_thread; /* client thread */ - - dn_rec_list_t *dnlp; /* Original datastore record */ - mutex_t pcd_mtx; /* overall struct lock */ - mutex_t pkt_mtx; /* lock for PKT_LIST */ - cond_t pcd_cv; /* cond var (clnt_thread == 0) */ - char cidbuf[DHCP_MAX_OPT_SIZE]; /* display buffer */ - uchar_t cid[DN_MAX_CID_LEN]; /* Offered cid */ - uchar_t cid_len; /* Offered cid length */ -} dsvc_clnt_t; - -/* - * Per Client flags and indices - */ -#define DHCP_HDR_CLIENT 0x0 /* clnt dsvc_clnt_t */ -#define DHCP_HDR_OFFER 0x1 /* offer dsvc_clnt_t */ - -#define DHCP_PCD_OFFER 0x1 /* Offered ip addr is valid */ -#define DHCP_PCD_WORK 0x2 /* Client is on deferred work list */ -#define DHCP_PCD_CLOSING 0x4 /* Client thread should exit */ - -/* - * Per Client macros - */ -#define PCD_OFFER_TIMEOUT(pcd, now) (hash_Htime(pcd->ihand) < (now) || \ - (pcd)->mtime != reinit_time) - -/* - * Datastore hash table dynamic data free timeout values - */ -#define DHCP_CLIENT_THRESHOLD 90 /* Time to free inactive clients */ -#define DHCP_NET_THRESHOLD 900 /* Time to free inactive nets */ - -/* - * Datastore database access routines. - */ -extern int open_dnet(dsvc_dnet_t **, struct in_addr *, struct in_addr *); -extern void close_dnet(dsvc_dnet_t *, boolean_t); - -/* - * Per Client hash and utility routines. - */ -extern int open_clnt(dsvc_dnet_t *, dsvc_clnt_t **, uchar_t *, uchar_t, - boolean_t); -extern void close_clnt(dsvc_clnt_t *, boolean_t); -extern int clnt_netcmp(dsvc_clnt_t *, dsvc_clnt_t *); -extern void close_clnts(void); -extern void purge_offer(dsvc_clnt_t *, boolean_t, boolean_t); - -#ifdef __cplusplus -} -#endif - -#endif /* _PER_DSTORE_H */ diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/relay.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/relay.c deleted file mode 100644 index 33f5ff620a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/relay.c +++ /dev/null @@ -1,303 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1996-2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <sys/types.h> -#include <assert.h> -#include <sys/socket.h> -#include <sys/sockio.h> -#include <net/if.h> -#include <errno.h> -#include <netdb.h> -#include <string.h> -#include <sys/syslog.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netinet/dhcp.h> -#include "dhcpd.h" -#include "per_dnet.h" -#include "interfaces.h" -#include <locale.h> - -#define MAX_RELAY_IP 5 /* Maximum of destinations */ - -static struct in_addr relay_ip[MAX_RELAY_IP]; /* IPs of targets */ -static struct in_addr relay_net[MAX_RELAY_IP]; /* target nets */ -static int relay_reply(IF *, PKT_LIST *); -static int relay_request(IF *, PKT_LIST *); - -/* - * This file contains the code which implements the BOOTP relay agent. - */ - -/* - * Parse arguments. If an agument begins with a digit, then it's - * an IP address, otherwise it's a hostname which needs to be - * resolved into an IP address. - * - * Use the arguments to fill in relay_ip array. - * - * Only callable by main thread. MT UNSAFE - */ -int -relay_agent_init(char *args) -{ - int i; - struct in_addr *ip; - struct hostent *hp; - char ntoab[INET_ADDRSTRLEN]; - - for (i = 0; i <= MAX_RELAY_IP; i++) { - if ((args = strtok(args, ",")) == NULL) - break; /* done */ - - /* - * If there's more than MAX_RELAY_IP addresses - * specified that's an error. If we can't - * resolve the host name, that's an error. - */ - if (i == MAX_RELAY_IP) { - (void) fprintf(stderr, - gettext("Too many relay agent destinations.\n")); - return (E2BIG); - } - - if ((hp = gethostbyname(args)) == NULL) { - (void) fprintf(stderr, gettext( - "Invalid relay agent destination name: %s\n"), - args); - return (EINVAL); - } - /* LINTED [will be lw aligned] */ - ip = (struct in_addr *)hp->h_addr; - - /* - * Note: no way to guess at destination subnet mask, - * and verify that it's not a new broadcast addr. - */ - if (ip->s_addr == INADDR_ANY || - ip->s_addr == INADDR_LOOPBACK || - ip->s_addr == INADDR_BROADCAST) { - (void) fprintf(stderr, gettext("Relay destination \ -cannot be 0, loopback, or broadcast address.\n")); - return (EINVAL); - } - - relay_ip[i].s_addr = ip->s_addr; - - ip = &relay_ip[i]; - get_netmask(ip, &relay_net[i]); - relay_net[i].s_addr &= ip->s_addr; - if (verbose) { - (void) fprintf(stdout, - gettext("Relay destination: %s (%s)"), - inet_ntop(AF_INET, &relay_ip[i], - ntoab, sizeof (ntoab)), args); - (void) fprintf(stdout, gettext("\t\tnetwork: %s\n"), - inet_ntop(AF_INET, &relay_net[i], - ntoab, sizeof (ntoab))); - } - args = NULL; /* for next call to strtok() */ - } - if (i == 0) { - /* - * Gotta specify at least one IP addr. - */ - (void) fprintf(stderr, - gettext("Specify at least one relay agent destination.\n")); - return (ENOENT); - } - if (i < MAX_RELAY_IP) - relay_ip[i].s_addr = NULL; /* terminate the list */ - - return (0); -} - -/* - * Note: if_head_mtx must be held by caller, as the interface list is - * walked in relay_reply. - * - * MT SAFE - */ -int -relay_agent(IF *ifp, PKT_LIST *plp) -{ - if (plp->pkt->op == BOOTREQUEST) - return (relay_request(ifp, plp)); - - return (relay_reply(ifp, plp)); -} - -/* - * MT SAFE - */ -static int -relay_request(IF *ifp, PKT_LIST *plp) -{ - PKT *pkp; - struct sockaddr_in to; - struct in_addr ifnet, any; - int i; - char ntoab[INET_ADDRSTRLEN]; - char buf[DN_MAX_CID_LEN], *msg; - - pkp = plp->pkt; - if (pkp->giaddr.s_addr == 0L) - pkp->giaddr.s_addr = ifp->addr.s_addr; - pkp->hops++; - - /* - * Send it on to the next relay(s)/servers - */ - to.sin_port = htons(IPPORT_BOOTPS + port_offset); - any.s_addr = htonl(INADDR_ANY); - (void) disp_cid(plp, buf, sizeof (buf)); - - for (i = 0; i < MAX_RELAY_IP; i++) { - if (relay_ip[i].s_addr == 0L) - break; /* we're done */ - - ifnet.s_addr = ifp->addr.s_addr & ifp->mask.s_addr; - if (relay_net[i].s_addr == ifnet.s_addr) { - if (verbose) { - dhcpmsg(LOG_INFO, "Target's network: \ -%1$s is the same as client %2$s network, ignored.\n", - inet_ntop(AF_INET, &relay_net[i], - ntoab, sizeof (ntoab)), - buf); - } - continue; /* skip this target */ - } - - to.sin_addr.s_addr = relay_ip[i].s_addr; - - if (to.sin_port == htons(IPPORT_BOOTPS + port_offset)) - msg = "Relaying request %1$s to %2$s, server port.\n"; - else - msg = "Relaying request %1$s to %2$s, client port.\n"; - - if (debug) { - dhcpmsg(LOG_INFO, msg, buf, - inet_ntop(AF_INET, &to.sin_addr, - ntoab, sizeof (ntoab))); - } - - if (write_interface(ifp, pkp, plp->len, &to)) { - dhcpmsg(LOG_INFO, "Cannot relay request %1$s to %2$s\n", - buf, inet_ntop(AF_INET, &to.sin_addr, - ntoab, sizeof (ntoab))); - } else { - logtrans(P_BOOTP, L_RELAY_REQ, 0, any, to.sin_addr, - plp); - } - } - return (0); -} - -/* - * Note: if_head_mtx must be held by caller, as the interface list is - * walked here. - */ -static int -relay_reply(IF *ifp, PKT_LIST *plp) -{ - int err; - IF *tifp; - PKT *pkp = plp->pkt; - struct in_addr to; - char buf[DHCP_MAX_OPT_SIZE]; - char ntoab_a[INET_ADDRSTRLEN], ntoab_b[INET_ADDRSTRLEN]; - - assert(MUTEX_HELD(&if_head_mtx)); - - if (pkp->giaddr.s_addr == 0L) { - /* - * Somehow we picked up a reply packet from a DHCP server - * on this net intended for a client on this net. Drop it. - */ - if (verbose) { - dhcpmsg(LOG_INFO, - "Reply packet without giaddr set ignored.\n"); - } - return (0); - } - - /* - * We can assume that the message came directly from a dhcp/bootp - * server to us, and we are to address it directly to the client. - */ - if (pkp->giaddr.s_addr != ifp->addr.s_addr) { - /* - * It is possible that this is a multihomed host. We'll - * check to see if this is the case, and handle it - * appropriately. - */ - for (tifp = if_head; tifp != NULL; tifp = tifp->next) { - if (tifp->addr.s_addr == pkp->giaddr.s_addr) - break; - } - - if (tifp == NULL) { - if (verbose) { - dhcpmsg(LOG_INFO, "Received relayed reply \ -not intended for this interface: %1$s giaddr: %2$s\n", - inet_ntop(AF_INET, &ifp->addr, - ntoab_a, sizeof (ntoab_a)), - inet_ntop(AF_INET, &pkp->giaddr, - ntoab_b, sizeof (ntoab_b))); - } - return (0); - } else - ifp = tifp; - } - - (void) disp_cid(plp, buf, sizeof (buf)); - pkp->hops++; - - if (debug) - dhcpmsg(LOG_INFO, "Relaying reply to client %s\n", buf); - - if ((ntohs(pkp->flags) & BCAST_MASK) == 0) { - if (pkp->yiaddr.s_addr == htonl(INADDR_ANY)) { - if (pkp->ciaddr.s_addr == htonl(INADDR_ANY)) { - dhcpmsg(LOG_INFO, "No destination IP \ -address or network IP address; cannot send reply to client: %s.\n", buf); - return (0); - } - to.s_addr = pkp->ciaddr.s_addr; - } else - to.s_addr = pkp->yiaddr.s_addr; - } - - if ((err = send_reply(ifp, pkp, plp->len, &to)) == 0) - logtrans(P_BOOTP, L_RELAY_REP, 0, ifp->addr, to, plp); - - return (err); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/Makefile b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/Makefile deleted file mode 100644 index 7e016815e5..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# -# cmd/cmd-inet/usr.lib/in.dhcpd/tests/Makefile -# - -COMMON_NET = $(SRC)/common/net/dhcp - -PROG = test_client -OBJS = test_client.o -SRCS = $(OBJS:%.o=%.c) - -DPROG = test_dstore -DOBJS = test_dstore.o -DSRCS = $(OBJS:%.o=%.c) - -MPROG = mkdstore -MOBJS = mkdstore.o -MSRCS = $(OBJS:%.o=%.c) - -include ../../../../Makefile.cmd - -DLIBS = -linetutil -ldhcpsvc -lsocket -lnsl -lmtmalloc -LDLIBS += $(DLIBS) -CPPFLAGS += -g -DNDEBUG -D_REENTRANT -I$(COMMON_NET) -LINTFLAGS += -Xt - -.KEEP_STATE: - -all: $(PROG) $(DPROG) $(MPROG) - -$(PROG): $(OBJS) - $(LINK.c) $(OBJS) -o $@ $(LDLIBS) - $(POST_PROCESS) - -$(DPROG): $(DOBJS) - $(LINK.c) $(DOBJS) -o $@ $(LDLIBS) - $(POST_PROCESS) - -$(MPROG): $(MOBJS) - $(LINK.c) $(MOBJS) -o $@ $(LDLIBS) - $(POST_PROCESS) - -%.o: $(COMMON_NET)/%.c - $(COMPILE.c) $(OUTPUT_OPTION) $< - $(POST_PROCESS_O) - -clean: - $(RM) $(OBJS) $(DOBJS) $(MOBJS) - -install: - $(ECHO) "Nothing to Install" >&2 - - -lint: - $(LINT.c) $(PROG).c $(ENVLDLIBS1) $(DLIBS) - $(LINT.c) $(DPROG).c $(ENVLDLIBS1) $(DLIBS) - $(LINT.c) $(MPROG).c $(ENVLDLIBS1) $(DLIBS) - -include ../../../../Makefile.targ diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/get_number_test.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/get_number_test.c deleted file mode 100644 index 688aca1af2..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/get_number_test.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -#ident "%Z%%M% %I% %E% SMI" - -/* - * Copyright (c) 1996, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#include <stdio.h> -#include <ctype.h> -#include <sys/types.h> - -/* - * More generic than get_u_long. Supports byte, short, long, longlong. - * Returns 0 for success, -1 for failure. - */ -int -get_number(char **src, void *dest, int len) -{ - register unsigned base; - register char c; - - if (len != 1 && (len % 2) != 0 || len > 8) - return (-1); /* not valid */ - /* - * Collect number up to first illegal character. Values are specified - * as for C: 0x=hex, 0=octal, other=decimal. - */ - base = 10; - if (**src == '0') { - base = 8; - (*src)++; - } - if (**src == 'x' || **src == 'X') { - base = 16, - (*src)++; - } - - while (c = **src) { - if (isdigit(c)) { - switch (len) { - case 1: - *(u_char *) dest = - (*(u_char *) dest) * base + (c - '0'); - break; - case 2: - *(u_short *) dest = (*(u_short *) dest) * - base + (c - '0'); - break; - case 4: - *(u_long *) dest = (*(u_long *) dest) * - base + (c - '0'); - break; - case 8: - *(u_longlong_t *) dest = - (*(u_longlong_t *) dest) * base + - (c - '0'); - break; - } - (*src)++; - continue; - } - if (base == 16 && isxdigit(c)) { - switch (len) { - case 1: - *(u_char *) dest = - ((*(u_char *) dest) << 4) + ((c & ~32) + - 10 - 'A'); - break; - case 2: - *(u_short *) dest = - ((*(u_short *) dest) << 4) + ((c & ~32) + - 10 - 'A'); - break; - case 4: - *(u_long *) dest = - ((*(u_long *) dest) << 4) + ((c & ~32) + - 10 - 'A'); - break; - case 8: - *(u_longlong_t *) dest = - ((*(u_longlong_t *) dest) << 4) + - ((c & ~32) + 10 - 'A'); - break; - } - (*src)++; - continue; - } - break; - } - return (0); -} -main() -{ - char *src; - u_char one; - u_short two; - u_long four; - u_longlong_t eight; - - /* - * Try single octet (dec) - */ - src = "a56"; - one = 0; - if (get_number(&src, (void *) &one, 1) != 0) - printf("byte failed.\n"); - else - printf("byte: %d\n", one); - - src = "65535"; - two = 0; - if (get_number(&src, (void *) &two, 2) != 0) - printf("short failed.\n"); - else - printf("short: %d\n", two); - - src = "4294967296"; - four = 0; - if (get_number(&src, (void *) &four, 4) != 0) - printf("long failed.\n"); - else - printf("long: %d\n", four); - - src = "4289672944289672944"; - eight = 0; - if (get_number(&src, (void *) &eight, 8) != 0) - printf("longlong failed.\n"); - else - printf("longlong: %d\n", eight); - - - - /* - * Try single octet (hex) - */ - src = "0xff"; - one = 0; - if (get_number(&src, (void *) &one, 1) != 0) - printf("byte failed.\n"); - else - printf("byte: 0x%x\n", one); - - src = "0xffff"; - two = 0; - if (get_number(&src, (void *) &two, 2) != 0) - printf("short failed.\n"); - else - printf("short: 0x%x\n", two); - - src = "0xffffffff"; - four = 0; - if (get_number(&src, (void *) &four, 4) != 0) - printf("long failed.\n"); - else - printf("long: 0x%x\n", four); - - src = "0xffffffffffffffff"; - eight = 0; - if (get_number(&src, (void *) &eight, 8) != 0) - printf("longlong failed.\n"); - else - printf("longlong: 0x%x\n", eight); - - /* - * Try single octet (Oct) - */ - src = "0376"; - one = 0; - if (get_number(&src, (void *) &one, 1) != 0) - printf("byte failed.\n"); - else - printf("byte: 0x%x\n", one); - - src = "0177776"; - two = 0; - if (get_number(&src, (void *) &two, 2) != 0) - printf("short failed.\n"); - else - printf("short: 0x%x\n", two); - - src = "037777777776"; - four = 0; - if (get_number(&src, (void *) &four, 4) != 0) - printf("long failed.\n"); - else - printf("long: 0x%x\n", four); - - src = "01777777777777777777776"; - eight = 0; - if (get_number(&src, (void *) &eight, 8) != 0) - printf("longlong failed.\n"); - else - printf("longlong: 0x%x\n", eight); - return (0); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/mkdstore.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/mkdstore.c deleted file mode 100644 index 0b30377918..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/mkdstore.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2001-2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * mkdstore: fast datastore creation program. - * - * mkdstore <table> <nrecords> <cid> <flags> <cip> <sip> <lease> <comment> - */ - -#include <stdio.h> -#include <netdb.h> - -#include <string.h> -#include <stdlib.h> -#include <rpcsvc/nis.h> - -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <errno.h> -#include <assert.h> -#include <string.h> -#include <syslog.h> -#include <sys/socket.h> -#include <net/if.h> -#include <netinet/in.h> -#include <netinet/if_ether.h> -#include <arpa/inet.h> -#include <netinet/dhcp.h> -#include <netdb.h> -#include <locale.h> -#include <signal.h> -#include <tnf/probe.h> - -#include <dhcp_svc_confopt.h> -#include <dhcp_svc_private.h> -#include <dhcp_impl.h> - -dsvc_handle_t dh; /* data handle */ -dsvc_datastore_t datastore; /* Datastore for container access */ -uint_t nrecords; -char network[INET_ADDRSTRLEN]; -struct in_addr net; - -/* - * mkdstore <table> <nrecords> <cid> <flags> <cip> <sip> <lease> <macro> - * <comment> - */ -main(int c, char **v) -{ - long long cid; - uchar_t flags; - struct in_addr cip; - struct in_addr sip; - int i, j; - char **entries; - uint_t lease; - char *network = v[1]; - int ct = strtol(v[2], 0L, 0L); - char *server; - char *macro; - int err; - uint32_t query; - dn_rec_t dn; - dn_rec_list_t *dncp = NULL; - dhcp_confopt_t *dsp = NULL; - -#ifdef DEBUG - mallocctl(MTDEBUGPATTERN, 1); - mallocctl(MTINITBUFFER, 1); -#endif /* DEBUG */ - - if (c == 1) { - (void) fprintf(stderr, "/*\n * mkdstore <table> <nrecords> " - "<cid> <flags> <cip> <sip> <lease> <comment>\n*/"); - return (0); - } - - cid = (c > 3) ? strtoul(v[3], 0L, 0L) : 0; - flags = (c > 4) ? (char)strtol(v[4], 0L, 0L) : 0; - cip.s_addr = (c > 5) ? strtoul(v[5], 0L, 0L) : 0; - sip.s_addr = (c > 6) ? strtoul(v[6], 0L, 0L) : 0; - lease = (c > 7) ? strtoul(v[7], 0L, 0L) : 0; - macro = (c > 8) ? v[8] : 0; - server = (c > 9) ? v[9] : "unknown"; - - entries = (char **) malloc(ct * (sizeof (char *) * 8 + 4)); - - /* Load current datastore. */ - (void) read_dsvc_conf(&dsp); - if ((i = confopt_to_datastore(dsp, &datastore)) != DSVC_SUCCESS) { - (void) fprintf(stderr, "Invalid datastore: %s\n", - dhcpsvc_errmsg(i)); - return (EINVAL); - } - err = open_dd(&dh, &datastore, DSVC_DHCPNETWORK, network, - DSVC_READ | DSVC_WRITE); - - if (err != DSVC_SUCCESS) { - (void) fprintf(stderr, "Invalid network: %s trying create...\n", - dhcpsvc_errmsg(err)); - - err = open_dd(&dh, &datastore, DSVC_DHCPNETWORK, network, - DSVC_READ | DSVC_WRITE | DSVC_CREATE); - if (err != DSVC_SUCCESS) { - (void) fprintf(stderr, "Can't create network: %s\n", - dhcpsvc_errmsg(err)); - return (err); - } - } - /* XXXX: bug: currently can't get the count as advertised */ - (void) memset(&dn, '\0', sizeof (dn)); - DSVC_QINIT(query); - err = lookup_dd(dh, B_FALSE, query, -1, - (const void *) &dn, (void **) &dncp, &nrecords); - if (dncp) - free_dd_list(dh, dncp); - - if (err != DSVC_SUCCESS) { - (void) fprintf(stderr, "Bad nrecords: %s [%d]\n", - dhcpsvc_errmsg(err), nrecords); - return (err); - } - - for (i = 0, j = 0; i < ct; i++) { - TNF_PROBE_1(main, "main", - "main%debug 'in function main'", - tnf_ulong, record, i); - if (cid) { - (void) memcpy(dn.dn_cid, &cid, sizeof (long long)); - dn.dn_cid_len = 7; - } else { - (void) memset(dn.dn_cid, '\0', sizeof (long long)); - dn.dn_cid_len = 1; - } - dn.dn_sig = 0; - dn.dn_flags = flags; - dn.dn_cip.s_addr = cip.s_addr; - dn.dn_sip.s_addr = sip.s_addr; - dn.dn_lease = lease; - strcpy(dn.dn_macro, macro); - strcpy(dn.dn_comment, server); - (void) add_dd_entry(dh, &dn); - if (cid) - cid += 0x100; - cip.s_addr++; - - TNF_PROBE_0(main_end, "main", ""); - } - (void) close_dd(&dh); - - return (0); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/test_client.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/test_client.c deleted file mode 100644 index 9aae3f7e95..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/test_client.c +++ /dev/null @@ -1,1446 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <stdio_ext.h> -#include <stdlib.h> -#include <unistd.h> -#include <ctype.h> -#include <string.h> -#include <syslog.h> -#include <signal.h> -#include <time.h> -#include <limits.h> -#include <sys/resource.h> -#include <sys/fcntl.h> -#include <sys/types.h> -#include <fcntl.h> -#include <sys/resource.h> -#include <sys/stat.h> -#include <sys/systeminfo.h> -#include <sys/socket.h> -#include <sys/sockio.h> -#include <net/if.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <errno.h> -#include <sys/stropts.h> -#include <netinet/dhcp.h> -#include <dhcp_impl.h> -#include <synch.h> -#include <netdb.h> -#include <locale.h> -#include <mtmalloc.h> -#include <tnf/probe.h> -#include <libinetutil.h> - -struct client { - thread_t id; - PKT_LIST *pktlistp; - cond_t cv; - cond_t acv; - mutex_t mtx; - int proto; - uchar_t chaddr[20]; - char chost[40]; - int hlen; - uint_t xid; - int flags; - time_t ltime; - int state; -}; - -#define CLIENT_BUSY 0x1 -#define CLIENT_FIRSTTIME 0x2 - -ushort_t port_offset = 0; /* offset to port for multiple server */ -int fast = 0; /* higher load */ -int bound = 0; /* only broadcast on given interface */ -int lrecv = 1; /* only receive on given interface */ -static struct in_addr relay; /* spoof being a relay agent */ -static struct sockaddr_in from, relfrom; -static int clients, s, srelay = -1; -static struct client *clientsp; - -static PKT request; -static char ifname[IFNAMSIZ]; -static int startindex; -static mutex_t go_mtx; -static cond_t go_cv; -static boolean_t time_to_go; -static int release_time = 0; -static int desynch = 1; -static double avg = 0; -static timespec_t avgslp; -static volatile ulong_t tops, otops; -static volatile ulong_t minops[6]; -static volatile time_t mintim[6]; -static volatile int minind; -long sample_time = 10L; -long nsamples = 2; - -static volatile ulong_t ops_outstanding; -static time_t start, ostart; -int verbose = 0; -int dohost = 0; -int randcl = 0; -int randhlen = 0; -int randerr = 0; -int dos = 0; -int dofork = 0; -int printid = 0; - -static time_t ltime; -static struct lifreq lifr; - -static void corrupt(char *, int); - -static void -dhcpmsgtype(uchar_t pkt, char *buf) -{ - char *p; - - switch (pkt) { - case DISCOVER: - p = "DISCOVER"; - break; - case OFFER: - p = "OFFER"; - break; - case REQUEST: - p = "REQUEST"; - break; - case DECLINE: - p = "DECLINE"; - break; - case ACK: - p = "ACK"; - break; - case NAK: - p = "NAK"; - break; - case RELEASE: - p = "RELEASE"; - break; - case INFORM: - p = "INFORM"; - break; - default: - p = "UNKNOWN"; - break; - } - - (void) strcpy(buf, p); -} - -static int -closeif(int ms, char *cifname, struct sockaddr_in *myip, thread_t myself) -{ - struct ifreq ifr; - int error = 0; - - (void) strcpy(ifr.ifr_name, cifname); - if (ioctl(ms, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) { - (void) fprintf(stderr, - "Client %04d - can't get interface flags on %s\n", myself, - cifname); - error = 7; - } - ifr.ifr_flags &= ~IFF_UP; - if (ioctl(ms, SIOCSIFFLAGS, (caddr_t)&ifr) < 0) { - (void) fprintf(stderr, - "Client %04d - can't set interface flags on %s\n", myself, - cifname); - error = 7; - } - myip->sin_addr.s_addr = htonl(INADDR_ANY); - ifr.ifr_addr = *(struct sockaddr *)myip; - if (ioctl(ms, SIOCSIFADDR, (caddr_t)&ifr)) { - (void) fprintf(stderr, - "Client %04d - Can't unset address on %s\n", myself, - cifname); - error = 8; - } - (void) close(ms); - return (error); -} - -static void * -client(void *args) -{ - PKT crequest, *irequestp; - PKT_LIST *bp = NULL, *wbp, *twbp; - struct client *mep = (struct client *)args; - time_t retry_time = 2, lease, sleep_time = 0; - uchar_t *endp; - boolean_t done, config, timeout; - int nstate, ms = -1; - DHCP_OPT *optp, *unused_optp; - timespec_t ts, tr; - int error = 0; - thread_t myself = thr_self(); - struct sockaddr_in to, myip, maskip; - struct in_addr serverip; - time_t start_time, expired = 0; - char cid[BUFSIZ]; - char cifname[IFNAMSIZ]; - char host[40]; - char domain[40]; - char p[30], np[30]; - struct ifreq ifr; - int moldy; - int i; - uint_t cidlen; - char *domainp; - -forever: - if (bp) { - (void) free(bp->pkt); - (void) free(bp); - bp = NULL; - } - if (!time_to_go) { - (void) mutex_lock(&mep->mtx); - mep->flags &= ~CLIENT_BUSY; - if (mep->flags & CLIENT_FIRSTTIME) { - mep->flags &= ~CLIENT_FIRSTTIME; - } else { - tops++; - ops_outstanding--; - } - if (avg) - (void) cond_wait(&mep->acv, &mep->mtx); - mep->flags |= CLIENT_BUSY; - mep->ltime = time(NULL); - ops_outstanding++; - (void) mutex_unlock(&mep->mtx); - } - if (desynch) - (void) sleep((desynch & myself) + 3); /* desynch clients */ - if (verbose == 1) - (void) fprintf(stdout, "Client %04d - started.\n", myself); - start_time = time(NULL); - (void) sprintf(cifname, "%s:%d", ifname, startindex + myself); - - /* reset client addr each time */ - if (relay.s_addr != INADDR_ANY) { - to.sin_addr.s_addr = relay.s_addr; - } else { - to.sin_addr.s_addr = INADDR_BROADCAST; - } - to.sin_port = htons(IPPORT_BOOTPS + port_offset); - to.sin_family = AF_INET; - - domain[0] = host[0] = NULL; - if (randcl) { - /* Further randomize. */ - if (randhlen > 0) { - mep->hlen = randhlen; - } - - for (i = 3; i < mep->hlen; i++) { - mep->chaddr[i] = random() & 0xff; - } - } - - (void) memcpy(&crequest, &request, sizeof (request)); - (void) memcpy(crequest.chaddr, mep->chaddr, mep->hlen); - crequest.hlen = mep->hlen; - - - if (mep->proto) { - mep->state = DISCOVER; - optp = (DHCP_OPT *) & crequest.options[3]; /* skip TYPE */ - optp->code = CD_CLIENT_ID; - optp->len = mep->hlen + 1; - optp->value[0] = 0x01; - (void) memcpy(&optp->value[1], mep->chaddr, mep->hlen); - cidlen = sizeof (cid); - (void) octet_to_hexascii(optp->value, mep->hlen + 1, cid, - &cidlen); - unused_optp = (DHCP_OPT *) & optp->value[mep->hlen + 1]; - } else { - mep->state = 0; - cidlen = sizeof (cid); - (void) octet_to_hexascii(mep->chaddr, mep->hlen, cid, &cidlen); - unused_optp = (DHCP_OPT *)&crequest.options[3]; /* skip TYPE */ - } - - /* Use global descriptor at first */ - ms = s; - - myip.sin_addr.s_addr = htonl(INADDR_ANY); - done = B_FALSE; - config = B_FALSE; - do { - timeout = B_FALSE; - - TNF_PROBE_2(client, - "client", - "client%debug 'in func client'", - tnf_ulong, state, mep->state, - tnf_string, cid, (char *)cid); - - if (time_to_go) { - if (mep->state == ACK) { - mep->state = RELEASE; - if (verbose == 1) - (void) fprintf(stderr, - "Client %04d - RELEASEing %s\n", - myself, inet_ntoa(myip.sin_addr)); - else if (verbose == 2) - fprintf(stderr, "[%d %s]", - clientsp[i].id, - inet_ntoa(myip.sin_addr)); - optp = (DHCP_OPT *) crequest.options; - (void) memset((char *)unused_optp, 0, - (int)((char *)&crequest.options[ - sizeof (crequest.options)] - - (char *)unused_optp)); - optp->value[0] = RELEASE; - } else { - done = B_TRUE; - if (verbose == 1) - (void) fprintf(stderr, - "Client %04d - terminated.\n", - myself); - break; - } - } else if (release_time || avg) { - if (mep->state == ACK) { - - /* lru testing: don't release lease */ - if (randcl & 0x2) { - done = B_FALSE; - mep->state = nstate = 0; - sleep_time = 0; - if (bp) { - (void) free(bp->pkt); - (void) free(bp); - bp = NULL; - } - goto forever; - } - mep->state = RELEASE; - if (verbose == 1) - (void) fprintf(stderr, - "Client %04d - RELEASEing %s\n", - myself, inet_ntoa(myip.sin_addr)); - else if (verbose == 2) - fprintf(stderr, "[%d %s]", - clientsp[i].id, - inet_ntoa(myip.sin_addr)); - optp = (DHCP_OPT *) crequest.options; - (void) memset((char *)unused_optp, 0, - (int)((char *)&crequest.options[ - sizeof (crequest.options)] - - (char *)unused_optp)); - optp->value[0] = RELEASE; - } - } - if (mep->state == REQUEST && expired < time(NULL)) { - /* drop back to INIT state. */ - if (verbose == 1) - (void) fprintf(stderr, - "Client %04d - Dropping back to INIT.\n", - myself); - done = B_FALSE; - mep->state = nstate = 0; - sleep_time = 0; - if (bp) { - (void) free(bp->pkt); - (void) free(bp); - bp = NULL; - } - goto forever; - } - if (mep->state == RELEASE && !time_to_go) { - (void) mutex_lock(&mep->mtx); - tops++; - ops_outstanding--; - mep->flags &= ~CLIENT_BUSY; - if (avg) - (void) cond_wait(&mep->acv, &mep->mtx); - mep->ltime = time(NULL); - ops_outstanding++; - mep->flags |= CLIENT_BUSY; - (void) mutex_unlock(&mep->mtx); - } - /* Send request... */ - crequest.secs = htons((ushort_t)(time(NULL) - start_time)); - crequest.xid = htonl((myself << 2) + mep->xid++); - - /* Randomly corrupt packets of a certain type. */ - if ((randerr & 0xF) == mep->state || (randerr & 0xF) == 0xF) { - if (randerr & 0x10) { - /* Randomly corrupt entire request. */ - corrupt((char *)&crequest, sizeof (crequest)); - } else { - /* Randomly corrupt options. */ - corrupt((char *)&crequest.options[3], - sizeof (crequest.options) - 3); - } - } - - if (sendto(ms, (char *)&crequest, sizeof (PKT), 0, - (struct sockaddr *)&to, sizeof (struct sockaddr)) < 0) { - perror("Sendto"); - error = 4; - thr_exit(&error); - } - if (mep->state == RELEASE) { - done = B_TRUE; - if (!avg) { - (void) strcpy(ifr.ifr_name, cifname); - if (ioctl(ms, SIOCGIFFLAGS, - (caddr_t)&ifr) < 0) { - (void) fprintf(stderr, "Client %04d - " - "can't get interface flags on %s\n", - myself, cifname); - error = 7; - } - ifr.ifr_flags &= ~IFF_UP; - if (ioctl(ms, SIOCSIFFLAGS, - (caddr_t)&ifr) < 0) { - (void) fprintf(stderr, "Client %04d - " - "can't set interface flags on %s\n", - myself, cifname); - error = 7; - } - myip.sin_addr.s_addr = htonl(INADDR_ANY); - ifr.ifr_addr = *(struct sockaddr *)&myip; - if (ioctl(ms, SIOCSIFADDR, (caddr_t)&ifr)) { - (void) fprintf(stderr, "Client %04d - " - "Can't unset address on %s\n", - myself, cifname); - error = 8; - } - (void) close(ms); - } - if (release_time || avg) { - done = B_FALSE; - mep->state = nstate = 0; - sleep_time = 0; - if (bp) { - (void) free(bp->pkt); - (void) free(bp); - bp = NULL; - } - goto forever; - } - break; - } - /* await reply */ -moldy: - (void) mutex_lock(&mep->mtx); - ts.tv_sec = time(NULL) + retry_time; - ts.tv_nsec = 0; - - while (mep->pktlistp == NULL) - if (cond_timedwait(&mep->cv, &mep->mtx, &ts) == ETIME) { - timeout = B_TRUE; - if (retry_time > 64) - retry_time = 2; - else if (fast) - retry_time += 2; - else - retry_time *= 2; - break; - } else { - if (time_to_go) - break; - } - (void) mutex_unlock(&mep->mtx); - - if (time_to_go || timeout) - continue; - - (void) mutex_lock(&mep->mtx); - moldy = 0; - if (bp) { - (void) free(bp->pkt); - (void) free(bp); - } - bp = NULL; - wbp = mep->pktlistp; - while (wbp != NULL) { - irequestp = wbp->pkt; - if (bp == NULL && irequestp->op == BOOTREPLY && - memcmp(&crequest.xid, &irequestp->xid, - sizeof (crequest.xid)) == 0) { - bp = wbp; - wbp = wbp->next; - continue; - } - (void) free(wbp->pkt); - twbp = wbp; - wbp = wbp->next; - (void) free(twbp); - if (verbose == 1) - (void) fprintf(stderr, - "Client %04d - Moldy xid\n", myself); - moldy++; - } - - mep->pktlistp = NULL; - (void) mutex_unlock(&mep->mtx); - - if (bp == NULL) { - if (moldy > 0) - goto moldy; - - continue; - } - irequestp = bp->pkt; - - if (mep->proto) { - /* - * Scan for CD_DHCP_TYPE, CD_SERVER_ID, and - * CD_LEASE_TIME if proto. - */ - nstate = 0; - maskip.sin_addr.s_addr = serverip.s_addr = INADDR_ANY; - maskip.sin_family = AF_INET; - lease = (time_t)0; - optp = (DHCP_OPT *) irequestp->options; - endp = (uchar_t *)irequestp + bp->len; - host[0] = NULL; - while ((uchar_t *)optp < (uchar_t *)endp) { - switch (optp->code) { - case CD_HOSTNAME: - (void) strncpy(host, - (const char *)optp->value, - optp->len); - host[optp->len] = '\0'; - break; - case CD_DNSDOMAIN: - (void) strncpy(domain, - (const char *)optp->value, - optp->len); - domain[optp->len] = '\0'; - break; - case CD_DHCP_TYPE: - nstate = optp->value[0]; - break; - case CD_SUBNETMASK: - (void) memcpy(&maskip.sin_addr, - optp->value, - sizeof (struct in_addr)); - break; - case CD_SERVER_ID: - (void) memcpy(&serverip, optp->value, - sizeof (struct in_addr)); - break; - case CD_LEASE_TIME: - (void) memcpy(&lease, optp->value, - sizeof (time_t)); - lease = htonl(lease); - break; - } - optp = (DHCP_OPT *) & optp->value[optp->len]; - } - if (mep->state == DISCOVER && nstate == OFFER) { - mep->state = REQUEST; - expired = time(NULL) + 60; - /* - * Add in the requested IP address option and - * server ID. - */ - optp = (DHCP_OPT *) crequest.options; - optp->value[0] = REQUEST; - optp = unused_optp; /* step over CD_DHCP_TYPE */ - optp->code = CD_REQUESTED_IP_ADDR; - optp->len = sizeof (struct in_addr); - (void) memcpy(optp->value, &irequestp->yiaddr, - sizeof (struct in_addr)); - optp = (DHCP_OPT *) & optp->value[ - sizeof (struct in_addr)]; - optp->code = CD_SERVER_ID; - optp->len = sizeof (struct in_addr); - (void) memcpy(optp->value, &serverip, - sizeof (struct in_addr)); - optp = (DHCP_OPT *) & optp->value[ - sizeof (struct in_addr)]; - if (dohost == 0) { - if (bp) { - (void) free(bp->pkt); - (void) free(bp); - bp = NULL; - } - continue; - } - - if (domain[0] == '\0' && host[0] != '\0' && - (domainp = strchr(host, '.')) != NULL) { - (void) snprintf(domain, sizeof (domain), - "%s", domainp); - } - - if (dohost & 0x2) { - cidlen = sizeof (cid); - (void) octet_to_hexascii(mep->chaddr, - mep->hlen, host, &cidlen); - - if (domain[0]) - (void) snprintf(host, - sizeof (host), "%s.%s", - cid, domain); - else - (void) snprintf(host, - sizeof (host), "%s", cid); - } - - optp->code = CD_HOSTNAME; - optp->len = strlen(host); - (void) memcpy(optp->value, host, strlen(host)); - optp->value[strlen(host)] = '\0'; - if (randcl && (random() & 0x1)) { - /* create a random name */ - for (i = 0; i < optp->len && - optp->value[i] != '.'; i++) - if (i & 1) - optp->value[i] = '0' + - (mep->chaddr[i] & 0x7); - else - optp->value[i] = 'a' + - (mep->chaddr[i] & 0x7); - strcpy((char *)mep->chost, - (const char *)optp->value); - } else if (randcl && mep->chost[0]) { - /* use the previous one */ - optp->len = strlen(mep->chost); - (void) memcpy(optp->value, mep->chost, - strlen(mep->chost)); - optp->value[strlen(mep->chost)] = '\0'; - } - if (bp) { - (void) free(bp->pkt); - (void) free(bp); - bp = NULL; - } - continue; - } else if ((mep->state == REQUEST || - mep->state == ACK) && nstate == ACK) { - /* - * we're bound. defend the lease. Add the - * address to our interface. Due to the - * service architecture of this program, we - * can't unset the broadcast bit.. - */ - mep->state = ACK; - nstate = 0; - retry_time = 2; - myip.sin_family = AF_INET; - myip.sin_addr.s_addr = irequestp->yiaddr.s_addr; - crequest.ciaddr.s_addr = myip.sin_addr.s_addr; - optp = unused_optp; - optp->code = CD_LEASE_TIME; - optp->len = sizeof (time_t); - (void) memcpy(optp->value, &lease, - sizeof (time_t)); - optp = (DHCP_OPT *) - & optp->value[sizeof (time_t)]; - (void) memset((char *)optp, 0, (int)((char *) - &crequest.options[ - sizeof (crequest.options)] - - (char *)optp)); - to.sin_addr.s_addr = serverip.s_addr; - - if (lease == -1) { - done = B_TRUE; /* permanent lease */ - sleep_time = 0; - } else { - sleep_time = lease / 2; - lease = time(NULL) + lease; - } - - if (release_time || avg) { - sleep_time = release_time; - done = B_FALSE; - } - if (verbose == 1) - (void) fprintf(stdout, - "Client %04d(%s) - DHCP: %s == %s", - myself, cid, - inet_ntoa(myip.sin_addr), - (lease == -1) ? "Forever\n" : - ctime(&lease)); - else if (verbose == 2) - fprintf(stderr, "(%d %s)", mep->id, - cid); - if (!config && !avg) { - /* Add mask and address */ - if ((ms = socket(AF_INET, SOCK_DGRAM, - 0)) < 0) { - (void) fprintf(stderr, - "Client %04d - can't open " - "DGRAM socket.\n", myself); - error = 7; - break; - } - (void) strcpy(ifr.ifr_name, cifname); - ifr.ifr_addr = - *(struct sockaddr *)&myip; - /* - * XXXX: needed in on81 - * for initial - * interface creation - */ - (void) (ioctl(ms, SIOCLIFADDIF, - (caddr_t)&ifr)); - (void) strcpy(ifr.ifr_name, cifname); - ifr.ifr_addr = - *(struct sockaddr *)&maskip; - if (ioctl(ms, SIOCSIFNETMASK, - (caddr_t)&ifr)) { - (void) fprintf(stderr, - "Client %04d - Can't set " - "netmask: %s on %s\n", - myself, - inet_ntoa(maskip.sin_addr), - cifname); - error = 7; - (void) close(ms); - break; - } - if (ioctl(ms, SIOCGIFFLAGS, - (caddr_t)&ifr) < 0) { - (void) fprintf(stderr, - "Client %04d - can't get " - "interface flags on %s\n", - myself, cifname); - error = 7; - (void) close(ms); - break; - } - ifr.ifr_flags |= IFF_UP; - if (ioctl(ms, SIOCSIFFLAGS, - (caddr_t)&ifr) < 0) { - (void) fprintf(stderr, - "Client %04d - can't set " - "interface flags on %s\n", - myself, cifname); - error = 7; - (void) close(ms); - break; - } - ifr.ifr_addr = - *(struct sockaddr *)&myip; - if (ioctl(ms, SIOCSIFADDR, - (caddr_t)&ifr)) { - (void) fprintf(stderr, - "Client %04d - Can't set " - "address on %s\n", - myself, cifname); - error = 8; - (void) close(ms); - break; - } - config = B_TRUE; - } - if (sleep_time != 0) { - /* Go to sleep for 50% of lease time. */ - tr.tv_sec = time(NULL) + sleep_time; - if (verbose == 1) - (void) fprintf(stderr, - "Client %04d - sleeping " - "until %s", myself, - ctime(&tr.tv_sec)); - tr.tv_nsec = 0; - (void) mutex_lock(&go_mtx); - while (!time_to_go) { - if (cond_timedwait(&go_cv, - &go_mtx, &tr) == ETIME) - break; - } - (void) mutex_unlock(&go_mtx); - if (verbose == 1) - (void) fprintf(stderr, - "Client %04d - awake\n", - myself); - } - } else if (mep->state == ACK && nstate == NAK) { - /* drop back to INIT state. */ - if (verbose == 1) { - (void) fprintf(stdout, "Client %04d - " - "DHCP: we got NAKed.\n", myself); - (void) fprintf(stderr, "Client %04d - " - "Dropping back to INIT.\n", myself); - } - if (!avg) - (void) closeif(ms, cifname, - &myip, myself); - done = B_FALSE; - mep->state = nstate = 0; - sleep_time = 0; - if (bp) { - (void) free(bp->pkt); - (void) free(bp); - bp = NULL; - } - goto forever; - } else { - dhcpmsgtype(nstate, np); - dhcpmsgtype(mep->state, p); - (void) fprintf(stderr, "Client %04d - " - "unexpected mesg: %s, when I'm in state: " - "%s.\n", myself, np, p); - error = 9; - break; - } - } else { - done = B_TRUE; /* BOOTP is done */ - if (verbose == 1) - (void) fprintf(stdout, - "Client %04d(%s) - BOOTP: %s\n", myself, - cid, inet_ntoa(irequestp->yiaddr)); - if (release_time || avg) { - done = B_FALSE; - mep->state = nstate = 0; - sleep_time = 0; - if (bp) { - (void) free(bp->pkt); - (void) free(bp); - bp = NULL; - } - goto forever; - } - } - if (bp) { - (void) free(bp->pkt); - (void) free(bp); - bp = NULL; - } - } while (!done); - - if (!done) { - (void) fprintf(stderr, - "Client %04d - %s: configuration failed.\n", - myself, (mep->proto) ? "DHCP" : "BOOTP"); - } - wbp = mep->pktlistp; - while (wbp != NULL) { - twbp = wbp->next; - if (wbp->pkt != NULL) - (void) free(wbp->pkt); - (void) free(wbp); - wbp = twbp; - } - - thr_exit(&error); - return (NULL); /* NOTREACHED */ -} - -/* - * Never returns. Just loads client lists. - */ -static void * -service(void *args) -{ - struct client *clientp = (struct client *)args; - PKT_LIST *bp, *wbp; - PKT *irequestp; - int error = 0; - struct pollfd pfd[2]; - ulong_t *bufp; /* ulong_t to force alignment */ - int len, i; - - pfd[0].fd = s; - pfd[0].events = POLLIN | POLLPRI; - if (relay.s_addr != INADDR_ANY) { - pfd[1].fd = srelay; - pfd[1].events = POLLIN | POLLPRI; - } else { - pfd[1].fd = -1; - pfd[1].events = 0; - } - - for (;;) { - pfd[0].revents = 0; - pfd[1].revents = 0; - if (poll(pfd, (nfds_t)2, INFTIM) < 0) { - (void) fprintf(stderr, "Service - can't poll...\n"); - error = 5; - break; - } - (void) mutex_lock(&go_mtx); - if (time_to_go) { - (void) fprintf(stderr, "Service - exiting...\n"); - error = 0; - break; - } - (void) mutex_unlock(&go_mtx); - len = BUFSIZ * 2; - bufp = malloc(len); - if (pfd[0].revents) - len = recv(s, (char *)bufp, len, 0); - else { - len = recv(srelay, (char *)bufp, len, 0); - } - - if (len < 0) { - (void) fprintf(stderr, - "Service - can't receive - %s\n", strerror(errno)); - error = 6; - break; - } else { - irequestp = (PKT *) bufp; - for (i = 0; i < clients; i++) { - if (memcmp(clientp[i].chaddr, irequestp->chaddr, - clientp[i].hlen) == 0) { - (void) mutex_lock(&clientp[i].mtx); - bp = malloc(sizeof (PKT_LIST)); - bp->pkt = irequestp; - bp->len = len; - if (verbose == 1) - (void) fprintf(stderr, - "Service - received packet " - "for thread %04d...\n", - clientp[i].id); - if (clientp[i].pktlistp == NULL) { - clientp[i].pktlistp = bp; - bp->prev = NULL; - } else { - for (wbp = clientp[i].pktlistp; - wbp->next != NULL; - wbp = wbp->next) - /* null */; - wbp->next = bp; - bp->prev = wbp; - } - bp->next = NULL; - (void) cond_signal(&clientp[i].cv); - (void) mutex_unlock(&clientp[i].mtx); - break; - } - } - if (i >= clients) - free(bufp); - } - } - thr_exit(&error); - return (NULL); /* NOTREACHED */ -} - -/* ARGSUSED */ -static void * -sig_handle(void *arg) -{ - boolean_t leave = B_FALSE; - int sig; - sigset_t set; - char buf[SIG2STR_MAX]; - int old, new, unstarted; - int i; - int oldi; - uint_t cidlen; - char cid[BUFSIZ]; - int discover, offer, req, decline, ack, nak; - int release, inform, unknown; - int kicked; - ulong_t minavg; - time_t minstime; - - (void) sigfillset(&set); - - if (avg == 0) { - avgslp.tv_sec = sample_time; - avgslp.tv_nsec = 0L; - } - while (!leave) { - discover = offer = req = decline = ack = nak = 0; - release = inform = unknown = 0; - switch (sig = sigtimedwait(&set, NULL, &avgslp)) { - case SIGHUP: - case -1: - old = time(NULL); - new = unstarted = 0; - kicked = 0; - for (i = 0; i < clients; i++) { - /* Start next client at avgslp offset */ - if (avg && kicked == 0 && - (clientsp[i].flags & - (CLIENT_FIRSTTIME | CLIENT_BUSY)) == 0) { - (void) mutex_lock(&clientsp[i].mtx); - (void) cond_signal(&clientsp[i].acv); - (void) mutex_unlock(&clientsp[i].mtx); - kicked++; - } - switch (clientsp[i].state) { - case DISCOVER: - discover++; - break; - case OFFER: - offer++; - break; - case REQUEST: - req++; - break; - case DECLINE: - decline++; - break; - case ACK: - ack++; - break; - case NAK: - nak++; - break; - case RELEASE: - release++; - break; - case INFORM: - inform++; - break; - default: - unknown++; - break; - } - if (clientsp[i].ltime == NULL || - (clientsp[i].flags & CLIENT_BUSY) == 0) - unstarted++; - if (clientsp[i].ltime && - clientsp[i].ltime < old) { - old = clientsp[i].ltime; - oldi = i; - } - if (clientsp[i].ltime && - clientsp[i].ltime > new) { - new = clientsp[i].ltime; - } - } - - if (time(NULL) < ltime + sample_time) - continue; - ltime = time(NULL); - - if (start == 0) { - /* toss initial sample */ - ostart = start = time(NULL); - otops = tops = 0; - minind = 0; - } else { - minops[minind] = tops - otops; - mintim[minind] = ostart; - otops = tops; - ostart = time(NULL); - minind = minind + 1 > nsamples - 1 ? 0 : - minind + 1; - minstime = 0; - minavg = 0; - for (i = 0; i < nsamples; i++) { - if (mintim[i]) - minavg += minops[i]; - if (minstime == 0) - minstime = mintim[i]; - else if (mintim[i] && - mintim[i] < minstime) - minstime = mintim[i]; - } - - cidlen = sizeof (cid); - (void) octet_to_hexascii(clientsp[oldi].chaddr, - clientsp[oldi].hlen, cid, &cidlen); - fprintf(stderr, "%9.9d: Totops %d Curr %d " - "Persec %4.2f (%4.2f) Oldest %d (%d) " - "Gap %d Free %d\n", time(NULL), tops, - ops_outstanding, - (double)tops / (double)(time(NULL) - start), - (double)minavg / (double)(time(NULL) - - minstime), - time(NULL) - old, clientsp[oldi].id, cid, - new - old, unstarted); - fprintf(stderr, "\tdiscov %d off %d req %d " - "decl %d ack %d nak %d rel %d inf %d " - "free/unknown %d\n", discover, offer, req, - decline, ack, nak, release, inform, - unknown); - } - break; - case SIGINT: - /* FALLTHRU */ - case SIGTERM: - (void) sig2str(sig, buf); - (void) fprintf(stderr, - "Signal: %s received...Exiting\n", buf); - (void) mutex_lock(&go_mtx); - time_to_go = B_TRUE; - (void) cond_broadcast(&go_cv); - (void) mutex_unlock(&go_mtx); - for (i = 0; i < clients; i++) { - (void) mutex_lock(&clientsp[i].mtx); - (void) cond_signal(&clientsp[i].acv); - (void) mutex_unlock(&clientsp[i].mtx); - } - leave = B_TRUE; - break; - default: - (void) sig2str(sig, buf); - (void) fprintf(stderr, - "Signal: %s received...Ignoring\n", buf); - leave = B_FALSE; - break; - } - } - thr_exit((void *) NULL); - return (NULL); /* NOTREACHED */ -} - -int -main(int argc, char *argv[]) -{ - boolean_t proto; - int i, j, threrror = 0, *threrrorp; - int sockoptbuf = 1; - register char *endp, *octet; - thread_t service_id, sig_id; - sigset_t set; - uint_t buf; - int slen; - socklen_t sslen = sizeof (slen); - unsigned int ifceno; - char cifname[IFNAMSIZ]; - struct rlimit rl; - - if (randcl) - srandom(time(NULL)); - - if (dofork) { - if (fork() != 0) - exit(0); - } - if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { - (void) fprintf(stderr, "Cannot get open file limit: %s\n", - strerror(errno)); - } - /* handle cases where limit is infinity */ - if (rl.rlim_cur == RLIM_INFINITY) { - rl.rlim_cur = (rl.rlim_max == RLIM_INFINITY) ? - OPEN_MAX : rl.rlim_max; - } - /* set NOFILE to unlimited */ - rl.rlim_cur = rl.rlim_max = RLIM_INFINITY; - if (setrlimit(RLIMIT_NOFILE, &rl) < 0) { - (void) fprintf(stderr, "Cannot set open file limit: %s\n", - strerror(errno)); - } - (void) enable_extended_FILE_stdio(-1, -1); - - if (argc < 5) { - (void) fprintf(stderr, "%s <interface> <ether_addr> <protocol> " - "<clients> [time] [desynch] [avg] [relayaddr]\n", argv[0]); - return (1); - } - (void) strcpy(ifname, argv[1]); - (void) strcpy(cifname, argv[1]); - if ((endp = strchr(ifname, ':')) != NULL) { - *endp = '\0'; - startindex = strtol(endp + 1, 0L, 0L); - } - if (strcasecmp(argv[3], "dhcp") == 0) - proto = B_TRUE; - else - proto = B_FALSE; - - clients = atoi(argv[4]); - - if (argc >= 6) { - release_time = atoi(argv[5]); - } - if (argc >= 7) - desynch = atoi(argv[6]); - - if (argc >= 8) { - avg = atof(argv[7]); - if (avg > 0.0) { - avgslp.tv_sec = avg; - avgslp.tv_nsec = (avg - - (double)((int)avg)) * 1000000000.0; - } else if (avg < 0.0) { - avgslp.tv_sec = abs((int)avg); - avgslp.tv_nsec = (avg + abs((double)((int)avg))) * - 1000000000.0; - } - } - if (argc >= 9) - relay.s_addr = inet_addr(argv[8]); - - if (argc >= 10) - slen = strtol(argv[0], 0L, 0L); - else - slen = 1024 * 64; - - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - perror("Socket"); - return (1); - } - (void) setsockopt(s, SOL_SOCKET, SO_SNDBUF, &slen, sslen); - (void) setsockopt(s, SOL_SOCKET, SO_RCVBUF, &slen, sslen); - - if (relay.s_addr == INADDR_ANY) - if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, (char *)&sockoptbuf, - (int)sizeof (sockoptbuf)) < 0) { - perror("Setsockopt"); - return (2); - } - if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, - (char *)&sockoptbuf, (int)sizeof (sockoptbuf)) < 0) { - perror("Setsockopt: REUSEADDR"); - return (2); - } - if (relay.s_addr != INADDR_ANY) { - relfrom.sin_port = htons(IPPORT_BOOTPS + port_offset); - relfrom.sin_family = AF_INET; - relfrom.sin_addr.s_addr = INADDR_ANY; - relfrom.sin_port = htons(IPPORT_BOOTPS + port_offset); - - (void) strncpy(lifr.lifr_name, cifname, - sizeof (lifr.lifr_name)); - if (lrecv) { - if (ioctl(s, SIOCGLIFADDR, (char *)&lifr) < 0) { - (void) fprintf(stderr, "Warning: SIOCGLIFADDR: %s", - strerror(errno)); - } else { - relfrom.sin_addr.s_addr = - ((struct sockaddr_in *) - &lifr.lifr_addr)->sin_addr.s_addr; - } - } - - if ((srelay = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - perror("Socket"); - return (1); - } - (void) setsockopt(srelay, SOL_SOCKET, SO_SNDBUF, &slen, sslen); - (void) setsockopt(srelay, SOL_SOCKET, SO_RCVBUF, &slen, sslen); - - if (setsockopt(srelay, SOL_SOCKET, SO_REUSEADDR, - (char *)&sockoptbuf, (int)sizeof (sockoptbuf)) < 0) { - perror("Setsockopt: REUSEADDR"); - return (2); - } - if (bind(srelay, (struct sockaddr *)&relfrom, - sizeof (relfrom)) < 0) { - perror("Bind"); - return (3); - } - ifceno = if_nametoindex(cifname); - if (bound) { - if (setsockopt(s, IPPROTO_IP, IP_BOUND_IF, - (char *)&ifceno, (int)sizeof (char *)) < 0) { - perror("Setsockopt bind"); - return (3); - } - } - } - from.sin_family = AF_INET; - if (relay.s_addr != INADDR_ANY) { - from.sin_addr.s_addr = - ((struct sockaddr_in *)&lifr.lifr_addr)->sin_addr.s_addr; - } else { - from.sin_addr.s_addr = INADDR_ANY; - } - from.sin_port = htons(IPPORT_BOOTPC + port_offset); - - if (bind(s, (struct sockaddr *)&from, sizeof (from)) < 0) { - perror("Bind"); - return (3); - } - ifceno = if_nametoindex(cifname); - if (bound) { - if (setsockopt(s, IPPROTO_IP, IP_BOUND_IF, - (char *)&ifceno, (int)sizeof (char *)) < 0) { - perror("Setsockopt bind"); - return (3); - } - } - request.op = 1; /* BOOTP request */ - request.htype = 1; /* Ethernet */ - request.hlen = 6; /* Ethernet addr len */ - - endp = octet = argv[2]; - for (i = 0; i < (int)request.hlen && octet != NULL; i++) { - if ((endp = (char *)strchr(endp, ':')) != NULL) - *endp++ = '\0'; - (void) sscanf(octet, "%x", &buf); - request.chaddr[i] = (uchar_t)buf; - octet = endp; - } - - /* broadcast bit */ - if (relay.s_addr == INADDR_ANY) - request.flags = htons(0x8000); - - /* magic cookie */ - request.cookie[0] = 99; - request.cookie[1] = 130; - request.cookie[2] = 83; - request.cookie[3] = 99; - - if (proto) { - /* Pretend to be a discover packet */ - request.options[0] = CD_DHCP_TYPE; - request.options[1] = 1; - request.options[2] = DISCOVER; - request.options[3] = 0xff; - - (void) cond_init(&go_cv, USYNC_THREAD, NULL); - (void) mutex_init(&go_mtx, USYNC_THREAD, NULL); - } - if (relay.s_addr != INADDR_ANY) - request.giaddr.s_addr = from.sin_addr.s_addr; - - (void) sigfillset(&set); - - (void) sigdelset(&set, SIGABRT); /* allow for user abort */ - - (void) thr_sigsetmask(SIG_SETMASK, &set, NULL); - - /* - * Create the client threads - */ - clientsp = malloc(sizeof (struct client) * clients); - (void) memset(clientsp, 0, sizeof (struct client) * clients); - if (clientsp == NULL) - return (1); - - for (i = 0; i < clients; i++) { - (void) memcpy(clientsp[i].chaddr, request.chaddr, request.hlen); - clientsp[i].hlen = request.hlen; - if (i > 100) - j = 3; - else if (i > 50) - j = 2; - else - j = 1; - - if (i) { - clientsp[i].chaddr[j] = (unsigned char) i; - clientsp[i].chaddr[3] += (unsigned char) j; - clientsp[i].chaddr[4] = (unsigned char) (i * j); - } - if (printid) - fprintf(stderr, "ID %x:%x:%x:%x:%x:%x\n", - clientsp[i].chaddr[0], - clientsp[i].chaddr[1], - clientsp[i].chaddr[2], - clientsp[i].chaddr[3], - clientsp[i].chaddr[4], - clientsp[i].chaddr[5]); - - (void) cond_init(&clientsp[i].cv, USYNC_THREAD, 0); - (void) mutex_init(&clientsp[i].mtx, USYNC_THREAD, 0); - clientsp[i].proto = proto; - clientsp[i].flags = CLIENT_FIRSTTIME; - if (thr_create(NULL, NULL, client, (void *) &clientsp[i], - THR_BOUND | THR_SUSPENDED, &clientsp[i].id) != 0) { - (void) fprintf(stderr, "Error starting Client %04d\n", - clientsp[i].id); - } - } - - /* - * Create signal handling thread. - */ - if (thr_create(NULL, 0, sig_handle, NULL, - THR_BOUND | THR_DAEMON | THR_DETACHED, &sig_id) != 0) { - (void) fprintf(stderr, "Error starting signal handler.\n"); - return (1); - } else - (void) fprintf(stderr, "Started Signal handler: %04d...\n", - sig_id); - - /* - * Create/start the service thread. - */ - if (thr_create(NULL, NULL, service, (void *) clientsp, THR_BOUND, - &service_id) != 0) { - (void) fprintf(stderr, "Error starting Service %d\n", - service_id); - exit(1); - } else - (void) fprintf(stderr, "Started Service %04d...\n", - service_id); - - /* - * Continue the client threads. - */ - for (i = 0; i < clients; i++) { - (void) thr_continue(clientsp[i].id); - } - - /* - * join them - */ - threrrorp = &threrror; - for (i = 0; i < clients; i++) { - if (thr_join(clientsp[i].id, NULL, (void **) &threrrorp) == 0) { - if (threrror != 0) { - (void) fprintf(stdout, - "Client %04d - exited with %d\n", - clientsp[i].id, threrror); - } - (void) cond_destroy(&clientsp[i].cv); - (void) mutex_destroy(&clientsp[i].mtx); - } - } - - (void) close(s); /* force service out of poll */ - - if (thr_join(service_id, NULL, (void **) &threrrorp) == 0) { - if (threrror != 0) { - (void) fprintf(stdout, "Service - exited with %d\n", - threrror); - } - } - (void) free((char *)clientsp); - (void) fprintf(stdout, "Exiting...\n"); - - return (0); -} - -/* - * corrupt: simulate packet corruption for debugging server - */ -static void -corrupt(char *pktp, int size) -{ - int c; - int i; - int p; - char *pp; - char *pe = pktp + size; - int li = rand() % (size - 1) + 1; - - for (pp = pktp; pp < pe; pp += li) { - c = ((pe - pp) < li ? pe - pp : li); - i = (rand() % c)>>1; - while (--i > 0) { - p = (rand() % c); - pp[p] = (unsigned char)(rand() & 0xFF); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/test_dstore.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/test_dstore.c deleted file mode 100644 index d96dec51e9..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/test_dstore.c +++ /dev/null @@ -1,942 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <stdio_ext.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/time.h> -#include <fcntl.h> -#include <sys/fcntl.h> -#include <errno.h> -#include <string.h> -#include <limits.h> -#include <sys/socket.h> -#include <net/if.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <thread.h> -#include <tnf/probe.h> - -#include <netinet/dhcp.h> -#include <locale.h> -#include <signal.h> -#include <tnf/probe.h> - -#include <dhcp_svc_confopt.h> -#include <dhcp_svc_private.h> -#include <dhcp_impl.h> - -#ifdef DEBUG -#include <mtmalloc.h> -#endif /* DEBUG */ - -/* - * Global variables. - */ -int verbose = 0; -thread_t *tp; -cond_t never; -volatile time_t *timp; -volatile int tms; -char *fl; -mutex_t mtx; -mutex_t thread_mtx; -volatile ulong_t ops_outstanding; - -static volatile ulong_t tops, otops; -static volatile ulong_t minops[6]; -static volatile time_t mintim[6]; -static volatile int minind; -long sample_time = 10L; -long nsamples = 2; - -static volatile time_t start, ostart; -volatile time_t ustart; -volatile int time_to_go; -volatile int spawn_helper; -char b[1024 * 1024]; -volatile double slp; -volatile int worktype; -thread_t sigthread; -volatile int old, new, unstarted; -volatile uint_t threads; -volatile unsigned int douwork = 0; -volatile int dofsync = 0; -volatile int domalloc = 0; -volatile int dofork = 0; -thread_t opnthread; -volatile int doopen = 0; - -dsvc_datastore_t datastore; /* Datastore for container access */ - -#define MAXTABLE 1024 -int ntable; - -dn_rec_list_t *thread_dncp[MAXTABLE]; -dsvc_handle_t dh[MAXTABLE]; /* data handle */ -struct in_addr net[MAXTABLE]; -uint_t nrecords[MAXTABLE]; -char *network; - -typedef struct work { - boolean_t isthreaded; - int thread; - cond_t cv; - mutex_t mtx; - dn_rec_t *dnp; -}work_t; - -void -free_work_t(work_t *wptr) { - free(wptr->dnp); - free(wptr); -} -/* - * Simulated binary datastore work - */ -/* ARGSUSED */ -static void * -uwork(void *argp) -{ - int i; - int err; - int fd; - long block; - work_t *wptr = argp; - char *ptr; - size_t size = ((random() & (domalloc - 1)) + 0x200) & - ~(0x200 - 1); - int wtype; - - if (domalloc) - ptr = malloc(size); - else - ptr = b; - - if (wptr->isthreaded) { - (void) mutex_lock(&wptr->mtx); - } - i = wptr->thread; - - TNF_PROBE_1(uwork, "work", "uwork%debug 'in function work'", - tnf_long, size, size); - - wtype = worktype == 0 ? random() & 0x7 : worktype; - block = (random() & (douwork - 1)) + (tms / 0x200) + 1; - - /* prewrite legal records */ - if (timp[i] == NULL && ustart == 0) { - ustart = time(NULL); - wtype = 4; - block = (tms / 0x200) + 1; - size = sizeof (b); - ptr = b; - } - timp[i] = time(NULL); - fd = open(fl, O_RDWR); - (void) write(fd, (char *)timp, tms); - (void) close(fd); - - if (wtype == 4) { - - TNF_PROBE_2(uwork_write, "work", - "uwork_write%debug 'in function work'", - tnf_long, block, block, - tnf_long, size, size); - - fd = open(fl, O_RDWR); - (void) lseek(fd, block * 0x200, 0L); - err = write(fd, ptr, size); - (void) close(fd); - - TNF_PROBE_1(uwork_write_end, "work", - "uwork_write_end%debug 'in function work'", - tnf_long, err, err); - - } else if (wtype == 3 && dofsync) { - - TNF_PROBE_0(uwork_fsync, "work", - "uwork_fsync%debug 'in function work'"); - - fd = open(fl, O_RDWR); - err = fsync(fd); - (void) close(fd); - - TNF_PROBE_1(uwork_fsync_end, "work", - "uwork_fsync_end%debug 'in function work'", - tnf_long, err, err); - } else { - TNF_PROBE_2(uwork_read, "work", - "uwork_read%debug 'in function work'", - tnf_long, block, block, - tnf_long, size, size); - - fd = open(fl, O_RDWR); - (void) lseek(fd, block * 0x200, 0L); - err = read(fd, ptr, size); - (void) close(fd); - - TNF_PROBE_1(uwork_read_end, "work", - "uwork_read_end%debug 'in function work'", - tnf_long, err, err); - - } - if (domalloc && ptr != b) - free(ptr); - - if (wptr->isthreaded) { - (void) mutex_unlock(&wptr->mtx); - cond_signal(&wptr->cv); - TNF_PROBE_0(work_end, "work", ""); - thr_exit(NULL); - } - TNF_PROBE_0(uwork_end, "work", ""); - - return ((void *) NULL); -} - -/* - * Simulated datastore work - */ -static void * -work(void *argp) -{ - int i, j; - dn_rec_t *dnp; - int err; - work_t *wptr = argp; - uchar_t cid_len; - char *ptr; - uint32_t query; - dn_rec_t dn, ndn; - dn_rec_list_t *dncp = NULL; - uint_t crecords, irecords; - int wtype; - int firsttime = 0; - int op; - size_t size = ((random() & (domalloc - 1)) + 0x100) & - ~(0x1000 - 1); - int table; - - if (domalloc) - ptr = malloc(size); - else - ptr = b; - - irecords = (random() & 0xff) + 1; - if (irecords == 12) { - irecords = (uint_t)-1; - } - if (wptr->isthreaded) { - (void) mutex_lock(&wptr->mtx); - } - i = wptr->thread; - dnp = wptr->dnp; - - table = i % ntable; - dn = *dnp; - - cid_len = 7; - - if (worktype == 0) { - wtype = random() & 0x7; - if (wtype == 4) - wtype--; - } else - wtype = worktype; - - /* preload a legal record */ - if (timp[i] == NULL) { - wtype = 3; - firsttime = 1; - irecords = threads * 2; - (void) mutex_lock(&thread_mtx); - if ((dncp = thread_dncp[table]) != NULL) { - thread_dncp[table] = dncp->dnl_next; - *dnp = *(dncp->dnl_rec); - dncp->dnl_next = NULL; - wtype = -1; - (void) mutex_unlock(&thread_mtx); - } - } - TNF_PROBE_2(work, "work", "work%debug 'in function work'", - tnf_ulong, worktype, wtype, - tnf_ulong, irecords, irecords); - - timp[i] = time(NULL); - crecords = 0; - DSVC_QINIT(query); - switch (wtype) { - case -1: - break; - case 1: - switch (random() & 0x7) { - case 1: - for (j = 0; j < cid_len; j++) - dn.dn_cid[j] = random() & 0xff; - break; - case 2: - for (j = 0; j < cid_len; j++) - dn.dn_cid[j] = '\0'; - dn.dn_cid_len = 1; - break; - } - DSVC_QEQ(query, DN_QCID); - - /* LINTED */ - TNF_PROBE_2(work_cid, "work work_cid", - "work_cid%debug 'in function work'", - tnf_ulong, cid, *(ulong_t *)&dn.dn_cid, - tnf_ulong, cid_len, dn.dn_cid_len); - - err = lookup_dd(dh[table], B_TRUE, query, -1, - (const void *)&dn, (void **)&dncp, &crecords); - - TNF_PROBE_2(work_cid_end, "work work_cid", - "work_cid_end%debug 'in function work'", - tnf_ulong, err, err, - tnf_ulong, crecords, crecords); - - if (crecords > 0 && dncp) - *dnp = *(dncp->dnl_rec); - break; - - case 2: - switch (random() & 0x7) { - case 1: - dn.dn_cip.s_addr = random(); - break; - case 2: - dn.dn_cip.s_addr = net[table].s_addr | - (random() & (nrecords[table] - 1)); - break; - } - - DSVC_QEQ(query, DN_QCIP); - - TNF_PROBE_1(work_cip, "work work_cip", - "work_cip%debug 'in function work'", - tnf_ulong, cip, dn.dn_cip.s_addr); - - err = lookup_dd(dh[table], B_TRUE, query, -1, - (const void *)&dn, (void **)&dncp, &crecords); - - TNF_PROBE_2(work_cip_end, "work work_cip", - "work_cip_end%debug 'in function work'", - tnf_ulong, err, err, - tnf_ulong, crecords, crecords); - - if (crecords > 0 && dncp) - *dnp = *(dncp->dnl_rec); - break; - case 3: - op = random() & 0x7; - if (firsttime) - op = 2; - - switch (op) { - case 1: - DSVC_QNEQ(query, DN_QLEASE); - dn.dn_lease = 0; - break; - case 2: - DSVC_QEQ(query, DN_QCID); - for (j = 0; j < cid_len; j++) - dn.dn_cid[j] = '\0'; - dn.dn_cid_len = 1; - break; - } - - TNF_PROBE_2(work_read, "work work_read", - "work_read%debug 'in function work'", - tnf_ulong, query, query, - tnf_ulong, cid_len, dn.dn_cid_len); - - err = lookup_dd(dh[table], B_TRUE, query, irecords, - (const void *)&dn, (void **)&dncp, &crecords); - - TNF_PROBE_2(work_read_end, "work work_read", - "work_read_end%debug 'in function work'", - tnf_ulong, err, err, - tnf_ulong, crecords, crecords); - - if (crecords > 0 && dncp) { - *dnp = *(dncp->dnl_rec); - if (firsttime) { - thread_dncp[table] = dncp->dnl_next; - dncp->dnl_next = NULL; - mutex_unlock(&thread_mtx); - } - } - break; - case 4: - op = dnp->dn_lease & 0x3; - switch (op) { - case 0: - /* write record w/ cid */ - ndn = *dnp; - ndn.dn_lease = (htonl(time(NULL)) & ~0x3) + 1; - ndn.dn_cid_len = 14; - for (j = 0; j < ndn.dn_cid_len; j++) - ndn.dn_cid[j] = random() & 0xff; - - /* LINTED */ - TNF_PROBE_2(work1_modify, "work work1_modify", - "work1_modify%debug 'in function work'", - tnf_ulong, cid, *(ulong_t *)&ndn.dn_cid, - tnf_ulong, cid_len, ndn.dn_cid_len); - - err = modify_dd_entry(dh[table], dnp, &ndn); - if (err != DSVC_SUCCESS && verbose) { - fprintf(stderr, "work: %d %d error %d\n", - wtype, op, err); - } - - TNF_PROBE_1(work1_modify_end, "work work1_modify_end", - "work1_modify_end%debug 'in function work'", - tnf_ulong, err, err); - *dnp = ndn; - break; - case 1: - /* re-read record w/ cid */ - DSVC_QEQ(query, DN_QCID); - TNF_PROBE_2(work_read1, "work work_read1", - "work_read1%debug 'in function work'", - tnf_ulong, query, query, - tnf_ulong, cid_len, dn.dn_cid_len); - - err = lookup_dd(dh[table], B_TRUE, query, - 1, - (const void *)dnp, (void **)&dncp, - &crecords); - TNF_PROBE_2(work_read1_end, "work work_read1", - "work_read1_end%debug 'in function work'", - tnf_ulong, err, err, - tnf_ulong, crecords, crecords); - - if ((err != DSVC_SUCCESS || crecords < 1) && verbose) { - fprintf(stderr, "work: %d %d error %d %d\n", - wtype, op, err, crecords); - } - dnp->dn_lease++; - break; - case 2: - /* write free record */ - dnp->dn_lease--; - ndn = *dnp; - DSVC_QEQ(query, DN_QCID); - for (j = 0; j < cid_len; j++) - ndn.dn_cid[j] = '\0'; - ndn.dn_cid_len = 1; - ndn.dn_lease = 0; - - TNF_PROBE_2(work_modify2, "work work_modify2", - "work_modify2%debug 'in function work'", - tnf_ulong, cid, *(ulong_t *)&ndn.dn_cid, - tnf_ulong, cid_len, ndn.dn_cid_len); - - err = modify_dd_entry(dh[table], dnp, &ndn); - - TNF_PROBE_1(work_modify2_end, "work work_modify2_end", - "work_modify2_end%debug 'in function work'", - tnf_ulong, err, err); - - if (err != DSVC_SUCCESS && verbose) { - fprintf(stderr, "work: %d %d error %d\n", - wtype, op, err); - } - *dnp = ndn; - break; - } - break; - - - default: - ndn = *dnp; - ndn.dn_cid_len = cid_len; - switch (random() & 0x1) { - case 0: - for (j = 0; j < cid_len; j++) - ndn.dn_cid[j] = random() & 0xff; - break; - case 1: - for (j = 0; j < cid_len; j++) - ndn.dn_cid[j] = '\0'; - ndn.dn_cid_len = 1; - break; - } - ndn.dn_lease = htonl(time(NULL)); - - /* LINTED */ - TNF_PROBE_2(work_modify, "work work_modify", - "work_modify%debug 'in function work'", - tnf_ulong, cid, *(ulong_t *)&ndn.dn_cid, - tnf_ulong, cid_len, ndn.dn_cid_len); - - err = modify_dd_entry(dh[table], dnp, &ndn); - if (err != DSVC_SUCCESS && err != DSVC_COLLISION) { - if (verbose) - fprintf(stderr, "modify: error %d\n", err); - } - - TNF_PROBE_1(work_modify_end, "work work_modify_end", - "work_modify_end%debug 'in function work'", - tnf_ulong, err, err); - - *dnp = ndn; - break; - } - - if (domalloc) - free(ptr); - - if (wptr->isthreaded) { - (void) mutex_unlock(&wptr->mtx); - cond_signal(&wptr->cv); - TNF_PROBE_2(work_end, "work", "work_end%debug 'in function " - "work'", tnf_ulong, err, err, - tnf_ulong, crecords, crecords); - thr_exit(NULL); - } - if (dncp) - free_dd_list(dh[table], dncp); - - TNF_PROBE_2(work_end, "work", "work_end%debug 'in function work'", - tnf_ulong, err, err, - tnf_ulong, crecords, crecords); - - return ((void *) NULL); -} - -/* - * Worker thread. - */ -static void * -dowork(void *argp) -{ - int i = (int)argp; - timestruc_t to; - work_t *wptr; - dn_rec_t dn; - - (void) memset((char *)&dn, '\0', sizeof (dn)); - (void) mutex_lock(&mtx); - for (; time_to_go == 0; ) { - TNF_PROBE_1(dowork, "dowork", - "dowork%debug 'in function dowork'", - tnf_long, thread_number, i); - - to.tv_sec = time(NULL) + random() & 0x3; - to.tv_nsec = 0; - - if (slp > 0.0) { - to.tv_sec = time(NULL) + slp; - to.tv_nsec = (slp - (double)((int)slp)) * 1000000000.0; - } else if (slp < 0.0) { - to.tv_sec = time(NULL) + abs((int)slp); - to.tv_nsec = (slp + abs((double)((int)slp))) * - 1000000000.0; - } - /* give up processor */ - if (slp != 0.0) { - (void) mutex_unlock(&mtx); - (void) cond_timedwait(&never, &mtx, &to); - } - ops_outstanding++; - (void) mutex_unlock(&mtx); - - if (spawn_helper) { - wptr = (work_t *)malloc(sizeof (work_t)); - wptr->thread = i * 2; - wptr->isthreaded = B_TRUE; - (void) cond_init(&wptr->cv, USYNC_THREAD, NULL); - (void) mutex_init(&wptr->mtx, USYNC_THREAD, NULL); - (void) mutex_lock(&wptr->mtx); - - /* fire up helper thread */ - if (thr_create(NULL, 0, douwork ? uwork : work, - (void *)wptr, 0, &tp[i * 2]) != 0) - fprintf(stderr, "can't spawn lthread %d\n", i); - - /* wait for completion */ - (void) cond_wait(&wptr->cv, &wptr->mtx); - (void) mutex_unlock(&wptr->mtx); - (void) thr_join(tp[i * 2], NULL, NULL); - free_work_t(wptr); - } else { - wptr = (work_t *)malloc(sizeof (work_t)); - wptr->isthreaded = B_FALSE; - wptr->thread = i; - wptr->dnp = &dn; - if (douwork) { - (void) uwork((void *)wptr); - } else { - (void) work((void *)wptr); - } - free_work_t(wptr); - } - (void) mutex_lock(&mtx); - tops++; - ops_outstanding--; - TNF_PROBE_0(dowork_end, "dowork", ""); - } - (void) mutex_unlock(&mtx); - thr_exit(NULL); - - return ((void *) NULL); -} - -/* - * Signal handler routine. All signals handled by calling thread. - */ -/* ARGSUSED */ -static void * -sig_handle(void *arg) -{ - int i; - int sig; - sigset_t set; - timespec_t ts; - siginfo_t si; - int go; - int oldi; - ulong_t minavg; - time_t minstime; - - (void) sigfillset(&set); /* catch all signals */ - - ts.tv_sec = sample_time; - ts.tv_nsec = 0L; - - for (;;) { - (void) mutex_lock(&mtx); - go = time_to_go; - (void) mutex_unlock(&mtx); - if (go) - break; - - switch (sig = sigtimedwait(&set, &si, &ts)) { - case -1: - case SIGHUP: - old = time(NULL); - oldi = new = unstarted = 0; - for (i = 0; i < threads; i++) { - if (timp[i] == NULL) - unstarted++; - if (timp[i] && timp[i] < old) { - old = timp[i]; - oldi = i; - } - if (timp[i] && timp[i] > new) - new = timp[i]; - } - - if (start == 0) { - /* toss initial sample */ - ostart = start = time(NULL); - (void) mutex_lock(&mtx); - otops = tops = 0; - (void) mutex_unlock(&mtx); - minind = 0; - } else { - minops[minind] = tops - otops; - mintim[minind] = ostart; - otops = tops; - ostart = time(NULL); - minind = minind + 1 > nsamples - 1 ? 0 : - minind + 1; - minstime = 0; - minavg = 0; - for (i = 0; i < nsamples; i++) { - if (mintim[i]) - minavg += minops[i]; - if (minstime == 0) - minstime = mintim[i]; - else if (mintim[i] && - mintim[i] < minstime) - minstime = mintim[i]; - } - - fprintf(stderr, "%9.9d: Totops %d Curr %d "\ - "Persec %4.2f (%4.2f) Oldest %d (%d) "\ - "Gap %d Unstarted %d\n", - time(NULL), - tops, - ops_outstanding, - (double)tops / (double)(time(NULL) - - start), - (double)minavg / (double)(time(NULL) - - minstime), - time(NULL) - old, - oldi, - new - old, - unstarted); - } - break; - default: - (void) mutex_lock(&mtx); - time_to_go++; - (void) mutex_unlock(&mtx); - break; - } - } - thr_exit(NULL); - return ((void *) sig); /* NOTREACHED */ -} - -int fd[0x10000]; -/* - * open handler routine. - */ -/* ARGSUSED */ -static void * -open_handle(void *arg) -{ - int i; - - for (;;) { - for (i = 0; i < doopen; i++) - fd[i] = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); - for (i = 0; i < doopen; i++) - if (fd[i] >= 0) - (void) close(fd[i]); - } - return ((void *) NULL); /* NOTREACHED */ -} -/* - * test_dstore network[,network] worktype[,worktype] <thr_create flags> - * <spawn_helper> <nlwp> <nthread> <file> <sleeptype> - * - * network - list of network containers, comma-separated - * worktypes: - * 0 - random - * 1 - cid reads - * 2 - cip reads - * 3 - whole db reads - * 4 - write read write (simulate simple test) - * 5 - modify writes - * sleeptypes: - * N == * condwait N sec.nsec period - * -N == condwait a random 1-N sec.nsec period - */ -main(int c, char **v) -{ - int i; - timespec_t to; - uint_t flags; - int err; - sigset_t set; - dhcp_confopt_t *dsp = NULL; - uint32_t query; - dn_rec_t dn; - dn_rec_list_t *dncp = NULL; - struct rlimit rl; - char *np; - -#ifdef DEBUG - mallocctl(MTDEBUGPATTERN, 1); - mallocctl(MTINITBUFFER, 1); -#endif /* DEBUG */ - - srandom(time(NULL)); - - if (dofork) - if (fork() != 0) - exit(0); - - if ((err = getrlimit(RLIMIT_NOFILE, &rl)) < 0) { - (void) fprintf(stderr, "Cannot get open file limit: %s\n", - strerror(errno)); - } - /* handle cases where limit is infinity */ - if (rl.rlim_cur == RLIM_INFINITY) { - rl.rlim_cur = (rl.rlim_max == RLIM_INFINITY) ? - OPEN_MAX : rl.rlim_max; - } - /* set NOFILE to unlimited */ - rl.rlim_cur = rl.rlim_max = RLIM_INFINITY; - if ((err = setrlimit(RLIMIT_NOFILE, &rl)) < 0) { - (void) fprintf(stderr, "Cannot set open file limit: %s\n", - strerror(errno)); - } - (void) enable_extended_FILE_stdio(-1, -1); - - if (c == 1) { - (void) fprintf(stderr, - "/*\n"\ - " * test_dstore network[,network] worktype[,"\ - "worktype] <thr_create flags>\n"\ - " * <spawn_helper> <nlwp> <nthread> "\ - "<file> <sleeptype>\n"\ - " *\n"\ - " * network - list of network containers, "\ - "comma-separated\n"\ - " * worktypes:\n"\ - " * 0 - random\n"\ - " * 1 - cid reads\n"\ - " * 2 - cip reads\n"\ - " * 3 - whole db reads\n"\ - " * 4 - write read write (simulate simple"\ - " test)\n"\ - " * 5 - modify writes\n"\ - " * sleeptypes:\n"\ - " * N == * condwait N sec.nsec period\n"\ - " * -N == condwait a random 1-N sec.nsec "\ - "period\n"\ - " */\n"); - return (0); - } - network = v[1]; - - worktype = strtoul(v[2], 0L, 0L); - flags = strtoul(v[3], 0L, 0L); - spawn_helper = strtoul(v[4], 0L, 0L); - if (strtoul(v[5], 0L, 0L) > 0) - (void) thr_setconcurrency(strtoul(v[5], 0L, 0L)); - threads = strtoul(v[6], 0L, 0L); - fl = v[7]; - if (c > 8) - slp = atof(v[8]); - - if (douwork == 0) { - /* Load current datastore. */ - (void) read_dsvc_conf(&dsp); - if ((i = confopt_to_datastore(dsp, &datastore)) - != DSVC_SUCCESS) { - (void) fprintf(stderr, "Invalid datastore: %s\n", - dhcpsvc_errmsg(i)); - return (EINVAL); - } - for (i = 0, np = strtok(network, ","); np; i++, - np = strtok(NULL, ",")) { - net[i].s_addr = inet_addr(np); - - err = open_dd(&dh[i], &datastore, DSVC_DHCPNETWORK, np, - DSVC_READ | DSVC_WRITE); - - if (err != DSVC_SUCCESS) { - (void) fprintf(stderr, "Invalid network: "\ - "%s %s\n", np, - dhcpsvc_errmsg(err)); - return (err); - } - /* - * XXXX: bug: currently can't get the count as - * advertised - */ - (void) memset(&dn, '\0', sizeof (dn)); - DSVC_QINIT(query); - err = lookup_dd(dh[i], B_FALSE, query, -1, - (const void *) &dn, (void **) &dncp, - &nrecords[i]); - if (dncp) - free_dd_list(dh[i], dncp); - - if (err != DSVC_SUCCESS) { - (void) fprintf(stderr, "Bad nrecords: %s " - "[%d]\n", dhcpsvc_errmsg(err), - nrecords[i]); - return (err); - } - } - ntable = i; - } - TNF_PROBE_2(main, "main", - "main%debug 'in function main'", - tnf_ulong, threads, threads, - tnf_ulong, nrecords, nrecords[i]); - - (void) sigfillset(&set); - - (void) sigdelset(&set, SIGABRT); /* allow for user abort */ - - (void) thr_sigsetmask(SIG_SETMASK, &set, NULL); - - tms = threads * sizeof (thread_t); - if (spawn_helper) - tms *= 2; - tp = malloc(tms); - tms = (threads * sizeof (time_t) + 0x200) & ~(0x200 - 1); - if (spawn_helper) - tms *= 2; - timp = malloc(tms); - (void) memset((char *)timp, NULL, tms); - - (void) mutex_init(&mtx, USYNC_THREAD, 0); - - /* - * Create signal handling thread. XXXX: due to threads library - * limitations, this must currently be directly called in the main - * program thread. - */ - if ((err = thr_create(NULL, 0, sig_handle, NULL, - THR_NEW_LWP | THR_DAEMON | THR_BOUND | - THR_DETACHED, &sigthread)) != 0) { - (void) fprintf(stderr, - gettext("Cannot start signal handling thread, error: %d\n"), - err); - return (err); - } - for (i = 0; i < threads; i++) - /* fire up monitor thread */ - if (thr_create(NULL, 0, dowork, (void *) i, - flags, &tp[i]) != 0) - fprintf(stderr, "can't spawn thread %d\n", i); - - /* - * Create open handling thread. - */ - if (doopen && (err = thr_create(NULL, 0, open_handle, NULL, - THR_NEW_LWP | THR_DAEMON | THR_BOUND | THR_DETACHED, - &opnthread)) != 0) { - (void) fprintf(stderr, - gettext("Cannot start open handling thread, error: %d\n"), - err); - return (err); - } - - (void) mutex_lock(&mtx); - for (; time_to_go == 0; ) { - to.tv_sec = time(NULL) + 10; - to.tv_nsec = 0L; - (void) cond_timedwait(&never, &mtx, &to); - (void) mutex_unlock(&mtx); - } - - /* - * Attempt to join threads. - */ - for (i = 0; i < threads; i++) - (void) thr_join(tp[i], NULL, NULL); - - (void) sleep(5); - - TNF_PROBE_0(main_end, "main", ""); - - return (0); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/test_per_net.c b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/test_per_net.c deleted file mode 100644 index 4ec09eccb4..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/test_per_net.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Copyright (c) 1996-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#include <stdio.h> -#include <sys/types.h> -#include <unistd.h> -#include <syslog.h> -#include <netinet/in.h> -#include <netinet/dhcp.h> -#include <dhcp_gen.h> -#include <dhcpd.h> -#include <per_network.h> -#include <dhcp_msgs.h> - -int debug = 1; -int verbose = 1; - -/* - * smalloc() -- safe malloc() - * - * Always returns a valid pointer (if it returns at all). The allocated - * memory is initialized to all zeros. If malloc() returns an error, a - * message is printed using the syslog() function and the program aborts - * with a status of 1. - */ -char * -smalloc(uint_t nbytes) -{ - char *retvalue; - - if ((retvalue = (char *)malloc(nbytes)) == (char *)NULL) { - dhcp_error(LOG_ERR, DHCP_MSGS(DCMSG_NO_MEMORY)); - (void) exit(1); - } - memset(retvalue, 0, nbytes); - return (retvalue); -} - -int -main(void) -{ - struct in_addr five_net = {109, 108, 5, 0}; - struct in_addr five_mask = {109, 108, 5, 255}; - struct in_addr serverid = {109, 108, 5, 138}; - struct in_addr scratch; - PER_NET_DB pndb; - PN_REC pn; - uchar_t buf[MAX_CID_LEN] = {0x1, 0x0, 0x0, 0xc0, 0xee, 0xe, 0x4c }; - char tbuf[MAX_CID_LEN]; - int recs; - unsigned int len; - register int i, err = 0; - - - /* - * Test 0. Open the per network database, and locate a *single* - * record by cid. - */ - printf("Test 0: START ******************************************\n"); - memset(&pndb, 0, sizeof (pndb)); - - if (open_per_net(&pndb, &five_net, &five_mask) != 0) { - printf("didn't work.\n"); - return (1); - } - - /* - * Should only be one. - */ - memset(&pn, 0, sizeof (pn)); - recs = lookup_per_net(&pndb, PN_CID, (void *)buf, 7, &serverid, &pn); - if (recs < 0) - printf("lookup didn't work.\n"); - else { - if (recs > 0) { - len = MAX_CID_LEN; - octet_to_hexascii(buf, 7, tbuf, &len); - printf("Client id: %s\n", tbuf); - printf("flags: 0x%x\n", pn.flags); - printf("IP address is: %s\n", inet_ntoa(pn.clientip)); - printf("server IP address is: %s\n", - inet_ntoa(pn.serverip)); - - len = MAX_CID_LEN; - octet_to_hexascii(&pn.lease, 4, tbuf, &len); - printf("lease is %s, 0x%x\n", tbuf, pn.lease); - printf("macro is %s\n", pn.macro); - printf("Number of records: %d\n", recs); - } - } - close_per_net(&pndb); - - printf("Test 0: END ******************************************\n"); - /* END TEST 0 ********************************************* */ - - /* - * Test 1. Open the per net database, locate all records with - * cid of 0. - */ - printf("Test 1: START ******************************************\n"); - if (open_per_net(&pndb, &five_net, &five_mask) != 0) { - printf("didn't work.\n"); - return (1); - } else { - printf("name: %s\n", pndb.name); - } - - memset(buf, 0, MAX_CID_LEN); - recs = lookup_per_net(&pndb, PN_CID, (void *)buf, 1, &serverid, &pn); - if (recs < 0) - printf("lookup didn't work.\n"); - else { - printf("datatype: %d\n", pndb.datatype); - printf("row: %d\n", pndb.row); - if (recs > 0) { - len = MAX_CID_LEN; - octet_to_hexascii(buf, 7, tbuf, &len); - printf("Client id: %s\n", tbuf); - printf("flags: 0x%x\n", pn.flags); - printf("IP address is: %s\n", inet_ntoa(pn.clientip)); - printf("server IP address is: %s\n", - inet_ntoa(pn.serverip)); - - len = MAX_CID_LEN; - octet_to_hexascii(&pn.lease, 4, tbuf, &len); - printf("lease is %s, 0x%x\n", tbuf, pn.lease); - printf("macro is %s\n", pn.macro); - printf("Number of records: %d\n", recs); - for (i = 0; i < recs; i++) { - if (get_per_net(&pndb, PN_CID, &pn) != 0) { - printf("didn't work 2: \n"); - break; - } - len = MAX_CID_LEN; - octet_to_hexascii(buf, 7, tbuf, &len); - printf("Client id: %s\n", tbuf); - printf("flags: 0x%x\n", pn.flags); - printf("IP address is: %s\n", - inet_ntoa(pn.clientip)); - printf("server IP address is: %s\n", - inet_ntoa(pn.serverip)); - - len = MAX_CID_LEN; - octet_to_hexascii(&pn.lease, 4, tbuf, &len); - printf("lease is %s, 0x%x\n", tbuf, pn.lease); - printf("macro is %s\n", pn.macro); - } - } - } - - close_per_net(&pndb); - printf("Test 1: END ******************************************\n"); - printf("Test 2: START ******************************************\n"); - /* - * Locate client ip 109.108.5.221. - */ - scratch.s_addr = 0x6d6c05dd; - if (open_per_net(&pndb, &five_net, &five_mask) != 0) { - printf("didn't work.\n"); - return (1); - } else { - printf("name: %s\n", pndb.name); - } - - recs = lookup_per_net(&pndb, PN_CLIENT_IP, (void *)&scratch, 4, - &serverid, &pn); - if (recs < 0) - printf("lookup didn't work.\n"); - else { - printf("datatype: %d\n", pndb.datatype); - printf("row: %d\n", pndb.row); - if (recs > 0) { - len = MAX_CID_LEN; - octet_to_hexascii(buf, 7, tbuf, &len); - printf("Client id: %s\n", tbuf); - printf("flags: 0x%x\n", pn.flags); - printf("IP address is: %s\n", inet_ntoa(pn.clientip)); - printf("server IP address is: %s\n", - inet_ntoa(pn.serverip)); - - len = MAX_CID_LEN; - octet_to_hexascii(&pn.lease, 4, tbuf, &len); - printf("lease is %s, 0x%x\n", tbuf, pn.lease); - printf("macro is %s\n", pn.macro); - printf("Number of records: %d\n", recs); - } - } - - printf("Test 2: END ******************************************\n"); - printf("Test 3: START ******************************************\n"); - if (recs > 0) { - /* - * Using the record from test 2, change the cid, flags, and - * lease, then write the record. - */ - pn.cid_len = 7; - for (i = 0; (uchar_t)i < pn.cid_len; i++) - pn.cid[i] = i; - pn.flags |= F_AUTOMATIC; - pn.lease = htonl(time(NULL)); - - if ((err = put_per_net(&pndb, &pn, PN_CLIENT_IP)) != 0) { - printf("didn't work. error: %d\n", err); - } else - printf("it worked.\n"); - } - close_per_net(&pndb); - printf("Test 3: END ******************************************\n"); - - return (0); -} diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/test_tnf.nawk b/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/test_tnf.nawk deleted file mode 100644 index eb5090593f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/tests/test_tnf.nawk +++ /dev/null @@ -1,100 +0,0 @@ -{ - # - # Copyright 2005 Sun Microsystems, Inc. All rights reserved. - # Use is subject to license terms. - # - # CDDL HEADER START - # - # The contents of this file are subject to the terms of the - # Common Development and Distribution License, Version 1.0 only - # (the "License"). You may not use this file except in compliance - # with the License. - # - # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - # or http://www.opensolaris.org/os/licensing. - # See the License for the specific language governing permissions - # and limitations under the License. - # - # When distributing Covered Code, include this CDDL HEADER in each - # file and include the License file at usr/src/OPENSOLARIS.LICENSE. - # If applicable, add the following below this CDDL HEADER, with the - # fields enclosed by brackets "[]" replaced with your own identifying - # information: Portions Copyright [yyyy] [name of copyright owner] - # - # CDDL HEADER END - # - #ident "%Z%%M% %I% %E% SMI" - - if (first_time == 0 && ($1 == "probe" || match($1, "---"))) - next; - else - first_time = 1; - - time = $1; - thread = $5; - type = $7; - val = pval = ""; - for (i = 8; i <= NF; i++) { - if (pval == "cip:") - val = val " " sprintf("%x", $i); - else - val = val " " $i; - pval=$i - } - - if (match(type, "_end")) { - type = substr(type, 1, match(type, "_end") - 1); - - if (int(start[thread "" type]) == 0) { - printf("Warning: missing match line %d: %s\n", NR, $0); - next; - } - - total[type]++; - alltotal++; - - elapsed = time - start[thread "" type]; - vchar = ""; - if (longest[type] < elapsed) { - longest[type] = elapsed; - vchar = "*"; - } - if (verbose) { - printf("\t\top: %s thread: %d elapsed %f%s%s\n", - type, thread, elapsed, val, vchar); - } - average[type] = (average[type] + elapsed)/total[type]; - averagedepth[type] = (averagedepth[type] + depth[type])/total[type]; - - allaverage= (allaverage + alldepth)/alltotal; - - depth[type]--; - alldepth--; - start[thread "" type] = 0; - - } else { - if (match(type, "_start")) { - type = substr(type, 1, match(type, "_start") - 1); - } - start[thread "" type] = time; - depth[type]++; - if (maxdepth[type] < depth[type]) - maxdepth[type] = depth[type]; - - alldepth++; - if (allmaxdepth < alldepth) - allmaxdepth = alldepth; - } -} - -END { - printf("\n"); - for (types in total) { - printf("op: %d %s: avg: %8.8f worst: %8.8f\n", - total[types], types, average[types], longest[types]); - printf(" avg concurrency: %8.8f greatest concurrency %8.8f\n\n", - averagedepth[types], maxdepth[types]); - } - printf("Totals: avg concurrency: %8.8f greatest concurrency %8.8f\n", - allaverage, allmaxdepth); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/Makefile index f17361b63e..be3ed4f1ce 100644 --- a/usr/src/cmd/cmd-inet/usr.sadm/Makefile +++ b/usr/src/cmd/cmd-inet/usr.sadm/Makefile @@ -23,26 +23,19 @@ # Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# ident "%Z%%M% %I% %E% SMI" +# Copyright 2014 Garrett D'Amore <garrett@damore.org> # # cmd/cmd-inet/usr.sadm/Makefile -SUBDIRS1= dhcpmgr SUBDIRS2= scripts include ../../Makefile.cmd -# -# Message catalog -# -POFILES= dhcpmgr/lib/dhcpmgr.po -POFILE= usr.sadm.po all:= TARGET= all install:= TARGET= install clean:= TARGET= clean clobber:= TARGET= clobber lint:= TARGET= lint -_msg:= TARGET= _msg .KEEP_STATE: @@ -52,15 +45,6 @@ all clean clobber lint: $(SUBDIRS1) install: $(SUBDIRS1) $(SUBDIRS2) -# -# message catalog -# -_msg: $(SUBDIRS1) .WAIT $(POFILE) - -$(POFILE): $(POFILES) - $(RM) $@ - cat $(POFILES) > $@ - $(SUBDIRS1) $(SUBDIRS2): FRC @cd $@; pwd; $(MAKE) $(TARGET) diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/Makefile deleted file mode 100644 index 6e04681792..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/Makefile +++ /dev/null @@ -1,164 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/Makefile - -include $(SRC)/Makefile.master - -SUBDIRS = com lib bin help - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -GUI_JAR= dhcpmgr.jar -GUI_JARFILES= com/sun/dhcpmgr/client/*.class \ - com/sun/dhcpmgr/ui/*.class \ - com/sun/dhcpmgr/ui/*.gif \ - com/sun/dhcpmgr/client/*.properties \ - com/sun/dhcpmgr/ui/*.properties - -SERVER_JAR= dhcpsvc.jar -SERVER_JARFILES= com/sun/dhcpmgr/server/*.class \ - com/sun/dhcpmgr/bridge/*.class \ - com/sun/dhcpmgr/bridge/*.properties - - -CLI_JAR= dhcpcli.jar -CLI_JARFILES= com/sun/dhcpmgr/cli/*/*.class \ - com/sun/dhcpmgr/cli/*/*.properties - -COMMON_JAR= dhcpcommon.jar -COMMON_JARFILES= com/sun/dhcpmgr/data/*.class \ - com/sun/dhcpmgr/data/qualifier/*.class \ - com/sun/dhcpmgr/common/*.class \ - com/sun/dhcpmgr/data/*.properties \ - com/sun/dhcpmgr/common/*.properties - -SUNWFILES_JAR= SUNWfiles.jar -SUNWFILES_JARFILES= com/sun/dhcpmgr/client/SUNWfiles/*.class \ - com/sun/dhcpmgr/client/SUNWfiles/*.properties -SUNWFILES_MANIFEST= SUNWfiles.manifest - -SUNWBINFILES_JAR= SUNWbinfiles.jar -SUNWBINFILES_JARFILES= com/sun/dhcpmgr/client/SUNWbinfiles/*.class \ - com/sun/dhcpmgr/client/SUNWbinfiles/*.properties -SUNWBINFILES_MANIFEST= SUNWbinfiles.manifest - -CLI_JARS=${CLI_JAR} ${SERVER_JAR} ${COMMON_JAR} -GUI_JARS=$(GUI_JAR) ${SUNWFILES_JAR} ${SUNWBINFILES_JAR} -ALL_JARS= ${GUI_JARS} ${CLI_JARS} - -MANIFEST_FILES= $(SUNWFILES_MANIFEST) $(SUNWBINFILES_MANIFEST) - -ROOTGUIDIR = $(ROOT)/usr/sadm/admin/dhcpmgr -ROOTCLIDIR = $(ROOT)/usr/lib/inet/dhcp/svcadm -ROOTDIRS= $(ROOT)/usr/sadm/admin $(ROOTGUIDIR) $(ROOTCLIDIR) - -ROOTCLIFILES = ${CLI_JARS} -ROOTGUIFILES = ${GUI_JARS} -ROOTCLIDIRJAR = $(ROOTCLIFILES:%=$(ROOTCLIDIR)/%) -ROOTGUIDIRJAR = $(ROOTGUIFILES:%=$(ROOTGUIDIR)/%) - -JAVADOC_PKGS= com.sun.dhcpmgr.client \ - com.sun.dhcpmgr.ui \ - com.sun.dhcpmgr.data \ - com.sun.dhcpmgr.data.qualifier \ - com.sun.dhcpmgr.server \ - com.sun.dhcpmgr.bridge \ - com.sun.dhcpmgr.cli.common \ - com.sun.dhcpmgr.cli.dhcpconfig \ - com.sun.dhcpmgr.cli.dhtadm \ - com.sun.dhcpmgr.cli.pntadm \ - com.sun.dhcpmgr.common - -FILEMODE = 0444 -DIRMODE = 0755 - -.KEEP_STATE: - -all: $(SUBDIRS) $(ALL_JARS) - -install: all $(ROOTDIRS) $(SUBDIRS) $(ROOTCLIDIRJAR) $(ROOTGUIDIRJAR) - -clean clobber: $(SUBDIRS) - -$(RM) $(MANIFEST_FILES) - -$(RM) $(ALL_JARS) - -lint: lib - -_msg: $(SUBDIRS) - -strip: - -# -# The javadocs target is non-standard; used for creating API reference docs -# The javadocs will be placed in $(CODEMGR_WS}/javadocs -# -javadocs: - $(RM) -r $(CODEMGR_WS)/$@; mkdir $(CODEMGR_WS)/$@ - $(JAVADOC) -classpath $(CLASSPATH) -sourcepath . -d $(CODEMGR_WS)/$@ $(JAVADOC_PKGS) -windowtitle "DHCP Administration packages" - -$(GUI_JAR): FRC - $(JAR) cf $@ $(GUI_JARFILES) - -$(SERVER_JAR): FRC - $(JAR) cf $@ $(SERVER_JARFILES) - -$(CLI_JAR): FRC - $(JAR) cf $@ $(CLI_JARFILES) - -$(COMMON_JAR): FRC - $(JAR) cf $@ $(COMMON_JARFILES) - -$(SUNWFILES_JAR): $(SUNWFILES_MANIFEST) FRC - $(JAR) cmf $(SUNWFILES_MANIFEST) $@ $(SUNWFILES_JARFILES) - -$(SUNWBINFILES_JAR): $(SUNWBINFILES_MANIFEST) FRC - $(JAR) cmf $(SUNWBINFILES_MANIFEST) $@ $(SUNWBINFILES_JARFILES) - -$(SUNWFILES_MANIFEST): - @$(ECHO) "Name: com/sun/dhcpmgr/client/SUNWfiles/SUNWfiles.class" > $@; - @$(ECHO) "Java-Bean: True" >> $@; - -$(SUNWBINFILES_MANIFEST): - @$(ECHO) "Name: com/sun/dhcpmgr/client/SUNWbinfiles/SUNWbinfiles.class" > $@; - @$(ECHO) "Java-Bean: True" >> $@; - -$(ROOTCLIDIR)/%: % - $(INS.file) - -$(ROOTGUIDIR)/%: % - $(INS.file) - -$(ROOTDIRS): - $(INS.dir) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/bin/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/bin/Makefile deleted file mode 100644 index 07daf35d2a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/bin/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2010 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/bin/Makefile -# - -include $(SRC)/cmd/Makefile.cmd - -PROG = dhcpmgr - -ROOTBIN = $(ROOT)/usr/sadm/admin/bin - -ROOTBINPROG = $(PROG:%=$(ROOTBIN)/%) - -ROOTUSRSBINLINK = $(PROG:%=$(ROOTUSRSBIN)/%) - -.KEEP_STATE: - -all: $(PROG) -install: all $(ROOTBIN) $(ROOTBINPROG) $(ROOTUSRSBINLINK) - -$(ROOTBIN)/%: % - $(INS.file) - -$(ROOTBIN): - $(INS.dir) - -$(ROOTUSRSBINLINK): - -$(RM) $@; $(SYMLINK) ../sadm/admin/bin/$(@F) $@ - -clean clobber: - -$(RM) $(PROG) - -lint _msg: diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/bin/dhcpmgr.sh b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/bin/dhcpmgr.sh deleted file mode 100644 index 09e5828788..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/bin/dhcpmgr.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -DMDIR=/usr/sadm/admin/dhcpmgr -DLDIR=/usr/lib/inet/dhcp/svcadm -L10NDIR=/usr/share/lib/locale - -CLASSPATH=${L10NDIR}:${DMDIR}/dhcpmgr.jar:${DMDIR}/SUNWfiles.jar:${DMDIR}/SUNWbinfiles.jar:${DLDIR}/dhcpsvc.jar:${DLDIR}/dhcpcommon.jar -export CLASSPATH - -# add /usr/dt/bin so sdtwebclient will be available for help -PATH=${PATH}:/usr/dt/bin -export PATH - -exec /usr/java/bin/java -DDHCPBEANSDIR=${DMDIR} com.sun.dhcpmgr.client.DhcpmgrApplet diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/Makefile deleted file mode 100644 index 6d183ff92a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%W% %E% SMI" -# -# Copyright (c) 1999 by Sun Microsystems, Inc. -# All rights reserved. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/Makefile - -include $(SRC)/cmd/Makefile.cmd - -SUBDIRS = sun - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -.KEEP_STATE: - -all install clean clobber lint _msg: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/Makefile deleted file mode 100644 index 541df6ff42..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%W% %E% SMI" -# -# Copyright (c) 1999 by Sun Microsystems, Inc. -# All rights reserved. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/Makefile - -include $(SRC)/cmd/Makefile.cmd - -SUBDIRS = dhcpmgr - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -.KEEP_STATE: - -all install clean clobber lint _msg: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/Makefile deleted file mode 100644 index dce7d79fc5..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/Makefile - -include $(SRC)/cmd/Makefile.cmd - -SUBDIRS = data bridge server client ui cli common - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -.KEEP_STATE: - -all install clean clobber lint _msg: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/Bridge.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/Bridge.java deleted file mode 100644 index b725e98212..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/Bridge.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -package com.sun.dhcpmgr.bridge; - -import java.util.Hashtable; -import com.sun.dhcpmgr.data.*; - -/** - * Bridge supplies access to the native functions in libdhcp and the - * dhcpmgr shared object which actually interact with the data stores - * used by DHCP. - */ - -public class Bridge { - public native DhcpDatastore getDataStore(String resource) - throws BridgeException; - public native DhcpDatastore [] getDataStores() throws BridgeException; - public native Option [] getInittabOptions(byte context) - throws BridgeException; - public native Macro getMacro(String key, DhcpDatastore datastore) - throws BridgeException; - public native Option getOption(String key, DhcpDatastore datastore) - throws BridgeException; - public native void createDhcptabRecord(DhcptabRecord rec, - DhcpDatastore datastore) throws BridgeException; - public native void modifyDhcptabRecord(DhcptabRecord oldRecord, - DhcptabRecord newRecord, DhcpDatastore datastore) - throws BridgeException; - public native void deleteDhcptabRecord(DhcptabRecord rec, - DhcpDatastore datastore) throws BridgeException; - public native void cvtDhcptab(DhcpDatastore datastore) - throws BridgeException; - public native Option createOption(String name, String value) - throws BridgeException; - public native Option [] getOptions(DhcpDatastore datastore) - throws BridgeException; - public native Macro [] getMacros(DhcpDatastore datastore) - throws BridgeException; - public native Network [] getNetworks(DhcpDatastore datastore) - throws BridgeException; - public native Network getNetwork(String network) - throws BridgeException; - public native void cvtNetwork(String table, - DhcpDatastore datastore) throws BridgeException; - public native DhcpClientRecord [] loadNetwork(String table, - DhcpDatastore datastore) throws BridgeException; - public native void createDhcpClientRecord(DhcpClientRecord rec, - String table, DhcpDatastore datastore) throws BridgeException; - public native void modifyDhcpClientRecord(DhcpClientRecord oldRecord, - DhcpClientRecord newRecord, String table, DhcpDatastore datastore) - throws BridgeException; - public native void deleteDhcpClientRecord(DhcpClientRecord rec, - String table, DhcpDatastore datastore) throws BridgeException; - public native DhcpClientRecord getDhcpClientRecord(DhcpClientRecord rec, - String table, DhcpDatastore datastore) throws BridgeException; - public native DhcpdOptions readDefaults() throws BridgeException; - public native void writeDefaults(DhcpdOptions defs) - throws BridgeException; - public native void removeDefaults() throws BridgeException; - public native void startup() throws BridgeException; - public native void shutdown() throws BridgeException; - public native void reload() throws BridgeException; - public native IPInterface [] getInterfaces() throws BridgeException; - public native String [] getArguments(String line) throws BridgeException; - public native String getStringOption(short code, String arg) - throws BridgeException; - public native IPAddress [] getIPOption(short code, String arg) - throws BridgeException; - public native long [] getNumberOption(short code, String arg) - throws BridgeException; - public native void createDhcptab(DhcpDatastore datastore) - throws BridgeException; - public native void deleteDhcptab(DhcpDatastore datastore) - throws BridgeException; - public native void createDhcpNetwork(String net, DhcpDatastore datastore) - throws BridgeException; - public native void deleteDhcpNetwork(String net, DhcpDatastore datastore) - throws BridgeException; - public native void makeLocation(DhcpDatastore datastore) - throws BridgeException; - public native boolean isServerRunning() throws BridgeException; - public native boolean isVersionCurrent() throws BridgeException; - static { - - System.load("/usr/sadm/admin/dhcpmgr/dhcpmgr.so.1"); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/BridgeException.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/BridgeException.java deleted file mode 100644 index 1668247e8a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/BridgeException.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -package com.sun.dhcpmgr.bridge; - -import java.text.MessageFormat; - -/** - * This class is the superclass for all exceptions (other than core java - * exceptions) thrown by the server and JNI routines. - */ -public class BridgeException extends Exception { - - /** - * Arguments to use when formatting the message for the exception. - */ - protected Object [] args = null; - - /** - * Simplest constructor. - */ - public BridgeException() { - super("internal_error"); - } // constructor - - /** - * Constructor that provides a msgid. - * @param msgid ResourceBundle id to link to this exception. - */ - public BridgeException(String msgid) { - super(msgid); - } // constructor - - /** - * Constructor that provides a msgid and an argument to the message. - * @param msgid ResourceBundle id to link to this exception. - * @param args array of arguments to be used in format of message. - */ - public BridgeException(String msgid, Object [] args) { - super(msgid); - this.args = args; - } // constructor - - /** - * Constructor that provides a msgid and an argument to the message. - * @param msgid ResourceBundle id to link to this exception. - * @param arg argument to be used in format of exception message. - */ - public BridgeException(String msgid, String arg) { - super(msgid); - args = new Object[1]; - args[0] = arg; - } // constructor - - /** - * Override of superclass getMessage(). Builds a message using the - * msgid and args (if any) that were provided at instantiation. - * @return message for the exception. - */ - public String getMessage() { - String message = null; - String messageId = super.getMessage(); - - try { - if (args != null) { - MessageFormat form = new MessageFormat( - ResourceStrings.getString(messageId)); - message = form.format(args); - } else { - message = ResourceStrings.getString(messageId); - } - } catch (Throwable e) { - message = messageId; - } - - return (message); - } // getMessage - -} // BridgeException diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/DsymException.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/DsymException.java deleted file mode 100644 index 48389131d9..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/DsymException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2000-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -package com.sun.dhcpmgr.bridge; - -/** - * This class is the exception class used by symbol parsing related errors. - */ -public class DsymException extends BridgeException { - - /** - * Constructor that provides a msgid and an argument to the message. - * @param msgid ResourceBundle id to link to this exception. - * @param args array of arguments to be used in format of message. - */ - public DsymException(String msgid, Object [] args) { - super(msgid, args); - } // constructor - -} // DsymException diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/ExistsException.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/ExistsException.java deleted file mode 100644 index 3ff69f3e8c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/ExistsException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.bridge; - -/** - * The exception that occurs if an object already exists. - */ -public class ExistsException extends BridgeException { - - /** - * The simplest constructor. - * @param entry the name of the object - */ - public ExistsException(String entry) { - super("exists_exception", entry); - } // constructor - - /** - * Constructor used by JNI code. - * @param ignored this argument will be ignored - * @param args array of arguments to be used in format of message. - */ - public ExistsException(String ignored, Object [] args) { - super("exists_exception", args); - } // constructor - -}// ExistsException diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/HostExistsException.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/HostExistsException.java deleted file mode 100644 index 1812079b0f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/HostExistsException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.bridge; - -/** - * The exception that occurs if host already exists. - */ -public class HostExistsException extends BridgeException { - /** - * The one and only constructor - * @param host the name of the host - */ - public HostExistsException(String host) { - super("host_exists_exception", host); - } // constructor -} // HostExistsException diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/InvalidPathException.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/InvalidPathException.java deleted file mode 100644 index b4820b1d58..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/InvalidPathException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2000-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.bridge; - -/** - * The exception that occurs if a data store path is not valid. - */ -public class InvalidPathException extends BridgeException { - - /** - * Constructor used by JNI code. - * @param ignored this argument will be ignored - * @param args array of arguments to be used in format of message. - */ - public InvalidPathException(String ignored, Object [] args) { - super("invalid_path_exception", args); - } // constructor - -} // InvalidPathException diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/InvalidRsrcException.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/InvalidRsrcException.java deleted file mode 100644 index 9476907c75..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/InvalidRsrcException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2000-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.bridge; - -/** - * The exception that occurs if a data store resource is not valid. - */ -public class InvalidRsrcException extends BridgeException { - - /** - * Constructor used by JNI code. - * @param ignored this argument will be ignored - * @param args array of arguments to be used in format of message. - */ - public InvalidRsrcException(String ignored, Object [] args) { - super("invalid_rsrc_exception", args); - } // constructor - -} // InvalidRsrcException diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/Makefile deleted file mode 100644 index b1b7821f2d..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/Makefile +++ /dev/null @@ -1,92 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/Makefile -# - -JNIHDR_FILES = com_sun_dhcpmgr_bridge_Bridge.h - -CLASSFILES = Bridge.class \ - BridgeException.class \ - HostExistsException.class \ - NoHostsEntryException.class \ - NoEntryException.class \ - ExistsException.class \ - NoTableException.class \ - TableExistsException.class \ - NoDefaultsException.class \ - NotRunningException.class \ - InvalidRsrcException.class \ - InvalidPathException.class \ - DsymException.class \ - WordexpException.class \ - ResourceStrings.class - -JNICLASSFILES = Bridge.class - -include $(SRC)/lib/Makefile.lib - -CLASSPATH= $(SRC)/cmd/cmd-inet/usr.sadm/dhcpmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -MSGDIR = $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/bridge -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr \ - $(MSGDIR) - -MSGFILES = ResourceBundle.properties -MSGS = $(MSGFILES:%=$(MSGDIR)/%) - -CLEANFILES= *.class $(JNIHDR_FILES) -CLOBBERFILES= - -.KEEP_STATE: - -all: $(CLASSFILES) $(JNIHDR_FILES) - -install: all - -# -# Build jni header file -# Use $@ instead of the "unreliable" $* -# -$(JNIHDR_FILES): $(JNICLASSFILES) - $(JAVAH) -jni -classpath $(CLASSPATH) \ - `$(ECHO) $@ | sed 's/.h$$//' | tr _ .` - -_msg: $(MSGDIRS) $(MSGS) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - -include $(SRC)/lib/Makefile.targ diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NoDefaultsException.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NoDefaultsException.java deleted file mode 100644 index e320c6ee62..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NoDefaultsException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2000-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.bridge; - -/** - * The exception that occurs if no DHCP defaults file exists. - */ -public class NoDefaultsException extends BridgeException { - - /** - * The basic constructor. - */ - public NoDefaultsException() { - super("no_defaults_exception"); - } // constructor - - /** - * Constructor used by JNI code. - * @param ignored this argument will be ignored - * @param args this argument will be ignored as well. - */ - public NoDefaultsException(String ignored, Object [] args) { - this(); - } // constructor - -} // NoDefaultsException diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NoEntryException.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NoEntryException.java deleted file mode 100644 index 9d04b5e8ff..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NoEntryException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.bridge; - -/** - * The exception that occurs if an object does not exist. - */ -public class NoEntryException extends BridgeException { - - /** - * The simplest constructor. - * @param entry the name of the object - */ - public NoEntryException(String entry) { - super("no_entry_exception", entry); - } // constructor - - /** - * Constructor used by JNI code. - * @param ignored this argument will be ignored - * @param args array of arguments to be used in format of message. - */ - public NoEntryException(String ignored, Object [] args) { - super("no_entry_exception", args); - } // constructor - -} // NoEntryException diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NoHostsEntryException.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NoHostsEntryException.java deleted file mode 100644 index a57b7ac827..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NoHostsEntryException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.bridge; - -/** - * The exception that occurs if a host does not exist. - */ -public class NoHostsEntryException extends BridgeException { - /** - * The one and only constructor - * @param host the name of the host - */ - public NoHostsEntryException(String host) { - super("no_hosts_entry_exception", host); - } // constructor -} // NoHostsEntryException diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NoTableException.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NoTableException.java deleted file mode 100644 index 5ba7d28ef5..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NoTableException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.bridge; - -/** - * The exception that occurs if a table does not exist. - */ -public class NoTableException extends BridgeException { - - /** - * Constructor used by JNI code. - * @param ignored this argument will be ignored - * @param args array of arguments to be used in format of message. - */ - public NoTableException(String ignored, Object [] args) { - super("no_table_exception", args); - } // constructor - -} // NoTableException diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NotRunningException.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NotRunningException.java deleted file mode 100644 index d53019b71a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/NotRunningException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.bridge; - -/** - * The exception that occurs if the DHCP server is not running. - */ -public class NotRunningException extends BridgeException { - - /** - * The simplest constructor. - */ - public NotRunningException() { - super("not_running_exception"); - } // constructor - - /** - * Constructor used by JNI code. - * @param ignored this argument will be ignored - * @param args this argument will be ignored as well. - */ - public NotRunningException(String ignored, Object [] args) { - this(); - } // constructor - -} // NotRunningException diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/ResourceBundle.properties b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/ResourceBundle.properties deleted file mode 100644 index 5c075abccc..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/ResourceBundle.properties +++ /dev/null @@ -1,79 +0,0 @@ -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -internal_error=An internal 'bridge' error has occurred. - -no_defaults_exception=The DHCP defaults file does not exist or cannot be read. -invalid_path_exception={0} is not a valid path. -invalid_rsrc_exception={0} is not a valid resource. -host_exists_exception=Host {0} already exists in hosts table. -no_hosts_entry_exception=Host {0} does not exist in hosts table. -not_running_exception=DHCP server is not running. -exists_exception={0} already exists. -table_exists_exception=Table for {0} already exists. -no_entry_exception={0} does not exist. -no_table_exception=Table for {0} does not exist. -inittab_cat_not_found=Requested inittab category does not exist. -wordexp_exception=wordexp(3c) returned {0}. - -dsvc_exists_exception=Already exists. -dsvc_access_exception=Access denied. -dsvc_credential_exception=No underlying service credential. -dsvc_no_ent_exception=Does not exist. -dsvc_busy_exception=Busy, try again. -dsvc_invalid_args_exception=Internal error, invalid arguments. -dsvc_internal_exception=Internal error. -dsvc_unavailable_exception=Underlying service required by public module is unavailable. -dsvc_collision_exception=Update collision. -dsvc_unsupported_exception=Operation unsupported. -dsvc_no_memory_exception=Virtual memory exhausted. -dsvc_no_resources_exception=Non-memory resources unavailable -dsvc_bad_resource_exception=Malformed/missing RESOURCE default. -dsvc_bad_path_exception=Malformed/missing PATH default. -dsvc_bad_authtoken_exception=Malformed/missing AUTHTOKEN default. -dsvc_mod_version_exception=Public module version mismatch. -dsvc_mod_err_exception=Error in public module. -dsvc_mod_load_err_exception=Error loading public module. -dsvc_mod_unload_err_exception=Error unloading public module. -dsvc_synch_err_exception=Error in synchronization protocol. -dsvc_no_lockmgr_exception=Cannot contact lock manager. -dsvc_no_location_exception=Location nonexistent. -dsvc_bad_conver_exception=Malformed/missing CONVER default. -dsvc_no_table_exception=Table does not exist. -dsvc_table_exists_exception=Table already exists. - -dsym_too_few_fields_exception={0} option definition does not contain enough fields. -dsym_too_many_fields_exception={0} option definition contains too many fields. -dsym_syntax_exception={0} is syntactically incorrect. -dsym_code_out_of_range_exception={0} option codes must be between {1} and {2}. -dsym_value_out_of_range_exception=The value {0} is outside the valid range. -dsym_invalid_cat_exception={0} is not a valid option category. -dsym_invalid_type_exception={0} is not a valid option type. -dsym_exceeds_class_size_exception=The option vendor definition contains classes that exceed the maximum of {0} characters. -dsym_exceeds_max_class_size_exception=The option vendor definition exceeds the maximum of {0} characters. -dsym_no_memory_exception=Virtual memory exhausted. -dsym_internal_exception=Internal error occurred while parsing dhcptab options. diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/ResourceStrings.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/ResourceStrings.java deleted file mode 100644 index fddc89bc17..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/ResourceStrings.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.bridge; - -import java.util.*; - -/** - * This class provides a static handle to the strings in the "bridge" - * ResourceBundle. - */ -public class ResourceStrings { - - /** - * The handle to the ResourceBundle. - */ - private static ResourceBundle bundle = null; - - /** - * This method retrieves a string from the ResourceBundle. - * @param key the ResourceBundle key - * @return the message from he ResourceBundle - */ - public static String getString(String key) { - String msg = null; - try { - if (bundle == null) { - bundle = ResourceBundle.getBundle( - "com.sun.dhcpmgr.bridge.ResourceBundle", - Locale.getDefault()); - } - msg = bundle.getString(key); - } catch (Throwable e) { - msg = new String(key); - } - return msg; - - } // getString - -} // ResourceStrings diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/TableExistsException.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/TableExistsException.java deleted file mode 100644 index 8493939eb1..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/TableExistsException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.bridge; - -/** - * The exception that occurs if a table already exists. - */ -public class TableExistsException extends BridgeException { - - /** - * Constructor used by JNI code. - * @param ignored this argument will be ignored - * @param args array of arguments to be used in format of message. - */ - public TableExistsException(String ignored, Object [] args) { - super("table_exists_exception", args); - } // constructor - -} // TableExistsException diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/WordexpException.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/WordexpException.java deleted file mode 100644 index 7e59601558..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/bridge/WordexpException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.bridge; - -/** - * The exception class used for wordexp(3c) errors. - */ -public class WordexpException extends BridgeException { - - /** - * Constructor used by JNI code. - * @param ignored this argument will be ignored. - * @param args array of arguments to be used in format of message. - */ - public WordexpException(String ignored, Object [] args) { - super("wordexp_exception", args); - } // constructor - -} // WordexpException diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/Makefile deleted file mode 100644 index fce34554a0..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/Makefile - -include $(SRC)/cmd/Makefile.cmd - -SUBDIRS = dhcpconfig dhtadm pntadm dhcpbatch common - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -.KEEP_STATE: - -all install clean clobber lint _msg: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/Console.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/Console.java deleted file mode 100644 index 6f69ed30e5..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/Console.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -package com.sun.dhcpmgr.cli.common; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.io.IOException; - -/** - * This class provides convenient methods to read from System.in. - */ -public class Console -{ - /** - * Prompt the user for a yes/no reply and read the reply. - * @param prompt the prompt message - * @param trueValue the value that represents an affirmative response - * @param falseValue the value that represents a negative response - * @param defaultReturn indicates whether affirmative or negative is - * the default (true means affirmative, false means negative) - * @return true if affirmative response, false if negative - */ - public static boolean promptUser(String prompt, - String trueValue, String falseValue, boolean defaultReturn) { - - boolean done = false; - boolean result = defaultReturn; - - StringBuffer buffer = new StringBuffer(prompt); - buffer.append(" ("); - if (defaultReturn) { - buffer.append('['); - buffer.append(trueValue); - buffer.append("]/"); - buffer.append(falseValue); - } else { - buffer.append(trueValue); - buffer.append("/["); - buffer.append(falseValue); - buffer.append(']'); - } - buffer.append("): "); - - while (!done) { - System.out.print(buffer.toString()); - System.out.flush(); - String line = readLine(); - if (line == null || line.length() == 0) { - done = true; - } else if (line.equalsIgnoreCase(trueValue)) { - result = true; - done = true; - } else if (line.equalsIgnoreCase(falseValue)) { - result = false; - done = true; - } - } - - return (result); - - } // promptUser - - /** - * Read a line from System.in. - * @return the line or null in case of exception - */ - public static String readLine() { - - String line = null; - - try { - BufferedReader reader = - new BufferedReader(new InputStreamReader(System.in)); - - line = reader.readLine(); - } catch (IOException e) { - // ignore and return null - } - - return (line); - } // readLine -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliFunction.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliFunction.java deleted file mode 100644 index 850506fc27..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliFunction.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.common; - -import com.sun.dhcpmgr.data.DhcpDatastore; -import com.sun.dhcpmgr.data.Option; -import com.sun.dhcpmgr.data.StandardOptions; -import com.sun.dhcpmgr.server.DhcpMgr; -import com.sun.dhcpmgr.server.DhcpMgrImpl; -import com.sun.dhcpmgr.server.DhcpServiceMgr; -import com.sun.dhcpmgr.server.DhcpNetMgr; -import com.sun.dhcpmgr.server.DhcptabMgr; -import com.sun.dhcpmgr.bridge.*; - -import java.lang.IllegalArgumentException; - -/** - * This class is the base class extended by the DHCP CLI subcommand classes. - */ -public abstract class DhcpCliFunction { - - /** - * The options for the function. - */ - protected DhcpCliOptions options = null; - protected int validOptions[]; - - /** - * Handles to the managers. - */ - static private DhcpMgr dhcpMgr = null; - static private DhcpNetMgr netMgr = null; - static private DhcptabMgr dhcptabMgr = null; - static private DhcpServiceMgr svcMgr = null; - - /** - * The DhcpDatastore to be used for this function. A value of 'null' - * means to just use DHCP defaults. - */ - private DhcpDatastore datastore = null; - - /** - * Constructor. - */ - public DhcpCliFunction() { - dhcpMgr = new DhcpMgrImpl(); - } // constructor - - /** - * Get a handle to the DhcpNetMgr - * @return an instance of DhcpNetMgr - */ - public static DhcpMgr getDhcpMgr() { - return dhcpMgr; - } // getDhcpMgr - - /** - * Get a handle to the DhcpNetMgr - * @return an instance of DhcpNetMgr - */ - public static DhcpNetMgr getNetMgr() { - if (netMgr == null) { - netMgr = dhcpMgr.getNetMgr(); - } - return netMgr; - } // getNetMgr - - /** - * Get a handle to the DhcptabMgr - * @return an instance of DhcptabMgr - */ - public static DhcptabMgr getDhcptabMgr() { - if (dhcptabMgr == null) { - dhcptabMgr = dhcpMgr.getDhcptabMgr(); - } - return dhcptabMgr; - } // getDhcptabMgr - - /** - * Get a handle to the DhcpServiceMgr - * @return an instance of DhcpServiceMgr - */ - public static DhcpServiceMgr getSvcMgr() { - if (svcMgr == null) { - svcMgr = dhcpMgr.getDhcpServiceMgr(); - } - return svcMgr; - } // getSvcMgr - - /** - * Used to execute the subcommand functionality. - */ - public abstract int execute() - throws IllegalArgumentException; - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public abstract int getFunctionFlag(); - - /** - * Returns the DhcpDatastore associated with this function. - * @returns the DhcpDatastore associated with this function. - */ - public DhcpDatastore getDhcpDatastore() { - return datastore; - } // getDhcpDatastore - - /** - * Sets the DhcpDatastore associated with this function. - * @param ds the data store - */ - public void setDhcpDatastore(DhcpDatastore ds) { - datastore = ds; - } // setDhcpDatastore - - /** - * Sets the DhcpDatastore associated with this function. - * @param r the data store resource - * @param l the data store location - * @param a the data store config - */ - public void setDhcpDatastore(String r, String l, String a) { - datastore = createDhcpDatastore(r, l, a); - } // setDhcpDatastore - - /** - * Create a DhcpDatastore with the given argument values as attributes. - * @param r the data store resource - * @param l the data store location - * @param a the data store config - * @returns a DhcpDatastore with the given argument values as attributes - * or null if all arguments are null. - */ - public DhcpDatastore createDhcpDatastore(String r, String l, String a) { - return this.createDhcpDatastore(r, l, a, -1); - } // createDhcpDatastore - - /** - * Create a DhcpDatastore with the given argument values as attributes. - * @param r the data store resource - * @param l the data store location - * @param a the data store config - * @param v the data store resource version - * @returns a DhcpDatastore with the given argument values as attributes - * or null if all arguments are null. - */ - public DhcpDatastore createDhcpDatastore(String r, String l, String a, - int v) { - - DhcpDatastore datastore = null; - - if (r != null || l != null || a != null || v != -1) { - datastore = new DhcpDatastore(r, l, a, v); - } - - return datastore; - } // createDhcpDatastore - - /** - * Used to determine whether or not the data store version is valid. - */ - public boolean isVersionValid(boolean ignoreAbsentDefaults) { - - boolean isValid = false; - try { - isValid = getSvcMgr().isVersionCurrent(); - - if (!isValid) { - printCmnErrMessage("need_to_convert_datastore"); - } - } catch (NoDefaultsException e) { - if (!ignoreAbsentDefaults) { - printCmnErrMessage("no_conf_warning"); - } - isValid = true; - } catch (Throwable e) { - printCmnErrMessage(e.getMessage()); - } - - return isValid; - - } // isVersionValid - - /** - * Used to set the read the STANDARD options from the DHCP inittab and - * to initialize the StandardOptions table with these options. - */ - public void setStandardOptions() { - try { - StandardOptions.setAllOptions(getSvcMgr().getInittabOptions( - Option.ctxts[Option.STANDARD].getCode())); - } catch (Throwable e) { - printCmnErrMessage(e.getMessage()); - } - } // setStandardOptions - - /** - * Used to set the options for this function. Validates that the options - * received were only options that are legitimate for this subcommand. - * @param options the options object built as a result of parsing - * command line input. - */ - public void setOptions(DhcpCliOptions options) - throws IllegalArgumentException { - - options.validate(validOptions); - this.options = options; - - } // setOptions - - /** - * Uses the resourceKey to retrieve a string from a ResourceBundle (if - * one exists) and prints the string to the console. - * @param resourceKey the ResourceBundle key value. - */ - public void printCmnMessage(String resourceKey) { - DhcpCliPrint.printMessage(ResourceStrings.getString(resourceKey)); - } // printMessage - - /** - * Uses the resourceKey to retrieve a string from a ResourceBundle (if - * one exists) and prints the string to the console error stream. - * @param resourceKey the ResourceBundle key value. - */ - public void printCmnErrMessage(String resourceKey) { - DhcpCliPrint.printErrMessage(ResourceStrings.getString(resourceKey)); - } // printErrMessage - - /** - * Given a Throwable object, returns a message for it. - * @param e the Throwable object. - * @returns a message. - */ - public static String getMessage(Throwable e) { - String message = e.getMessage(); - if (message == null) { - message = e.toString(); - } - return message; - } // getMessage - -} // DhcpCliFunction diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliOption.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliOption.java deleted file mode 100644 index 667cd64d6d..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliOption.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.common; - -/** - * This class is used to represent one command line option. - */ -public class DhcpCliOption { - - /** - * The option key. - */ - private int option; - - /** - * The value of the option. - */ - private String value; - - /** - * Constructor most likely used to create a boolean option. - * @param option the option key value - */ - public DhcpCliOption(int option) { - - this(option, null); - - } // constructor - - /** - * Constructor most likely used to create a String valued option. - * @param option the option key value - */ - public DhcpCliOption(int option, String value) { - - this.option = option; - this.value = value; - - } // constructor - - /** - * Returns the option key value. - * @return the option key value - */ - public int getOption() { - - return option; - - } // getOption - - /** - * Set the option key value. - * @param option the option key value - */ - public void setOption(int option) { - - this.option = option; - - } // setOption - - /** - * Returns the option key value as a Character. - * @param option the key value which needs converting. - * @return the option key value as a Character. - */ - public static Character getOptionCharacter(int option) { - - return (new Character((char)option)); - - } // getOptionCharacter - - /** - * Returns the option key value as a Character. - * @return the option key value as a Character. - */ - public Character getOptionCharacter() { - - return (getOptionCharacter(option)); - - } // getOptionCharacter - - /** - * Returns the option value. - * @return the option value - */ - public String getValue() { - - return value; - - } // getValue - - /** - * Set the option value. - * @param option the option value - */ - public void setValue(String value) { - - this.value = value; - - } // setValue - - /** - * Compare for equality against another object. - * @return true if the object is another DhcpCliOption instance and - * they are both have the same key value. The value of 'value' is - * irrelevant. This is primarily used by the indexOf method of the - * ArrayList used to store the options in DhcpCliOptions. - */ - public boolean equals(Object o) { - - if (o instanceof DhcpCliOption) { - DhcpCliOption op = (DhcpCliOption)o; - return (option == op.getOption()); - } else { - return false; - } - - } // equals - - /** - * The obligatory toString() method that returns a string representation - * of an object of this class. - * @return a string representation of an object of this class. - */ - public String toString() { - - return option + "=" + value; - - } // toString - -} // DhcpCliOption diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliOptions.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliOptions.java deleted file mode 100644 index f7ae59a93e..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliOptions.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.common; - -import java.lang.IllegalArgumentException; -import java.util.ArrayList; -import java.text.MessageFormat; - -/** - * This class is used to represent all the command line options. - */ -public class DhcpCliOptions { - - /** - * Actual container for the options. - */ - ArrayList options; - - /** - * Basic constructor. - */ - public DhcpCliOptions() { - - options = new ArrayList(); - - } // constructor - - /** - * Creates a new option and adds it to the list. - * @param flag the option key value - * @param value the option value - */ - public void setOption(int flag, String value) - throws IllegalArgumentException { - - DhcpCliOption option = new DhcpCliOption(flag, value); - int i = options.indexOf(option); - if (i == -1) { - options.add(option); - } else { - String format = - ResourceStrings.getString("repeated_option"); - Object[] args = new Object[1]; - args[0] = option.getOptionCharacter(); - String msg = MessageFormat.format(format, args); - throw new IllegalArgumentException(msg); - } - - } // setOption - - /** - * Reports as to whether or not an option exists in the list. - * @param flag the option key value - * @return true if the option is in the list, false if not - */ - public boolean isSet(int flag) { - - DhcpCliOption option = new DhcpCliOption(flag); - return options.contains(option); - - } // isSet - - /** - * Returns the value of an option. - * @param flag the option key value - * @return the value of the option or null if the option is not - * in the list. - */ - public String valueOf(int flag) { - - DhcpCliOption option = new DhcpCliOption(flag); - - int i = options.indexOf(option); - if (i != -1) { - return ((DhcpCliOption)options.get(i)).getValue(); - } else { - return null; - } - } // valueOf - - /** - * Given a list of supported options, validates that there are no - * options in the in the option list that are not supported. - * @param supportedOptions array of option key values - * @return true if there are no options in the option list that are - * not in the supportedOptions, false otherwise. - */ - public void validate(int [] supportedOptions) - throws IllegalArgumentException { - - boolean result = true; - int option = 0; - - for (int i = 0; i < options.size() && result; i++) { - option = ((DhcpCliOption)options.get(i)).getOption(); - result = false; - for (int j = 0; j < supportedOptions.length && !result; j++) { - if (supportedOptions[j] == option) { - result = true; - } - } - } - - if (!result) { - String format = - ResourceStrings.getString("bad_function_option"); - Object[] args = new Object[1]; - args[0] = DhcpCliOption.getOptionCharacter(option); - String msg = MessageFormat.format(format, args); - throw new IllegalArgumentException(msg); - } - - } // validate - -} // DhcpCliOptions diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliPrint.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliPrint.java deleted file mode 100644 index c0a4ae8735..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliPrint.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.common; - -/** - * This class provides methods that may be used to retrieve strings from - * ResourceBundles and print resulting messages to the console. - */ -public class DhcpCliPrint { - - /** - * Prints a message to standard output stream. - * @param msg the message to print. - */ - public static void printMessage(String msg) { - System.out.println(msg); - } // printMessage - - /** - * Prints a message to the standard error stream. - * @param msg the message to print. - */ - public static void printErrMessage(String msg) { - System.err.println(msg); - } // printErrMessage - -} // DhcpCliPrint diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliProgram.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliProgram.java deleted file mode 100644 index f266eee112..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/DhcpCliProgram.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.common; - -import java.text.MessageFormat; - -/** - * This class is the base class extended by the DHCP CLI program classes. - */ -public abstract class DhcpCliProgram { - - /** - * Defines the functionality to be performed. - */ - protected DhcpCliFunction function = null; - protected DhcpCliOptions options = null; - - /** - * Program arguments. - */ - protected String [] args = null; - - /** - * Return codes. - */ - public static final int FAILURE = -1; - public static final int SUCCESS = 0; - public static final int EXISTS = 1; - public static final int ENOENT = 2; - public static final int WARNING = 3; - public static final int CRITICAL = 4; - - /** - * Returns the manpage signature for the program. - * @return the manpage signature for the program. - */ - public abstract String getManPage(); - - /** - * Uninitializes the program function. - */ - protected void clearFunction() { - function = null; - } - - /** - * Sets the function that the user has requested. - * @param function user requested function. - */ - protected void setFunction(DhcpCliFunction function) - throws IllegalArgumentException { - - if (this.function != null) { - Object [] args = new Object[2]; - args[0] = DhcpCliOption.getOptionCharacter( - this.function.getFunctionFlag()); - args[1] = DhcpCliOption.getOptionCharacter( - function.getFunctionFlag()); - String msg = ResourceStrings.getString("multiple_functions"); - MessageFormat form = new MessageFormat(msg); - throw new IllegalArgumentException(form.format(args)); - } - - this.function = function; - } - - /** - * Checks to see if the user has permission to run the program. - * @return true if the user has permission to execute, false otherwise. - */ - protected boolean isValidUser() { - - // Must be root to run. - // - if (!System.getProperty("user.name").equals("root")) { - - Object [] args = new Object[1]; - args[0] = getManPage(); - String msg = ResourceStrings.getString("user_not_allowed"); - MessageFormat form = new MessageFormat(msg); - DhcpCliPrint.printErrMessage(form.format(args)); - - return false; - } - return true; - - } // isValidUser - -} // DhcpCliProgram diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/Format.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/Format.java deleted file mode 100644 index f53c12cb24..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/Format.java +++ /dev/null @@ -1,608 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -/* - * Cay S. Horstmann & Gary Cornell, Core Java - * Published By Sun Microsystems Press/Prentice-Hall - * Copyright (C) 1997 Sun Microsystems Inc. - * All Rights Reserved. - * - * Permission to use, copy, modify, and distribute this - * software and its documentation for NON-COMMERCIAL purposes - * and without fee is hereby granted provided that this - * copyright notice appears in all copies. - * - * THE AUTHORS AND PUBLISHER MAKE NO REPRESENTATIONS OR - * WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHORS - * AND PUBLISHER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED - * BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING - * THIS SOFTWARE OR ITS DERIVATIVES. - */ - -/** - * A class for formatting numbers that follows printf conventions. - * Also implements C-like atoi and atof functions - * @version 1.01 15 Feb 1996 - * @author Cay Horstmann - */ - -package com.sun.dhcpmgr.cli.common; - -import java.io.*; - -public class Format - -{ - /** - * Formats the number following printf conventions. - * Main limitation: Can only handle one format parameter at a time - * Use multiple Format objects to format more than one number - * @param s the format string following printf conventions - * The string has a prefix, a format code and a suffix. The prefix and - * suffix become part of the formatted output. The format code directs the - * formatting of the (single) parameter to be formatted. The code has the - * following structure - * <ul> - * <li> a % (required) - * <li> a modifier (optional) - * <dl> - * <dt> + <dd> forces display of + for positive numbers - * <dt> 0 <dd> show leading zeroes - * <dt> - <dd> align left in the field - * <dt> space <dd> prepend a space in front of positive numbers - * <dt> # <dd> use "alternate" format. Add 0 or 0x for octal or hexadecimal - * numbers. Don't suppress trailing zeroes in general floating point format. - * </dl> - * <li> an integer denoting field width (optional) - * <li> a period followed by an integer denoting precision (optional) - * <li> a format descriptor (required) - * <dl> - * <dt>f <dd> floating point number in fixed format - * <dt>e, E <dd> floating point number in exponential notation (scientific - * format). The E format results in an uppercase E for the exponent - * (1.14130E+003), the e format in a lowercase e. - * <dt>g, G <dd> floating point number in general format (fixed format for - * small numbers, exponential format for large numbers). Trailing zeroes - * are suppressed. The G format results in an uppercase E for the exponent - * (if any), the g format in a lowercase e. - * <dt>d, i <dd> integer in decimal - * <dt>x <dd> integer in hexadecimal - * <dt>o <dd> integer in octal - * <dt>s <dd> string - * <dt>c <dd> character - * </dl> - * </ul> - * @exception IllegalArgumentException if bad format - */ - public Format(String s) { - width = 0; - precision = -1; - pre = ""; - post = ""; - leading_zeroes = false; - show_plus = false; - alternate = false; - show_space = false; - left_align = false; - fmt = ' '; - - int state = 0; - int length = s.length(); - int parse_state = 0; - // 0 = prefix, 1 = flags, 2 = width, 3 = precision, - // 4 = format, 5 = end - int i = 0; - - while (parse_state == 0) { - if (i >= length) { - parse_state = 5; - } else if (s.charAt(i) == '%') { - if (i < length - 1) { - if (s.charAt(i + 1) == '%') { - pre = pre + '%'; - i++; - } else { - parse_state = 1; - } - } else { - throw new java.lang.IllegalArgumentException(); - } - } else { - pre = pre + s.charAt(i); - } - i++; - } - - while (parse_state == 1) { - if (i >= length) { - parse_state = 5; - } else if (s.charAt(i) == ' ') { - show_space = true; - } else if (s.charAt(i) == '-') { - left_align = true; - } else if (s.charAt(i) == '+') { - show_plus = true; - } else if (s.charAt(i) == '0') { - leading_zeroes = true; - } else if (s.charAt(i) == '#') { - alternate = true; - } else { - parse_state = 2; i--; - } - i++; - } - - while (parse_state == 2) { - if (i >= length) { - parse_state = 5; - } else if ('0' <= s.charAt(i) && s.charAt(i) <= '9') { - width = width * 10 + s.charAt(i) - '0'; - i++; - } else if (s.charAt(i) == '.') { - parse_state = 3; - precision = 0; - i++; - } else { - parse_state = 4; - } - } - - while (parse_state == 3) { - if (i >= length) { - parse_state = 5; - } else if ('0' <= s.charAt(i) && s.charAt(i) <= '9') { - precision = precision * 10 + s.charAt(i) - '0'; - i++; - } else { - parse_state = 4; - } - } - - if (parse_state == 4) { - if (i >= length) { - parse_state = 5; - } else { - fmt = s.charAt(i); - } - i++; - } - - if (i < length) { - post = s.substring(i, length); - } - } - - /** - * prints a formatted number following printf conventions - * @param s a PrintStream - * @param fmt the format string - * @param x the double to print - */ - public static void print(java.io.PrintStream s, String fmt, double x) { - s.print(new Format(fmt).form(x)); - } - - /** - * prints a formatted number following printf conventions - * @param s a PrintStream - * @param fmt the format string - * @param x the long to print - */ - public static void print(java.io.PrintStream s, String fmt, long x) { - s.print(new Format(fmt).form(x)); - } - - /** - * prints a formatted number following printf conventions - * @param s a PrintStream - * @param fmt the format string - * @param x the character to - */ - public static void print(java.io.PrintStream s, String fmt, char x) { - s.print(new Format(fmt).form(x)); - } - - /** - * prints a formatted number following printf conventions - * @param s a PrintStream, fmt the format string - * @param x a string that represents the digits to print - */ - public static void print(java.io.PrintStream s, String fmt, String x) { - s.print(new Format(fmt).form(x)); - } - - /** - * Converts a string of digits(decimal, octal or hex) to an integer - * @param s a string - * @return the numeric value of the prefix of s representing a base - * 10 integer - */ - public static int atoi(String s) { - return (int)atol(s); - } - - /** - * Converts a string of digits(decimal, octal or hex) to a long integer - * @param s a string - * @return the numeric value of the prefix of s representing a base - * 10 integer - */ - public static long atol(String s) { - int i = 0; - - while (i < s.length() && Character.isWhitespace(s.charAt(i))) { - i++; - } - - if (i < s.length() && s.charAt(i) == '0') { - if (i + 1 < s.length() && (s.charAt(i + 1) == 'x' || - s.charAt(i + 1) == 'X')) { - return parseLong(s.substring(i + 2), 16); - } else { - return parseLong(s, 8); - } - } else { - return parseLong(s, 10); - } - } - - private static long parseLong(String s, int base) { - int i = 0; - int sign = 1; - long r = 0; - - while (i < s.length() && Character.isWhitespace(s.charAt(i))) { - i++; - } - - if (i < s.length() && s.charAt(i) == '-') { - sign = -1; i++; - } else if (i < s.length() && s.charAt(i) == '+') { - i++; - } - - while (i < s.length()) { - char ch = s.charAt(i); - if ('0' <= ch && ch < '0' + base) { - r = r * base + ch - '0'; - } else if ('A' <= ch && ch < 'A' + base - 10) { - r = r * base + ch - 'A' + 10; - } else if ('a' <= ch && ch < 'a' + base - 10) { - r = r * base + ch - 'a' + 10; - } else { - return r * sign; - } - i++; - } - return r * sign; - } - - /** - * Converts a string of digits to an double - * @param s a string - */ - public static double atof(String s) { - int i = 0; - int sign = 1; - double r = 0; // integer part - double f = 0; // fractional part - double p = 1; // exponent of fractional part - int state = 0; // 0 = int part, 1 = frac part - - while (i < s.length() && Character.isWhitespace(s.charAt(i))) { - i++; - } - - if (i < s.length() && s.charAt(i) == '-') { - sign = -1; i++; - } else if (i < s.length() && s.charAt(i) == '+') { - i++; - } - - while (i < s.length()) { - char ch = s.charAt(i); - if ('0' <= ch && ch <= '9') { - if (state == 0) { - r = r * 10 + ch - '0'; - } else if (state == 1) { - p = p / 10; - r = r + p * (ch - '0'); - } - } else if (ch == '.') { - if (state == 0) { - state = 1; - } else { - return sign * r; - } - } else if (ch == 'e' || ch == 'E') { - long e = (int)parseLong(s.substring(i + 1), 10); - return sign * r * Math.pow(10, e); - } else { - return sign * r; - } - i++; - } - return sign * r; - } - - /** - * Formats a double into a string (like sprintf in C) - * @param x the number to format - * @return the formatted string - * @exception IllegalArgumentException if bad argument - */ - public String form(double x) { - String r; - if (precision < 0) { - precision = 6; - } - - int s = 1; - if (x < 0) { - x = -x; - s = -1; - } - - if (fmt == 'f') { - r = fixed_format(x); - } else if (fmt == 'e' || fmt == 'E' || fmt == 'g' || fmt == 'G') { - r = exp_format(x); - } else { - throw new java.lang.IllegalArgumentException(); - } - - return pad(sign(s, r)); - } - - /** - * Formats a long integer into a string (like sprintf in C) - * @param x the number to format - * @return the formatted string - */ - public String form(long x) { - String r; - int s = 0; - if (fmt == 'd' || fmt == 'i') { - s = 1; - if (x < 0) { - x = -x; s = -1; - } - r = "" + x; - } else if (fmt == 'o') { - r = convert(x, 3, 7, "01234567"); - } else if (fmt == 'x') { - r = convert(x, 4, 15, "0123456789abcdef"); - } else if (fmt == 'X') { - r = convert(x, 4, 15, "0123456789ABCDEF"); - } else { - throw new java.lang.IllegalArgumentException(); - } - return pad(sign(s, r)); - } - - /** - * Formats a character into a string (like sprintf in C) - * @param x the value to format - * @return the formatted string - */ - public String form(char c) { - if (fmt != 'c') { - throw new java.lang.IllegalArgumentException(); - } - String r = "" + c; - return pad(r); - } - - /** - * Formats a string into a larger string (like sprintf in C) - * @param x the value to format - * @return the formatted string - */ - public String form(String s) { - if (fmt != 's') { - throw new java.lang.IllegalArgumentException(); - } - - if (precision >= 0) { - s = s.substring(0, precision); - } - return pad(s); - } - - private static String repeat(char c, int n) { - if (n <= 0) { - return ""; - } - StringBuffer s = new StringBuffer(n); - for (int i = 0; i < n; i++) { - s.append(c); - } - return s.toString(); - } - - private static String convert(long x, int n, int m, String d) { - if (x == 0) { - return "0"; - } - String r = ""; - while (x != 0) { - r = d.charAt((int)(x & m)) + r; - x = x >>> n; - } - return r; - } - - private String pad(String r) { - String p = repeat(' ', width - r.length()); - if (left_align) { - return pre + r + p + post; - } else { - return pre + p + r + post; - } - } - - private String sign(int s, String r) { - String p = ""; - if (s < 0) { - p = "-"; - } else if (s > 0) { - if (show_plus) { - p = "+"; - } else if (show_space) { - p = " "; - } - } else { - if (fmt == 'o' && alternate && r.length() > 0 && - r.charAt(0) != '0') { - p = "0"; - } else if (fmt == 'x' && alternate) { - p = "0x"; - } else if (fmt == 'X' && alternate) { - p = "0X"; - } - } - - int w = 0; - if (leading_zeroes) { - w = width; - } else if ((fmt == 'd' || fmt == 'i' || fmt == 'x' || - fmt == 'X' || fmt == 'o') && precision > 0) { - w = precision; - } - - return p + repeat('0', w - p.length() - r.length()) + r; - } - - - private String fixed_format(double d) { - String f = ""; - - if (d > 0x7FFFFFFFFFFFFFFFL) { - return exp_format(d); - } - - long l = (long)(precision == 0 ? d + 0.5 : d); - f = f + l; - - double fr = d - l; // fractional part - if (fr >= 1 || fr < 0) { - return exp_format(d); - } - - return f + frac_part(fr); - } - - private String frac_part(double fr) { - // precondition: 0 <= fr < 1 - String z = ""; - if (precision > 0) { - double factor = 1; - String leading_zeroes = ""; - for (int i = 1; i <= precision && factor <= 0x7FFFFFFFFFFFFFFFL; - i++) { - factor *= 10; - leading_zeroes = leading_zeroes + "0"; - } - long l = (long) (factor * fr + 0.5); - - z = leading_zeroes + l; - z = z.substring(z.length() - precision, z.length()); - } - - - if (precision > 0 || alternate) { - z = "." + z; - } - - if ((fmt == 'G' || fmt == 'g') && !alternate) { - // remove trailing zeroes and decimal point - int t = z.length() - 1; - while (t >= 0 && z.charAt(t) == '0') { - t--; - } - if (t >= 0 && z.charAt(t) == '.') { - t--; - } - z = z.substring(0, t + 1); - } - return z; - } - - private String exp_format(double d) { - String f = ""; - int e = 0; - double dd = d; - double factor = 1; - - while (dd > 10) { - e++; factor /= 10; dd = dd / 10; - } - - while (dd < 1) { - e--; factor *= 10; dd = dd * 10; - } - - if ((fmt == 'g' || fmt == 'G') && e >= -4 && e < precision) { - return fixed_format(d); - } - - d = d * factor; - f = f + fixed_format(d); - - if (fmt == 'e' || fmt == 'g') { - f = f + "e"; - } else { - f = f + "E"; - } - - String p = "000"; - if (e >= 0) { - f = f + "+"; - p = p + e; - } else { - f = f + "-"; - p = p + (-e); - } - - return f + p.substring(p.length() - 3, p.length()); - } - - private int width; - private int precision; - private String pre; - private String post; - private boolean leading_zeroes; - private boolean show_plus; - private boolean alternate; - private boolean show_space; - private boolean left_align; - private char fmt; // one of cdeEfgGiosxXos -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/GetOpt.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/GetOpt.java deleted file mode 100644 index 4aae63cd4a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/GetOpt.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.common; - -import java.lang.IllegalArgumentException; -import java.text.MessageFormat; - -/** - * This class provides the functionality for parsing command line - * arguments (similar to getopt(3C)). - * After constructing an instance of it, getNextOption() can be used - * to get the next option. getOptionArg() can be used to get the argument for - * that option. getNextOptionIndex() returns how many arguments are already - * processed from the arguments list. - * - * This code was "borrowed" from the Viper project. We have our own copy of - * this code, because the Viper project has deprecated their class and we - * have had to modify the original code. - */ -public class GetOpt { - protected int optind = 0; - protected String optarg = null; - protected String argv[] = null; - protected int argc = 0; - protected String optionString = null; - - // e.g in -v (- is in 0th position) - // - int MINUS_POSITION = 0; - - // e.g. in -v (v is in 1st position ) - // - int OPTION_POSITION = 1; - - // e.g. in -vGoldrush (G is in 2nd position ) - // - int AFTER_OPTION_POSITION = 2; - - /** - * Constructor - * @parameter argv -- Array of string arguments. - * @parameter optionString -- contains the option letters that - * will be recognized; - * if a letter is followed by a colon, - * the option is expected to have an argument. - * if a letter is followed by a semi-colon, - * the argument to the letter is optional. - * e.g. abdf:e - * legal arguments are a, b, d, f, e. - * f option requires a argument. - */ - public GetOpt(String argv[], String optionString) { - this.argv = argv; - this.optionString = optionString; - this.argc = argv.length; - } - - /* - * Returns the next valid option. - * Throws an IllegalArgumentException - * a) if option is not valid or - * b) an option required an argument and is not provided - * Returns -1 if no more options left. - */ - public int getNextOption() throws IllegalArgumentException { - char currentOption; - optarg = null; - - // ------------------------------------------------ - // Find out if option exists - - if (optind >= argc || (argv[optind].length() < 2) || - argv[optind].charAt(MINUS_POSITION) != '-') { - - return -1; - } - - // --------------------------------------------------- - // So see if it is a legal option - - currentOption = argv[optind].charAt(OPTION_POSITION); - - if (!isValidOption(currentOption)) { - optind = optind + 1; - String format = ResourceStrings.getString("getopt_illegal_option"); - Object[] args = new Object[1]; - args[0] = new Character((char)currentOption); - String msg = MessageFormat.format(format, args); - throw new IllegalArgumentException(msg); - } - - // ------------------------------------------------------------ - // We have a legal option now, find out if it expected to have optarg. - - if (isOptionArgAllowedByOption(currentOption) && - OPTION_POSITION == 1) { - - // ------------------------------------- - // Case when optarg is given with the option itself, - // like -hlastgas.east. Then extract the optarg out. - - if (argv[optind].length() != 2) { - optarg = argv[optind].substring(AFTER_OPTION_POSITION); - optind++; - } - // ------------------------------------------ - // Case when optarg is not provided, return error if it was - // mandatory - - else if (optind+1 >= argc) { - optind++; - if (isOptionArgMandatoryByOption(currentOption)) { - String format = - ResourceStrings.getString("getopt_requires_argument"); - Object[] args = new Object[1]; - args[0] = new Character((char)currentOption); - String msg = MessageFormat.format(format, args); - throw new IllegalArgumentException(msg); - } - } - // ------------------------------------------------ - // Case when there is a argument that could have been used - // as a optarg, but actually it is just another option. - - else if ((argv[optind+1].length() > MINUS_POSITION) && - (argv[optind+1].charAt(MINUS_POSITION) == '-') && - (isValidOption(argv[optind+1].charAt(OPTION_POSITION)))) { - optind++; - if (isOptionArgMandatoryByOption(currentOption)) { - String format = - ResourceStrings.getString("getopt_requires_argument"); - Object[] args = new Object[1]; - args[0] = new Character((char)currentOption); - String msg = MessageFormat.format(format, args); - throw new IllegalArgumentException(msg); - } - } - - // -------------------------------------------- - // Finally the good case - - else { - optarg = argv[++optind]; - optind++; - } - - OPTION_POSITION = 1; - - } else if (isOptionArgMandatoryByOption(currentOption)) { - String format = ResourceStrings.getString("getopt_cannot_group"); - Object[] args = new Object[1]; - args[0] = new Character((char)currentOption); - String msg = MessageFormat.format(format, args); - throw new IllegalArgumentException(msg); - } else if (argv[optind].length() == OPTION_POSITION + 1) { - OPTION_POSITION = 1; - optind++; - } else { // illegal argument supplied for option - OPTION_POSITION++; - } - return currentOption; - } - - /** - * Returns the argument for the option being handled. - */ - public String getOptionArg() { - return optarg; - } - - /** - * Returns true if option is a valid option - */ - private boolean isValidOption(char c) { - if ((c == ':') || (optionString.indexOf(c) == -1)) { - return false; - } else { - return true; - } - } - - /** - * Returns true if option provided needs a argument. - * throws exception if option is not a valid option at first place. - */ - private boolean isOptionArgMandatoryByOption(char option) { - int x = option; - if (isValidOption(option) - && (optionString.length() > optionString.indexOf(option) + 1) - && (optionString.charAt(optionString.indexOf(option) + 1) == ':')) - return true; - else - return false; - } - - /** - * Returns how many arguments are already processed by the getNextOption() - * function. The other way to look at it is what argument is going to be - * processed by getNextOption() method next. - */ - public int getNextOptionIndex() { - return optind; - } - - /** - * Returns true if option provided allows a argument. - * throws exception if option is not a valid option at first place. - */ - private boolean isOptionArgAllowedByOption(char option) { - int x = option; - if (isValidOption(option) - && (optionString.length() > optionString.indexOf(option) + 1) - && ((optionString.charAt(optionString.indexOf(option) + 1) == ':') || - (optionString.charAt(optionString.indexOf(option) + 1) == ';'))) - return true; - else - return false; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/GetSubOpt.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/GetSubOpt.java deleted file mode 100644 index 7f634f45fd..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/GetSubOpt.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.common; - -import java.lang.IllegalArgumentException; -import java.text.MessageFormat; - -/** - * This class provides the functionality for parsing command line - * arguments (similar to getsubopt(3C)). - * <br> - * After constructing an instance of it, getNextSubOption() can be used - * to get the next suboption. getSubOptionArg() can be used to get the argument - * for that option. - * - */ -public class GetSubOpt { - - /** - * Delimiter between suboptions. - */ - public final static String OPTION_DELIM = ","; - - /** - * Delimiter between suboption and suboption argument. - */ - public final static String VALUE_DELIM = "="; - - /** - * List of suboptions. - */ - protected String subOptions; - - /** - * The length of the suboptions. - */ - private final int subOptionsLen; - - /** - * Current position with in suboptions. - */ - protected int index; - - /** - * Last suboption found. - */ - protected String subOption; - - /** - * Last suboption argument found. - */ - protected String value; - - /** - * Prepare a GetSubOpt object. - * - * @param subOptions - * String containing the list of suboptions. This value was most likely - * returned as an option argument by <i>GetOpt</i>. - */ - public GetSubOpt(String subOptions) { - if (subOptions == null) { - this.subOptions = null; - } else { - this.subOptions = subOptions.trim(); - } - - index = 0; - subOptionsLen = subOptions.length(); - } - - /** - * Get the next suboption. The suboptions arguement is available from - * calling <i>getSubOptionArg()</i>. - * - * @return - * The next suboption. - * @exception IllegalArgumentException - * Thrown when no more suboptions remain. - */ - public String getNextSubOption() throws IllegalArgumentException { - - subOption = null; - value = null; - - while (subOption == null || subOption.length() == 0) { - - if (!hasMoreSubOptions()) { - String format = - ResourceStrings.getString("getsubopt_end_of_optionarg"); - Object[] args = new Object[0]; - String msg = MessageFormat.format(format, args); - throw new IllegalArgumentException(msg); - } - - int optionIndex = subOptions.indexOf(OPTION_DELIM, index); - int valueIndex = subOptions.indexOf(VALUE_DELIM, index); - - if (optionIndex == -1 && valueIndex == -1) { - // Last suboption and no value. - subOption = subOptions.substring(index); - index = subOptionsLen; - } else if (valueIndex == -1 || - (optionIndex != -1 && optionIndex < valueIndex)) { - // Suboption has no value. - subOption = subOptions.substring(index, optionIndex); - index = optionIndex + OPTION_DELIM.length(); - } else { - // Suboption with value. - subOption = subOptions.substring(index, valueIndex); - index = valueIndex + VALUE_DELIM.length(); - - boolean quoted = false; - int endIndex; - - if (index < subOptionsLen && - (subOptions.charAt(index) == '\"' || - subOptions.charAt(index) == '\'')) { - // Value is quoted. - endIndex = - subOptions.indexOf(subOptions.charAt(index), index + 1); - - // Missing close quote. - if (endIndex == -1) { - String format = - ResourceStrings.getString( - "getsubopt_missing_close_quote"); - Object[] args = new Object[1]; - args[0] = subOption; - String msg = MessageFormat.format(format, args); - throw new IllegalArgumentException(msg); - } - - quoted = true; - index++; - } else { - // Value is not quoted. - endIndex = subOptions.indexOf(OPTION_DELIM, index); - - if (endIndex == -1) { - endIndex = subOptionsLen; - } - } - - value = subOptions.substring(index, endIndex); - index = endIndex; - - // Skip closing quote. - if (quoted) { - index++; - } - - /* - * Ensure that either the end of the suboptions has been - * reached or the next suboption is ready for parsing. For - * example, quoted values must not contain characters between - * the closing quote and OPTION_DELIM. - */ - if (optionIndex >= 0) { - if (index < subOptionsLen && - !subOptions.startsWith(OPTION_DELIM, index)) { - String format = - ResourceStrings.getString( - "getsubopt_malformed_value"); - Object[] args = new Object[1]; - args[0] = subOption; - String msg = MessageFormat.format(format, args); - throw new IllegalArgumentException(msg); - } - - index += OPTION_DELIM.length(); - } - } - } - - return subOption; - } - - /** - * Indicates whether more suboptions exist. - * - * @return - * True if at least one more suboption exists, otherwise false. - */ - public boolean hasMoreSubOptions() throws IllegalArgumentException { - if (subOptions == null) { - return false; - } - - // Skip over leading OPTION_DELIMs. - while (index < subOptionsLen && - subOptions.indexOf(OPTION_DELIM, index) == index) { - index += OPTION_DELIM.length(); - } - - /* - * Ensure that there really is a suboption present. If a - * VALUE_DELIM has been found the suboption string is missing. - */ - if (index < subOptionsLen && - subOptions.indexOf(VALUE_DELIM, index) == index) { - String format = - ResourceStrings.getString( - "getsubopt_value_without_suboption"); - Object[] args = new Object[0]; - String msg = MessageFormat.format(format, args); - throw new IllegalArgumentException(msg); - } - - return (index < subOptionsLen); - } - - /** - * Get the current suboptions argument, or null if no argument is present. - * - * @return - * String containing the current suboptions argument, or null if the - * no argument is present. - */ - public String getSubOptionArg() { - return value; - } -} - diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/Makefile deleted file mode 100644 index 8479a9974d..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/Makefile +++ /dev/null @@ -1,84 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/Makefile -# - -CLASSFILES = \ - Console.class \ - DhcpCliProgram.class \ - DhcpCliFunction.class \ - DhcpCliOption.class \ - DhcpCliOptions.class \ - DhcpCliPrint.class \ - Format.class \ - GetOpt.class \ - GetSubOpt.class \ - ResourceStrings.class \ - Util.class - -include $(SRC)/Makefile.master - -CLASSPATH = $(SRC)/cmd/cmd-inet/usr.sadm/dhcpmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -MSGDIR = $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/cli/common -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/cli \ - $(MSGDIR) - - -MSGFILES = ResourceBundle.properties -MSGS= $(MSGFILES:%=$(MSGDIR)/%) - -CLEANFILES= *.class -CLOBBERFILES= - -.KEEP_STATE: - -all: $(CLASSFILES) - -install: all - -_msg: $(MSGDIRS) $(MSGS) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - -lint: - -clean: - $(RM) $(CLEANFILES) - -clobber: clean diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/ResourceBundle.properties b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/ResourceBundle.properties deleted file mode 100644 index a5544c5439..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/ResourceBundle.properties +++ /dev/null @@ -1,71 +0,0 @@ -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Need to convert data store. -# -need_to_convert_datastore=\nThere is a version mismatch between the DHCP management software and the DHCP\ndata stores configured for the server.\n\nTo correct this situation run 'dhcpconfig -C' to convert the data stores to\nthe new version. - -# -# No configuration file warning. -# -no_conf_warning=\nWarning: No DHCP configuration file exists. There is no way to verify the\ndata store version for this operation.\n - -# -# Bad option for function -# -bad_function_option=Illegal option for this function: {0} - -# -# Multiple functions requested -# -multiple_functions=Options {0} and {1} cannot be used together. - -# -# Repeated option -# -repeated_option=Specify option {0} once per command. - -# -# User is not authorized -# -user_not_allowed=User does not have authorization to perform operation. See {0}\nfor more information. - -# -# GetOpt messages -# -getopt_illegal_option=Illegal Option: {0} -getopt_requires_argument=Option requires an argument: {0} -getopt_cannot_group=Option cannot be grouped with other options: {0} - -# -# GetSubOpt messages -# -getsubopt_end_of_optionarg=No more suboptions. -getsubopt_missing_close_quote=Missing closing quote in value for suboption {0}. -getsubopt_value_without_suboption=Malformed suboptions - found value without suboption. -getsubopt_malformed_value=Malformed value - garbled value for suboption {0}. diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/ResourceStrings.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/ResourceStrings.java deleted file mode 100644 index 8278cad4e9..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/ResourceStrings.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.common; - -import java.util.*; - -/** - * This class provides a convenient method to retrieve resources for - * the common package. - */ -public class ResourceStrings { - - /** - * The handle to the resource bundle for the module. - */ - private static ResourceBundle bundle = null; - - /** - * Return a string from the resource bundle. - * @param key the key to the resource bundle string. - * @return the resource bundle string. - */ - public static String getString(String key) { - String msg = null; - try { - if (bundle == null) { - bundle = ResourceBundle.getBundle( - "com.sun.dhcpmgr.cli.common.ResourceBundle", - Locale.getDefault()); - } - msg = bundle.getString(key); - } catch (Throwable e) { - msg = new String(key); - } - return msg; - - } // getString - -} // ResourceStrings diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/Util.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/Util.java deleted file mode 100644 index 3225d3761c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/common/Util.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -package com.sun.dhcpmgr.cli.common; - -/** - * This class contains common utilites used by the CLI programs. - */ -public class Util -{ - /** - * Array of hex characters, used by for translations. - */ - private static final char hexChars[] = {'0', '1', '2', '3', '4', '5', '6', - '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - - /** - * Converts an ascii string into a string containing its hex value. - * @param ascii the ascii representation - * @return the hex representation - */ - public static String asciiToHex(String ascii) { - - StringBuffer hex = new StringBuffer(); - - if (ascii == null) { - return null; - } - - for (int i = 0; i < ascii.length(); i++) { - char aChar = ascii.charAt(i); - int ndx = (aChar >> 4) & 0x000f; - hex.append(hexChars[ndx]); - ndx = aChar & 0x000f; - hex.append(hexChars[ndx]); - } - - return hex.toString(); - - } // asciiToHex - -} // Util diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/DhcpBatch.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/DhcpBatch.java deleted file mode 100644 index 60c90d0416..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/DhcpBatch.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhcpbatch; - -import java.io.*; -import java.text.MessageFormat; - -import com.sun.dhcpmgr.bridge.BridgeException; -import com.sun.dhcpmgr.cli.common.DhcpCliPrint; -import com.sun.dhcpmgr.cli.common.DhcpCliProgram; -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; - -/** - * This class represents the entry point to the DHCP CLI batch - * administration. - */ -public class DhcpBatch - extends DhcpCliProgram { - - /** - * The program signature. - */ - public static final String SIGNATURE = "dhcpbatch: "; - - /** - * The source of the batch input. Either a fullpath to an - * input file or null if standard input is the source. - */ - String inputSource = null; - - /** - * Flag indicating whether or not the batch processing - * should be verbose. - */ - boolean verbose = false; - - /** - * The constructor used by the DHCP CLIs. - * @param inputSource a filepath or null if STDIN is to be used. - */ - public DhcpBatch(String inputSource) { - this(); - this.inputSource = inputSource; - } // constructor - - /** - * The easy constructor that does nothing for now. - */ - public DhcpBatch() { - } // constructor - - /** - * Required by DhcpCliProgram. - * @return null - */ - public String getManPage() { - return null; - } - - /** - * Returns a localized string for this function - * @param key the resource bundle string identifier - * @return string from resource bundle. - */ - public String getString(String key) { - return ResourceStrings.getString(key); - } // getString - - /** - * Sets the inputSource value. - * @param inputSource the input source. - */ - public void setInputSource(String inputSource) { - this.inputSource = inputSource; - } // setInputSource - - /** - * Sets the verbose value. - * @param value the new value for the verbose attribute. - */ - public void setVerbose(boolean value) { - verbose = value; - } // setVerbose - - /** - * Executes the batch. - * @return return code as returned by batched program - */ - public int execute() { - - int returnCode = SUCCESS; - - // By default read input from standard input. - // - InputStream in = System.in; - - // If an argument was was provided, then it must be the batch file. - // Read input from the file rather than standard input. - // - if (inputSource != null) { - try { - in = new FileInputStream(inputSource); - } catch (FileNotFoundException e) { - Object [] arguments = new Object[1]; - arguments[0] = inputSource; - printErrMessage(getString("dhcpbatch_file_not_found"), - arguments); - return (CRITICAL); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = inputSource; - printErrMessage(getString("dhcpbatch_open_failed"), arguments); - printErrMessage(DhcpCliFunction.getMessage(e)); - return (CRITICAL); - } - } - - // Really just want to read lines at a time so, a BufferedReader - // will do the trick. - // - BufferedReader bufferedIn = - new BufferedReader(new InputStreamReader(in)); - - // Read a line at a time and exec the appropriate DHCP CLI command. - // - StringBuffer line = new StringBuffer(200); - line.append("> "); - DhcpCommand command = new DhcpCommand(); - for (boolean end = false; end != true; ) { - try { - // Read a line. End of file seems to result in null line. - // - String input = bufferedIn.readLine(); - if (input == null) { - // eof - end = true; - continue; - } else if (input.length() == 0) { - // empty line - } else if (input.charAt(0) == '#' && line.length() == 2) { - // comment - continue; - } else { - line.append(input); - if (input.charAt(input.length() - 1) == '\\') { - // continuation - continue; - } - } - - if (verbose) { - DhcpCliPrint.printMessage(line.toString()); - } - command.init(line.substring(2)); - command.execute(); - } catch (BridgeException e) { - // Failed to process command; print message and continue on - Object [] arguments = new Object[2]; - arguments[0] = line.substring(2); - arguments[1] = DhcpCliFunction.getMessage(e); - printErrMessage(getString("dhcpbatch_cmd_error"), arguments); - returnCode = CRITICAL; - } catch (EOFException e) { - // Don't ever seem to get this, but just in case. - // - end = true; - } catch (IOException e) { - Object [] arguments = new Object[1]; - arguments[0] = inputSource; - printErrMessage(getString("dhcpbatch_read_failed"), arguments); - printErrMessage(DhcpCliFunction.getMessage(e)); - end = true; - returnCode = CRITICAL; - } finally { - // Reset buffer to process next command - line.setLength(2); - } - } - - // Close the stream. Ignore errors as we're exiting anyway. - // - try { - bufferedIn.close(); - } catch (IOException e) { - // Ignore it. - } - - return (returnCode); - - } // execute - - /** - * Prints an error message. - * @param msg the message to print. - */ - public static void printErrMessage(String msg) { - StringBuffer fullmsg = new StringBuffer(SIGNATURE); - fullmsg.append(msg); - DhcpCliPrint.printErrMessage(fullmsg.toString()); - } // printErrMessage - - /** - * Prints an error message. - * @param msg the message to print. - */ - public static void printErrMessage(String msg, Object [] arguments) { - StringBuffer fullmsg = new StringBuffer(SIGNATURE); - fullmsg.append(msg); - MessageFormat form = new MessageFormat(fullmsg.toString()); - DhcpCliPrint.printErrMessage(form.format(arguments)); - } // printErrMessage - - /** - * The entry point for the program. - * @param args the program arguments - */ - public static void main(String[] args) { - - DhcpBatch dhcpbatch = new DhcpBatch(); - - // Check usage. - // - String source = null; - if (args.length == 1) { - source = args[0]; - } else if (args.length > 1) { - DhcpCliPrint.printErrMessage( - dhcpbatch.getString("dhcpbatch_usage")); - return; - } - - dhcpbatch.setInputSource(source); - dhcpbatch.execute(); - - } // main - -} // DhcpBatch diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/DhcpCommand.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/DhcpCommand.java deleted file mode 100644 index e7b33d8669..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/DhcpCommand.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.dhcpbatch; - -import com.sun.dhcpmgr.bridge.BridgeException; -import com.sun.dhcpmgr.cli.common.DhcpCliPrint; -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.cli.common.DhcpCliProgram; -import com.sun.dhcpmgr.cli.dhtadm.DhtAdm; -import com.sun.dhcpmgr.cli.pntadm.PntAdm; - -/** - * This class represents a DHCP CLI command. - */ -public class DhcpCommand { - - /** - * The dhtadm CLI command. - */ - public static String DHTADM = "dhtadm"; - public static DhtAdm dhtadm = null; - - /** - * The pntadm CLI command. - */ - public static String PNTADM = "pntadm"; - public static PntAdm pntadm = null; - - private String [] arglist; - - /** - * The constructor for a DhcpCommand. - */ - public DhcpCommand() { - // nothing to do. - } // constructor - - /** - * Sets the arglist for the command. - * @param input the batch input line. - */ - public void init(String input) throws BridgeException { - arglist = DhcpCliFunction.getSvcMgr().getArguments(input); - } // reset - - /** - * Returns a localized string for this function - * @param key the resource bundle string identifier - * @return string from resource bundle. - */ - public String getString(String key) { - return ResourceStrings.getString(key); - } // getString - - /** - * Get the name of the CLI program. - * @return the name of the CLI for this command. - */ - public String getProgram() { - - String program = null; - if (arglist.length != 0) { - program = arglist[0]; - } - - return program; - - } // getProgram - - /** - * Returns the arguments for the CLI. - * @return the arguments. - */ - public String [] getArgs() { - - String [] args = new String[arglist.length - 1]; - - System.arraycopy(arglist, 1, args, 0, arglist.length - 1); - return args; - - } // getArgs - - /** - * Executes the CLI. - * @return return code as returned by caller. - */ - public int execute() { - String program = getProgram(); - String [] args = getArgs(); - int returnCode = DhcpCliProgram.SUCCESS; - - if (program == null) { - Object [] arguments = new Object[1]; - arguments[0] = program; - DhcpBatch.printErrMessage(getString("dhcpcommand_invalid_command"), - arguments); - } else if (program.equals(PNTADM)) { - if (pntadm == null) { - pntadm = new PntAdm(args); - } else { - pntadm.reset(args); - } - returnCode = pntadm.execute(); - } else if (program.equals(DHTADM)) { - if (dhtadm == null) { - dhtadm = new DhtAdm(args); - } else { - dhtadm.reset(args); - } - returnCode = dhtadm.execute(); - } else { - Object [] arguments = new Object[1]; - arguments[0] = program; - DhcpBatch.printErrMessage(getString("dhcpcommand_invalid_command"), - arguments); - returnCode = DhcpCliProgram.FAILURE; - } - return (returnCode); - } // execute - -} // DhcpCommand diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/Makefile deleted file mode 100644 index 0b45d7a49f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/Makefile +++ /dev/null @@ -1,75 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/Makefile -# - -CLASSFILES = \ - DhcpBatch.class \ - DhcpCommand.class \ - ResourceStrings.class - -include $(SRC)/Makefile.master - -CLASSPATH= $(SRC)/cmd/cmd-inet/usr.sadm/dhcpmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -MSGDIR= $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/cli/dhcpbatch -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/cli \ - $(MSGDIR) - -MSGFILES= ResourceBundle.properties -MSGS= $(MSGFILES:%=$(MSGDIR)/%) - -CLEANFILES= *.class -CLOBBERFILES= - -.KEEP_STATE: - -all: $(CLASSFILES) - -install: all - -_msg: $(MSGDIRS) $(MSGS) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - -lint: - -clean: - $(RM) $(CLEANFILES) - -clobber: clean diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/ResourceBundle.properties b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/ResourceBundle.properties deleted file mode 100644 index b62656aaf6..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/ResourceBundle.properties +++ /dev/null @@ -1,36 +0,0 @@ -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# DhcpBatch messages. -# -dhcpbatch_usage=dhcpbatch [batchfile] -dhcpbatch_file_not_found=File not found - {0} -dhcpbatch_open_failed=Error opening batch file - {0} -dhcpbatch_read_failed=Error reading batch file - {0} -dhcpbatch_cmd_error=Error processing command: {0}\nMessage is: {1} -dhcpcommand_invalid_command=Invalid command - {0} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/ResourceStrings.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/ResourceStrings.java deleted file mode 100644 index f0941e09c7..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpbatch/ResourceStrings.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.dhcpbatch; - -import java.util.*; - -/** - * This class provides a convenient method to retrieve resources for - * the dhcpbatch package. - */ -public class ResourceStrings { - - /** - * The handle to the resource bundle for the module. - */ - private static ResourceBundle bundle = null; - - /** - * Return a string from the resource bundle. - * @param key the key to the resource bundle string. - * @return the resource bundle string. - */ - public static String getString(String key) { - String msg = null; - try { - if (bundle == null) { - bundle = ResourceBundle.getBundle( - "com.sun.dhcpmgr.cli.dhcpbatch.ResourceBundle", - Locale.getDefault()); - } - msg = bundle.getString(key); - } catch (Throwable e) { - msg = new String(key); - } - return msg; - - } // getString - -} // ResourceStrings diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConfigureBootp.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConfigureBootp.java deleted file mode 100644 index c667cfc1f6..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConfigureBootp.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.dhcpconfig; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.data.DhcpdOptions; -import com.sun.dhcpmgr.data.ValidationException; - -/** - * The main class for the "configure BOOTP relay" functionality of dhcpconfig. - */ -public class ConfigureBootp extends DhcpCfgFunction { - - /** - * The valid options associated with configuring a BOOTP relay agent. - */ - static final int supportedOptions[] = { - }; - - /** - * The addresses of servers for which to serve as a relay. - */ - String addresses; - - /** - * Constructs a ConfigureBootp object. - * @param addresses the addresses of servers for which to serve as a relay. - */ - public ConfigureBootp(String addresses) { - - validOptions = supportedOptions; - this.addresses = addresses; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (DhcpCfg.CONFIGURE_BOOTP); - } - - /** - * Executes the "configure BOOTP relay" functionality. - * @return DhcpCfg.SUCCESS or DhcpCfg.FAILURE - */ - public int execute() { - - // Check to see if DHCP or BOOTP relay is already configured. - // - boolean isServer = false; - boolean isRelay = false; - try { - DhcpdOptions opts = getSvcMgr().readDefaults(); - if (opts.isRelay()) { - isRelay = true; - } else { - isServer = true; - } - } catch (Throwable e) { - // this is to be expected - } - - if (isServer) { - printErrMessage(getString("config_dhcp_configured_error")); - return (DhcpCfg.FAILURE); - } - - if (isRelay) { - printErrMessage(getString("config_bootp_configured_error")); - return (DhcpCfg.FAILURE); - } - - // Write the information to the DHCP configuration file. - // - try { - IPAddressList list = new IPAddressList(addresses); - DhcpdOptions options = new DhcpdOptions(); - options.setDaemonEnabled(true); - options.setRelay(true, list.toString()); - getSvcMgr().writeDefaults(options); - printMessage(getString("config_create_conf_progress")); - } catch (ValidationException e) { - printErrMessage(getMessage(e)); - return (DhcpCfg.FAILURE); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("config_writing_conf_error"), arguments); - return (DhcpCfg.FAILURE); - } - - // Start it up. - // - try { - getSvcMgr().startup(); - printMessage(getString("config_startup_progress")); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("config_startup_error"), arguments); - return (DhcpCfg.FAILURE); - } - - return (DhcpCfg.SUCCESS); - - } // execute - -} // ConfigureBootp diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConfigureDhcp.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConfigureDhcp.java deleted file mode 100644 index 1f11c41854..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConfigureDhcp.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhcpconfig; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.data.DhcpdOptions; -import com.sun.dhcpmgr.data.DhcpDatastore; -import com.sun.dhcpmgr.data.ValidationException; -import com.sun.dhcpmgr.data.StandardOptions; -import com.sun.dhcpmgr.bridge.ExistsException; -import com.sun.dhcpmgr.bridge.TableExistsException; - -import java.net.InetAddress; -import java.lang.IllegalArgumentException; - -/** - * The main class for the "configure DHCP server" functionality of dhcpconfig. - */ -public class ConfigureDhcp extends DhcpCfgFunction { - - /** - * The valid options associated with configuring a DHCP server. - */ - static final int supportedOptions[] = { - DhcpCfg.NON_NEGOTIABLE_LEASE, - DhcpCfg.LEASE_LENGTH, - DhcpCfg.DNS_ADDRESSES, - DhcpCfg.DNS_DOMAIN, - DhcpCfg.RESOURCE, - DhcpCfg.RESOURCE_CONFIG, - DhcpCfg.PATH - }; - - /** - * Constructs a ConfigureDhcp object. - */ - public ConfigureDhcp() { - - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (DhcpCfg.CONFIGURE_DHCP); - } - - /** - * Executes the "configure DHCP server" functionality. - * @return DhcpCfg.SUCCESS or DhcpCfg.FAILURE - */ - public int execute() throws IllegalArgumentException { - - // Check to see if DHCP or BOOTP relay is already configured. - // - boolean isServer = false; - boolean isRelay = false; - try { - DhcpdOptions opts = getSvcMgr().readDefaults(); - if (opts.isRelay()) { - isRelay = true; - } else { - isServer = true; - } - } catch (Throwable e) { - // this is to be expected - } - - if (isServer) { - printErrMessage(getString("config_dhcp_configured_error")); - return (DhcpCfg.FAILURE); - } - - if (isRelay) { - printErrMessage(getString("config_bootp_configured_error")); - return (DhcpCfg.FAILURE); - } - - // User must define both resource and path. - // - if (options.valueOf(DhcpCfg.RESOURCE) == null || - options.valueOf(DhcpCfg.PATH) == null) { - String msg = getString("config_null_datastore_error"); - throw new IllegalArgumentException(msg); - } - - try { - setDhcpDatastore(getSvcMgr().getDataStore( - options.valueOf(DhcpCfg.RESOURCE))); - getDhcpDatastore().setLocation(options.valueOf(DhcpCfg.PATH)); - getDhcpDatastore().setConfig( - options.valueOf(DhcpCfg.RESOURCE_CONFIG)); - } catch (Throwable e) { - // resource will not be valid - } - - - if (getDhcpDatastore() == null || !getDhcpDatastore().isEnabled()) { - Object [] arguments = new Object[1]; - arguments[0] = getDhcpDatastore().getResource(); - printErrMessage(getString("config_invalid_resource_error"), - arguments); - return (DhcpCfg.FAILURE); - } - - // Retrieve the leaseLength option and check its validity. - // The default (3600*24 = 1 day) should be defined as static somewhere. - // - Integer leaseLength = new Integer(3600*24); - if (options.isSet(DhcpCfg.LEASE_LENGTH)) { - try { - leaseLength = - new Integer(options.valueOf(DhcpCfg.LEASE_LENGTH)); - } catch (Throwable e) { - printErrMessage(getString("config_lease_error")); - return (DhcpCfg.FAILURE); - } - - if (leaseLength.intValue() == 0) { - printErrMessage(getString("config_lease_zero_error")); - return (DhcpCfg.FAILURE); - } - } - - // Are leases negotiable - // - boolean leaseNegotiable = - !options.isSet(DhcpCfg.NON_NEGOTIABLE_LEASE); - - // Get the DNS information. - // - String dnsDomain = options.valueOf(DhcpCfg.DNS_DOMAIN); - String dnsServers = options.valueOf(DhcpCfg.DNS_ADDRESSES); - if ((dnsDomain == null) != (dnsServers == null)) { - String msg = getString("config_dns_error"); - throw new IllegalArgumentException(msg); - } - - IPAddressList dnsAddresses = null; - try { - if (dnsDomain == null) { - dnsDomain = getSvcMgr().getStringOption( - StandardOptions.CD_DNSDOMAIN, ""); - } - if (dnsServers != null) { - dnsAddresses = new IPAddressList(dnsServers); - } else { - dnsAddresses = new IPAddressList( - getSvcMgr().getIPOption(StandardOptions.CD_DNSSERV, "")); - } - } catch (ValidationException e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("config_dns_server_error"), arguments); - return (DhcpCfg.FAILURE); - } catch (Throwable e) { - // Ignore, DNS info will not be configured in the server macro. - } - - // Create the location if it does not exist. - // - try { - getSvcMgr().makeLocation(getDhcpDatastore()); - } catch (ExistsException e) { - // this is o.k. - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getDhcpDatastore().getLocation(); - printErrMessage(getString("config_make_location_error"), - arguments); - return (DhcpCfg.FAILURE); - } - - // Create the DHCP configuration file - // - DhcpdOptions dhcpdOptions = new DhcpdOptions(); - dhcpdOptions.setDaemonEnabled(true); - dhcpdOptions.setDhcpDatastore(getDhcpDatastore()); - try { - getSvcMgr().writeDefaults(dhcpdOptions); - printMessage(getString("config_create_conf_progress")); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("config_writing_conf_error"), arguments); - return (DhcpCfg.FAILURE); - } - - // Create the dhcptab - // - try { - getDhcptabMgr().createDhcptab(getDhcpDatastore()); - printMessage(getString("config_dhcptab_progress")); - } catch (TableExistsException e) { - // Not an error; some data stores are shared by multiple servers - printMessage(getString("config_dhcptab_exists_progress")); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("config_dhcptab_error"), arguments); - return (DhcpCfg.FAILURE); - } - - // Create the locale macro - // - try { - getDhcptabMgr().createLocaleMacro(); - printMessage(getString("config_locale_progress")); - } catch (ExistsException e) { - /* - * Ignore this error, if one's already there we'll assume - * it's correct - */ - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("config_locale_error"), arguments); - return (DhcpCfg.FAILURE); - } - - // Create the Server macro - // - String svrName = null; - try { - svrName = getSvcMgr().getShortServerName(); - InetAddress svrAddress = getSvcMgr().getServerAddress(); - getDhcptabMgr().createServerMacro(svrName, svrAddress, - leaseLength.intValue(), leaseNegotiable, dnsDomain, - dnsAddresses); - Object [] arguments = new Object[1]; - arguments[0] = svrName; - printMessage(getString("config_server_macro_progress"), arguments); - } catch (Throwable e) { - // Couldn't create it; inform user because this is serious - Object [] arguments = new Object[2]; - arguments[1] = svrName; - arguments[0] = getMessage(e); - printErrMessage(getString("config_server_macro_error"), arguments); - return (DhcpCfg.FAILURE); - } - - // Start it up. - // - try { - getSvcMgr().startup(); - printMessage(getString("config_startup_progress")); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("config_startup_error"), arguments); - return (DhcpCfg.FAILURE); - } - - return (DhcpCfg.SUCCESS); - - } // execute - -} // ConfigureDhcp diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConfigureNetwork.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConfigureNetwork.java deleted file mode 100644 index 19239b61de..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConfigureNetwork.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhcpconfig; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.data.IPAddress; -import com.sun.dhcpmgr.data.Network; -import com.sun.dhcpmgr.data.ValidationException; -import com.sun.dhcpmgr.data.StandardOptions; - -/** - * The main class for the "configure network" functionality of dhcpconfig. - */ -public class ConfigureNetwork extends DhcpCfgFunction { - - /** - * The valid options associated with configuring a network. - */ - static final int supportedOptions[] = { - DhcpCfg.SUBNET_MASK, - DhcpCfg.POINT_TO_POINT, - DhcpCfg.ROUTER_ADDRESSES, - DhcpCfg.NIS_DOMAIN, - DhcpCfg.NIS_ADDRESSES, - DhcpCfg.SIGHUP - }; - - /** - * The address of the network to configure. - */ - String address; - - /** - * Constructs a ConfigureNetwork object. - * @param address the address of the network to configure - */ - public ConfigureNetwork(String address) { - - validOptions = supportedOptions; - this.address = address; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (DhcpCfg.CONFIGURE_NETWORK); - } - - /** - * Executes the "configure network" functionality. - * @return DhcpCfg.SUCCESS or DhcpCfg.FAILURE - */ - public int execute() { - - // Make sure that server is configured as a DHCP server. - // - if (!isServerConfigured()) { - return (DhcpCfg.FAILURE); - } - - // Check the validity of the data store version. - // - if (!isVersionValid(false)) { - return (DhcpCfg.FAILURE); - } - - // Validate the network address - // - Network network; - try { - network = getNetMgr().getNetwork(address); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = address; - printErrMessage(getString("cfgnet_invalid_network_error"), - arguments); - return (DhcpCfg.FAILURE); - } - - // Determine/validate the subnet mask. - // - IPAddress netmask = null; - String mask = options.valueOf(DhcpCfg.SUBNET_MASK); - if (mask != null) { - try { - netmask = new IPAddress(mask); - network.setMask(netmask); - } catch (ValidationException e) { - Object [] arguments = new Object[1]; - arguments[0] = address; - printErrMessage(getString("cfgnet_invalid_ip_error"), - arguments); - return (DhcpCfg.FAILURE); - } - } - - boolean isLan = !options.isSet(DhcpCfg.POINT_TO_POINT); - - // Get the list of router addresses - // - IPAddressList routers = null; - if (options.isSet(DhcpCfg.ROUTER_ADDRESSES)) { - try { - String addrs = options.valueOf(DhcpCfg.ROUTER_ADDRESSES); - routers = new IPAddressList(addrs); - } catch (ValidationException e) { - printErrMessage(getMessage(e)); - return (DhcpCfg.FAILURE); - } - } - - // Get the NIS info. - // - String nisDomain = options.valueOf(DhcpCfg.NIS_DOMAIN); - String nisServers = options.valueOf(DhcpCfg.NIS_ADDRESSES); - if ((nisDomain == null) != (nisServers == null)) { - String msg = getString("cfgnet_nis_error"); - throw new IllegalArgumentException(msg); - } - - IPAddressList nisAddresses = null; - try { - if (nisDomain == null) { - nisDomain = getSvcMgr().getStringOption( - StandardOptions.CD_NIS_DOMAIN, ""); - } - if (nisServers != null) { - nisAddresses = new IPAddressList(nisServers); - } else { - nisAddresses = new IPAddressList( - getSvcMgr().getIPOption(StandardOptions.CD_NIS_SERV, "")); - } - } catch (ValidationException e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("cfgnet_nis_server_error"), arguments); - return (DhcpCfg.FAILURE); - } catch (Throwable e) { - // Ignore, NIS info will not be configured in the network macro. - } - - // Create the network macro in the dhcptab - // - try { - IPAddress[] routersArray = null; - if (routers != null) { - routersArray = routers.toIPAddressArray(); - } - getDhcptabMgr().createNetworkMacro(network, routersArray, - isLan, nisDomain, nisAddresses); - Object [] arguments = new Object[1]; - arguments[0] = network.toString(); - printMessage(getString("cfgnet_network_macro_progress"), - arguments); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("cfgnet_network_macro_error"), - arguments); - return (DhcpCfg.FAILURE); - } - - - // Create the network table for this network - // - try { - getNetMgr().createNetwork(network.toString()); - printMessage(getString("cfgnet_network_table_progress")); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("cfgnet_network_table_error"), - arguments); - return (DhcpCfg.FAILURE); - } - - // Signal the server if the user asked us to - try { - if (options.isSet(DhcpCfg.SIGHUP)) { - getSvcMgr().reload(); - } - } catch (Throwable e) { - printErrMessage(getString("sighup_failed")); - return (DhcpCfg.FAILURE); - } - - return (DhcpCfg.SUCCESS); - - } // execute - -} // ConfigureNetwork diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConfigureService.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConfigureService.java deleted file mode 100644 index c3c5c48852..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConfigureService.java +++ /dev/null @@ -1,362 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhcpconfig; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.data.DhcpdOptions; -import com.sun.dhcpmgr.data.qualifier.*; -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.bridge.BridgeException; - -/** - * Functions for handling all dhcpconfig options that manage the DHCP server - * parameters. - */ -public class ConfigureService extends DhcpCfgFunction { - - /** - * Return codes. - * - * These supplement the inherited SUCCESS and FAILURE return codes. - * Note that these values are binary!!! The next value would be 4. - */ - public static final int ENABLED = 1; - public static final int DISABLED = 0; - public static final int RUNNING = 2; - public static final int STOPPED = 0; - - /** - * Options that this DhcpCfgFunction will accept. - */ - static final int supportedOptions[] = { - DhcpCfg.SERVICE_ENABLE, - DhcpCfg.SERVICE_DISABLE, - DhcpCfg.SERVICE_REENABLE, - DhcpCfg.SERVICE_QUERY, - }; - - public ConfigureService() { - validOptions = supportedOptions; - } // constructor - - /** - * Returns the option flag for this function. - * @returns - * The option flag for this function. - */ - public int getFunctionFlag() { - return DhcpCfg.CONFIGURE_SERVICE; - } // getFunctionFlag - - /** - * Parse and execute the options for this function. - * @return - * DhcpCfg.SUCCESS for success and DhcpCfg.FAILURE for failure. - */ - public int execute() throws IllegalArgumentException { - Action action = null; - boolean enableOptionSet; - boolean disableOptionSet; - boolean reenableOptionSet; - boolean queryOptionSet; - boolean[] possibleOptions = { - enableOptionSet = options.isSet(DhcpCfg.SERVICE_ENABLE), - disableOptionSet = options.isSet(DhcpCfg.SERVICE_DISABLE), - reenableOptionSet = options.isSet(DhcpCfg.SERVICE_REENABLE), - queryOptionSet = options.isSet(DhcpCfg.SERVICE_QUERY) - }; - - int numOptionsSet = 0; - for (int index = 0; index < possibleOptions.length; index++) { - if (possibleOptions[index]) { - numOptionsSet++; - } - } - - if (numOptionsSet != 1) { - String msg = getString("config_service_bad_action_error"); - throw new IllegalArgumentException(msg); - } - - if (enableOptionSet) { - action = new ActionEnable(); - } else if (disableOptionSet) { - action = new ActionDisable(); - } else if (reenableOptionSet) { - action = new ActionReenable(); - } else { - action = new ActionQuery(); - } - - return action.execute(); - } // execute - - /** - * All functions are carried out through a specific action sub-classed - * from this class. - */ - private interface Action { - /** - * Execute the action. - * - * @return - * DhcpCfg.SUCCESS for success and DhcpCfg.FAILURE for failure. - */ - public int execute(); - } - - /** - * Shared super class for actions. - */ - private abstract class ActionImpl implements Action { - /** - * Server parameters. - */ - protected DhcpdOptions dhcpdOptions; - - /** - * Service manager. - */ - protected DhcpServiceMgr dhcpServiceMgr; - - /** - * Validate and execute the action. A sub-classed action is passed - * execution control via the doExecute() callback method. - * - * @return - * DhcpCfg.SUCCESS for success and DhcpCfg.FAILURE for failure. - */ - public final int execute() { - dhcpServiceMgr = getSvcMgr(); - - try { - dhcpdOptions = dhcpServiceMgr.readDefaults(); - } catch (BridgeException be) { - printErrMessage( - getString("config_service_failed_read_params_error")); - return DhcpCfg.FAILURE; - } - - dhcpdOptions.clearDirty(); - - int result = doExecute(); - - if (result != DhcpCfg.FAILURE) { - if (dhcpdOptionsWrite() == DhcpCfg.FAILURE) { - return DhcpCfg.FAILURE; - } - } - - return result; - } // execute - - /** - * Sub-classed action callback method. Once validation has been - * performed execution is continued in the action sub-class by calling - * this method. - * - * @return - * DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure. - */ - protected abstract int doExecute(); - - /** - * Ensures that changes to the parameter are written back to the data - * store. - * - * @return - * DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure. - */ - protected int dhcpdOptionsWrite() { - if (dhcpdOptions.isDirty()) { - try { - dhcpServiceMgr.writeDefaults(dhcpdOptions); - } catch (BridgeException e) { - printErrMessage(getString( - "config_service_failed_write_params_error")); - return DhcpCfg.FAILURE; - } - - dhcpdOptions.clearDirty(); - } - - return DhcpCfg.SUCCESS; - } - } - - /** - * Enable the DHCP service. - */ - private class ActionEnable extends ActionImpl { - /** - * Enable the DHCP service. - * - * @return - * DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure. - */ - protected int doExecute() { - if (!dhcpdOptions.isDaemonEnabled()) { - dhcpdOptions.setDaemonEnabled(true); - if (dhcpdOptionsWrite() == DhcpCfg.FAILURE) { - return DhcpCfg.FAILURE; - } - printMessage(getString("config_service_state_enabled")); - } - - try { - if (!dhcpServiceMgr.isServerRunning()) { - dhcpServiceMgr.startup(); - printMessage(getString("config_service_state_startup")); - } - } catch (BridgeException e) { - printErrMessage( - getString("config_service_failed_startup_error")); - return DhcpCfg.FAILURE; - } - - return DhcpCfg.SUCCESS; - } // doExecute - } - - /** - * Disable the DHCP service. - */ - private class ActionDisable extends ActionImpl { - /** - * Disable the DHCP service. - * - * @return - * DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure. - */ - protected int doExecute() { - if (dhcpdOptions.isDaemonEnabled()) { - dhcpdOptions.setDaemonEnabled(false); - if (dhcpdOptionsWrite() == DhcpCfg.FAILURE) { - return DhcpCfg.FAILURE; - } - printMessage(getString("config_service_state_disabled")); - } - - try { - if (dhcpServiceMgr.isServerRunning()) { - dhcpServiceMgr.shutdown(); - printMessage(getString("config_service_state_shutdown")); - } - } catch (BridgeException e) { - printErrMessage( - getString("config_service_failed_shutdown_error")); - return DhcpCfg.FAILURE; - } - - return DhcpCfg.SUCCESS; - } // doExecute - } - - /** - * Reenable the DHCP service. - */ - private class ActionReenable extends ActionImpl { - /** - * Reenable the DHCP service. - * - * @return - * DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure. - */ - protected int doExecute() { - try { - if (dhcpServiceMgr.isServerRunning()) { - dhcpServiceMgr.shutdown(); - printMessage(getString("config_service_state_shutdown")); - } - } catch (BridgeException e) { - printErrMessage( - getString("config_service_failed_shutdown_error")); - return DhcpCfg.FAILURE; - } - - if (!dhcpdOptions.isDaemonEnabled()) { - dhcpdOptions.setDaemonEnabled(true); - if (dhcpdOptionsWrite() == DhcpCfg.FAILURE) { - return DhcpCfg.FAILURE; - } - printMessage(getString("config_service_state_enabled")); - } - - try { - dhcpServiceMgr.startup(); - printMessage(getString("config_service_state_startup")); - } catch (BridgeException e) { - printErrMessage( - getString("config_service_failed_startup_error")); - return DhcpCfg.FAILURE; - } - - return DhcpCfg.SUCCESS; - } // doExecute - } - - /** - * Query the DHCP service. - */ - private class ActionQuery extends ActionImpl { - /** - * Query the DHCP service. - * - * @return - * DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure. - */ - protected int doExecute() { - int serviceState = DhcpCfg.SUCCESS; - - if (dhcpdOptions.isDaemonEnabled()) { - printMessage(getString("config_service_state_enabled")); - serviceState += ENABLED; - } else { - printMessage(getString("config_service_state_disabled")); - serviceState += DISABLED; - } - - try { - if (dhcpServiceMgr.isServerRunning()) { - printMessage(getString("config_service_state_running")); - serviceState += RUNNING; - } else { - printMessage(getString("config_service_state_stopped")); - serviceState += STOPPED; - } - } catch (BridgeException e) { - printErrMessage(getString("config_service_failed_query_error")); - return DhcpCfg.FAILURE; - } - - return serviceState; - } // doExecute - } - - -} // ConfigureService diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConvertDataStore.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConvertDataStore.java deleted file mode 100644 index d66367a442..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ConvertDataStore.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.dhcpconfig; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.cli.common.Console; -import com.sun.dhcpmgr.data.DhcpdOptions; -import com.sun.dhcpmgr.data.DhcpDatastore; -import com.sun.dhcpmgr.data.Network; -import com.sun.dhcpmgr.bridge.ExistsException; - -public class ConvertDataStore extends DhcpCfgFunction { - - static final int supportedOptions[] = { - DhcpCfg.FORCE, - DhcpCfg.KEEP_TABLES, - DhcpCfg.RESOURCE, - DhcpCfg.RESOURCE_CONFIG, - DhcpCfg.PATH - }; - - public ConvertDataStore() { - - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (DhcpCfg.CONVERT_DATA_STORE); - } - - public int execute() throws IllegalArgumentException { - - // User must define both resource and path. - // - if (options.valueOf(DhcpCfg.RESOURCE) == null || - options.valueOf(DhcpCfg.PATH) == null) { - String msg = getString("convert_null_datastore_error"); - throw new IllegalArgumentException(msg); - } - - try { - setDhcpDatastore(getSvcMgr().getDataStore( - options.valueOf(DhcpCfg.RESOURCE))); - getDhcpDatastore().setLocation(options.valueOf(DhcpCfg.PATH)); - getDhcpDatastore().setConfig( - options.valueOf(DhcpCfg.RESOURCE_CONFIG)); - } catch (Throwable e) { - // resource will not be valid - } - - - if (getDhcpDatastore() == null || !getDhcpDatastore().isEnabled()) { - Object [] arguments = new Object[1]; - arguments[0] = getDhcpDatastore().getResource(); - printErrMessage(getString("convert_invalid_resource_error"), - arguments); - return (DhcpCfg.FAILURE); - } - - // Should we delete the dhcptab and the network tables after - // they have been converted? - // - boolean deleteTables = !options.isSet(DhcpCfg.KEEP_TABLES); - - // Get the old configuration values. - // - DhcpdOptions dhcpdOptions = null; - try { - dhcpdOptions = getSvcMgr().readDefaults(); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("convert_conf_read_error"), arguments); - return (DhcpCfg.FAILURE); - } - - // If the source, destination, and version are all the same - // then there is nothing to do ... report it as an error. - // - DhcpDatastore oldDatastore = dhcpdOptions.getDhcpDatastore(); - if (getDhcpDatastore().equals(oldDatastore)) { - printErrMessage(getString("convert_same_datastore_error")); - return (DhcpCfg.FAILURE); - } - - // Confirm? - // - if (!options.isSet(DhcpCfg.FORCE)) { - printMessage(getString("convert_explanation")); - String confirmationMsg = getString("convert_confirmation"); - String affirmative = getString("affirmative"); - String negative = getString("negative"); - boolean doit = Console.promptUser(confirmationMsg, affirmative, - negative, true); - if (!doit) { - return (DhcpCfg.FAILURE); - } - } - - // Create the location if it does not exist. - // - try { - getSvcMgr().makeLocation(getDhcpDatastore()); - } catch (ExistsException e) { - // this is o.k. - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getDhcpDatastore().getLocation(); - printErrMessage(getString("convert_make_location_error"), - arguments); - return (DhcpCfg.FAILURE); - } - - // Shut down the server if it is running - // - try { - if (getSvcMgr().isServerRunning()) { - getSvcMgr().shutdown(); - printMessage(getString("convert_shutdown_progress")); - } else { - printMessage(getString("convert_no_shutdown_progress")); - } - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("convert_shutdown_error"), arguments); - } - - // Convert the dhcptab. - // - try { - getDhcptabMgr().cvtDhcptab(getDhcpDatastore()); - printMessage(getString("convert_dhcptab_progress")); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("convert_dhcptab_error"), arguments); - deleteTables = false; - } - - // Go get a list of the network tables to convert. - // - Network[] networks = new Network[0]; - try { - networks = getNetMgr().getNetworks(oldDatastore); - if (networks == null) { - networks = new Network[0]; - } - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("convert_get_nets_error"), arguments); - deleteTables = false; - } - - // Convert the network tables - // - for (int i = 0; i < networks.length; ++i) { - String netString = networks[i].toString(); - try { - getNetMgr().cvtNetwork(netString, getDhcpDatastore()); - Object [] arguments = new Object[1]; - arguments[0] = netString; - printMessage(getString("convert_network_progress"), arguments); - } catch (Throwable e) { - Object [] arguments = new Object[2]; - arguments[0] = netString; - arguments[1] = getMessage(e); - printErrMessage(getString("convert_network_error"), - arguments); - } - } - - dhcpdOptions.setDhcpDatastore(getDhcpDatastore()); - try { - getSvcMgr().writeDefaults(dhcpdOptions); - printMessage(getString("convert_conf_update_progress")); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("convert_conf_write_error"), arguments); - deleteTables = false; - } - - if (deleteTables) { - // Delete the network tables - // - for (int i = 0; i < networks.length; ++i) { - String netString = networks[i].toString(); - try { - getNetMgr().deleteNetwork(netString, false, oldDatastore); - Object [] arguments = new Object[1]; - arguments[0] = netString; - printMessage(getString("convert_delete_network_progress"), - arguments); - } catch (Throwable e) { - Object [] arguments = new Object[2]; - arguments[0] = netString; - arguments[1] = getMessage(e); - printErrMessage(getString("convert_delete_network_error"), - arguments); - } - } - - // Delete the dhcptab - // - try { - getDhcptabMgr().deleteDhcptab(oldDatastore); - printMessage(getString("convert_delete_dhcptab_progress")); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("convert_delete_dhcptab_error"), - arguments); - } - } - - // Start it up. - // - if (dhcpdOptions.isDaemonEnabled()) { - try { - getSvcMgr().startup(); - printMessage(getString("convert_startup_progress")); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("convert_startup_error"), arguments); - } - } - - return (DhcpCfg.SUCCESS); - - } // execute - -} // ConvertDataStore diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/DhcpCfg.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/DhcpCfg.java deleted file mode 100644 index 2369d1be57..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/DhcpCfg.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhcpconfig; - -import com.sun.dhcpmgr.cli.common.*; - -import java.lang.IllegalArgumentException; -import java.text.MessageFormat; - -/** - * This class represents the entry point to the DHCP CLI dhcp configuration - * administration. - */ -public class DhcpCfg - extends DhcpCliProgram { - - /** - * The program signature. - */ - public static final String SIGNATURE = "dhcpconfig: "; - - /** - * The valid options for all DhcpCfg administration. - */ - private static String optString = - "DUCnfxbkgI:R:N:X:r;p:u:l:d;a:m:t:y:s:o:P;Seq"; - - public static final int CONFIGURE_DHCP = 'D'; - public static final int CONFIGURE_BOOTP = 'R'; - public static final int UNCONFIGURE_DHCP = 'U'; - public static final int CONFIGURE_NETWORK = 'N'; - public static final int CONVERT_DATA_STORE = 'C'; - public static final int EXPORT_DATA = 'X'; - public static final int IMPORT_DATA = 'I'; - public static final int CONFIGURE_SERVER_PARAMETER = 'P'; - public static final int CONFIGURE_SERVICE = 'S'; - - public static final int NON_NEGOTIABLE_LEASE = 'n'; - public static final int FORCE = 'f'; - public static final int DELETE_DATA = 'x'; - public static final int DELETE_TABLES = 'x'; - public static final int KEEP_TABLES = 'k'; - public static final int POINT_TO_POINT = 'b'; - public static final int RESOURCE = 'r'; - public static final int RESOURCE_CONFIG = 'u'; - public static final int PATH = 'p'; - public static final int LEASE_LENGTH = 'l'; - public static final int DNS_DOMAIN = 'd'; - public static final int SERVICE_DISABLE = 'd'; - public static final int DNS_ADDRESSES = 'a'; - public static final int NIS_ADDRESSES = 'a'; - public static final int NETWORK_ADDRESSES = 'a'; - public static final int SUBNET_MASK = 'm'; - public static final int MACRO_LIST = 'm'; - public static final int OPTION_LIST = 'o'; - public static final int ROUTER_ADDRESSES = 't'; - public static final int NIS_DOMAIN = 'y'; - public static final int SIGHUP = 'g'; - public static final int SERVICE_ENABLE = 'e'; - public static final int SERVICE_REENABLE = 'r'; - public static final int SERVICE_QUERY = 'q'; - - /** - * Constructs a dhcpconfig command. - * @param args the options to the command. - */ - public DhcpCfg(String args[]) { - - // Set the options. - // - options = new DhcpCliOptions(); - this.args = args; - - } // constructor - - /** - * Returns the manpage signature for the program. - * @return the manpage signature for the program. - */ - public String getManPage() { - return "dhcpconfig(1M)"; - } - - /** - * Displays program usage. - */ - public void usage() { - - DhcpCliPrint.printErrMessage(getString("dhcpcfg_usage")); - - } // usage - - /** - * Executes the program function. - * @return SUCCESS or FAILURE - */ - public int execute() { - - int returnCode = SUCCESS; - - // Get the options and go exec the correct function. - // - GetOpt getopt = new GetOpt(args, optString); - try { - int option; - while ((option = getopt.getNextOption()) != -1) { - processArg(option, getopt.getOptionArg()); - } - - int lastIndex = getopt.getNextOptionIndex(); - if (args.length != lastIndex) { - Object [] arguments = new Object[1]; - arguments[0] = args[lastIndex]; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("dhcpcfg_invalid_arg")); - throw new IllegalArgumentException(form.format(arguments)); - } - - if (function == null) { - String msg = getString("dhcpcfg_no_function_error"); - throw new IllegalArgumentException(msg); - } - - function.setOptions(options); - function.setStandardOptions(); - returnCode = function.execute(); - - } catch (IllegalArgumentException e) { - StringBuffer msg = new StringBuffer(SIGNATURE); - msg.append(DhcpCliFunction.getMessage(e)); - DhcpCliPrint.printErrMessage(msg.toString()); - DhcpCliPrint.printErrMessage(""); - usage(); - returnCode = FAILURE; - } catch (Throwable e) { - StringBuffer msg = new StringBuffer(SIGNATURE); - msg.append(DhcpCliFunction.getMessage(e)); - DhcpCliPrint.printErrMessage(msg.toString()); - returnCode = FAILURE; - } - - return (returnCode); - - } // execute - - /** - * Processes one program argument. - * @param option the option flag - * @param value the option value(if any) - * @exception IllegalArgumentException if an invalid argument was entered - */ - public void processArg(int option, String value) - throws IllegalArgumentException { - - switch (option) { - case CONFIGURE_DHCP: - setFunction(new ConfigureDhcp()); - break; - case CONFIGURE_BOOTP: - setFunction(new ConfigureBootp(value)); - break; - case UNCONFIGURE_DHCP: - setFunction(new UnconfigureDhcp()); - break; - case CONFIGURE_NETWORK: - setFunction(new ConfigureNetwork(value)); - break; - case CONVERT_DATA_STORE: - setFunction(new ConvertDataStore()); - break; - case EXPORT_DATA: - setFunction(new ExportData(value)); - break; - case IMPORT_DATA: - setFunction(new ImportData(value)); - break; - case CONFIGURE_SERVER_PARAMETER: - setFunction(new ServerParameter(value)); - break; - case CONFIGURE_SERVICE: - setFunction(new ConfigureService()); - break; - default: - options.setOption(option, value); - } - - } // processArg - - /** - * Returns a localized string for this function - * @param key the resource bundle string identifier - * @return string from resource bundle. - */ - public String getString(String key) { - - return ResourceStrings.getString(key); - - } // getString - - /** - * The entry point for the program. - * @param args the program arguments - */ - public static void main(String[] args) { - - DhcpCfg dhcpconfig = new DhcpCfg(args); - int returnCode = DhcpCfg.FAILURE; - if (dhcpconfig.isValidUser()) { - returnCode = dhcpconfig.execute(); - } - System.exit(returnCode); - - } // main - -} // DhcpConfig diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/DhcpCfgFunction.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/DhcpCfgFunction.java deleted file mode 100644 index f9c568267b..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/DhcpCfgFunction.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.dhcpconfig; - -import java.text.MessageFormat; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.cli.common.DhcpCliPrint; -import com.sun.dhcpmgr.data.DhcpdOptions; - -/** - * Abstract class implemented by all the dhcpconfig "function" classes. - */ -public abstract class DhcpCfgFunction - extends DhcpCliFunction { - - /** - * Returns a localized string for this function - * @param key the resource bundle string identifier - * @return string from resource bundle. - */ - public String getString(String key) { - - return ResourceStrings.getString(key); - - } // getString - - /** - * Determines whether or not the DHCP service is configured. - * @return true if configured, false if not. - */ - public boolean isServerConfigured() { - - boolean result = false; - - try { - DhcpdOptions opts = getSvcMgr().readDefaults(); - if (!opts.isRelay()) { - result = true; - } - } catch (Throwable e) { - // nothing to do. - } - - if (!result) { - printErrMessage(getString("dhcpcfg_func_not_configured_error")); - } - - return (result); - - } // isServerConfigured - - /** - * Prints a message to the console. - * @param msg the message to print. - */ - public void printMessage(String msg) { - DhcpCliPrint.printMessage(msg); - } // printMessage - - /** - * Prints a message to the console.. - * @param msg the message to print. - */ - public void printMessage(String msg, Object [] arguments) { - MessageFormat form = new MessageFormat(msg); - DhcpCliPrint.printMessage(form.format(arguments)); - } // printMessage - - /** - * Prints an error message. - * @param msg the message to print. - */ - public void printErrMessage(String msg) { - StringBuffer fullmsg = new StringBuffer(DhcpCfg.SIGNATURE); - fullmsg.append(msg); - DhcpCliPrint.printErrMessage(fullmsg.toString()); - } // printErrMessage - - /** - * Prints an error message. - * @param msg the message to print. - */ - public void printErrMessage(String msg, Object [] arguments) { - StringBuffer fullmsg = new StringBuffer(DhcpCfg.SIGNATURE); - fullmsg.append(msg); - MessageFormat form = new MessageFormat(fullmsg.toString()); - DhcpCliPrint.printErrMessage(form.format(arguments)); - } // printErrMessage - -} // DhcpCfgFunction diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ExportData.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ExportData.java deleted file mode 100644 index b4a4a2b163..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ExportData.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhcpconfig; - -import java.util.ArrayList; -import java.util.StringTokenizer; -import java.text.MessageFormat; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.cli.common.DhcpCliPrint; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.bridge.BridgeException; -import com.sun.dhcpmgr.bridge.ExistsException; - -import com.sun.dhcpmgr.common.ExportController; -import com.sun.dhcpmgr.common.Exporter; - -/** - * The main class for the "export move data" functionality of dhcpconfig. - */ -public class ExportData extends DhcpCfgFunction implements Exporter { - - /** - * The valid options associated with exporting data. - */ - private static final int supportedOptions[] = { - DhcpCfg.MACRO_LIST, - DhcpCfg.OPTION_LIST, - DhcpCfg.NETWORK_ADDRESSES, - DhcpCfg.DELETE_DATA, - DhcpCfg.FORCE, - DhcpCfg.SIGHUP - }; - - /** - * Keyword that may be used to define all options, all macros, or all - * network tables. - */ - private static final String ALL = "ALL"; - - /** - * The name of the export file. - */ - private String exportFile; - - /** - * Simple constructor - */ - public ExportData(String exportFile) { - - validOptions = supportedOptions; - this.exportFile = exportFile; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (DhcpCfg.EXPORT_DATA); - } - - /** - * Executes the "export move data" functionality. - * @return DhcpCfg.SUCCESS or DhcpCfg.FAILURE - */ - public int execute() { - - // Make sure that server is configured as a DHCP server. - // - if (!isServerConfigured()) { - return (DhcpCfg.FAILURE); - } - - // Check the validity of the data store version. - if (!isVersionValid(false)) { - return (DhcpCfg.FAILURE); - } - - // Should export file be overwritten if it exists? - boolean force = options.isSet(DhcpCfg.FORCE); - - // Should exported data be deleted or just copied? - boolean deleteData = options.isSet(DhcpCfg.DELETE_DATA); - - // Create the export controller - ExportController controller = new ExportController(this, getDhcpMgr()); - controller.setFile(exportFile); - // Store user name - controller.setUser(System.getProperty("user.name")); - - /* - * Get the macro list. The keyword of "ALL" means that all macros in - * the dhcptab should be exported. - */ - if (options.isSet(DhcpCfg.MACRO_LIST)) { - String macroNames = options.valueOf(DhcpCfg.MACRO_LIST); - if (ALL.equals(macroNames)) { - controller.setAllMacros(); - } else { - // Parse macro list and give to controller - controller.setMacros(argsToArray(macroNames)); - } - } - - /* - * Get the option list. Keyword of "ALL" means that all options in the - * dhcptab should be exported. - */ - if (options.isSet(DhcpCfg.OPTION_LIST)) { - String optionNames = options.valueOf(DhcpCfg.OPTION_LIST); - if (ALL.equals(optionNames)) { - controller.setAllOptions(); - } else { - controller.setOptions(argsToArray(optionNames)); - } - } - - /* - * Get the list of network addresses. If the option is set to the - * keyword "ALL", all network tables should be exported. - */ - if (options.isSet(DhcpCfg.NETWORK_ADDRESSES)) { - String addrs = options.valueOf(DhcpCfg.NETWORK_ADDRESSES); - if (ALL.equals(addrs)) { - controller.setAllNetworks(); - } else { - // Parse network list - IPAddressList networkAddresses; - try { - networkAddresses = new IPAddressList(addrs); - } catch (ValidationException e) { - printErrMessage(getMessage(e)); - printErrMessage(getString("export_abort")); - return (DhcpCfg.FAILURE); - } - - // Now ensure all networks specified exist - ArrayList netList = new ArrayList(); - try { - Network [] nets = getNetMgr().getNetworks(); - - for (int i = 0; - !networkAddresses.isEmpty() && i < nets.length; - ++i) { - int index = networkAddresses.indexOf( - nets[i].getNetworkNumber()); - // Found; remove from search list, add to export list - if (index != -1) { - netList.add(nets[i]); - networkAddresses.remove(index); - } - } - } catch (BridgeException e) { - e.printStackTrace(); - } - - if (!networkAddresses.isEmpty()) { - // One of the networks was not valid - System.err.print(networkAddresses.firstElement()); - System.err.println(" is not a valid network"); - return (DhcpCfg.FAILURE); - } - - controller.setNetworks( - (Network [])netList.toArray(new Network[0])); - } - } - - // Do the export - try { - // result should affect exit status once that's implemented - if (!controller.exportData(deleteData, force)) { - return (DhcpCfg.FAILURE); - } - } catch (ExistsException e) { - // File already exists, print error and exit - Object [] arguments = new Object[1]; - arguments[0] = exportFile; - printErrMessage(getString("export_file_exist_error"), arguments); - printErrMessage(getString("export_abort")); - return (DhcpCfg.FAILURE); - } - - // Signal server if requested by user - try { - if (options.isSet(DhcpCfg.SIGHUP)) { - getSvcMgr().reload(); - } - } catch (Throwable e) { - printErrMessage(getString("sighup_failed")); - return (DhcpCfg.FAILURE); - } - - return (DhcpCfg.SUCCESS); - - } // execute - - /** - * Convert a comma-separated list of arguments to an array of tokens - */ - private String [] argsToArray(String arg) { - ArrayList argList = new ArrayList(); - StringTokenizer st = new StringTokenizer(arg, ","); - while (st.hasMoreTokens()) { - argList.add(st.nextToken()); - } - return (String [])argList.toArray(new String[0]); - } - - /** - * Initialize progress. A no-op for us. - */ - public void initializeProgress(int length) { - // Do nothing - } - - /** - * Display progress. Just print the message. - */ - public void updateProgress(int done, String message) { - printMessage(message); - } - - /** - * Display an error. - */ - public void displayError(String message) { - Object [] arguments = new Object[1]; - arguments[0] = message; - printErrMessage(getString("export_err_message"), arguments); - } - - /** - * Display a set of errors during export - */ - public void displayErrors(String msg, String label, ActionError [] errs) { - printErrMessage(msg); - Object [] args = new Object[3]; - args[0] = label; - MessageFormat form = - new MessageFormat(getString("export_action_error")); - for (int i = 0; i < errs.length; ++i) { - args[1] = errs[i].getName(); - args[2] = errs[i].getException().getMessage(); - printErrMessage(form.format(args)); - } - } - -} // ExportData diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/IPAddressList.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/IPAddressList.java deleted file mode 100644 index e5b18c75fb..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/IPAddressList.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.dhcpconfig; - -import com.sun.dhcpmgr.data.IPAddress; -import com.sun.dhcpmgr.data.ValidationException; - -import java.util.Vector; -import java.util.Enumeration; -import java.util.StringTokenizer; -import java.text.MessageFormat; - -/** - * Class that builds a vector of IPAddress objects. - */ -public class IPAddressList extends Vector { - - /** - * Construct a IPAddressList from a String list of IP addresses - * and/or host names. - * @param addresses a String list of IP addresses - */ - public IPAddressList(String addresses) throws ValidationException { - - removeAllElements(); - - if (addresses == null) { - return; - } - - StringTokenizer st = new StringTokenizer(addresses, ","); - while (st.hasMoreTokens()) { - String address = st.nextToken(); - try { - addElement(new IPAddress(address.trim())); - } catch (ValidationException e) { - Object [] args = new Object[1]; - args[0] = address; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_ip_address")); - throw new ValidationException(form.format(args)); - } - } - } // constructor - - /** - * Construct a IPAddressList from an array of IPAddress objects. - * @param addresses array of IPAddress objects - */ - public IPAddressList(IPAddress [] addresses) { - - removeAllElements(); - - if (addresses == null) { - return; - } - - for (int i = 0; i < addresses.length; i++) { - addElement(addresses[i]); - } - } // constructor - - /** - * Returns an array of IP Addresses. - * @return an array of IP Addresses. - */ - public IPAddress [] toIPAddressArray() { - return ((IPAddress [])toArray(new IPAddress[size()])); - } // toIPAddressArray - - /** - * Returns a comma separated list of IP Addresses. - * @return a comma separated list of IP Addresses. - */ - public String toString() { - StringBuffer b = new StringBuffer(); - Enumeration en = elements(); - while (en.hasMoreElements()) { - if (b.length() != 0) { - b.append(','); - } - b.append(((IPAddress)en.nextElement()).getHostAddress()); - } - return b.toString(); - } // toString - -} // IPAddressList diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ImportData.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ImportData.java deleted file mode 100644 index 44455fde7f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ImportData.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhcpconfig; - -import java.text.MessageFormat; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.cli.common.DhcpCliPrint; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.bridge.BridgeException; -import com.sun.dhcpmgr.bridge.ExistsException; - -import com.sun.dhcpmgr.common.Importer; -import com.sun.dhcpmgr.common.ImportController; - -/** - * The main class for the "import move data" functionality of dhcpconfig. - */ -public class ImportData extends DhcpCfgFunction implements Importer { - - /** - * The valid options associated with importing data. - */ - private static final int supportedOptions[] = { - DhcpCfg.FORCE, - DhcpCfg.SIGHUP - }; - - /** - * The name of the import file. - */ - private String importFile; - - /** - * Simple constructor - */ - public ImportData(String importFile) { - - validOptions = supportedOptions; - this.importFile = importFile; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (DhcpCfg.IMPORT_DATA); - } - - /** - * Executes the "import move data" functionality. - * @return DhcpCfg.SUCCESS or DhcpCfg.FAILURE - */ - public int execute() { - - // Make sure that server is configured as a DHCP server. - // - if (!isServerConfigured()) { - return (DhcpCfg.FAILURE); - } - - // Check the validity of the data store version. - // - if (!isVersionValid(false)) { - return (DhcpCfg.FAILURE); - } - - // Shall we overwrite any existing, conflicting data? - boolean force = options.isSet(DhcpCfg.FORCE); - - // Create import controller and do the import - ImportController controller = new ImportController(this, getDhcpMgr()); - controller.setFile(importFile); - if (!controller.importData(force)) { - return (DhcpCfg.FAILURE); - } - - // Signal server if user requested - try { - if (options.isSet(DhcpCfg.SIGHUP)) { - getSvcMgr().reload(); - } - } catch (Throwable e) { - printErrMessage(getString("sighup_failed")); - return (DhcpCfg.FAILURE); - } - - return (DhcpCfg.SUCCESS); - - } // execute - - public void initializeProgress(int length) { - // Do nothing - } - - public void updateProgress(int done, String message) { - // Just print the message - printMessage(message); - } - - public void displayError(String message) { - Object [] arguments = new Object[1]; - arguments[0] = message; - printErrMessage(getString("import_error_msg"), arguments); - } - - public void displayErrors(String msg, String label, ActionError [] errs) { - printErrMessage(msg); - String [] args = new String[3]; - args[0] = label; - MessageFormat form = - new MessageFormat(getString("import_action_error")); - for (int i = 0; i < errs.length; ++i) { - args[1] = errs[i].getName(); - args[2] = errs[i].getException().getMessage(); - printErrMessage(form.format(args)); - } - } - -} // ImportData diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/Makefile deleted file mode 100644 index 155552263d..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/Makefile +++ /dev/null @@ -1,86 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/Makefile -# - -# Place high-level classes first to minimize build time. -CLASSFILES = DhcpCfg.class \ - ConfigureBootp.class \ - ConfigureDhcp.class \ - ConfigureNetwork.class \ - ConvertDataStore.class \ - ExportData.class \ - IPAddressList.class \ - ImportData.class \ - UnconfigureDhcp.class \ - ServerParameter.class \ - ConfigureService.class \ - DhcpCfgFunction.class \ - ResourceStrings.class - - -include $(SRC)/Makefile.master - -CLASSPATH= $(SRC)/cmd/cmd-inet/usr.sadm/dhcpmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -MSGDIR= $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/cli/dhcpconfig -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/cli \ - $(MSGDIR) - -MSGFILES= ResourceBundle.properties -MSGS= $(MSGFILES:%=$(MSGDIR)/%) - -CLEANFILES= *.class -CLOBBERFILES= - -.KEEP_STATE: - -all: $(CLASSFILES) - -install: all - -_msg: $(MSGDIRS) $(MSGS) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - -lint: - -clean: - $(RM) $(CLEANFILES) - -clobber: clean diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ResourceBundle.properties b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ResourceBundle.properties deleted file mode 100644 index f85392bc03..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ResourceBundle.properties +++ /dev/null @@ -1,173 +0,0 @@ -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# ConfigureDhcp & ConfigureBootp messages. -# -config_dhcp_configured_error=Error - DHCP service is already configured on this server. -config_bootp_configured_error=Error - server is already configured as a BOOTP relay agent. -config_null_datastore_error=Error - cannot configure without resource and path options. -config_invalid_resource_error=Error - {0} is not a valid resource. -config_make_location_error=Error - creating location: {0}. -config_hosts_domain_ignored_error=Error - host domain does not make sense for a host resource type - {0} -config_lease_error=Error - the lease value specified is not valid. -config_lease_zero_error=Error - a lease value of zero is not valid. -config_dns_error=Error - DNS domain or server information is incomplete. -config_dns_server_error=Error - building the DNS server list. {0} -config_startup_progress=DHCP server started. -config_startup_error=Error - starting the DHCP server. {0} -config_create_conf_progress=Created DHCP configuration file. -config_writing_conf_error=Error - could not write to the DHCP configuration file. {0} -config_dhcptab_progress=Created dhcptab. -config_dhcptab_exists_progress=Dhcptab already exists. -config_dhcptab_error=Error - creating dhcptab. {0} -config_locale_progress=Added "Locale" macro to dhcptab. -config_locale_error=Error - adding locale macro to dhcptab. {0} -config_server_macro_progress=Added server macro to dhcptab - {0}. -config_server_macro_error=Error - creating server macro for server {0}. {1} - -# -# ConfigureNetwork messages. -# -cfgnet_invalid_network_error=Error - {0} is not a valid network. -cfgnet_invalid_ip_error=Error - {0} is an invalid address. -cfgnet_nis_error=Error - NIS domain or server information is incomplete. -cfgnet_nis_server_error=Error - building the NIS server list. {0} -cfgnet_network_macro_progress=Added network macro to dhcptab - {0}. -cfgnet_network_macro_error=Error - creating network macro. {0} -cfgnet_network_table_progress=Created network table. -cfgnet_network_table_error=Error - creating network table. {0} - -# -# UnconfigureDhcp messages. -# -unconfigure_read_conf_error=Error - reading DHCP configuration file. {0} -unconfigure_shutdown_progress=DHCP server shutdown. -unconfigure_no_shutdown_progress=DHCP server not running. -unconfigure_shutdown_error=Error - shutting down DHCP server. {0} -unconfigure_server_macro_progress=Deleted the server macro from dhcptab. -unconfigure_server_macro_error=Error - deleting server macro. {0} -unconfigure_get_nets_error=Error - determining list of networks. {0} -unconfigure_network_progress=Deleted table for network {0}. -unconfigure_network_error=Error - deleting table for network {0}. {1} -unconfigure_dhcptab_progress=Deleted the dhcptab. -unconfigure_dhcptab_error=Error - deleting dhcptab. {0} -unconfigure_remove_conf_progress=Deleted the DHCP configuration file. -unconfigure_remove_conf_error=Error - deleting DHCP configuration file. {0} -unconfigure_confirmation=Unconfigure will stop the DHCP service and remove the DHCP configuration file.\nAre you SURE you want to unconfigure the DHCP service? - -# -# ConvertDataStore errors. -# -convert_null_datastore_error=Error - cannot convert without resource and path options. -convert_same_datastore_error=Error - the source data store is the same as destination data store. -convert_invalid_resource_error=Error - {0} is not a valid resource. -convert_make_location_error=Error - creating location - {0}. -convert_dhcptab_progress=Converted dhcptab. -convert_dhcptab_error=Error - converting dhcptab. {0} -convert_get_nets_error=Error - failure getting list of networks. {0} -convert_network_progress=Converted table for network {0}. -convert_network_error=Error - converting table for network {0}. {1} -convert_conf_read_error=Error - reading DHCP configuration file. {0} -convert_conf_write_error=Error - could not write to the DHCP configuration file. {0} -convert_conf_update_progress=Updated DHCP configuration file with new resource and path. -convert_delete_network_progress=Deleted old table for network {0}. -convert_delete_network_error=Error - deleting old table for network {0}. {1} -convert_delete_dhcptab_progress=Deleted old dhcptab table. -convert_delete_dhcptab_error=Error - deleting old dhcptab table. {0} -convert_explanation=\nConverting your data stores will result in your DHCP service being\nstopped, the data stores converted, and the DHCP service restarted.\n -convert_confirmation=Are you SURE you want to convert the DHCP data stores? -convert_shutdown_progress=DHCP server shutdown. -convert_no_shutdown_progress=DHCP server not running. -convert_shutdown_error=Error - shutting down DHCP server. {0} -convert_startup_progress=DHCP server started. -convert_startup_error=Error - starting the DHCP server. {0} - -# -# ExportData messages. -# -export_err_message=Export error - {0} -export_abort=Export aborted! -export_file_exist_error=Error - file already exists and will not be overwritten - {0} -export_action_error={0} {1} - {2} - -# -# ImportData messages. -# -import_error_msg=Import error - {0} -import_action_error={0} {1} - {2} - -# -# DhcpCfgFunction messages. -# -dhcpcfg_func_not_configured_error=Error - DHCP service is not configured on this server.\nMust execute 'dhcpconfig -D' first. - -# -# Common messages. -# -invalid_ip_address={0} is not a valid IP address. -affirmative=Y -negative=N -sighup_failed=Unable to signal the daemon to reload the dhcptab - -# -# DhcpCfg messages. -# -dhcpcfg_invalid_arg=Invalid argument - {0} -dhcpcfg_no_function_error=Error - must specify one of 'D', 'R', 'U', 'N', 'C', 'X', 'I', 'P' or 'S'. -dhcpcfg_usage=dhcpconfig (options)\n\nWhere (options) is one of:\n\n -D -r (resource) -p (path) Configure the DHCP service. Sub-options:\n [-u (uninterpreted data)]\n [-l (lease length)]\n [-n] Leases are not negotiable\n [-d (DNS domain)]\n [-a (DNS servers)]\n\n -R (server addresses) Configure BOOTP relay service.\n\n -U Unconfigure DHCP or BOOTP relay service. Sub-options:\n [-f] No confirmation prompt\n [-x] Delete dhcptab and network tables\n\n -N (network address) Configure network. Sub-options:\n [-m (subnet mask)]\n [-t (router addresses)]\n [-y (NIS domain)]\n [-a (NIS addreses)]\n [-b] Network is point-to-point\n [-g] Signal daemon\n\n -C -r (resource) -p (path) Convert to new data store. Sub-options:\n [-u (uninterpreted data)]\n [-f] No confirmation prompt\n [-k] Do not delete original files\n\n -X (export filename) Export data. Sub-options:\n [-m (macro list)]\n [-o (option list)]\n [-a (network addresses)]\n [-f] Overwrite an existing export file\n [-x] Delete exported data\n [-g] Signal daemon\n\n -I (import filename) Import data. Sub-options:\n [-f] Overwrite existing data\n [-g] Signal daemon\n\n -P [parameter[=value]] Configure or print DHCP server parameters.\n\n -S Control the DHCP server. Sub-options:\n [-e] Enable and start the DHCP server\n [-d] Disable and stop the DHCP server\n [-r] Re-enable the DHCP server\n [-q] Query the DHCP server status\n - -# -# ServerParameter errors. -# -server_parameter_keyword_missing_error=Error - server parameter missing. -server_parameter_failed_read_params_error=Error - failed to read DHCP server parameters. -server_parameter_failed_write_params_error=Error - failed to write DHCP server parameters. -server_parameter_keyword_bad_keyword_error=Error - invalid DHCP server parameter {0}. -server_parameter_keyword_set_read_only_error=Error - the DHCP server parameter {0} cannot be changed. -server_parameter_keyword_set_bad_value_error=Error - the value {1} is unacceptable for DHCP server parameter {0}. -server_parameter_keyword_delete_read_only_error=Error - the DHCP server parameter {0} cannot be deleted. -server_parameter_keyword_getall_bad_keyword_error=Error - invalid DHCP server parameter {0}. -server_parameter_keyword_not_set_error=DHCP server parameter {0} is not set. -server_parameter_get_value={0} -server_parameter_get_keyword_value={0} {1} - -# -# ConfigureService errors. -# -config_service_failed_read_params_error=Error - failed to read DHCP server parameters. -config_service_failed_write_params_error=Error - failed to write DHCP server parameters. -config_service_bad_action_error=Error - must specify one of 's', 'e', 'r' or 'q'. -config_service_failed_enabled_error=Error - failed to enable DHCP server. -config_service_failed_disabled_error=Error - failed to disable DHCP server. -config_service_failed_startup_error=Error - failed to start DHCP server. -config_service_failed_shutdown_error=Error - failed to stop DHCP server. -config_service_failed_query_error=Error - failed to query DHCP server. -config_service_state_startup=DHCP server started. -config_service_state_shutdown=DHCP server shutdown. -config_service_state_enabled=DHCP server enabled. -config_service_state_disabled=DHCP server disabled. -config_service_state_running=DHCP server running. -config_service_state_stopped=DHCP server stopped. - diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ResourceStrings.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ResourceStrings.java deleted file mode 100644 index 395b9a1e39..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ResourceStrings.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.dhcpconfig; - -import java.util.*; - -/** - * This class provides a convenient method to retrieve resources for - * the dhcpconfig package. - */ -public class ResourceStrings { - - /** - * The handle to the resource bundle for the module. - */ - private static ResourceBundle bundle = null; - - /** - * Return a string from the resource bundle. - * @param key the key to the resource bundle string. - * @return the resource bundle string. - */ - public static String getString(String key) { - String msg = null; - try { - if (bundle == null) { - bundle = ResourceBundle.getBundle( - "com.sun.dhcpmgr.cli.dhcpconfig.ResourceBundle", - Locale.getDefault()); - } - msg = bundle.getString(key); - } catch (Throwable e) { - msg = new String(key); - } - return msg; - - } // getString - -} // ResourceStrings diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ServerParameter.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ServerParameter.java deleted file mode 100644 index 6421ff071b..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/ServerParameter.java +++ /dev/null @@ -1,581 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhcpconfig; - -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; -import com.sun.dhcpmgr.cli.common.GetSubOpt; -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.data.DhcpdOptions; -import com.sun.dhcpmgr.data.DhcpResource; -import com.sun.dhcpmgr.data.qualifier.*; -import com.sun.dhcpmgr.bridge.BridgeException; - -/** - * Functions for handling all dhcpconfig options that manage the DHCP server - * parameters. - */ -public class ServerParameter extends DhcpCfgFunction { - - /** - * Options that this DhcpCfgFunction will accept. - */ - static final int supportedOptions[] = { - }; - - /** - * List of suboptions. - */ - private String subOptions; - - /** - * Simple constructor - */ - public ServerParameter(String subOptions) { - validOptions = supportedOptions; - this.subOptions = subOptions; - } // constructor - - /** - * Returns the option flag for this function. - * @returns - * The option flag for this function. - */ - public int getFunctionFlag() { - return DhcpCfg.CONFIGURE_SERVER_PARAMETER; - } // getFunctionFlag - - /** - * Parse and execute the options for this function. - * @return - * DhcpCfg.SUCCESS for success and DhcpCfg.FAILURE for failure. - */ - public int execute() throws IllegalArgumentException { - List actions = new ArrayList(); - - if (subOptions == null || subOptions.length() == 0) { - actions.add(new ActionGetAll()); - } else { - GetSubOpt getSubOpt = new GetSubOpt(subOptions); - - while (getSubOpt.hasMoreSubOptions()) { - String keyword = getSubOpt.getNextSubOption(); - String value = getSubOpt.getSubOptionArg(); - - boolean valueSet = (value != null); - - if (value == null) { - actions.add(new ActionGet(keyword)); - } else { - if (value.equals("")) { - actions.add(new ActionDelete(keyword)); - } else { - actions.add(new ActionSet(keyword, value)); - } - } - } - } - - DhcpdOptions dhcpdOptions; - boolean atLeastOneActionFailed; - Iterator iterator; - - try { - dhcpdOptions = getSvcMgr().readDefaults(); - } catch (BridgeException be) { - printErrMessage( - getString("server_parameter_failed_read_params_error")); - return DhcpCfg.FAILURE; - } - - atLeastOneActionFailed = false; - - // Initialise the actions. - iterator = actions.iterator(); - while (iterator.hasNext()) { - Action action = (Action) iterator.next(); - - if (action.init(dhcpdOptions) != DhcpCfg.SUCCESS) { - atLeastOneActionFailed = true; - } - } - - if (atLeastOneActionFailed) { - return DhcpCfg.FAILURE; - } - - dhcpdOptions.clearDirty(); - - atLeastOneActionFailed = false; - - // Execute the actions. - iterator = actions.iterator(); - while (iterator.hasNext()) { - Action action = (Action) iterator.next(); - - if (action.execute() != DhcpCfg.SUCCESS) { - atLeastOneActionFailed = true; - } - } - - if (atLeastOneActionFailed) { - return DhcpCfg.FAILURE; - } - - if (dhcpdOptions.isDirty()) { - try { - getSvcMgr().writeDefaults(dhcpdOptions); - } catch (BridgeException e) { - printErrMessage( - getString( - "server_parameter_failed_write_params_error")); - return DhcpCfg.FAILURE; - } - - dhcpdOptions.clearDirty(); - } - - return DhcpCfg.SUCCESS; - } // execute - - /** - * All functions are carried out through a specific action sub-classed - * from this class. - */ - private interface Action { - /** - * Initialise the action. - * - * @param dhcpdOptions - * The server options that an action manipulates. - * - * @return - * DhcpCfg.SUCCESS for success and DhcpCfg.FAILURE for failure. - */ - public int init(DhcpdOptions dhcpdOptions); - - /** - * Execute the action. - * - * @return - * DhcpCfg.SUCCESS for success and DhcpCfg.FAILURE for failure. - */ - public int execute(); - } - - /** - * Shared super class for actions. - */ - private abstract class ActionImpl implements Action { - - /** - * The server parameter this action works upon. Could be null. - */ - protected String keyword; - - /** - * The value this action works upon. Could be null. - */ - protected String value; - - /** - * The qualifier for the server parameter. If the keyword is null - * the qualifier will be null. The general rule is that if keyword is - * not null, qualifier must not be null. If it is then the keyword - * is not a recognised server parameter. - */ - protected Qualifier qualifier; - - /** - * Server parameters. - */ - protected DhcpdOptions dhcpdOptions; - - /** - * Construct an action for the given server parameter keyword and - * value. The constructor will find the appropriate qualifier that - * matches the keyword if the keyword is not null. Note that no - * checking on the validity of the keyword contents is made at this - * point. - * - * @param keyword - * The server parameter this action works upon. Could be null. - * @param value - * The value this action works upon. Could be null. - */ - protected ActionImpl(String keyword, String value) { - this.keyword = keyword; - this.value = value; - } // constructor - - /** - * Get the keyword. - * - * @return - * The keyword this action operates upon. - */ - public String getKeyword() { - return keyword; - } - - /** - * Validate and initialise the action. A sub-classed action is passed - * execution control via the doExecute() callback method. - * - * @return - * DhcpCfg.SUCCESS for success and DhcpCfg.FAILURE for failure. - */ - public final int init(DhcpdOptions dhcpdOptions) { - if (dhcpdOptions == null) { - return DhcpCfg.FAILURE; - } - - this.dhcpdOptions = dhcpdOptions; - - if (keyword != null) { - qualifier = dhcpdOptions.getQualifier(keyword); - - if (qualifier == null) { - Object[] arguments = new Object[1]; - arguments[0] = keyword; - printErrMessage( - getString( - "server_parameter_keyword_bad_keyword_error"), - arguments); - return DhcpCfg.FAILURE; - } - } - - return doInit(); - } // execute - - /** - * Sub-classed action callback method. Once validation has been - * performed initialisation is continued in the action sub-class - * by calling this method. - * - * @return - * DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure. - */ - protected abstract int doInit(); - - /** - * Validate and execute the action. A sub-classed action is passed - * execution control via the doExecute() callback method. - * - * @return - * DhcpCfg.SUCCESS for success and DhcpCfg.FAILURE for failure. - */ - public final int execute() { - if (dhcpdOptions == null) { - return DhcpCfg.FAILURE; - } - - return doExecute(); - } // execute - - /** - * Sub-classed action callback method. Once validation has been - * performed execution is continued in the action sub-class by calling - * this method. - * - * @return - * DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure. - */ - protected abstract int doExecute(); - } - - /** - * Set a parameter action. - */ - private class ActionSet extends ActionImpl { - - /** - * Construct an add action. - * - * @param keyword - * The server parameter this action works upon. - * @param value - * The value this action works upon. - */ - public ActionSet(String keyword, String value) { - super(keyword, value); - } // constructor - - protected int doInit() { - if (qualifier.isReadOnly()) { - Object[] arguments = new Object[1]; - arguments[0] = keyword; - printErrMessage( - getString( - "server_parameter_keyword_set_read_only_error"), - arguments); - return DhcpCfg.FAILURE; - } - - QualifierType qualifierType = qualifier.getType(); - - if (qualifierType.parseValue(value) == null) { - Object[] arguments = new Object[2]; - arguments[0] = keyword; - arguments[1] = value; - printErrMessage( - getString( - "server_parameter_keyword_set_bad_value_error"), - arguments); - return DhcpCfg.FAILURE; - } - - return DhcpCfg.SUCCESS; - } - - /** - * Set the parameters value. - * - * @return - * DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure. - */ - protected int doExecute() { - QualifierType qualifierType = qualifier.getType(); - - dhcpdOptions.set(keyword, qualifierType.formatValue(value)); - dhcpdOptions.set(keyword, qualifierType.formatValue(value)); - - return DhcpCfg.SUCCESS; - } // doExecute - - } - - /** - * Get a parameter action. - */ - private class ActionGet extends ActionImpl { - - /** - * This field controls the displaying of the keyword in addition - * to the keywords value. The default is to not show the keyword. - */ - protected boolean showKeyword = false; - - /** - * Construct a get action - * - * @param keyword - * The server parameter this action works upon. - */ - public ActionGet(String keyword) { - super(keyword, null); - } // constructor - - protected int doInit() { - if (!dhcpdOptions.isSet(keyword)) { - Object[] arguments = new Object[1]; - arguments[0] = keyword; - printErrMessage( - getString("server_parameter_keyword_not_set_error"), - arguments); - - return DhcpCfg.FAILURE; - } - - return DhcpCfg.SUCCESS; - } - - /** - * Get the parameters value. - * - * @return - * DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure. - */ - protected int doExecute() { - Object[] arguments; - - if (showKeyword) { - arguments = new Object[2]; - arguments[0] = keyword; - arguments[1] = dhcpdOptions.valueOf(keyword); - printMessage( - getString("server_parameter_get_keyword_value"), - arguments); - } else { - arguments = new Object[1]; - arguments[0] = dhcpdOptions.valueOf(keyword); - printMessage(getString("server_parameter_get_value"), - arguments); - } - - return DhcpCfg.SUCCESS; - - } // doExecute - - /** - * This method controls the displaying of the keyword in addition - * to the keywords value. - * - * @param showKeyword - * If true the keyword is shown with the value, otherwise only the - * the value is shown. - */ - public void setShowKeyword(boolean showKeyword) { - this.showKeyword = showKeyword; - } - - } - - /** - * Get all parameters action. - */ - private class ActionGetAll extends ActionImpl { - - protected List subActions; - - /** - * Construct a get all action. - */ - public ActionGetAll() { - super(null, null); - subActions = new ArrayList(); - } // constructor - - protected int doInit() { - Object[] parameters = dhcpdOptions.getAll(); - boolean atLeastOneSubActionFailed = false; - - for (int index = 0; index < parameters.length; index++) { - ActionGet subAction; - String parameter = ((DhcpResource) parameters[index]).getKey(); - qualifier = dhcpdOptions.getQualifier(parameter); - - if (qualifier == null) { - Object[] arguments = new Object[1]; - arguments[0] = keyword; - printErrMessage( - getString( - "server_parameter_keyword_bad_keyword_error"), - arguments); - continue; - } - - if (qualifier.isHidden()) { - continue; - } - - subAction = new ActionGet(parameter); - subAction.setShowKeyword(true); - subActions.add(subAction); - - if (subAction.init(dhcpdOptions) == DhcpCfg.FAILURE) { - atLeastOneSubActionFailed = true; - } - } - - if (atLeastOneSubActionFailed) { - return DhcpCfg.FAILURE; - } else { - return DhcpCfg.SUCCESS; - } - } - - /** - * Get all the parameters and their values. - * - * @return - * DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure. - */ - protected int doExecute() { - Iterator iterator = subActions.iterator(); - - while (iterator.hasNext()) { - ActionGet subAction = (ActionGet) iterator.next(); - String parameter = subAction.getKeyword(); - qualifier = dhcpdOptions.getQualifier(parameter); - - if (subAction.execute() == DhcpCfg.FAILURE) { - return DhcpCfg.FAILURE; - } - } - - return DhcpCfg.SUCCESS; - } // doExecute - - } - - /** - * Delete a parameter action. - */ - private class ActionDelete extends ActionImpl { - - /** - * Construct a get delete action - * - * @param keyword - * The server parameter this action works upon. - */ - public ActionDelete(String keyword) { - super(keyword, null); - } // constructor - - protected int doInit() { - if (!dhcpdOptions.isSet(keyword)) { - Object[] arguments = new Object[1]; - arguments[0] = keyword; - printErrMessage( - getString("server_parameter_keyword_not_set_error"), - arguments); - return DhcpCfg.FAILURE; - } - - if (qualifier.isReadOnly()) { - Object[] arguments = new Object[1]; - arguments[0] = keyword; - printErrMessage( - getString( - "server_parameter_keyword_delete_read_only_error"), - arguments); - return DhcpCfg.FAILURE; - } - - return DhcpCfg.SUCCESS; - } - - /** - * Delete the parameter and its value. - * - * @return - * DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure. - */ - protected int doExecute() { - dhcpdOptions.clear(keyword); - - return DhcpCfg.SUCCESS; - } // doExecute - - } - -} // ServerParameter diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/UnconfigureDhcp.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/UnconfigureDhcp.java deleted file mode 100644 index bcc2b9cff5..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhcpconfig/UnconfigureDhcp.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.dhcpconfig; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.cli.common.Console; -import com.sun.dhcpmgr.data.ValidationException; -import com.sun.dhcpmgr.data.Network; -import com.sun.dhcpmgr.data.Macro; -import com.sun.dhcpmgr.data.DhcpdOptions; - -/** - * The main class for the "unconfigure DHCP server" functionality of - * dhcpconfig. - */ -public class UnconfigureDhcp extends DhcpCfgFunction { - - /** - * The valid options associated with unconfiguring a DHCP server. - */ - static final int supportedOptions[] = { - DhcpCfg.FORCE, - DhcpCfg.DELETE_TABLES - }; - - /** - * Constructs a UnconfigureDhcp object. - */ - public UnconfigureDhcp() { - - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (DhcpCfg.UNCONFIGURE_DHCP); - } - - /** - * Executes the "unconfigure DHCP server" functionality. - * @return DhcpCfg.SUCCESS or DhcpCfg.FAILURE - */ - public int execute() { - - // Confirm? - // - if (!options.isSet(DhcpCfg.FORCE)) { - String confirmationMsg = getString("unconfigure_confirmation"); - String affirmative = getString("affirmative"); - String negative = getString("negative"); - boolean doit = Console.promptUser(confirmationMsg, affirmative, - negative, true); - if (!doit) { - return (DhcpCfg.FAILURE); - } - } - - // Retrieve the configuration values from the server. - // - boolean isRelay = false; - try { - DhcpdOptions opts = getSvcMgr().readDefaults(); - isRelay = opts.isRelay(); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("unconfigure_read_conf_error"), - arguments); - return (DhcpCfg.FAILURE); - } - - // Shut down the server if it is running - // - try { - if (getSvcMgr().isServerRunning()) { - getSvcMgr().shutdown(); - printMessage(getString("unconfigure_shutdown_progress")); - } else { - printMessage(getString("unconfigure_no_shutdown_progress")); - } - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("unconfigure_shutdown_error"), - arguments); - } - - // Should we delete the dhcptab and the network tables? - // - boolean deleteTables = options.isSet(DhcpCfg.DELETE_TABLES); - - // If this server is just acting as a relay then we don't need to - // clean up the dhcptab or the networks. - // - if (!isRelay) { - // Delete the server macro. - // - try { - Macro serverMacro = - new Macro(getSvcMgr().getShortServerName()); - getDhcptabMgr().deleteRecord(serverMacro, false); - printMessage(getString("unconfigure_server_macro_progress")); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("unconfigure_server_macro_error"), - arguments); - } - - // Delete the dhcptab and the network tables if requested. - // - if (deleteTables) { - // Go get a list of the network tables to delete. - // - Network[] networks = new Network[0]; - try { - networks = getNetMgr().getNetworks(); - if (networks == null) { - networks = new Network[0]; - } - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("unconfigure_get_nets_error"), - arguments); - } - - // Delete the network tables - // - for (int i = 0; i < networks.length; ++i) { - String netString = networks[i].toString(); - try { - getNetMgr().deleteNetwork(netString, false); - Object [] arguments = new Object[1]; - arguments[0] = netString; - printMessage(getString("unconfigure_network_progress"), - arguments); - } catch (Throwable e) { - Object [] arguments = new Object[2]; - arguments[0] = netString; - arguments[1] = getMessage(e); - printErrMessage(getString("unconfigure_network_error"), - arguments); - } - } - - // Delete the dhcptab - // - try { - getDhcptabMgr().deleteDhcptab(); - printMessage(getString("unconfigure_dhcptab_progress")); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("unconfigure_dhcptab_error"), - arguments); - } - } - } - - // Remove the configuration file - // - try { - getSvcMgr().removeDefaults(); - printMessage(getString("unconfigure_remove_conf_progress")); - } catch (Throwable e) { - Object [] arguments = new Object[1]; - arguments[0] = getMessage(e); - printErrMessage(getString("unconfigure_remove_conf_error"), - arguments); - } - - return (DhcpCfg.SUCCESS); - - } // execute - -} // UnconfigureDhcp diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/AddEntry.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/AddEntry.java deleted file mode 100644 index 3cd93c6171..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/AddEntry.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhtadm; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.data.DhcptabRecord; -import com.sun.dhcpmgr.data.Macro; -import com.sun.dhcpmgr.data.Option; -import com.sun.dhcpmgr.data.OptionsTable; -import com.sun.dhcpmgr.bridge.ExistsException; - -import java.lang.IllegalArgumentException; - -/** - * The main class for the "add entry" functionality of dhtadm. - */ -public class AddEntry extends DhtAdmFunction { - - /** - * The valid options associated with adding an entry. - */ - static final int supportedOptions[] = { - DhtAdm.MACRONAME, - DhtAdm.SYMBOLNAME, - DhtAdm.DEFINITION, - DhtAdm.RESOURCE, - DhtAdm.RESOURCE_CONFIG, - DhtAdm.PATH, - DhtAdm.SIGHUP - }; - - /** - * Constructs a AddEntry object. - */ - public AddEntry() { - - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (DhtAdm.ADD_ENTRY); - } - - /** - * Executes the "add entry" functionality. - * @return DhtAdm.SUCCESS, DhtAdm.EXISTS, DhtAdm.WARNING, or - * DhtAdm.CRITICAL - */ - public int execute() - throws IllegalArgumentException { - - int returnCode = DhtAdm.SUCCESS; - - // Get macro or symbol name. One and only one should be set. - // - String macroName = options.valueOf(DhtAdm.MACRONAME); - String symbolName = options.valueOf(DhtAdm.SYMBOLNAME); - - if (macroName != null && symbolName != null) { - String msg = getString("two_keys_error"); - throw new IllegalArgumentException(msg); - } - - if (macroName == null && symbolName == null) { - String msg = getString("no_keys_error"); - throw new IllegalArgumentException(msg); - } - - // Get the definition. It's an error if it does not exist. - // - String definition = options.valueOf(DhtAdm.DEFINITION); - if (definition == null) { - String msg = getString("no_definition_error"); - throw new IllegalArgumentException(msg); - } - - // Create a DhcptabRecord. - // - try { - DhcptabRecord dhcptabRecord = null; - if (macroName != null) { - OptionsTable optionsTable = OptionsTable.getTable(); - optionsTable.add( - getDhcptabMgr().getOptions(getDhcpDatastore())); - Macro macro = new Macro(macroName); - macro.setValue(definition, false, true); - dhcptabRecord = macro; - } else if (symbolName != null) { - Option option = - getDhcptabMgr().createOption(symbolName, definition); - dhcptabRecord = option; - } else { - printErrMessage(getString("internal_error")); - returnCode = DhtAdm.CRITICAL; - } - - // Add the entry. - // - if (returnCode == DhtAdm.SUCCESS) { - getDhcptabMgr().createRecord(dhcptabRecord, false, - getDhcpDatastore()); - } - } catch (ExistsException e) { - printErrMessage(getMessage(e)); - returnCode = DhtAdm.EXISTS; - } catch (Throwable e) { - printErrMessage(getMessage(e)); - returnCode = DhtAdm.WARNING; - } - - return (returnCode); - - } // execute - -} // AddEntry diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/CreateTable.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/CreateTable.java deleted file mode 100644 index 8f709c1889..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/CreateTable.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhtadm; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.bridge.TableExistsException; - -import java.lang.IllegalArgumentException; - -/** - * The main class for the "create table" functionality of dhtadm. - */ -public class CreateTable extends DhtAdmFunction { - - /** - * The valid options associated with creating the table. - */ - static final int supportedOptions[] = { - DhtAdm.RESOURCE, - DhtAdm.RESOURCE_CONFIG, - DhtAdm.PATH, - DhtAdm.SIGHUP - }; - - /** - * Constructs a CreateTable object. - */ - public CreateTable() { - - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (DhtAdm.CREATE_TABLE); - } - - /** - * Executes the "create table" functionality. - * @return DhtAdm.SUCCESS, DhtAdm.EXISTS, DhtAdm.WARNING, or - * DhtAdm.CRITICAL - */ - public int execute() - throws IllegalArgumentException { - - int returnCode = DhtAdm.SUCCESS; - - // Create the table. - // - try { - getDhcptabMgr().createDhcptab(getDhcpDatastore()); - } catch (TableExistsException e) { - printErrMessage(getMessage(e)); - returnCode = DhtAdm.EXISTS; - } catch (Throwable e) { - printErrMessage(getMessage(e)); - returnCode = DhtAdm.WARNING; - } - - return (returnCode); - - } // execute - -} // CreateTable diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DeleteEntry.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DeleteEntry.java deleted file mode 100644 index dc84b17416..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DeleteEntry.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhtadm; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.data.DhcptabRecord; -import com.sun.dhcpmgr.data.Macro; -import com.sun.dhcpmgr.data.Option; -import com.sun.dhcpmgr.bridge.NoEntryException; - -import java.lang.IllegalArgumentException; - -/** - * The main class for the "delete entry" functionality of dhtadm. - */ -public class DeleteEntry extends DhtAdmFunction { - - /** - * The valid options associated with deleting an entry. - */ - static final int supportedOptions[] = { - DhtAdm.MACRONAME, - DhtAdm.SYMBOLNAME, - DhtAdm.RESOURCE, - DhtAdm.RESOURCE_CONFIG, - DhtAdm.PATH, - DhtAdm.SIGHUP - }; - - /** - * Constructs a DeleteEntry object. - */ - public DeleteEntry() { - - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (DhtAdm.DELETE_ENTRY); - } - - /** - * Executes the "delete entry" functionality. - * @return DhtAdm.SUCCESS, DhtAdm.ENOENT, DhtAdm.WARNING, or - * DhtAdm.CRITICAL - */ - public int execute() - throws IllegalArgumentException { - - int returnCode = DhtAdm.SUCCESS; - - // Get macro or symbol name. One and only one should be set. - // - String macroName = options.valueOf(DhtAdm.MACRONAME); - String symbolName = options.valueOf(DhtAdm.SYMBOLNAME); - - if (macroName != null && symbolName != null) { - String msg = getString("two_keys_error"); - throw new IllegalArgumentException(msg); - } - - if (macroName == null && symbolName == null) { - String msg = getString("no_keys_error"); - throw new IllegalArgumentException(msg); - } - - try { - // Get the DhcptabRecord. - // - DhcptabRecord dhcptabRecord = null; - if (macroName != null) { - dhcptabRecord = new Macro(macroName); - } else if (symbolName != null) { - dhcptabRecord = new Option(); - dhcptabRecord.setKey(symbolName); - } else { - printErrMessage(getString("internal_error")); - returnCode = DhtAdm.CRITICAL; - } - - // Delete the entry. - // - if (returnCode == DhtAdm.SUCCESS) { - getDhcptabMgr().deleteRecord(dhcptabRecord, false, - getDhcpDatastore()); - } - - } catch (NoEntryException e) { - printErrMessage(getMessage(e)); - returnCode = DhtAdm.ENOENT; - } catch (Throwable e) { - printErrMessage(getMessage(e)); - returnCode = DhtAdm.WARNING; - } - - return (returnCode); - - } // execute - -} // DeleteEntry diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DhtAdm.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DhtAdm.java deleted file mode 100644 index 05f171fc0e..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DhtAdm.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhtadm; - -import com.sun.dhcpmgr.cli.common.*; -import com.sun.dhcpmgr.server.*; - -import java.lang.IllegalArgumentException; -import java.text.MessageFormat; - -/** - * This class represents the entry point to the DHCP CLI dhcptab - * administration. - */ -public class DhtAdm - extends DhcpCliProgram { - - /** - * The program signature. - */ - public static final String SIGNATURE = "dhtadm: "; - - /** - * The valid options for all DhtAdm administration. - */ - private static String optString = "ACDIMPRvgr:p:u:s:m:n:e:d:B;"; - - public static final int ADD_ENTRY = 'A'; - public static final int MODIFY_ENTRY = 'M'; - public static final int DELETE_ENTRY = 'D'; - public static final int CREATE_TABLE = 'C'; - public static final int REMOVE_TABLE = 'R'; - public static final int DISPLAY_TABLE = 'P'; - public static final int BATCH_EXECUTION = 'B'; - - public static final int MACRONAME = 'm'; - public static final int SYMBOLNAME = 's'; - public static final int NEWNAME = 'n'; - public static final int DEFINITION = 'd'; - public static final int EDITSYMBOL = 'e'; - public static final int RESOURCE = 'r'; - public static final int RESOURCE_CONFIG = 'u'; - public static final int PATH = 'p'; - public static final int VERBOSE = 'v'; - public static final int SIGHUP = 'g'; - - /** - * Constructs a dhtadm command. - * @param args the options to the command. - */ - public DhtAdm(String [] args) { - - reset(args); - // Set the options. - // - options = new DhcpCliOptions(); - this.args = args; - - } // constructor - - /** - * Resets a DhtAdm for reuse. Used by DhcpBatch program. - * @param args the options to the command. - */ - public void reset(String [] args) { - - clearFunction(); - options = new DhcpCliOptions(); - this.args = args; - - } - - /** - * Returns the manpage signature for the program. - * @return the manpage signature for the program. - */ - public String getManPage() { - return "dhtadm(1M)"; - } - - /** - * Displays program usage. - */ - public void usage() { - - DhcpCliPrint.printErrMessage(getString("usage")); - - } // usage - - /** - * Executes the program function. - * @return SUCCESS, EXISTS, ENOENT, WARNING, or CRITICAL - */ - public int execute() { - - int returnCode = SUCCESS; - - // Get the options and go exec the correct function. - // - GetOpt getopt = new GetOpt(args, optString); - try { - int option; - while ((option = getopt.getNextOption()) != -1) { - processArg(option, getopt.getOptionArg()); - } - - int lastIndex = getopt.getNextOptionIndex(); - if (args.length != lastIndex) { - Object [] arguments = new Object[1]; - arguments[0] = args[lastIndex]; - MessageFormat form = - new MessageFormat(getString("invalid_arg")); - throw new IllegalArgumentException(form.format(arguments)); - } - - if (function == null) { - String msg = getString("no_function_error"); - throw new IllegalArgumentException(msg); - } - - // Check the validity of the data store version. - // - if (!function.isVersionValid(false)) { - return (CRITICAL); - } - - // Create a DHCP datastore object with the user specified objects. - // - function.setDhcpDatastore(options.valueOf(RESOURCE), - options.valueOf(PATH), options.valueOf(RESOURCE_CONFIG)); - - function.setOptions(options); - function.setStandardOptions(); - returnCode = function.execute(); - - } catch (IllegalArgumentException e) { - StringBuffer msg = new StringBuffer(SIGNATURE); - msg.append(DhcpCliFunction.getMessage(e)); - DhcpCliPrint.printErrMessage(msg.toString()); - DhcpCliPrint.printErrMessage(""); - usage(); - returnCode = CRITICAL; - } catch (Throwable e) { - StringBuffer msg = new StringBuffer(SIGNATURE); - msg.append(DhcpCliFunction.getMessage(e)); - DhcpCliPrint.printErrMessage(msg.toString()); - returnCode = CRITICAL; - } - - // Signal server if requested by user and main operation successful - if (returnCode == SUCCESS && options.isSet(SIGHUP)) { - try { - DhcpMgr dhcpMgr = new DhcpMgrImpl(); - dhcpMgr.getDhcpServiceMgr().reload(); - } catch (Throwable e) { - returnCode = WARNING; - // Display warning - StringBuffer msg = new StringBuffer(SIGNATURE); - msg.append(getString("sighup_failed")); - DhcpCliPrint.printErrMessage(msg.toString()); - } - } - - return (returnCode); - - } // execute - - /** - * Processes one program argument. - * @param option the option flag - * @param value the option value(if any) - * @exception IllegalArgumentException if an invalid argument was entered - */ - public void processArg(int option, String value) - throws IllegalArgumentException { - - switch (option) { - - case ADD_ENTRY: - setFunction(new AddEntry()); - break; - case MODIFY_ENTRY: - setFunction(new ModifyEntry()); - break; - case DELETE_ENTRY: - setFunction(new DeleteEntry()); - break; - case CREATE_TABLE: - setFunction(new CreateTable()); - break; - case REMOVE_TABLE: - setFunction(new RemoveTable()); - break; - case DISPLAY_TABLE: - setFunction(new DisplayTable()); - break; - case BATCH_EXECUTION: - setFunction(new DhtAdmBatch(value)); - break; - default: - options.setOption(option, value); - } - - } // processArg - - /** - * Returns a localized string for this function - * @param key the resource bundle string identifier - * @return string from resource bundle. - */ - public String getString(String key) { - - return ResourceStrings.getString(key); - - } // getString - - /** - * The entry point for the program. - * @param args the program arguments - */ - public static void main(String[] args) { - - DhtAdm dhtadm = new DhtAdm(args); - int returnCode = DhtAdm.CRITICAL; - if (dhtadm.isValidUser()) { - returnCode = dhtadm.execute(); - } - System.exit(returnCode); - - } // main - -} // DhtAdm diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DhtAdmBatch.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DhtAdmBatch.java deleted file mode 100644 index c4a78106fe..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DhtAdmBatch.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhtadm; - -import com.sun.dhcpmgr.cli.dhcpbatch.*; - -import java.lang.IllegalArgumentException; - -/** - * The main class for the batch functionality of dhtadm. - */ -public class DhtAdmBatch extends DhtAdmFunction { - - /** - * The valid options associated with batching. - */ - static final int supportedOptions[] = { - DhtAdm.VERBOSE, - DhtAdm.SIGHUP - }; - - private String inputSource = null; - - /** - * Constructs a DhtAdmBatch object. - */ - public DhtAdmBatch(String inputSource) { - - this.inputSource = inputSource; - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (DhtAdm.BATCH_EXECUTION); - } - - /** - * Executes the batch functionality. - * @return one of the DhtAdm return codes. - */ - public int execute() - throws IllegalArgumentException { - - DhcpBatch batch = new DhcpBatch(inputSource); - batch.setVerbose(options.isSet(DhtAdm.VERBOSE)); - return (batch.execute()); - - } // execute - -} // DhtAdmBatch diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DhtAdmFunction.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DhtAdmFunction.java deleted file mode 100644 index 92c8ab42ea..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DhtAdmFunction.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.dhtadm; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.cli.common.DhcpCliPrint; - -/** - * Abstract class implemented by all the dhtadm "function" classes. - */ -public abstract class DhtAdmFunction - extends DhcpCliFunction { - - /** - * Returns a localized string for this function - * @param key the resource bundle string identifier - */ - public String getString(String key) { - - return ResourceStrings.getString(key); - - } // getString - - /** - * Prints an error message. - * @param msg the message to print. - */ - public void printErrMessage(String msg) { - StringBuffer fullmsg = new StringBuffer(DhtAdm.SIGNATURE); - fullmsg.append(msg); - DhcpCliPrint.printErrMessage(fullmsg.toString()); - } // printErrMessage - -} // DhtAdmFunction diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DisplayTable.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DisplayTable.java deleted file mode 100644 index 262832e2cc..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/DisplayTable.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhtadm; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.cli.common.Format; -import com.sun.dhcpmgr.data.Macro; -import com.sun.dhcpmgr.data.Option; -import com.sun.dhcpmgr.bridge.NoTableException; - -import java.lang.IllegalArgumentException; - -/** - * The main class for the "display table" functionality of dhtadm. - */ -public class DisplayTable extends DhtAdmFunction { - - /** - * The valid options associated with displaying the table. - */ - static final int supportedOptions[] = { - DhtAdm.RESOURCE, - DhtAdm.RESOURCE_CONFIG, - DhtAdm.PATH, - DhtAdm.SIGHUP - }; - - /** - * Constructs a DisplayTable object. - */ - public DisplayTable() { - - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (DhtAdm.DISPLAY_TABLE); - } - - /** - * Executes the "display table" functionality. - * @return DhtAdm.SUCCESS, DhtAdm.ENOENT, DhtAdm.WARNING, or - * DhtAdm.CRITICAL - */ - public int execute() - throws IllegalArgumentException { - - int returnCode = DhtAdm.SUCCESS; - - // Retrieve the table contents. Table consists of macros - // and options ... go get them. - // - Macro [] macros = null; - Option [] options = null; - try { - macros = getDhcptabMgr().getMacros(getDhcpDatastore()); - options = getDhcptabMgr().getOptions(getDhcpDatastore()); - } catch (NoTableException e) { - printErrMessage(getMessage(e)); - returnCode = DhtAdm.ENOENT; - } catch (Throwable e) { - printErrMessage(getMessage(e)); - returnCode = DhtAdm.WARNING; - } - - if (returnCode == DhtAdm.SUCCESS) { - Format.print(System.out, "%-20s\t", getString("Name")); - Format.print(System.out, "%-8s\t", getString("Type")); - Format.print(System.out, "%s\n", getString("Value")); - Format.print(System.out, "%s\n", - "=================================================="); - - for (int i = 0; macros != null && i < macros.length; i++) { - Macro macro = macros[i]; - Format.print(System.out, "%-20s\t", macro.getKey()); - Format.print(System.out, "%-8s\t", getString("Macro")); - Format.print(System.out, "%s\n", macro.getValue()); - } - - for (int i = 0; options != null && i < options.length; i++) { - Option option = options[i]; - Format.print(System.out, "%-20s\t", option.getKey()); - Format.print(System.out, "%-8s\t", getString("Symbol")); - Format.print(System.out, "%s\n", option.getValue()); - } - } - - return (returnCode); - - } // execute - -} // DisplayTable diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/Makefile deleted file mode 100644 index 2e76fe1f98..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/Makefile -# - -# Place high-level classes first to minimize build time. -CLASSFILES = DhtAdm.class \ - AddEntry.class \ - CreateTable.class \ - DeleteEntry.class \ - DhtAdmBatch.class \ - DisplayTable.class \ - ModifyEntry.class \ - RemoveTable.class \ - DhtAdmFunction.class \ - ResourceStrings.class - -include $(SRC)/Makefile.master - -CLASSPATH= $(SRC)/cmd/cmd-inet/usr.sadm/dhcpmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -MSGDIR= $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/cli/dhtadm -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/cli \ - $(MSGDIR) - -MSGFILES= ResourceBundle.properties -MSGS= $(MSGFILES:%=$(MSGDIR)/%) - -CLEANFILES= *.class -CLOBBERFILES= - -.KEEP_STATE: - -all: $(CLASSFILES) - -install: all - -_msg: $(MSGDIRS) $(MSGS) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - -lint: - -clean: - $(RM) $(CLEANFILES) - -clobber: clean diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/ModifyEntry.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/ModifyEntry.java deleted file mode 100644 index d46385ff73..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/ModifyEntry.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhtadm; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.data.DhcptabRecord; -import com.sun.dhcpmgr.data.Macro; -import com.sun.dhcpmgr.data.Option; -import com.sun.dhcpmgr.bridge.NoEntryException; - -import java.lang.IllegalArgumentException; - -/** - * The main class for the "modify entry" functionality of dhtadm. - */ -public class ModifyEntry extends DhtAdmFunction { - - /** - * The valid options associated with modifying an entry. - */ - static final int supportedOptions[] = { - DhtAdm.MACRONAME, - DhtAdm.SYMBOLNAME, - DhtAdm.NEWNAME, - DhtAdm.DEFINITION, - DhtAdm.EDITSYMBOL, - DhtAdm.RESOURCE, - DhtAdm.RESOURCE_CONFIG, - DhtAdm.PATH, - DhtAdm.SIGHUP - }; - - /** - * Constructs a ModifyEntry object. - */ - public ModifyEntry() { - - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (DhtAdm.MODIFY_ENTRY); - } - - /** - * Executes the "modify entry" functionality. - * @return DhtAdm.SUCCESS, DhtAdm.ENOENT, DhtAdm.WARNING, or - * DhtAdm.CRITICAL - */ - public int execute() - throws IllegalArgumentException { - - int returnCode = DhtAdm.SUCCESS; - - // Get macro or symbol name. One and only one should be set. - // - String macroName = options.valueOf(DhtAdm.MACRONAME); - String symbolName = options.valueOf(DhtAdm.SYMBOLNAME); - - if (macroName != null && symbolName != null) { - String msg = getString("two_keys_error"); - throw new IllegalArgumentException(msg); - } - - if (macroName == null && symbolName == null) { - String msg = getString("no_keys_error"); - throw new IllegalArgumentException(msg); - } - - // Get the modify "sub-functions" - // One and only one of the options should be set. - // - int count = 0; - String newName = options.valueOf(DhtAdm.NEWNAME); - if (newName != null) { - count++; - } - - String definition = options.valueOf(DhtAdm.DEFINITION); - if (definition != null) { - count++; - } - - String editSymbol = options.valueOf(DhtAdm.EDITSYMBOL); - if (editSymbol != null) { - if (symbolName != null) { - printErrMessage(getString("symbol_edit_error")); - return (DhtAdm.CRITICAL); - } - count++; - } - - if (count != 1) { - printErrMessage(getString("modify_no_function_error")); - return (DhtAdm.CRITICAL); - } - - // Get macro or symbol name. One and only one should be set. - // Then go get the instance of the macro or symbol. - // - try { - DhcptabRecord oldDhcptabRecord = null; - if (macroName != null) { - oldDhcptabRecord = - getDhcptabMgr().getMacro(macroName, getDhcpDatastore()); - } else if (symbolName != null) { - oldDhcptabRecord = - getDhcptabMgr().getOption(symbolName, - getDhcpDatastore()); - } else { - printErrMessage(getString("internal_error")); - return (DhtAdm.CRITICAL); - } - - // Identify the function and create the newDhcptabRecord - // given the function. - // - DhcptabRecord newDhcptabRecord = null; - - if (definition != null) { - if (macroName != null) { - Macro newMacro = new Macro(macroName); - newMacro.setValue(definition, false, true); - newDhcptabRecord = newMacro; - } else if (symbolName != null) { - newDhcptabRecord = - getDhcptabMgr().createOption(symbolName, definition); - } else { - printErrMessage(getString("internal_error")); - return (DhtAdm.CRITICAL); - } - - - } else if (newName != null) { - definition = oldDhcptabRecord.getValue().toString(); - if (macroName != null) { - Macro newMacro = new Macro(newName); - newMacro.setValue(definition, false, true); - newDhcptabRecord = newMacro; - } else if (symbolName != null) { - newDhcptabRecord = - getDhcptabMgr().createOption(newName, definition); - } else { - printErrMessage(getString("internal_error")); - return (DhtAdm.CRITICAL); - } - - } else if (editSymbol != null) { - - Macro oldMacro = (Macro)oldDhcptabRecord; - Macro newMacro = (Macro)oldMacro.clone(); - newMacro.editOption(editSymbol); - newDhcptabRecord = newMacro; - - } else { - printErrMessage(getString("internal_error")); - return (DhtAdm.CRITICAL); - } - - getDhcptabMgr().modifyRecord(oldDhcptabRecord, newDhcptabRecord, - false, getDhcpDatastore()); - } catch (NoEntryException e) { - printErrMessage(getMessage(e)); - returnCode = DhtAdm.ENOENT; - } catch (Throwable e) { - printErrMessage(getMessage(e)); - returnCode = DhtAdm.WARNING; - } - - return (returnCode); - - } // execute - -} // ModifyEntry diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/RemoveTable.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/RemoveTable.java deleted file mode 100644 index 91cdf21013..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/RemoveTable.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.dhtadm; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.bridge.NoTableException; - -import java.lang.IllegalArgumentException; - -/** - * The main class for the "remove table" functionality of dhtadm. - */ -public class RemoveTable extends DhtAdmFunction { - - /** - * The valid options associated with removing the table. - */ - static final int supportedOptions[] = { - DhtAdm.RESOURCE, - DhtAdm.RESOURCE_CONFIG, - DhtAdm.PATH, - DhtAdm.SIGHUP - }; - - /** - * Constructs a RemoveTable object. - */ - public RemoveTable() { - - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (DhtAdm.REMOVE_TABLE); - } - - /** - * Executes the "remove table" functionality. - * @return DhtAdm.SUCCESS, DhtAdm.ENOENT, DhtAdm.WARNING, or - * DhtAdm.CRITICAL - */ - public int execute() - throws IllegalArgumentException { - - int returnCode = DhtAdm.SUCCESS; - - // Remove the table. - // - try { - getDhcptabMgr().deleteDhcptab(getDhcpDatastore()); - } catch (NoTableException e) { - printErrMessage(getMessage(e)); - returnCode = DhtAdm.ENOENT; - } catch (Throwable e) { - printErrMessage(getMessage(e)); - returnCode = DhtAdm.WARNING; - } - - return (returnCode); - - } // execute - -} // RemoveTable diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/ResourceBundle.properties b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/ResourceBundle.properties deleted file mode 100644 index 77daefee59..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/ResourceBundle.properties +++ /dev/null @@ -1,89 +0,0 @@ -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Headers for display -# -Name=Name -Type=Type -Value=Value - -# -# Dhcptab flags -# -Macro=Macro -Symbol=Symbol - -# -# Internal error -# -internal_error=Program internal error - -# -# Specifying both macro name and symbol name error -# -two_keys_error=Cannot specify both macro name and symbol name - -# -# Specifying neither macro name and symbol name error -# -no_keys_error=Must specify either macro name or symbol name - -# -# Specifying no definition error -# -no_definition_error=Must specify macro or symbol definition - -# -# Cannot edit symbol error -# -symbol_edit_error=Cannot edit symbols - -# -# Cannot edit symbol error -# -modify_no_function_error=Only one of '-d', '-e', '-n' can be defined - -# -# No function defined error -# -no_function_error=Must specify one of 'C', 'A', 'M', 'D', 'R', 'P', or 'B' - -# -# An invalid argument was input to the program. -# -invalid_arg=Invalid argument - {0} - -# -# Couldn't signal daemon -# -sighup_failed=Unable to signal the daemon to reload the dhcptab - -# -# Usage -# -usage=dhtadm [-r (resource)] [-p (path)] [-u (uninterpreted data)] [-g] (options)\n\nWhere (options) is one of:\n\n-C Create the dhcptab\n\n-A Add symbol or macro. Sub-options:\n { -s (symbol name) | -m (macro name) } -d (definition)\n\n-M Modify symbol or macro. Sub-options:\n -s (old symbol name) {-n (new name) | -d (definition)}\n Or\n -m (old macro name) {-n (new name) | -d (definition) | -e (symbol = value)}\n\n-D Delete symbol or macro definition. Sub-options:\n -s ( symbol name ) | -m ( macro name )\n\n-R Remove the dhcptab\n\n-P Display the dhcptab\n\n-B [batchfile] Run command in batch input mode. Sub-options:\n [-v] Output commands as they are processed.\n diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/ResourceStrings.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/ResourceStrings.java deleted file mode 100644 index e1c7eb3b2b..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/dhtadm/ResourceStrings.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.dhtadm; - -import java.util.*; - -/** - * This class provides a convenient method to retrieve resources for - * the dhtadm package. - */ -public class ResourceStrings { - - /** - * The handle to the resource bundle for the module. - */ - private static ResourceBundle bundle = null; - - /** - * Return a string from the resource bundle. - * @param key the key to the resource bundle string. - * @return the resource bundle string. - */ - public static String getString(String key) { - String msg = null; - try { - if (bundle == null) { - bundle = ResourceBundle.getBundle( - "com.sun.dhcpmgr.cli.dhtadm.ResourceBundle", - Locale.getDefault()); - } - msg = bundle.getString(key); - } catch (Throwable e) { - msg = new String(key); - } - return msg; - - } // getString - -} // ResourceStrings diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/AddClientEntry.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/AddClientEntry.java deleted file mode 100644 index d34356f535..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/AddClientEntry.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.pntadm; - -import com.sun.dhcpmgr.cli.common.Util; -import com.sun.dhcpmgr.data.DhcpClientRecord; -import com.sun.dhcpmgr.data.Macro; -import com.sun.dhcpmgr.data.Network; -import com.sun.dhcpmgr.bridge.BridgeException; -import com.sun.dhcpmgr.bridge.ExistsException; - -import java.lang.IllegalArgumentException; - -/** - * The main class for the "add client" functionality of pntadm. - */ -public class AddClientEntry extends PntAdmFunction { - - /** - * The valid options associated with adding a client entry. - */ - static final int supportedOptions[] = { - PntAdm.COMMENT, - PntAdm.LEASE_EXPIRATION, - PntAdm.FLAGS, - PntAdm.CLIENTID, - PntAdm.CONVERT_CLIENTID, - PntAdm.MACRO_NAME, - PntAdm.VERIFY_MACRO, - PntAdm.SERVER, - PntAdm.RESOURCE, - PntAdm.RESOURCE_CONFIG, - PntAdm.PATH - }; - - /** - * The client entry to add. - */ - String clientIP; - - /** - * Constructs a AddClientEntry object for the client, clientIP. - * @param clientIP the client name or IP address. - */ - public AddClientEntry(String clientIP) { - - this.clientIP = clientIP; - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (PntAdm.ADD_CLIENT_ENTRY); - } - - /** - * Executes the "add client" functionality. - * @return PntAdm.SUCCESS, PntAdm.EXISTS, PntAdm.WARNING, or - * PntAdm.CRITICAL - */ - public int execute() - throws IllegalArgumentException { - - int returnCode = PntAdm.SUCCESS; - - // Build up a DhcpClientRecord from the user specified options. - // - try { - DhcpClientRecord dhcpClientRecord = new DhcpClientRecord(clientIP); - - String clientId = options.valueOf(PntAdm.CLIENTID); - boolean convertClientId = options.isSet(PntAdm.CONVERT_CLIENTID); - if (convertClientId) { - if (clientId == null) { - String msg = getString("no_clientid_specified"); - throw new IllegalArgumentException(msg); - } - clientId = Util.asciiToHex(clientId); - } - if (clientId != null) { - dhcpClientRecord.setClientId(clientId); - } - - String flags = options.valueOf(PntAdm.FLAGS); - if (flags != null) { - dhcpClientRecord.setFlags(flags); - } - - String serverIP = options.valueOf(PntAdm.SERVER); - if (serverIP == null) { - serverIP = getSvcMgr().getServerName(); - } - dhcpClientRecord.setServerIP(serverIP); - - String expiration = options.valueOf(PntAdm.LEASE_EXPIRATION); - if (expiration != null) { - dhcpClientRecord.setExpiration(shortFormat, expiration); - } - - boolean verifyMacro = options.isSet(PntAdm.VERIFY_MACRO); - String macro = options.valueOf(PntAdm.MACRO_NAME); - if (verifyMacro) { - if (macro == null) { - String msg = getString("no_macro_specified"); - throw new IllegalArgumentException(msg); - } - - // Create a Macro entry so that we can check to see if it - // exists in the dhcptab. - // - try { - Macro existingMacro = getDhcptabMgr().getMacro(macro); - } - catch (BridgeException e) { - printErrMessage(getString("macro_not_found")); - return (PntAdm.WARNING); - } - } - if (macro != null) { - dhcpClientRecord.setMacro(macro); - } - - String comment = options.valueOf(PntAdm.COMMENT); - if (comment != null) { - dhcpClientRecord.setComment(comment); - } - - // Create a Network object. - // - Network network = getNetMgr().getNetwork(networkName); - if (network == null) { - printErrMessage(getString("network_name_error")); - return (PntAdm.WARNING); - } - - // Add the client. The host will be added to the hosts table - // if necessary. - // - getNetMgr().addClient(dhcpClientRecord, network.toString(), - getDhcpDatastore()); - } catch (IllegalArgumentException e) { - throw e; - } catch (ExistsException e) { - printErrMessage(getMessage(e)); - returnCode = PntAdm.EXISTS; - } catch (Throwable e) { - printErrMessage(getMessage(e)); - returnCode = PntAdm.WARNING; - } - - return (returnCode); - - } // execute - -} // AddClientEntry diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/CreateNetworkTable.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/CreateNetworkTable.java deleted file mode 100644 index 0b34f7783c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/CreateNetworkTable.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.pntadm; - -import com.sun.dhcpmgr.data.Network; -import com.sun.dhcpmgr.bridge.TableExistsException; - -import java.lang.IllegalArgumentException; - -/** - * The main class for the "create network table" functionality - * of pntadm. - */ -public class CreateNetworkTable extends PntAdmFunction { - - /** - * The valid options associated with creating a network table. - */ - static final int supportedOptions[] = { - PntAdm.RESOURCE, - PntAdm.RESOURCE_CONFIG, - PntAdm.PATH - }; - - /** - * Constructs a CreateNetworkTable object. - */ - public CreateNetworkTable() { - - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (PntAdm.CREATE_NETWORK_TABLE); - } - - /** - * Executes the "create network table" functionality. - * @return PntAdm.SUCCESS, PntAdm.EXISTS, PntAdm.WARNING, or - * PntAdm.CRITICAL - */ - public int execute() - throws IllegalArgumentException { - - int returnCode = PntAdm.SUCCESS; - - // Create a Network object. - // - try { - Network network = getNetMgr().getNetwork(networkName); - if (network == null) { - printErrMessage(getString("network_name_error")); - return (PntAdm.WARNING); - } - - getNetMgr().createNetwork(network.toString(), getDhcpDatastore()); - } catch (TableExistsException e) { - printErrMessage(getMessage(e)); - returnCode = PntAdm.EXISTS; - } catch (Throwable e) { - printErrMessage(getMessage(e)); - returnCode = PntAdm.WARNING; - } - - return (returnCode); - - } // execute - -} // CreateNetworkTable diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/DeleteClientEntry.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/DeleteClientEntry.java deleted file mode 100644 index fc6bf65f90..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/DeleteClientEntry.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.pntadm; - -import com.sun.dhcpmgr.data.DhcpClientRecord; -import com.sun.dhcpmgr.data.Network; -import com.sun.dhcpmgr.bridge.BridgeException; -import com.sun.dhcpmgr.bridge.NoEntryException; - -import java.lang.IllegalArgumentException; - -/** - * The main class for the "delete client" functionality of pntadm. - */ -public class DeleteClientEntry extends PntAdmFunction { - - /** - * The valid options associated with deleting a client entry. - */ - static final int supportedOptions[] = { - PntAdm.RESOURCE, - PntAdm.RESOURCE_CONFIG, - PntAdm.PATH - }; - - /** - * The client entry to delete. - */ - String clientIP; - - /** - * Constructs a DeleteClientEntry object for the client, clientIP. - * @param clientIP the client name or IP address. - */ - public DeleteClientEntry(String clientIP) { - - this.clientIP = clientIP; - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (PntAdm.DELETE_CLIENT_ENTRY); - } - - /** - * Executes the "delete client" functionality. - * @return PntAdm.SUCCESS, PntAdm.ENOENT, PntAdm.WARNING, or - * PntAdm.CRITICAL - */ - public int execute() - throws IllegalArgumentException { - - int returnCode = PntAdm.SUCCESS; - - // Build up a DhcpClientRecord from the user specified options. - // - try { - DhcpClientRecord dhcpClientRecord = new DhcpClientRecord(clientIP); - - // Create a Network object. - // - Network network = getNetMgr().getNetwork(networkName); - if (networkName == null) { - printErrMessage(getString("network_name_error")); - return (PntAdm.WARNING); - } - - // Delete the client and remove host from the hosts table - // if requested. - // - getNetMgr().deleteClient(dhcpClientRecord, network.toString(), - getDhcpDatastore()); - - } catch (NoEntryException e) { - printErrMessage(getMessage(e)); - returnCode = PntAdm.ENOENT; - } catch (Throwable e) { - printErrMessage(getMessage(e)); - returnCode = PntAdm.WARNING; - } - - return (returnCode); - - } // execute - -} // DeleteClientEntry diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/DisplayNetworkTable.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/DisplayNetworkTable.java deleted file mode 100644 index 6db4d65ba5..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/DisplayNetworkTable.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.pntadm; - -import com.sun.dhcpmgr.cli.common.Format; -import com.sun.dhcpmgr.data.DhcpClientRecord; -import com.sun.dhcpmgr.data.Network; -import com.sun.dhcpmgr.bridge.NoEntryException; -import com.sun.dhcpmgr.bridge.NoTableException; - -import java.util.Date; -import java.lang.IllegalArgumentException; - -/** - * The main class for the "display network table" functionality - * of pntadm. - */ -public class DisplayNetworkTable extends PntAdmFunction { - - /** - * The valid options associated with displaying a network table. - */ - static final int supportedOptions[] = { - PntAdm.VERBOSE, - PntAdm.RAW, - PntAdm.RESOURCE, - PntAdm.RESOURCE_CONFIG, - PntAdm.PATH - }; - - /** - * Constructs a DisplayNetworkTable object. - */ - public DisplayNetworkTable() { - - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (PntAdm.DISPLAY_NETWORK_TABLE); - } - - /** - * Executes the "display network table" functionality. - * @return PntAdm.SUCCESS, PntAdm.ENOENT, PntAdm.WARNING, or - * PntAdm.CRITICAL - */ - public int execute() - throws IllegalArgumentException { - - int returnCode = PntAdm.SUCCESS; - - // Is this a verbose display? - // - boolean verbose = false; - if (options.isSet(PntAdm.VERBOSE)) { - verbose = true; - } - - // Is this a raw display? - // - boolean raw = false; - if (options.isSet(PntAdm.RAW)) { - raw = true; - } - - if (verbose && raw) { - String msg = getString("display_mode_error"); - throw new IllegalArgumentException(msg); - } - - // Display the network table. - DhcpClientRecord [] dhcpClientRecords = null; - try { - - Network network = getNetMgr().getNetwork(networkName); - if (network == null) { - printErrMessage(getString("network_name_error")); - return (PntAdm.WARNING); - } - - dhcpClientRecords = - getNetMgr().loadNetwork(network.toString(), - getDhcpDatastore()); - } catch (NoTableException e) { - printErrMessage(getMessage(e)); - return (PntAdm.ENOENT); - } catch (Throwable e) { - printErrMessage(getMessage(e)); - return (PntAdm.WARNING); - } - - Format.print(System.out, "%-8s\t", getString("Client_ID")); - Format.print(System.out, "%-4s\t", getString("Flags")); - Format.print(System.out, "%-8s\t", getString("Client_IP")); - Format.print(System.out, "%-8s\t", getString("Server_IP")); - Format.print(System.out, "%-25s\t", getString("Lease_Expiration")); - Format.print(System.out, "%-8s\t", getString("Macro")); - Format.print(System.out, "%s\n\n", getString("Comment")); - - DhcpClientRecord dhcpClientRecord; - for (int i = 0; - dhcpClientRecords != null && i < dhcpClientRecords.length; - i++) { - - dhcpClientRecord = dhcpClientRecords[i]; - Format.print(System.out, "%-8s\t", dhcpClientRecord.getClientId()); - Format.print(System.out, "%-4s\t", - dhcpClientRecord.getFlagString(verbose)); - - String client; - if (verbose) { - client = dhcpClientRecord.getClientIP().getHostName(); - } else { - client = dhcpClientRecord.getClientIP().toString(); - } - Format.print(System.out, "%-8s\t", client); - - String server; - if (verbose) { - server = dhcpClientRecord.getServerIP().getHostName(); - } else { - server = dhcpClientRecord.getServerIP().toString(); - } - Format.print(System.out, "%-8s\t", server); - - String lease; - Date expiration = dhcpClientRecord.getExpiration(); - if (raw) { - // Print date in seconds since the epoch - lease = Long.toString(expiration.getTime()/1000); - } else if (expiration == null || expiration.getTime() == 0) { - lease = getString("Zero"); - } else if (expiration.getTime() < 0) { - lease = getString("Forever"); - } else if (verbose) { - // Print date and time for lease in locale format - lease = verboseFormat.format(expiration); - } else { - // Print just the lease date in short format for locale - lease = shortFormat.format(expiration); - } - Format.print(System.out, "%-25s\t", lease); - - Format.print(System.out, "%-8s\t", dhcpClientRecord.getMacro()); - Format.print(System.out, "%s\n", dhcpClientRecord.getComment()); - } - - return (returnCode); - - } // execute - -} // DisplayNetworkTable diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/ListNetworkTables.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/ListNetworkTables.java deleted file mode 100644 index 1fa24ff217..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/ListNetworkTables.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.pntadm; - -import com.sun.dhcpmgr.data.Network; -import com.sun.dhcpmgr.bridge.NoEntryException; -import com.sun.dhcpmgr.bridge.NoDefaultsException; - -import java.lang.IllegalArgumentException; - -/** - * The main class for the "list network tables" functionality - * of pntadm. - */ -public class ListNetworkTables extends PntAdmFunction { - - /** - * The valid options associated with listing network tables. - */ - static final int supportedOptions[] = { - PntAdm.RESOURCE, - PntAdm.RESOURCE_CONFIG, - PntAdm.PATH - }; - - /** - * Constructs a ListNetworkTables object. - */ - public ListNetworkTables() { - - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (PntAdm.LIST_NETWORK_TABLES); - } - - /** - * Executes the "list network tables" functionality. - * @return PntAdm.SUCCESS, PntAdm.ENOENT, PntAdm.WARNING, or - * PntAdm.CRITICAL - */ - public int execute() - throws IllegalArgumentException { - - int returnCode = PntAdm.SUCCESS; - - // Get the list of networks. - // - Network [] networks = null; - try { - networks = getNetMgr().getNetworks(getDhcpDatastore()); - } catch (NoEntryException e) { - // No network tables - } catch (Throwable e) { - printErrMessage(getMessage(e)); - return (PntAdm.WARNING); - } - - if (networks != null) { - for (int i = 0; i < networks.length; i++) { - System.out.println(networks[i].toString()); - } - } - - return (returnCode); - - } // execute - -} // ListNetworkTables diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/Makefile deleted file mode 100644 index 47c30961aa..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/Makefile -# - -CLASSFILES = PntAdm.class \ - AddClientEntry.class \ - CreateNetworkTable.class \ - DeleteClientEntry.class \ - DisplayNetworkTable.class \ - ListNetworkTables.class \ - ModifyClientEntry.class \ - PntAdmBatch.class \ - RemoveNetworkTable.class \ - PntAdmFunction.class \ - ResourceStrings.class - -include $(SRC)/Makefile.master - -CLASSPATH= $(SRC)/cmd/cmd-inet/usr.sadm/dhcpmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -MSGDIR= $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/cli/pntadm -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/cli \ - $(MSGDIR) - -MSGFILES= ResourceBundle.properties -MSGS= $(MSGFILES:%=$(MSGDIR)/%) - -CLEANFILES= *.class -CLOBBERFILES= - -.KEEP_STATE: - -all: $(CLASSFILES) - -install: all - -_msg: $(MSGDIRS) $(MSGS) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - -lint: - -clean: - $(RM) $(CLEANFILES) - -clobber: clean diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/ModifyClientEntry.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/ModifyClientEntry.java deleted file mode 100644 index 9985026e50..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/ModifyClientEntry.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.pntadm; - -import com.sun.dhcpmgr.cli.common.Util; -import com.sun.dhcpmgr.data.DhcpClientRecord; -import com.sun.dhcpmgr.data.Macro; -import com.sun.dhcpmgr.data.Network; -import com.sun.dhcpmgr.bridge.BridgeException; -import com.sun.dhcpmgr.bridge.NoEntryException; - -import java.lang.IllegalArgumentException; - -/** - * The main class for the "modify client" functionality of pntadm. - */ -public class ModifyClientEntry extends PntAdmFunction { - - /** - * The valid options associated with modifying a client entry. - */ - static final int supportedOptions[] = { - PntAdm.NEW_IP, - PntAdm.COMMENT, - PntAdm.LEASE_EXPIRATION, - PntAdm.FLAGS, - PntAdm.CLIENTID, - PntAdm.CONVERT_CLIENTID, - PntAdm.MACRO_NAME, - PntAdm.VERIFY_MACRO, - PntAdm.SERVER, - PntAdm.RESOURCE, - PntAdm.RESOURCE_CONFIG, - PntAdm.PATH - }; - - /** - * The client entry to modify. - */ - String clientIP; - - /** - * Constructs a ModifyClientEntry object for the client, clientIP. - * @param clientIP the client name or IP address. - */ - public ModifyClientEntry(String clientIP) { - - this.clientIP = clientIP; - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (PntAdm.MODIFY_CLIENT_ENTRY); - } - - /** - * Executes the "modify client" functionality. - * @return PntAdm.SUCCESS, PntAdm.ENOENT, PntAdm.WARNING, or - * PntAdm.CRITICAL - */ - public int execute() - throws IllegalArgumentException { - - int returnCode = PntAdm.SUCCESS; - - // Build up a DhcpClientRecord so that we can retrieve the current - // client record from the network table. - // - try { - DhcpClientRecord oldDhcpClientRecord = new DhcpClientRecord(); - oldDhcpClientRecord.setClientIP(clientIP); - - // Create a Network object. - // - Network network = getNetMgr().getNetwork(networkName); - if (network == null) { - printErrMessage(getString("network_name_error")); - return (PntAdm.WARNING); - } - - // Go and get the current client record from the network table. - // - oldDhcpClientRecord = - getNetMgr().getClient(oldDhcpClientRecord, network.toString(), - getDhcpDatastore()); - - // Build up the new DhcpClientRecord from the original and the - // user specified options. - // - DhcpClientRecord newDhcpClientRecord = - (DhcpClientRecord)oldDhcpClientRecord.clone(); - - String newClientIP = options.valueOf(PntAdm.NEW_IP); - if (newClientIP != null) { - newDhcpClientRecord.setClientIP(newClientIP); - } else { - newDhcpClientRecord.setClientIP(clientIP); - } - - String clientId = options.valueOf(PntAdm.CLIENTID); - boolean convertClientId = options.isSet(PntAdm.CONVERT_CLIENTID); - if (convertClientId) { - if (clientId == null) { - String msg = getString("no_clientid_specified"); - throw new IllegalArgumentException(msg); - } - clientId = Util.asciiToHex(clientId); - } - if (clientId != null) { - newDhcpClientRecord.setClientId(clientId); - } - - String flags = options.valueOf(PntAdm.FLAGS); - if (flags != null) { - newDhcpClientRecord.setFlags(flags); - } - - String serverIP = options.valueOf(PntAdm.SERVER); - if (serverIP == null) { - serverIP = getSvcMgr().getServerName(); - } - newDhcpClientRecord.setServerIP(serverIP); - - String expiration = options.valueOf(PntAdm.LEASE_EXPIRATION); - if (expiration != null) { - newDhcpClientRecord.setExpiration(shortFormat, expiration); - } - - boolean verifyMacro = options.isSet(PntAdm.VERIFY_MACRO); - String macro = options.valueOf(PntAdm.MACRO_NAME); - if (verifyMacro) { - if (macro == null) { - String msg = getString("no_macro_specified"); - throw new IllegalArgumentException(msg); - } - - // Create a Macro entry so that we can check to see if it - // exists in the dhcptab. - // - try { - Macro existingMacro = - getDhcptabMgr().getMacro(macro); - } - catch (BridgeException e) { - printErrMessage(getString("macro_not_found")); - return (PntAdm.WARNING); - } - } - if (macro != null) { - newDhcpClientRecord.setMacro(macro); - } - - String comment = options.valueOf(PntAdm.COMMENT); - if (comment != null) { - newDhcpClientRecord.setComment(comment); - } - - // Modify the client and adds host if necessary. - // - getNetMgr().modifyClient(oldDhcpClientRecord, newDhcpClientRecord, - network.toString(), getDhcpDatastore()); - - } catch (NoEntryException e) { - printErrMessage(getMessage(e)); - returnCode = PntAdm.ENOENT; - } catch (Throwable e) { - printErrMessage(getMessage(e)); - returnCode = PntAdm.WARNING; - } - - return (returnCode); - - } // execute - -} // ModifyClientEntry diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/PntAdm.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/PntAdm.java deleted file mode 100644 index ccb8c47805..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/PntAdm.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.pntadm; - -import com.sun.dhcpmgr.cli.common.*; - -import java.lang.IllegalArgumentException; - -/** - * This class represents the entry point to the DHCP CLI network tables - * administration. - */ -public class PntAdm - extends DhcpCliProgram { - - /** - * The program signature. - */ - public static final String SIGNATURE = "pntadm: "; - - /** - * The valid options for all PntAdm administration. - */ - private static String optString = "LPCRyavxA:D:M:r:p:u:s:i:f:e:m:c:n:B;"; - - public static final int ADD_CLIENT_ENTRY = 'A'; - public static final int MODIFY_CLIENT_ENTRY = 'M'; - public static final int DELETE_CLIENT_ENTRY = 'D'; - public static final int CREATE_NETWORK_TABLE = 'C'; - public static final int REMOVE_NETWORK_TABLE = 'R'; - public static final int DISPLAY_NETWORK_TABLE = 'P'; - public static final int LIST_NETWORK_TABLES = 'L'; - public static final int BATCH_EXECUTION = 'B'; - - public static final int VERIFY_MACRO = 'y'; - public static final int CONVERT_CLIENTID = 'a'; - public static final int RAW = 'x'; - public static final int VERBOSE = 'v'; - public static final int RESOURCE = 'r'; - public static final int RESOURCE_CONFIG = 'u'; - public static final int PATH = 'p'; - public static final int SERVER = 's'; - public static final int CLIENTID = 'i'; - public static final int FLAGS = 'f'; - public static final int LEASE_EXPIRATION = 'e'; - public static final int MACRO_NAME = 'm'; - public static final int COMMENT = 'c'; - public static final int NEW_IP = 'n'; - - /** - * Constructs a pntadm command. - * @param args the options to the command. - */ - public PntAdm(String [] args) { - reset(args); - } // constructor - - /** - * Resets a PntAdm for reuse. Used by DhcpBatch program. - * @param args the options to the command. - */ - public void reset(String [] args) { - - clearFunction(); - options = new DhcpCliOptions(); - this.args = args; - - } - - /** - * Returns the manpage signature for the program. - * @return the manpage signature for the program. - */ - public String getManPage() { - return "pntadm(1M)"; - } - - /** - * Displays program usage. - */ - public void usage() { - - DhcpCliPrint.printErrMessage(getString("usage")); - - } // usage - - /** - * Executes the program function. - * @return SUCCESS, EXISTS, ENOENT, WARNING, or CRITICAL - */ - public int execute() { - - int returnCode = SUCCESS; - - // Get the options and go exec the correct function. - // - GetOpt getopt = new GetOpt(args, optString); - try { - int option; - while ((option = getopt.getNextOption()) != -1) { - processArg(option, getopt.getOptionArg()); - } - - int networkIndex = getopt.getNextOptionIndex(); - String network = null; - - if (args.length == (networkIndex + 1)) { - network = args[networkIndex]; - } else if (args.length >= networkIndex + 1) { - throw new IllegalArgumentException( - ResourceStrings.getString("invalid_args")); - } - - if (function == null) { - String msg = getString("no_function_error"); - throw new IllegalArgumentException(msg); - } - - // Check the validity of the data store version. - // - if (!function.isVersionValid(false)) { - return (CRITICAL); - } - - // Not all functions accept network arguments. - // - if (function instanceof ListNetworkTables || - function instanceof PntAdmBatch) { - if (network != null) { - String msg = getString("network_specified"); - throw new IllegalArgumentException(msg); - } - } else { - if (network == null) { - String msg = getString("no_network_specified"); - throw new IllegalArgumentException(msg); - } - } - - // Create a DHCP datastore object with the user specified objects. - // - function.setDhcpDatastore(options.valueOf(RESOURCE), - options.valueOf(PATH), options.valueOf(RESOURCE_CONFIG)); - - function.setOptions(options); - ((PntAdmFunction)function).setNetworkName(network); - returnCode = function.execute(); - - } catch (IllegalArgumentException e) { - StringBuffer msg = new StringBuffer(SIGNATURE); - msg.append(DhcpCliFunction.getMessage(e)); - DhcpCliPrint.printErrMessage(msg.toString()); - DhcpCliPrint.printErrMessage(""); - usage(); - returnCode = CRITICAL; - } catch (Throwable e) { - StringBuffer msg = new StringBuffer(SIGNATURE); - msg.append(DhcpCliFunction.getMessage(e)); - DhcpCliPrint.printErrMessage(msg.toString()); - returnCode = CRITICAL; - } - - return (returnCode); - - } // execute - - /** - * Processes one program argument. - * @param option the option flag - * @param value the option value(if any) - * @exception IllegalArgumentException if an invalid argument was entered - */ - public void processArg(int option, String value) - throws IllegalArgumentException { - - switch (option) { - case ADD_CLIENT_ENTRY: - setFunction(new AddClientEntry(value)); - break; - case MODIFY_CLIENT_ENTRY: - setFunction(new ModifyClientEntry(value)); - break; - case DELETE_CLIENT_ENTRY: - setFunction(new DeleteClientEntry(value)); - break; - case CREATE_NETWORK_TABLE: - setFunction(new CreateNetworkTable()); - break; - case REMOVE_NETWORK_TABLE: - setFunction(new RemoveNetworkTable()); - break; - case DISPLAY_NETWORK_TABLE: - setFunction(new DisplayNetworkTable()); - break; - case LIST_NETWORK_TABLES: - setFunction(new ListNetworkTables()); - break; - case BATCH_EXECUTION: - setFunction(new PntAdmBatch(value)); - break; - default: - options.setOption(option, value); - } - - } // processArg - - /** - * Returns a localized string for this function - * @param key the resource bundle string identifier - * @return string from resource bundle. - */ - public String getString(String key) { - - return ResourceStrings.getString(key); - - } // getString - - /** - * The entry point for the program. - * @param args the program arguments - */ - public static void main(String[] args) { - - PntAdm pntadm = new PntAdm(args); - int returnCode = PntAdm.CRITICAL; - if (pntadm.isValidUser()) { - returnCode = pntadm.execute(); - } - System.exit(returnCode); - - } // main - -} // PntAdm diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/PntAdmBatch.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/PntAdmBatch.java deleted file mode 100644 index d5c20e2118..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/PntAdmBatch.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.pntadm; - -import com.sun.dhcpmgr.cli.dhcpbatch.*; - -import java.lang.IllegalArgumentException; - -/** - * The main class for the batch functionality of pntadm. - */ -public class PntAdmBatch extends PntAdmFunction { - - /** - * The valid options associated with batching. - */ - static final int supportedOptions[] = { - PntAdm.VERBOSE - }; - - private String inputSource = null; - - /** - * Constructs a PntAdmBatch object. - */ - public PntAdmBatch(String inputSource) { - - this.inputSource = inputSource; - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (PntAdm.BATCH_EXECUTION); - } - - /** - * Executes the batch functionality. - * @return one of the PntAdm return codes. - */ - public int execute() - throws IllegalArgumentException { - - DhcpBatch batch = new DhcpBatch(inputSource); - batch.setVerbose(options.isSet(PntAdm.VERBOSE)); - return (batch.execute()); - - } // execute - -} // PntAdmBatch diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/PntAdmFunction.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/PntAdmFunction.java deleted file mode 100644 index a89dd71550..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/PntAdmFunction.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.cli.pntadm; - -import com.sun.dhcpmgr.cli.common.DhcpCliFunction; -import com.sun.dhcpmgr.cli.common.DhcpCliPrint; -import com.sun.dhcpmgr.data.DhcpdOptions; -import com.sun.dhcpmgr.bridge.BridgeException; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; - -/** - * Abstract class implemented by all the pntadm "function" classes. - */ -public abstract class PntAdmFunction - extends DhcpCliFunction { - - /** - * Short date format for printing/parsing lease expiration - */ - DateFormat shortFormat = new SimpleDateFormat("MM/dd/yyyy"); - - /** - * Verbose date format for printing/parsing lease expiration. - */ - DateFormat verboseFormat = - DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG); - - /** - * The network on which the functions should "operate" - */ - String networkName = null; - - /** - * Sets the networkName. - * @param network name of the network - */ - public void setNetworkName(String network) { - - networkName = network; - - } // setNetworkName - - /** - * Returns a localized string for this function - * @param key the resource bundle string identifier - */ - public String getString(String key) { - - return ResourceStrings.getString(key); - - } // getString - - /** - * Returns whether or not hosts table is manageable. - * @return whether or not hosts table is manageable. - */ - public boolean isHostsManaged() { - - boolean result = false; - - try { - DhcpdOptions opts = - getSvcMgr().readDefaults(); - if (opts.getHostsResource() != null) { - result = true; - } else { - throw new BridgeException(); - } - } catch (BridgeException e) { - printErrMessage(getString("no_host_resource_warning")); - } - - return result; - - } // isHostsManaged - - /** - * Prints an error message. - * @param msg the message to print. - */ - public void printErrMessage(String msg) { - StringBuffer fullmsg = new StringBuffer(PntAdm.SIGNATURE); - fullmsg.append(msg); - DhcpCliPrint.printErrMessage(fullmsg.toString()); - } // printErrMessage - -} // PntAdmFunction diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/RemoveNetworkTable.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/RemoveNetworkTable.java deleted file mode 100644 index 958e899c4a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/RemoveNetworkTable.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.pntadm; - -import com.sun.dhcpmgr.data.DhcpClientRecord; -import com.sun.dhcpmgr.data.Network; -import com.sun.dhcpmgr.bridge.BridgeException; -import com.sun.dhcpmgr.bridge.NoTableException; - -import java.lang.IllegalArgumentException; - -/** - * The main class for the "remove network table" functionality - * of pntadm. - */ -public class RemoveNetworkTable extends PntAdmFunction { - - /** - * The valid options associated with removing a network table. - */ - static final int supportedOptions[] = { - PntAdm.RESOURCE, - PntAdm.RESOURCE_CONFIG, - PntAdm.PATH - }; - - /** - * Constructs a RemoveNetworkTable object. - */ - public RemoveNetworkTable() { - - validOptions = supportedOptions; - - } // constructor - - /** - * Returns the option flag for this function. - * @returns the option flag for this function. - */ - public int getFunctionFlag() { - return (PntAdm.REMOVE_NETWORK_TABLE); - } - - /** - * Executes the "remove network table" functionality. - * @return PntAdm.SUCCESS, PntAdm.ENOENT, PntAdm.WARNING, or - * PntAdm.CRITICAL - */ - public int execute() - throws IllegalArgumentException { - - int returnCode = PntAdm.SUCCESS; - - // Create a Network object. - // - try { - Network network = getNetMgr().getNetwork(networkName); - if (network == null) { - printErrMessage(getString("network_name_error")); - return (PntAdm.WARNING); - } - - // Delete the network table. - // - getNetMgr().deleteNetwork(network.toString(), false, - getDhcpDatastore()); - } catch (NoTableException e) { - printErrMessage(getMessage(e)); - returnCode = PntAdm.ENOENT; - } catch (Throwable e) { - printErrMessage(getMessage(e)); - returnCode = PntAdm.WARNING; - } - - return (returnCode); - - } // execute - -} // RemoveNetworkTable diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/ResourceBundle.properties b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/ResourceBundle.properties deleted file mode 100644 index b7fa8c2ca9..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/ResourceBundle.properties +++ /dev/null @@ -1,96 +0,0 @@ -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Cannot create Network -# -network_name_error=Could not determine correct network table name. - -# -# Specifying both verbose and raw display mode error -# -display_mode_error=Cannot specify both raw and verbose display modes. - -# -# No network specified error -# -no_network_specified=This function requires a network to be specified. - -# -# No network specified error -# -network_specified=This function does not accept a network argument. - -# -# No client ID specified error -# -no_clientid_specified=Cannot verify undefined client ID - -# -# No macro specified error -# -no_macro_specified=Cannot verify undefined macro. - -# -# No hosts resource warning -# -no_host_resource_warning=Warning - No hosts resource value found in DHCP configuration file.\nOperation succeeded, but hosts table was not updated. - -# -# Display Network Table Headers -# -Client_ID=Client ID -Flags=Flags -Client_IP=Client IP -Server_IP=Server IP -Lease_Expiration=Lease Expiration -Macro=Macro -Comment=Comment - -# -# Lease literals -# -Zero=Zero -Forever= Forever - -# -# Macro does not exist error message -# -macro_not_found=Cannot find macro in dhcptab. - -# -# No function defined error -# -no_function_error=Must specify one of 'C', 'A', 'M', 'D', 'R', 'P', 'L' or 'B'. - -# -# An invalid argument was input to the program. -# -invalid_args=Invalid arguments on command line. - -# -# Usage -# -usage=pntadm [-r (resource)] [-p (path)] [-u (uninterpreted data)] (options) [(network ip or name)]\n\nWhere (options) is one of:\n\n -C Create the named table\n\n -A (client ip or name) Add client entry. Sub-options:\n [-c (comment)]\n [-e (lease expiration)]\n [-f (flags)]\n [-i (client identifier)[-a]]\n [-m (dhcptab macro reference)[-y]]\n [-s (server ip or name)]\n\n -M (client ip or name) Modify client entry. Sub-options:\n [-c (new comment)]\n [-e (new lease expiration)]\n [-f (new flags)]\n [-i (new client identifier)[-a]]\n [-m (new dhcptab macro reference)[-y]]\n [-n (new client ip)]\n [-s (new server ip or name)]\n\n -D (client ip or name) Delete client entry.\n\n -R Remove the named table\n\n -P Display the named table. Sub-options:\n [-v] Display lease time in full format.\n [-x] Display lease time in raw format.\n\n -L List the configured DHCP networks\n\n -B [batchfile] Run command in batch input mode. Sub-options:\n [-v] Output commands as they are processed.\n\n The network ip or name argument is required for all options except -L and -B\n diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/ResourceStrings.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/ResourceStrings.java deleted file mode 100644 index e8c1753640..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/pntadm/ResourceStrings.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.cli.pntadm; - -import java.util.*; - -/** - * This class provides a convenient method to retrieve resources for - * the pntadm package. - */ -public class ResourceStrings { - - /** - * The handle to the resource bundle for the module. - */ - private static ResourceBundle bundle = null; - - /** - * Return a string from the resource bundle. - * @param key the key to the resource bundle string. - * @return the resource bundle string. - */ - public static String getString(String key) { - String msg = null; - try { - if (bundle == null) { - bundle = ResourceBundle.getBundle( - "com.sun.dhcpmgr.cli.pntadm.ResourceBundle", - Locale.getDefault()); - } - msg = bundle.getString(key); - } catch (Throwable e) { - msg = new String(key); - } - return msg; - - } // getString - -} // ResourceStrings diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/cfgboot.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/cfgboot.san deleted file mode 100644 index 3af808a428..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/cfgboot.san +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=d -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Set variables. -# -SRVNAME=`uname -n` -SRVADDR=`get_server_ip` -DHCP_CONFIG=/etc/inet/dhcpsvc.conf - -# -# If the DHCP server is running, kill it. -# -pkill -x -u 0 in.dhcpd - -# -# Make sure to clean up before we configure. -# -rm -f ${DHCP_CONFIG} >>${OUTFILE} 2>&1 - -# -# Config. -# -/usr/sbin/dhcpconfig -R ${SRVADDR} >>${OUTFILE} 2>&1 - -# -# Verify that the dhcp config file was created. -# -if [ ! -f ${DHCP_CONFIG} ] -then - echo "${DHCP_CONFIG} not created." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the run mode was defined in the config file -# -DEFLINE=`grep "RUN_MODE=relay" ${DHCP_CONFIG}` -if [ -z "${DEFLINE}" ] -then - echo "RUN_MODE not set correctly in ${DHCP_CONFIG}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the relay destinations was defined in the config file -# -DEFLINE=`grep "RELAY_DESTINATIONS=${SRVADDR}" ${DHCP_CONFIG}` -if [ -z "${DEFLINE}" ] -then - echo "RELAY_DESTINATIONS not set correctly in ${DHCP_CONFIG}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the dhcp server was started. -# -PID=`pgrep -x -u 0 in.dhcpd` -if [ -z "${PID}" ] -then - echo "DHCP Server was not started." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/cfgdhcp.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/cfgdhcp.san deleted file mode 100644 index 36338c0a0b..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/cfgdhcp.san +++ /dev/null @@ -1,295 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Set DNSSERV and DNSDMAIN if server has a resolv.conf. Return 0 if it does, -# nonzero otherwise. -# -get_dns_parms() -{ - if [ ! -f /etc/resolv.conf ] - then - return 1 - fi - - nsr=0 - dmn=0 - DNSRV="" - DNAME="" - for item in `cat /etc/resolv.conf` - do - if [ "${item}" = "nameserver" ] - then - nsr=1 - continue - fi - if [ "${item}" = "domain" ] - then - dmn=1 - continue - fi - if [ ${nsr} -eq 1 ] - then - if [ -z "${DNSRV}" ] - then - DNSRV=${item} - else - DNSRV="${DNSRV} ${item}" - fi - nsr=0 - continue - fi - if [ ${dmn} -eq 1 ] - then - DNAME="${item}" - dmn=0 - continue - fi - done - if [ ! -z "${DNSRV}" ] - then - DNSSERV="DNSserv=${DNSRV}" - fi - if [ ! -z "${DNAME}" ] - then - DNSDMAIN="DNSdmain=\"${DNAME}\"" - fi - if [ ! -z "${DNSSERV}" -o ! -z "${DNSDMAIN}" ] - then - return 0 - fi - return 1 -} - -# -# Set variables. -# -SRVNAME=`uname -n` -SRVADDR=`get_server_ip` -DHCP_DEFAULTS=/etc/inet/dhcpsvc.conf - -# -# If the DHCP server is running, kill it. -# -pkill -x -u 0 in.dhcpd - -# -# Make sure to clean up before we configure. -# -/usr/sbin/dhcpconfig -U -f -x >>${OUTFILE} 2>&1 -rm -f ${DHCP_DEFAULTS} >>${OUTFILE} 2>&1 - -# -# Config. -# -/usr/sbin/dhcpconfig -D -r ${DHCPRSRC} -p ${DHCPPATH} >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error configuring DHCP = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the dhcp defaults file was created. -# -if [ ! -f ${DHCP_DEFAULTS} ] -then - echo "${DHCP_DEFAULTS} not created." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the run mode was defined in the defaults file -# -DEFLINE=`grep "RUN_MODE=server" ${DHCP_DEFAULTS}` -if [ -z "${DEFLINE}" ] -then - echo "RUN_MODE not set correctly in ${DHCP_DEFAULTS}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the datastore resource was defined in the defaults file -# -DEFLINE=`grep "RESOURCE=${DHCPRSRC}" ${DHCP_DEFAULTS}` -if [ -z "${DEFLINE}" ] -then - echo "RESOURCE not set correctly in ${DHCP_DEFAULTS}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the datastore path was defined in the defaults file -# -DEFLINE=`grep "PATH=${DHCPPATH}" ${DHCP_DEFAULTS}` -if [ -z "${DEFLINE}" ] -then - echo "PATH not set correctly in ${DHCP_DEFAULTS}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the dhcptab data was created. -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the Locale symbol is defined in the dhcptab. -# -LOCALE=`grep "^Locale" ${DATAFILE}` -if [ -z "${LOCALE}" ] -then - rm ${DATAFILE} - echo "Locale macro does not exist in dhcptab" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the server macro is defined in the dhcptab. -# -SERVER_MACRO=`grep "^${SRVNAME}" ${DATAFILE}` -if [ -z "${SERVER_MACRO}" ] -then - rm ${DATAFILE} - echo "Server macro does not exist in dhcptab" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Grab the server macro definition -# -MACRO_DEFINITION=$(get_value ${SERVER_MACRO}) - -# -# Verify that the Locale symbol is defined as part of the macro definition -# -SRCH=":Include=Locale:" -macro_find_and_replace - -# -# Verify that the LeaseTim symbol is defined as part of the macro definition -# -SRCH=":LeaseTim=86400:" -macro_find_and_replace - -# -# Verify that the LeaseNeg symbol is defined as part of the macro definition -# -SRCH=":LeaseNeg:" -macro_find_and_replace - -# -# Verify that the Timeserv symbol is defined as part of the macro definition -# -SRCH=":Timeserv=${SRVADDR}:" -macro_find_and_replace - -# -# Go get the DNS settings -# -get_dns_parms - -# -# Verify that the DNSdmain symbol is defined as part of the macro definition -# -SRCH=:${DNSDMAIN}: -macro_find_and_replace - -# -# Verify that the DNSserv symbol is defined as part of the macro definition -# -SRCH=:${DNSSERV}: -macro_find_and_replace - -# -# Verify that all symbols have been accounted for -# -if [ "${MACRO_DEFINITION}" != ":" ] -then - echo "Server macro definition has invalid extra symbols: ${MACRO_DEFINITION}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the dhcp server was started. -# -PID=`pgrep -x -u 0 in.dhcpd` -if [ -z "${PID}" ] -then - echo "DHCP Server was not started." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/cfgnet.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/cfgnet.san deleted file mode 100644 index d05d68ef1e..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/cfgnet.san +++ /dev/null @@ -1,229 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Set NISSERV and NISDMAIN if NIS or NIS+ in YP compat mode. -# Returns 0 if these variables are set, nonzero otherwise. -# -get_nis_parms() -{ - unset NISSERV - unset NISDMAIN - NSSHOSTS=`grep '^hosts:' /etc/nsswitch.conf` - for TMP in ${NSSHOSTS} - do - case "${TMP}" in - "nis") - ypwhich >/dev/null 2>&1 - if [ ${?} -eq 0 ] - then - X=`ypwhich -m hosts` - NISSERV="" - for NSERV in `ypmatch ${X} hosts.byname | awk '{ print $1 }'` - do - if [ -z "${NISSERV}" ] - then - NISSERV=${NSERV} - else - NISSERV="${NISSERV} ${NSERV}" - fi - done - unset NSERV - NISDMAIN=`domainname` - fi - ;; - esac - unset TMP - done -} - -# -# Set variables. -# -SRVNAME=`uname -n` -SRVADDR=`get_server_ip` - -# -# Determine subnet, netmask, and broadcast address. -# -get_default_class ${SRVADDR} | read DEFNET DEFMASK -SUBNET=`get_netmask ${SRVADDR}` -if [ -z "${SUBNET}" ] -then - if [ "${DEFNET}" != "${SRVADDR}" ] - then - # likely subnetted/supernetted. - print - "\n\n###\tWarning\t###\n" - print - "Network ${SRVADDR} is netmasked, but no entry was found in the 'netmasks'\ntable; please update the 'netmasks' table in the appropriate\nnameservice before continuing (see /etc/nsswitch.conf).\n" >&2 - return 1 - else - # use the default. - SUBNET="${DEFMASK}" - fi -fi - -BCAST=`get_bcast_addr ${SRVADDR} ${SUBNET}` -SUBNETADDR=`get_subnet_addr ${SRVADDR} ${SUBNET}` - -# -# Make sure to clean up before we configure. -# -/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -R ${SUBNETADDR} >>${OUTFILE} 2>&1 -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -D -m ${SUBNETADDR} >>${OUTFILE} 2>&1 - -# -# Configure. -# -/usr/sbin/dhcpconfig -N ${SUBNETADDR} >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error configuring ${SUBNETADDR} table = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the network table was created. -# -NETTABS=`/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -L 2>>${OUTFILE}` -NETTAB=`echo ${NETTABS} | fgrep ${SUBNETADDR}` -if [ -z ${NETTAB} ] -then - echo "Network table for ${SUBNETADDR} not created." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the network macro was created. -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -NETWORK_MACRO=`grep "^${SUBNETADDR}" ${DATAFILE}` -if [ -z "${NETWORK_MACRO}" ] -then - rm ${DATAFILE} - echo "Server macro does not exist in dhcptab" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Grab the server macro definition -# -MACRO_DEFINITION=$(get_value ${NETWORK_MACRO}) - -# -# Verify that the Subnet symbol is defined as part of the macro definition -# -SRCH=":Subnet=${SUBNET}:" -macro_find_and_replace - -# -# Verify that the RDiscvyF symbol is defined as part of the macro definition -# -SRCH=":RDiscvyF=1:" -macro_find_and_replace - -# -# Verify that the Broadcst symbol is defined as part of the macro definition -# -SRCH=":Broadcst=${BCAST}:" -macro_find_and_replace - -# -# Get the NIS info -# -get_nis_parms - -# -# Verify that the DNSdmain symbol is defined as part of the macro definition -# -if [ ! -z "${NISDMAIN}" ] -then - SRCH=":NISdmain=\"${NISDMAIN}\":" - macro_find_and_replace -fi - -if [ ! -z "${NISSERV}" ] -then - SRCH=":NISservs=${NISSERV}:" - macro_find_and_replace -fi - -# -# Verify that all symbols have been accounted for -# -if [ "${MACRO_DEFINITION}" != ":" ] -then - echo "Network macro definition has invalid extra symbols: ${MACRO_DEFINITION}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createaddr.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createaddr.san deleted file mode 100644 index 35d8518958..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createaddr.san +++ /dev/null @@ -1,199 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.debug.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Set variables. -# -SRVNAME=`uname -n` -SRVADDR=`get_server_ip` - -# -# Determine subnet, netmask, and broadcast address. -# -get_default_class ${SRVADDR} | read DEFNET DEFMASK -SUBNET=`get_netmask ${SRVADDR}` -if [ -z "${SUBNET}" ] -then - if [ "${DEFNET}" != "${SRVADDR}" ] - then - # likely subnetted/supernetted. - print - "\n\n###\tWarning\t###\n" - print - "Network ${SRVADDR} is netmasked, but no entry was found in the 'netmasks'\ntable; please update the 'netmasks' table in the appropriate\nnameservice before continuing (see /etc/nsswitch.conf).\n" >&2 - return 1 - else - # use the default. - SUBNET="${DEFMASK}" - fi -fi - -SUBNETADDR=`get_subnet_addr ${SRVADDR} ${SUBNET}` - -# -# Verify that the network table exists. -# -NETTABS=`/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -L 2>>${OUTFILE}` -NETTAB=`echo ${NETTABS} | fgrep ${SUBNETADDR}` -if [ -z ${NETTAB} ] -then - echo "Network table for ${SUBNETADDR} does not exist." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Create the client entry. -# -CLIENTID="01AABBCCDDEEFF" -FLAGS="00" -CADDR=${SRVADDR} -SADDR=${SRVADDR} -EXPIRE="03/15/2000" -MACRO="UNKNOWN" -HOST="TESTCLIENT" - -/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -A ${SRVADDR} -e ${EXPIRE} -i ${CLIENTID} -s ${SRVADDR} ${SUBNETADDR} >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error adding entry ${SRVADDR} to table ${SUBNETADDR} = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that entry was added. -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -P ${SUBNETADDR} >${DATAFILE} 2>>${OUTFILE} - -ENTRY=`grep "^${CLIENTID}" ${DATAFILE}` -if [ -z "${ENTRY}" ] -then - rm ${DATAFILE} - echo "Client entry not added to ${SUBNETADDR}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Verify that the entry fields are correct. -# -FIELD=`echo $ENTRY | cut -d " " -f1,1` -if [ "${FIELD}" != "${CLIENTID}" ] -then - echo "ClientID of entry was not added correctly to ${SUBNETADDR}" - echo "${FIELD} != ${CLIENTID}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f2,2` -if [ "${FIELD}" != "${FLAGS}" ] -then - echo "Flags of entry was not added correctly to ${SUBNETADDR}" - echo "${FIELD} != ${FLAGS}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f3,3` -if [ "${FIELD}" != "${CADDR}" ] -then - echo "Client address of entry was not added correctly to ${SUBNETADDR}" - echo "${FIELD} != ${CADDR}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f4,4` -if [ "${FIELD}" != "${SADDR}" ] -then - echo "Server address of entry was not added correctly to ${SUBNETADDR}" - echo "${FIELD} != ${SADDR}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f5,5` -if [ "${FIELD}" != "${EXPIRE}" ] -then - echo "Lease expiration of entry was not added correctly to ${SUBNETADDR}" - echo "${FIELD} != ${EXPIRE}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f6,6` -if [ "${FIELD}" != "${MACRO}" ] -then - echo "Macro of entry was not added correctly to ${SUBNETADDR}" - echo "${FIELD} != ${MACRO}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f7,7` -if [ ! -z "${FIELD}" ] -then - echo "Comment field of entry was not added correctly to ${SUBNETADDR}" - echo "Should have no comment" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createdhcp.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createdhcp.san deleted file mode 100644 index 09b033ec83..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createdhcp.san +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Make sure to clean up before we configure. -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -R >>${OUTFILE} 2>&1 - -# -# Create the table. -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -C >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error creating the dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createmac.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createmac.san deleted file mode 100644 index d44d3385c2..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createmac.san +++ /dev/null @@ -1,138 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Verify that the macro is not already defined. -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -MACRO=`grep "^TestMac" ${DATAFILE}` -if [ ! -z "${MACRO}" ] -then - rm ${DATAFILE} - echo "Macro already exists in dhcptab" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Create the macro. -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -A -m TestMac -d ':Rootpath=/usr:' >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error creating macro = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the macro is defined in the dhcptab. -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -MACRO=`grep "^TestMac" ${DATAFILE}` -if [ -z "${MACRO}" ] -then - rm ${DATAFILE} - echo "Macro not added to dhcptab." - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Grab the macro definition from the dhcptab -# -MACRO_DEFINITION=$(get_value ${MACRO}) - -# -# Verify that the defintion was defined correctly -# -SRCH=":Rootpath=\/usr:" -macro_find_and_replace - -# -# Verify that there was nothing else in the definition -# -if [ "${MACRO_DEFINITION}" != ":" ] -then - echo "Macro definition has invalid extra symbols: ${MACRO_DEFINITION}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createnet.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createnet.san deleted file mode 100644 index f8edb794b9..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createnet.san +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Set variables. -# -SRVNAME=`uname -n` -SRVADDR=`get_server_ip` - -# -# Determine subnet, netmask, and broadcast address. -# -get_default_class ${SRVADDR} | read DEFNET DEFMASK -SUBNET=`get_netmask ${SRVADDR}` -if [ -z "${SUBNET}" ] -then - if [ "${DEFNET}" != "${SRVADDR}" ] - then - # likely subnetted/supernetted. - print - "\n\n###\tWarning\t###\n" - print - "Network ${SRVADDR} is netmasked, but no entry was found in the 'netmasks'\ntable; please update the 'netmasks' table in the appropriate\nnameservice before continuing (see /etc/nsswitch.conf).\n" >&2 - return 1 - else - # use the default. - SUBNET="${DEFMASK}" - fi -fi - -SUBNETADDR=`get_subnet_addr ${SRVADDR} ${SUBNET}` - -# -# Make sure to clean up before we configure. -# -/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -R ${SUBNETADDR} >>${OUTFILE} 2>&1 - -# -# Create the table. -# -/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -C ${SUBNETADDR} >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error creating table for ${SUBNETADDR} = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the network table was created. -# -NETTABS=`/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -L 2>>${OUTFILE}` -NETTAB=`echo ${NETTABS} | fgrep ${SUBNETADDR}` -if [ -z ${NETTAB} ] -then - echo "Network table for ${SUBNETADDR} not created." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createopt.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createopt.san deleted file mode 100644 index ad420c007d..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/createopt.san +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Verify that the option is not already defined. -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -OPTION=`grep "^TestOpt" ${DATAFILE}` -if [ ! -z "${OPTION}" ] -then - rm ${DATAFILE} - echo "Option already exists in dhcptab" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Create the option. -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -A -s TestOpt -d 'Vendor=the_test_class,11,ASCII,1,0' >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error creating option = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the option is defined in the dhcptab. -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -OPTION=`grep "^TestOpt" ${DATAFILE}` -if [ -z "${OPTION}" ] -then - rm ${DATAFILE} - echo "Option not added to dhcptab." - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Verify that the defintion was defined correctly -# -OPTION_DEFINITION=$(get_value ${OPTION}) -if [ "${OPTION_DEFINITION}" != "Vendor=the_test_class,11,ASCII,1,0" ] -then - echo "Option definition is not valid: *${OPTION_DEFINITION}*" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/cvtdhcp.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/cvtdhcp.san deleted file mode 100644 index e6825f20a4..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/cvtdhcp.san +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p:R:P: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Set variables. -# - -SRVNAME=`uname -n` -SRVADDR=`get_server_ip` -DHCP_DEFAULTS=/etc/inet/dhcpsvc.conf - -# -# Convert. -# -/usr/sbin/dhcpconfig -C -f -r ${DHCPRSRC_NEW} -p ${DHCPPATH_NEW} >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error converting datastore = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the datastore resource was defined in the defaults file -# -DEFLINE=`grep "RESOURCE=${DHCPRSRC_NEW}" ${DHCP_DEFAULTS}` -if [ -z "${DEFLINE}" ] -then - echo "New RESOURCE not set correctly in ${DHCP_DEFAULTS}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the datastore path was defined in the defaults file -# -DEFLINE=`grep "PATH=${DHCPPATH_NEW}" ${DHCP_DEFAULTS}` -if [ -z "${DEFLINE}" ] -then - echo "New PATH not set correctly in ${DHCP_DEFAULTS}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the dhcptab was created. -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/dhtadm -r ${DHCPRSRC_NEW} -p ${DHCPPATH_NEW} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Verify that the network table was created. -# -SUBNET=`get_netmask ${SRVADDR}` -SUBNETADDR=`get_subnet_addr ${SRVADDR} ${SUBNET}` -/usr/sbin/pntadm -r ${DHCPRSRC_NEW} -p ${DHCPPATH_NEW} -L >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error listing network tables = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -ENTRY=`grep "^${SUBNETADDR}$" ${DATAFILE}` -if [ -z "${ENTRY}" ] -then - rm ${DATAFILE} - echo "Did not find network table, ${SUBNETADDR}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -echo "${TESTNAME} - Test passed." -exit 0 - - - diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/deleteaddr.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/deleteaddr.san deleted file mode 100644 index c20954869d..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/deleteaddr.san +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.debug.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Set variables. -# -SRVNAME=`uname -n` -SRVADDR=`get_server_ip` - -# -# Determine subnet, netmask, and broadcast address. -# -get_default_class ${SRVADDR} | read DEFNET DEFMASK -SUBNET=`get_netmask ${SRVADDR}` -if [ -z "${SUBNET}" ] -then - if [ "${DEFNET}" != "${SRVADDR}" ] - then - # likely subnetted/supernetted. - print - "\n\n###\tWarning\t###\n" - print - "Network ${SRVADDR} is netmasked, but no entry was found in the 'netmasks'\ntable; please update the 'netmasks' table in the appropriate\nnameservice before continuing (see /etc/nsswitch.conf).\n" >&2 - return 1 - else - # use the default. - SUBNET="${DEFMASK}" - fi -fi - -SUBNETADDR=`get_subnet_addr ${SRVADDR} ${SUBNET}` - -# -# Verify that the network table exists. -# -NETTABS=`/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -L 2>>${OUTFILE}` -NETTAB=`echo ${NETTABS} | fgrep ${SUBNETADDR}` -if [ -z ${NETTAB} ] -then - echo "Network table for ${SUBNETADDR} does not exist." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Delete the client entry from the table. -# -CLIENTID="01AABBCCDDEEFF" -CADDR=${SRVADDR} -HOST="TESTCLIENT" - -/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -D ${CADDR} ${SUBNETADDR} >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error deleting entry ${CADDR} from table ${SUBNETADDR} = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that entry was deleted. -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -P ${SUBNETADDR} >${DATAFILE} 2>>${OUTFILE} -ENTRY=`grep "^${CLIENTID}" ${DATAFILE}` -if [ ! -z "${ENTRY}" ] -then - rm ${DATAFILE} - echo "Client entry still found in ${SUBNETADDR}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/deletemac.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/deletemac.san deleted file mode 100644 index 3a49c70d6f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/deletemac.san +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Verify that macro is already defined in the dhcptab -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -MACRO=`grep "^TestMac" ${DATAFILE}` -MACRO_DEFINITION=$(get_value ${MACRO}) -if [ "${MACRO_DEFINITION}" != ":TestOpt=129.148.11.240:" ] -then - rm ${DATAFILE} - echo "Macro definition should have been defined as: :TestOpt=129.148.11.240:" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Delete the macro -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -D -m TestMac >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error deleting macro = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the macro has been removed from the dhcptab. -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -MACRO=`grep "^TestMac" ${DATAFILE}` -if [ ! -z "${MACRO}" ] -then - rm ${DATAFILE} - echo "Macro was not removed from the dhcptab" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/deleteopt.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/deleteopt.san deleted file mode 100644 index c9a71cb155..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/deleteopt.san +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Verify that option is already defined in the dhcptab -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -OPTION=`grep "^TestOpt" ${DATAFILE}` -OPTION_DEFINITION=$(get_value ${OPTION}) -if [ "${OPTION_DEFINITION}" != "Site,130,IP,1,0" ] -then - rm ${DATAFILE} - echo "Option definition should have been defined as: Site,130,IP,1,0" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Delete the option. -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -D -s TestOpt >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error deleting option = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the option was removed from the dhcptab. -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -OPTION=`grep "^TestOpt" ${DATAFILE}` -if [ ! -z "${OPTION}" ] -then - rm ${DATAFILE} - echo "Option was not removed from dhcptab" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/dhcpconfig.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/dhcpconfig.san deleted file mode 100644 index c837a42d42..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/dhcpconfig.san +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p:R:P: -process_args $@ - -ksh ${DIRNAME}/cfgboot.san ${DEBUG} -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/cfgdhcp.san ${DEBUG} -r ${DHCPRSRC} -p ${DHCPPATH} -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/cfgnet.san ${DEBUG} -r ${DHCPRSRC} -p ${DHCPPATH} -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/export.san ${DEBUG} -r ${DHCPRSRC} -p ${DHCPPATH} -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/import.san ${DEBUG} -r ${DHCPRSRC} -p ${DHCPPATH} -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/cvtdhcp.san ${DEBUG} -r ${DHCPRSRC} -p ${DHCPPATH} -R ${DHCPRSRC_NEW} -P ${DHCPPATH_NEW} -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/ucfgdhcp.san ${DEBUG} -R ${DHCPRSRC_NEW} -P ${DHCPPATH_NEW} -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/dhtadm.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/dhtadm.san deleted file mode 100644 index 7670712f24..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/dhtadm.san +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -ksh ${DIRNAME}/createdhcp.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/createmac.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/createopt.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/modifyopt.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/modifymac.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/displaydhcp.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/deleteopt.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/deletemac.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/removedhcp.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/displaydhcp.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/displaydhcp.san deleted file mode 100644 index fb0accd77b..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/displaydhcp.san +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# Set variables. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Display the table. -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the option is in the displayed output. -# -OPTION=`grep "^TestOpt" ${DATAFILE}` -if [ -z "${OPTION}" ] -then - rm ${DATAFILE} - echo "Option, TestOpt, not found in dhcptab" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the defintion was defined correctly -# -OPTION_DEFINITION=$(get_value ${OPTION}) -if [ "${OPTION_DEFINITION}" != "Site,130,IP,1,0" ] -then - echo "Option definition is not valid: ${OPTION_DEFINITION}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the macro is in the displayed output. -# -MACRO=`grep "^TestMac" ${DATAFILE}` -if [ -z "${MACRO}" ] -then - rm ${DATAFILE} - echo "Macro, TestMac, not found in dhcptab" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Verify that the defintion was defined correctly -# -MACRO_DEFINITION=$(get_value ${MACRO}) -SRCH=":TestOpt=129.148.11.240:" -macro_find_and_replace - -# -# Verify that there was nothing else in the definition -# -if [ "${MACRO_DEFINITION}" != ":" ] -then - echo "Macro definition has invalid extra symbols: ${MACRO_DEFINITION}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/displaynet.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/displaynet.san deleted file mode 100644 index f38dc58adb..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/displaynet.san +++ /dev/null @@ -1,196 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Set variables. -# -TESTNAME=`basename $0` -SRVNAME=`uname -n` -SRVADDR=`get_server_ip` - -# -# Determine subnet, netmask, and broadcast address. -# -get_default_class ${SRVADDR} | read DEFNET DEFMASK -SUBNET=`get_netmask ${SRVADDR}` -if [ -z "${SUBNET}" ] -then - if [ "${DEFNET}" != "${SRVADDR}" ] - then - # likely subnetted/supernetted. - print - "\n\n###\tWarning\t###\n" - print - "Network ${SRVADDR} is netmasked, but no entry was found in the 'netmasks'\ntable; please update the 'netmasks' table in the appropriate\nnameservice before continuing (see /etc/nsswitch.conf).\n" >&2 - return 1 - else - # use the default. - SUBNET="${DEFMASK}" - fi -fi - -SUBNETADDR=`get_subnet_addr ${SRVADDR} ${SUBNET}` - -# -# Verify that the network table exists. -# -NETTABS=`/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -L 2>>${OUTFILE}` -NETTAB=`echo ${NETTABS} | fgrep ${SUBNETADDR}` -if [ -z ${NETTAB} ] -then - echo "Network table for ${SUBNETADDR} does not exist." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Display the table. -# -CLIENTID="01AABBCCDDEEFF" -FLAGS="01" -CADDR=${SRVADDR} -SADDR=${SRVADDR} -EXPIRE="03/15/2001" -MACRO="UNKNOWN" -COMMENT=Modified -DATAFILE=/tmp/${TESTNAME}.data.$$ - -/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -P ${SUBNETADDR} >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error listing table for ${SUBNETADDR} = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -ENTRY=`grep "^${CLIENTID}" ${DATAFILE}` -if [ -z "${ENTRY}" ] -then - rm ${DATAFILE} - echo "Client entry not found in ${SUBNETADDR}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Verify that the entry fields are correct. -# -FIELD=`echo $ENTRY | cut -d " " -f1,1` -if [ "${FIELD}" != "${CLIENTID}" ] -then - echo "ClientID of entry is not correct in ${SUBNETADDR}" - echo "${FIELD} != ${CLIENTID}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f2,2` -if [ "${FIELD}" != "${FLAGS}" ] -then - echo "Flags of entry is not correct in ${SUBNETADDR}" - echo "${FIELD} != ${FLAGS}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f3,3` -if [ "${FIELD}" != "${CADDR}" ] -then - echo "Client address of entry is not correct in ${SUBNETADDR}" - echo "${FIELD} != ${CADDR}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f4,4` -if [ "${FIELD}" != "${SADDR}" ] -then - echo "Server address of entry is not correct in ${SUBNETADDR}" - echo "${FIELD} != ${SADDR}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f5,5` -if [ "${FIELD}" != "${EXPIRE}" ] -then - echo "Lease expiration of entry is not correct in ${SUBNETADDR}" - echo "${FIELD} != ${EXPIRE}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f6,6` -if [ "${FIELD}" != "${MACRO}" ] -then - echo "Macro of entry is not correct in ${SUBNETADDR}" - echo "${FIELD} != ${MACRO}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f7,7` -if [ "${FIELD}" != "${COMMENT}" ] -then - echo "Comment field of entry is not correct in ${SUBNETADDR}" - echo "${FIELD} != ${COMMENT}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/export.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/export.san deleted file mode 100644 index d702f81407..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/export.san +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Set variables. -# - -SRVNAME=`uname -n` -SRVADDR=`get_server_ip` -DHCPCONFIG=/usr/sbin/dhcpconfig -EXPORTFILE=/tmp/move.zip - -# -# Export. -# -${DHCPCONFIG} -X ${EXPORTFILE} -m ALL -o ALL -a ALL -f -x >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error exporting DHCP data = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the export file exists. -# -if [ ! -f ${EXPORTFILE} ] -then - echo "${EXPORTFILE} does not exist" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that all symbols and macros was removed from the dhcptab. -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -ENTRIES=`wc -l ${DATAFILE} | sed 's/^ *//' | cut -d " " -f1,1` -if [ "${ENTRIES}" != "2" ] -then - rm ${DATAFILE} - echo "The dhcptab is not empty as it should be." - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Verify that the network tables were removed. -# -/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -L >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error listing networks = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -ENTRIES=`wc -l ${DATAFILE} | sed 's/^ *//' | cut -d " " -f1,1` -if [ "${ENTRIES}" != "0" ] -then - rm ${DATAFILE} - echo "Some network tables still exist and they should not." - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/import.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/import.san deleted file mode 100644 index 134645190a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/import.san +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Set variables. -# - -SRVNAME=`uname -n` -SRVADDR=`get_server_ip` -DHCPCONFIG=/usr/sbin/dhcpconfig -IMPORTFILE=/tmp/move.zip - -# -# Import. -# -${DHCPCONFIG} -I ${IMPORTFILE} >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error importing DHCP data = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the Locale macro was added to the dhcptab. -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -LOCALE=`grep "^Locale" ${DATAFILE}` -if [ -z "${LOCALE}" ] -then - rm ${DATAFILE} - echo "Locale macro was not added to the dhcptab" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the server macro was added to the dhcptab. -# -SERVER_MACRO=`grep "^${SRVNAME}" ${DATAFILE}` -if [ -z "${SERVER_MACRO}" ] -then - rm ${DATAFILE} - echo "Server macro was not removed from the dhcptab" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Verify that the network table was created. -# -SUBNET=`get_netmask ${SRVADDR}` -SUBNETADDR=`get_subnet_addr ${SRVADDR} ${SUBNET}` -NETTABS=`/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -L 2>>${OUTFILE}` -NETTAB=`echo ${NETTABS} | fgrep ${SUBNETADDR}` -if [ -z ${NETTAB} ] -then - echo "${SUBNETADDR} was not imported." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/listnet.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/listnet.san deleted file mode 100644 index 2f1cea7238..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/listnet.san +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Set variables. -# -TESTNAME=`basename $0` -SRVNAME=`uname -n` -SRVADDR=`get_server_ip` - -# -# Determine subnet, netmask, and broadcast address. -# -get_default_class ${SRVADDR} | read DEFNET DEFMASK -SUBNET=`get_netmask ${SRVADDR}` -if [ -z "${SUBNET}" ] -then - if [ "${DEFNET}" != "${SRVADDR}" ] - then - # likely subnetted/supernetted. - print - "\n\n###\tWarning\t###\n" - print - "Network ${SRVADDR} is netmasked, but no entry was found in the 'netmasks'\ntable; please update the 'netmasks' table in the appropriate\nnameservice before continuing (see /etc/nsswitch.conf).\n" >&2 - return 1 - else - # use the default. - SUBNET="${DEFMASK}" - fi -fi - -SUBNETADDR=`get_subnet_addr ${SRVADDR} ${SUBNET}` - -# -# Display the table. -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -L >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error listing ${SUBNETADDR} table = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -ENTRY=`grep "^${SUBNETADDR}$" ${DATAFILE}` -if [ -z "${ENTRY}" ] -then - rm ${DATAFILE} - echo "Did not find network table, ${SUBNETADDR}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/modifyaddr.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/modifyaddr.san deleted file mode 100644 index 629dc19db9..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/modifyaddr.san +++ /dev/null @@ -1,199 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.debug.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Set variables. -# -SRVNAME=`uname -n` -SRVADDR=`get_server_ip` - -# -# Determine subnet, netmask, and broadcast address. -# -get_default_class ${SRVADDR} | read DEFNET DEFMASK -SUBNET=`get_netmask ${SRVADDR}` -if [ -z "${SUBNET}" ] -then - if [ "${DEFNET}" != "${SRVADDR}" ] - then - # likely subnetted/supernetted. - print - "\n\n###\tWarning\t###\n" - print - "Network ${SRVADDR} is netmasked, but no entry was found in the 'netmasks'\ntable; please update the 'netmasks' table in the appropriate\nnameservice before continuing (see /etc/nsswitch.conf).\n" >&2 - return 1 - else - # use the default. - SUBNET="${DEFMASK}" - fi -fi - -SUBNETADDR=`get_subnet_addr ${SRVADDR} ${SUBNET}` - -# -# Verify that the network table exists. -# -NETTABS=`/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -L 2>>${OUTFILE}` -NETTAB=`echo ${NETTABS} | fgrep ${SUBNETADDR}` -if [ -z ${NETTAB} ] -then - echo "Network table for ${SUBNETADDR} does not exist." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Modify the client entry. -# -CLIENTID="01AABBCCDDEEFF" -FLAGS="01" -CADDR=${SRVADDR} -SADDR=${SRVADDR} -EXPIRE="03/15/2001" -MACRO="UNKNOWN" -COMMENT=Modified - -/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -M ${SRVADDR} -e ${EXPIRE} -c ${COMMENT} -f ${FLAGS} ${SUBNETADDR} >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error modifying entry ${SRVADDR} to table ${SUBNETADDR} = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Get the entry. -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -P ${SUBNETADDR} >${DATAFILE} 2>>${OUTFILE} - -ENTRY=`grep "^${CLIENTID}" ${DATAFILE}` -if [ -z "${ENTRY}" ] -then - rm ${DATAFILE} - echo "Client entry not found in ${SUBNETADDR}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Verify that the entry fields are correct. -# -FIELD=`echo $ENTRY | cut -d " " -f1,1` -if [ "${FIELD}" != "${CLIENTID}" ] -then - echo "ClientID of entry is not correct in ${SUBNETADDR}" - echo "${FIELD} != ${CLIENTID}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f2,2` -if [ "${FIELD}" != "${FLAGS}" ] -then - echo "Flags of entry is not correct in ${SUBNETADDR}" - echo "${FIELD} != ${FLAGS}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f3,3` -if [ "${FIELD}" != "${CADDR}" ] -then - echo "Client address of entry is not correct in ${SUBNETADDR}" - echo "${FIELD} != ${CADDR}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f4,4` -if [ "${FIELD}" != "${SADDR}" ] -then - echo "Server address of entry is not correct in ${SUBNETADDR}" - echo "${FIELD} != ${SADDR}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f5,5` -if [ "${FIELD}" != "${EXPIRE}" ] -then - echo "Lease expiration of entry is not correct in ${SUBNETADDR}" - echo "${FIELD} != ${EXPIRE}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f6,6` -if [ "${FIELD}" != "${MACRO}" ] -then - echo "Macro of entry is not correct in ${SUBNETADDR}" - echo "${FIELD} != ${MACRO}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -FIELD=`echo $ENTRY | cut -d " " -f7,7` -if [ "${FIELD}" != "${COMMENT}" ] -then - echo "Comment field of entry is not correct in ${SUBNETADDR}" - echo "${FIELD} != ${COMMENT}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/modifymac.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/modifymac.san deleted file mode 100644 index e45225ea48..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/modifymac.san +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Verify that macro is already defined in the dhcptab -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -MACRO=`grep "^TestMac" ${DATAFILE}` -MACRO_DEFINITION=$(get_value ${MACRO}) -if [ "${MACRO_DEFINITION}" != ":Rootpath=/usr:" ] -then - rm ${DATAFILE} - echo "Macro definition should have been defined as: :Rootpath=/usr:" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Modify the macro -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -M -m TestMac -d ':TestOpt=129.148.11.240:' >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error modifying macro = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the macro is defined in the dhcptab. -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -MACRO=`grep "^TestMac" ${DATAFILE}` -if [ -z "${MACRO}" ] -then - rm ${DATAFILE} - echo "Macro not modified in dhcptab" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Verify that the defintion was defined correctly -# -MACRO_DEFINITION=$(get_value ${MACRO}) -SRCH=":TestOpt=129.148.11.240:" -macro_find_and_replace - -# -# Verify that there was nothing else in the definition -# -if [ "${MACRO_DEFINITION}" != ":" ] -then - echo "Macro definition has invalid extra symbols: ${MACRO_DEFINITION}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/modifyopt.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/modifyopt.san deleted file mode 100644 index 30593a48d1..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/modifyopt.san +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Verify that option is already defined in the dhcptab -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -OPTION=`grep "^TestOpt" ${DATAFILE}` -OPTION_DEFINITION=$(get_value ${OPTION}) -if [ "${OPTION_DEFINITION}" != "Vendor=the_test_class,11,ASCII,1,0" ] -then - rm ${DATAFILE} - echo "Option definition should have been defined as: Vendor=the_test_class,11,ASCII,1,0" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Modify the option. -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -M -s TestOpt -d 'Site,130,IP,1,0' >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error modifying option = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the option is defined in the dhcptab. -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" != "0" ] -then - rm ${DATAFILE} - echo "Error displaying dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -OPTION=`grep "^TestOpt" ${DATAFILE}` -if [ -z "${OPTION}" ] -then - rm ${DATAFILE} - echo "Option not modified in dhcptab" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Verify that the defintion was defined correctly -# -OPTION_DEFINITION=$(get_value ${OPTION}) -if [ "${OPTION_DEFINITION}" != "Site,130,IP,1,0" ] -then - echo "Option definition is not valid: ${OPTION_DEFINITION}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/pntadm.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/pntadm.san deleted file mode 100644 index 7000cc22ca..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/pntadm.san +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -ksh ${DIRNAME}/createnet.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/createaddr.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/modifyaddr.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/displaynet.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/deleteaddr.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/listnet.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - -ksh ${DIRNAME}/removenet.san $@ -if [ $? != 0 ] -then - echo "`basename $0` - aborted!" - exit 1 -fi - diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/removedhcp.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/removedhcp.san deleted file mode 100644 index 50ea84c6cf..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/removedhcp.san +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Remove the table. -# -/usr/sbin/dhtadm -r ${DHCPRSRC} -p ${DHCPPATH} -R >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error removing the dhcptab = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/removenet.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/removenet.san deleted file mode 100644 index e539d70437..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/removenet.san +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dr:p: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Set variables. -# -SRVNAME=`uname -n` -SRVADDR=`get_server_ip` - -# -# Determine subnet, netmask, and broadcast address. -# -get_default_class ${SRVADDR} | read DEFNET DEFMASK -SUBNET=`get_netmask ${SRVADDR}` -if [ -z "${SUBNET}" ] -then - if [ "${DEFNET}" != "${SRVADDR}" ] - then - # likely subnetted/supernetted. - print - "\n\n###\tWarning\t###\n" - print - "Network ${SRVADDR} is netmasked, but no entry was found in the 'netmasks'\ntable; please update the 'netmasks' table in the appropriate\nnameservice before continuing (see /etc/nsswitch.conf).\n" >&2 - return 1 - else - # use the default. - SUBNET="${DEFMASK}" - fi -fi - -SUBNETADDR=`get_subnet_addr ${SRVADDR} ${SUBNET}` - -# -# Verify that the network table exists. -# -NETTABS=`/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -L 2>>${OUTFILE}` -NETTAB=`echo ${NETTABS} | fgrep ${SUBNETADDR}` -if [ -z ${NETTAB} ] -then - echo "Network table for ${SUBNETADDR} does not exist." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Remove the table. -# -/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -R ${SUBNETADDR} >>${OUTFILE} 2>&1 -RET=$? -if [ "${RET}" != "0" ] -then - echo "Error removing ${SUBNETADDR} table = ${RET}" - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the network table was removed. -# -NETTABS=`/usr/sbin/pntadm -r ${DHCPRSRC} -p ${DHCPPATH} -L 2>>${OUTFILE}` -NETTAB=`echo ${NETTABS} | fgrep ${SUBNETADDR}` -if [ ! -z ${NETTAB} ] -then - echo "${SUBNETADDR} not removed." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/ucfgdhcp.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/ucfgdhcp.san deleted file mode 100644 index 1e9f4760b2..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/ucfgdhcp.san +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Source the utilities. -# -DIRNAME=`dirname $0` -. ${DIRNAME}/utilities.san - -# -# Process the input arguments. -# -VALIDOPTS=dR:P: -process_args $@ - -# -# In case the tester wants to see script output, allow them -# to run in debug mode. -# -TESTNAME=`basename $0` -if [ ! -z "${DEBUG}" ] -then - OUTFILE=/tmp/${TESTNAME}.$$ - echo "Output from test: ${TESTNAME}" >${OUTFILE} - echo >>${OUTFILE} - echo "debug output can be found at ${OUTFILE}" -else - OUTFILE=/dev/null -fi - -# -# Set variables. -# - -SRVNAME=`uname -n` -SRVADDR=`get_server_ip` -DHCPHOSTS_RSRC=files -DHCP_DEFAULTS=/etc/inet/dhcpsvc.conf - -# -# Unconfig. -# -/usr/sbin/dhcpconfig -U -f -x >>${OUTFILE} 2>&1 - -# -# Verify that the dhcp defaults file was removed. -# -if [ -f ${DHCP_DEFAULTS} ] -then - echo "${DHCP_DEFAULTS} was not removed." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -# -# Verify that the dhcptab was removed. -# -DATAFILE=/tmp/${TESTNAME}.data.$$ -/usr/sbin/dhtadm -r ${DHCPRSRC_NEW} -p ${DHCPPATH_NEW} -P >${DATAFILE} 2>>${OUTFILE} -RET=$? -if [ "${RET}" == "0" ] -then - rm ${DATAFILE} - echo "Error the dhcptab still exists?" - echo "${TESTNAME} - Test failed!" - exit 1 -fi -rm ${DATAFILE} - -# -# Verify that the dhcp server was stopped. -# -PID=`pgrep -x -u 0 in.dhcpd` -if [ ! -z "${PID}" ] -then - echo "DHCP Server was not stopped." - echo "${TESTNAME} - Test failed!" - exit 1 -fi - -echo "${TESTNAME} - Test passed." -exit 0 diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/utilities.san b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/utilities.san deleted file mode 100644 index 8fd3db1208..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/cli/tests/utilities.san +++ /dev/null @@ -1,285 +0,0 @@ -#!/usr/bin/ksh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -# -# Process arguments. -# -process_args() -{ - DEBUG= - DHCPRSRC= - DHCPPATH= - DHCPRSRC_NEW= - DHCPPATH_NEW= - ERR= - USAGE="Usage: %s: [-d]" - while getopts ${VALIDOPTS} name - do - case $name in - d) DEBUG="-d";; - r) DHCPRSRC="${OPTARG}";; - p) DHCPPATH="${OPTARG}";; - R) DHCPRSRC_NEW="${OPTARG}";; - P) DHCPPATH_NEW="${OPTARG}";; - ?) ERR=1;; - esac - done - - # - # If the resource is a valid option, then it is a required one - # - echo ${VALIDOPTS} | grep r: >/dev/null - if [ $? == 0 ] - then - USAGE="${USAGE} -r resource" - if [ -z "${DHCPRSRC}" ] - then - ERR=1 - fi - fi - - # - # If the path is a valid option, then it is a required one - # - echo ${VALIDOPTS} | grep p: >/dev/null - if [ $? == 0 ] - then - USAGE="${USAGE} -p path" - if [ -z "${DHCPPATH}" ] - then - ERR=1 - fi - fi - - # - # If the conversion resource is a valid option, then it is a required one - # - echo ${VALIDOPTS} | grep R: >/dev/null - if [ $? == 0 ] - then - USAGE="${USAGE} -R resource" - if [ -z "${DHCPRSRC_NEW}" ] - then - ERR=1 - fi - fi - - # - # If the conversion path is a valid option, then it is a required one - # - echo ${VALIDOPTS} | grep P: >/dev/null - if [ $? == 0 ] - then - USAGE="${USAGE} -P path" - if [ -z "${DHCPPATH_NEW}" ] - then - ERR=1 - fi - fi - - if [ ! -z "${ERR}" ] - then - printf "$USAGE\n" $0 - exit -1 - fi -} - -# -# Return the primary interface's IP address. -# -get_server_ip() -{ - awk '$1 ~ /^[0-9]/ && $2 == "'${SRVNAME}'" { printf "%s", $1; exit }' /etc/inet/hosts -} - -# -# Based on the network specification, determine whether or not network is -# subnetted or supernetted. -# Given a dotted IP network number, convert it to the default class -# network.(used to detect subnetting). Requires one argument, the -# network number. (e.g. 10.0.0.0) Echos the default network and default -# mask for success, null if error. -# -get_default_class() -{ - NN01=${1%%.*} - tmp=${1#*.} - NN02=${tmp%%.*} - tmp=${tmp#*.} - NN03=${tmp%%.*} - tmp=${tmp#*.} - NN04=${tmp%%.*} - RETNET="" - RETMASK="" - - typeset -i16 ONE=10#${1%%.*} - typeset -i10 X=$((${ONE}&16#f0)) - if [ ${X} -eq 224 ] - then - # Multicast - typeset -i10 TMP=$((${ONE}&16#f0)) - RETNET="${TMP}.0.0.0" - RETMASK="240.0.0.0" - fi - typeset -i10 X=$((${ONE}&16#80)) - if [ -z "${RETNET}" -a ${X} -eq 0 ] - then - # Class A - RETNET="${NN01}.0.0.0" - RETMASK="255.0.0.0" - fi - typeset -i10 X=$((${ONE}&16#c0)) - if [ -z "${RETNET}" -a ${X} -eq 128 ] - then - # Class B - RETNET="${NN01}.${NN02}.0.0" - RETMASK="255.255.0.0" - fi - typeset -i10 X=$((${ONE}&16#e0)) - if [ -z "${RETNET}" -a ${X} -eq 192 ] - then - # Class C - RETNET="${NN01}.${NN02}.${NN03}.0" - RETMASK="255.255.255.0" - fi - print - ${RETNET} ${RETMASK} - unset NNO1 NNO2 NNO3 NNO4 RETNET RETMASK X ONE -} - -# -# Based on the nsswitch setting, query the netmasks table for a netmask. -# Accepts one argument, a dotted IP address. -# -get_netmask() -{ - MTMP=`getent netmasks ${1} | awk '{ print $2 }'` - if [ ! -z "${MTMP}" ] - then - print - ${MTMP} - fi -} - -# Given a network number and subnetmask, return the broadcast address. -get_bcast_addr() -{ - typeset -i16 NNO1=10#${1%%.*} - tmp=${1#*.} - typeset -i16 NNO2=10#${tmp%%.*} - tmp=${tmp#*.} - typeset -i16 NNO3=10#${tmp%%.*} - tmp=${tmp#*.} - typeset -i16 NNO4=10#${tmp%%.*} - - typeset -i16 NMO1=10#${2%%.*} - tmp=${2#*.} - typeset -i16 NMO2=10#${tmp%%.*} - tmp=${tmp#*.} - typeset -i16 NMO3=10#${tmp%%.*} - tmp=${tmp#*.} - typeset -i16 NMO4=10#${tmp%%.*} - - typeset -i16 ONE - typeset -i16 TWO - typeset -i16 THREE - typeset -i16 FOUR - let ONE=\~${NMO1}\|${NNO1} - let ONE=${ONE}\&16#ff - let TWO=\~${NMO2}\|${NNO2} - let TWO=${TWO}\&16#ff - let THREE=\~${NMO3}\|${NNO3} - let THREE=${THREE}\&16#ff - let FOUR=\~${NMO4}\|${NNO4} - let FOUR=${FOUR}\&16#ff - typeset -i10 ONE - typeset -i10 TWO - typeset -i10 THREE - typeset -i10 FOUR - print - "${ONE}.${TWO}.${THREE}.${FOUR}" -} - -# Given a network number and subnetmask, return the subnet address. -get_subnet_addr() -{ - typeset -i16 NNO1=10#${1%%.*} - tmp=${1#*.} - typeset -i16 NNO2=10#${tmp%%.*} - tmp=${tmp#*.} - typeset -i16 NNO3=10#${tmp%%.*} - tmp=${tmp#*.} - typeset -i16 NNO4=10#${tmp%%.*} - - typeset -i16 NMO1=10#${2%%.*} - tmp=${2#*.} - typeset -i16 NMO2=10#${tmp%%.*} - tmp=${tmp#*.} - typeset -i16 NMO3=10#${tmp%%.*} - tmp=${tmp#*.} - typeset -i16 NMO4=10#${tmp%%.*} - - typeset -i16 ONE - typeset -i16 TWO - typeset -i16 THREE - typeset -i16 FOUR - let ONE=${NMO1}\&${NNO1} - let TWO=${NMO2}\&${NNO2} - let THREE=${NMO3}\&${NNO3} - let FOUR=${NMO4}\&${NNO4} - typeset -i10 ONE - typeset -i10 TWO - typeset -i10 THREE - typeset -i10 FOUR - print - "${ONE}.${TWO}.${THREE}.${FOUR}" -} - -# -# Given a macro definition defined in MACRO_DEFINITION and a symbol/value string -# defined in SRCH, search the macro definition for the string. If not found, abort. -# If found, remove the string from the definition. -# -macro_find_and_replace() -{ - VAL=`expr "${MACRO_DEFINITION}" : .*"${SRCH}".*` - if [ "${VAL}" = "0" ] - then - echo "${SRCH} not defined as part of the macro definition" - echo "${TESTNAME} - Test failed!" - exit 1 - fi - - SRCH=`echo "${SRCH}" | cut -c2-` - MACRO_DEFINITION=`echo "${MACRO_DEFINITION}" | sed s/"${SRCH}"//` -} - -# -# Given a macro or option definition, returns its value. -# -function get_value -{ - echo $* | cut -d ' ' -f 3- -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/AddressView.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/AddressView.java deleted file mode 100644 index 4eb1ea32e3..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/AddressView.java +++ /dev/null @@ -1,803 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.table.*; -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.text.*; -import java.net.*; - -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.bridge.BridgeException; -import com.sun.dhcpmgr.bridge.NoEntryException; - -/** - * Address View displays the networks currently under DHCP management, and - * as a network is selected from the list its addresses are displayed. - */ -public class AddressView implements View { - private JPanel displayPanel; - protected static AutosizingTable addressTable; - private JScrollPane addressPane; - private boolean firstActivation = true; - private NetworkListModel networkListModel; - private JList networkList; - protected static AddressTableModel addressTableModel = null; - private TableSorter sortedTableModel; - private JCheckBoxMenuItem showGrid; - private JCheckBoxMenuItem showAddresses; - private JMenuItem addAddrs; - private JMenuItem releaseAddrs; - private JMenuItem addNet; - private JMenuItem deleteNets; - private JMenuItem addressHelp; - private Vector[] menuItems; - private Frame myFrame; - private Vector selectionListeners = new Vector(); - private int sortModelIndex = -1; - private static final String NO_NETWORKS = - ResourceStrings.getString("no_networks"); - - // Model class for the network list - class NetworkListModel extends AbstractListModel { - private Object currentValue; - private Network data[] = null; - - public void load() { - try { - MainFrame.setStatusText( - ResourceStrings.getString("loading_networks")); - data = DataManager.get().getNetworks(true); - } catch (Throwable e) { - e.printStackTrace(); - } finally { - int len = 0; - if (data != null) { - len = data.length; - } - MainFrame.setStatusText( - MessageFormat.format( - ResourceStrings.getString("networks_loaded"), len)); - } - } - - public void reload() { - load(); - fireContentsChanged(this, -1, -1); - } - - public int getSize() { - if (data == null) { - load(); - } - if (data == null) { - return 0; - } else { - return data.length; - } - } - - public Object getElementAt(int index) { - if (data == null) { - load(); - } - if (data == null || index >= data.length) { - return ""; - } else { - return data[index].toString(); - } - } - - public Network getNetworkAt(int index) { - if (data == null || index >= data.length) { - return null; - } else { - return data[index]; - } - } - } - - // Container class for the address data - class AddressTableModel extends AbstractTableModel { - private DhcpClientRecord [] data; - private String network; - private boolean showAddresses; - private boolean firstLoad; - - public AddressTableModel() { - data = null; - network = ""; - showAddresses = false; - firstLoad = true; - } - - public void load(String network) { - data = null; - fireTableDataChanged(); - if (network.length() == 0) { - // No network number supplied, so can't load - return; - } - this.network = network; - - // Update the status line - Object [] objs = {network}; - String s = MessageFormat.format( - ResourceStrings.getString("loading_addresses"), objs); - MainFrame.setStatusText(s); - - // Kick off background loading of addresses - AddressLoader loader = new AddressLoader(); - - } - - // Loading is done, re-sort and tell the view to repaint - protected void doneLoading() { - sortedTableModel.reallocateIndexes(); - if (firstLoad) { - sortedTableModel.sortByColumn(0); - firstLoad = false; - } - fireTableDataChanged(); - } - - protected String getNetwork() { - return network; - } - - protected void setData(DhcpClientRecord [] newdata) { - data = newdata; - } - - public void setShowAddresses(boolean state) { - showAddresses = state; - fireTableStructureChanged(); - sortedTableModel.sortByColumn(sortModelIndex); - } - - public int getRowCount() { - if (data == null) { - return 0; - } else { - return data.length; - } - } - - public int getColumnCount() { - return 7; - } - - public Object getValueAt(int row, int column) { - switch (column) { - case 0: - if (showAddresses) { - return data[row].getClientIP(); - } else { - return data[row].getClientName(); - } - case 1: - if (data[row].isUnusable()) { - return ResourceStrings.getString("unusable"); - } else if (data[row].isBootp()) { - return ResourceStrings.getString("bootp"); - } else if (data[row].isManual()) { - return ResourceStrings.getString("manual"); - } else if (data[row].isPermanent()) { - return ResourceStrings.getString("permanent"); - } else { - return ResourceStrings.getString("dynamic"); - } - case 2: - return data[row].getExpiration(); - case 3: - if (showAddresses) { - return data[row].getServerIP(); - } else { - return data[row].getServerName(); - } - case 4: - return data[row].getMacro(); - case 5: - return data[row].getClientId(); - case 6: - return data[row].getComment(); - default: - return null; - } - } - - public Class getColumnClass(int column) { - switch (column) { - case 0: - case 3: - if (showAddresses) { - return IPAddress.class; - } else { - return String.class; - } - case 2: - return Date.class; - case 1: - case 4: - case 5: - case 6: - return String.class; - default: - return super.getColumnClass(column); - } - } - - public String getColumnName(int column) { - switch (column) { - case 0: - if (showAddresses) { - return ResourceStrings.getString("address_column"); - } else { - return ResourceStrings.getString("client_name_column"); - } - case 1: - return ResourceStrings.getString("flags_column"); - case 2: - return ResourceStrings.getString("expires_column"); - case 3: - return ResourceStrings.getString("server_column"); - case 4: - return ResourceStrings.getString("macro_column"); - case 5: - return ResourceStrings.getString("client_column"); - case 6: - return ResourceStrings.getString("comment_column"); - default: - return super.getColumnName(column); - } - } - - protected DhcpClientRecord getClientAt(int row) { - return data[row]; - } - } - - // Background loader for addresses. - class AddressLoader extends com.sun.dhcpmgr.ui.SwingWorker { - public Object construct() { - try { - String net = addressTableModel.getNetwork(); - return DataManager.get().getClients(net, true); - } catch (final BridgeException e) { - // Since we're in a background thread, ask Swing to run ASAP. - SwingUtilities.invokeLater(new Runnable() { - Object [] args = new Object[] { e.getMessage() }; - public void run() { - MessageFormat form = new MessageFormat( - ResourceStrings.getString("error_loading_addrs")); - JOptionPane.showMessageDialog(null, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - }); - } - return null; - } - - public void finished() { - addressTableModel.setData((DhcpClientRecord [])get()); - addressTableModel.doneLoading(); - MainFrame.setStatusText( - MessageFormat.format( - ResourceStrings.getString("address_status_message"), - addressTableModel.getRowCount())); - addressTable.clearSelection(); - } - } - - // Renderer class used to make unusable addresses bold in the display - class AddressTableCellRenderer extends ExtendedCellRenderer { - public Component getTableCellRendererComponent(JTable table, - Object value, boolean isSelected, boolean hasFocus, int row, - int column) { - Component c = super.getTableCellRendererComponent(table, value, - isSelected, hasFocus, row, column); - int modelRow = sortedTableModel.mapRowAt(row); - if (modelRow != -1) { - if (addressTableModel.getClientAt(modelRow).isUnusable()) { - Font f = c.getFont(); - c.setFont(new Font(f.getName(), Font.BOLD, f.getSize())); - } - } - return c; - } - } - - // Recipient of update messages sent when the editing dialogs exit - class DialogListener implements ActionListener { - public void actionPerformed(ActionEvent e) { - // Don't reload if cancel happened - if (!e.getActionCommand().equals(DialogActions.CANCEL)) { - AddressView.this.reload(); - } - } - } - - public AddressView() { - displayPanel = new JPanel(new BorderLayout()); - - // Create network selection list, tie it to table - networkListModel = new NetworkListModel(); - networkList = new JList(networkListModel); - networkList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - networkList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - // Ignore all but the last in a series of these events - if (e.getValueIsAdjusting()) { - return; - } - String net = ""; - int index = networkList.getSelectedIndex(); - if (index != -1) { - net = (String)networkListModel.getElementAt( - networkList.getSelectedIndex()); - } - if (net.length() == 0) { - // No networks are selected; disable menu items - deleteNets.setEnabled(false); - addAddrs.setEnabled(false); - showAddresses.setEnabled(false); - showGrid.setEnabled(false); - } else { - deleteNets.setEnabled(true); - addAddrs.setEnabled(true); - showAddresses.setEnabled(true); - showGrid.setEnabled(true); - } - addressTableModel.load(net); - } - }); - - // Use a prototype value as a performance enhancement - networkList.setPrototypeCellValue("222.222.222.222"); - JScrollPane networkPane = new JScrollPane(networkList); - JPanel networkPanel = new JPanel(new BorderLayout()); - networkPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); - - Mnemonic mnNetwork = new Mnemonic(ResourceStrings.getString("network")); - JLabel nwLbl = new JLabel(mnNetwork.getString()); - nwLbl.setLabelFor(networkPanel); - nwLbl.setToolTipText(mnNetwork.getString()); - networkPanel.add(nwLbl, BorderLayout.NORTH); - nwLbl.setDisplayedMnemonic(mnNetwork.getMnemonic()); - - networkPanel.add(networkPane, BorderLayout.CENTER); - displayPanel.add(networkPanel, BorderLayout.WEST); - - // Create table to display in data area - addressTableModel = new AddressTableModel(); - sortedTableModel = new TableSorter(addressTableModel); - addressTable = new AutosizingTable(sortedTableModel); - sortedTableModel.addMouseListenerToHeaderInTable(addressTable); - addressTable.getTableHeader().setReorderingAllowed(true); - addressTable.getTableHeader().setResizingAllowed(true); - addressTable.setSelectionMode( - ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - - sortedTableModel.addActionListener(new ActionListener() { - private SortedHeaderRenderer sortedRenderer = - new SortedHeaderRenderer(addressTable); - private TableCellRenderer savedRenderer; - public void actionPerformed(ActionEvent e) { - // Clear the selection when sorting is changed - addressTable.clearSelection(); - /* - * Change the header rendering to show which column is - * being used for sorting of the data. - */ - int modelIndex = Integer.parseInt(e.getActionCommand()); - int viewIndex = - addressTable.convertColumnIndexToView(modelIndex); - if (sortModelIndex != -1) { - int sortViewIndex = - addressTable.convertColumnIndexToView(sortModelIndex); - addressTable.getColumnModel().getColumn( - sortViewIndex).setHeaderRenderer(savedRenderer); - } - /* - * Save the column currently being sorted so we can restore - * the renderer later. We save model columns rather than - * view columns because model columns are invariant while - * view columns can be reordered with confusion resulting. - */ - TableColumn c = - addressTable.getColumnModel().getColumn(viewIndex); - savedRenderer = c.getHeaderRenderer(); - c.setHeaderRenderer(sortedRenderer); - sortModelIndex = modelIndex; - } - }); - - // Make double-clicks the same as Edit->Properties - addressTable.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) { - handleProperties(); - } - } - }); - - // Install custom renderer to bold the entries which are unusable - TableCellRenderer renderer = new AddressTableCellRenderer(); - addressTable.setDefaultRenderer(String.class, renderer); - addressTable.setDefaultRenderer(IPAddress.class, renderer); - addressTable.setDefaultRenderer(Date.class, renderer); - - // Wrap it in a scroll pane - addressPane = new JScrollPane(addressTable); - - displayPanel.add(addressPane, BorderLayout.CENTER); - - // Create menu items - Mnemonic mnShowAddrs = - new Mnemonic(ResourceStrings.getString("show_addresses")); - showAddresses = new JCheckBoxMenuItem(mnShowAddrs.getString(), - false); - showAddresses.setMnemonic(mnShowAddrs.getMnemonic()); - showAddresses.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - addressTableModel.setShowAddresses(showAddresses.getState()); - } - }); - - Mnemonic mnShowGrid = - new Mnemonic(ResourceStrings.getString("show_grid")); - showGrid = new JCheckBoxMenuItem(mnShowGrid.getString(), - true); - showGrid.setMnemonic(mnShowGrid.getMnemonic()); - showGrid.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - addressTable.setShowGrid(showGrid.getState()); - } - }); - - Mnemonic mnAddNet = - new Mnemonic(ResourceStrings.getString("add_network")); - addNet = new JMenuItem(mnAddNet.getString()); - addNet.setMnemonic(mnAddNet.getMnemonic()); - addNet.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - ConfigWizard wiz = new ConfigWizard(myFrame, - ResourceStrings.getString("net_wiz_title"), false); - wiz.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("finished")) { - reload(); - } - } - }); - wiz.pack(); - wiz.setVisible(true); - } - }); - - - Mnemonic mnDelNets = - new Mnemonic(ResourceStrings.getString("delete_networks")); - deleteNets = new JMenuItem(mnDelNets.getString()); - deleteNets.setMnemonic(mnDelNets.getMnemonic()); - deleteNets.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - DeleteNetworksDialog d = new DeleteNetworksDialog(myFrame); - d.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals(DialogActions.OK)) { - reload(); - } - } - }); - d.pack(); - d.setVisible(true); - } - }); - - Mnemonic mnAddAddr = - new Mnemonic(ResourceStrings.getString("add_addresses")); - addAddrs = new JMenuItem(mnAddAddr.getString()); - addAddrs.setMnemonic(mnAddAddr.getMnemonic()); - addAddrs.setEnabled(false); // Start out disabled - addAddrs.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - AddressWizard wiz = new AddressWizard(myFrame, - networkListModel.getNetworkAt( - networkList.getSelectedIndex())); - wiz.addActionListener(new DialogListener()); - wiz.pack(); - wiz.setVisible(true); - } - }); - - Mnemonic mnRelAddr = - new Mnemonic(ResourceStrings.getString("release_addresses")); - releaseAddrs = new JMenuItem(mnRelAddr.getString()); - releaseAddrs.setMnemonic(mnRelAddr.getMnemonic()); - releaseAddrs.setEnabled(false); // Start out disabled - releaseAddrs.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - int [] rows = addressTable.getSelectedRows(); - if (rows.length == 0) { - return; - } - DhcpClientRecord [] recs = new DhcpClientRecord[rows.length]; - for (int i = 0; i < rows.length; ++i) { - recs[i] = addressTableModel.getClientAt( - sortedTableModel.mapRowAt(rows[i])); - } - ReleaseAddressDialog d = new ReleaseAddressDialog(myFrame, recs, - (String)networkListModel.getElementAt( - networkList.getSelectedIndex()), - showAddresses.isSelected()); - d.addActionListener(new DialogListener()); - d.pack(); - d.setVisible(true); - } - }); - - Mnemonic mnOnAddrs = - new Mnemonic(ResourceStrings.getString("on_addresses_item")); - addressHelp = new JMenuItem(mnOnAddrs.getString()); - addressHelp.setMnemonic(mnOnAddrs.getMnemonic()); - addressHelp.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - DhcpmgrApplet.showHelp("addresses_reference"); - } - }); - - /* - * Construct the menu lists - */ - menuItems = new Vector[MainFrame.MENU_COUNT]; - for (int i = 0; i < menuItems.length; ++i) { - menuItems[i] = new Vector(); - } - menuItems[MainFrame.VIEW_MENU].addElement(showAddresses); - menuItems[MainFrame.VIEW_MENU].addElement(showGrid); - menuItems[MainFrame.EDIT_MENU].addElement(addAddrs); - menuItems[MainFrame.EDIT_MENU].addElement(releaseAddrs); - menuItems[MainFrame.EDIT_MENU].addElement(addNet); - menuItems[MainFrame.EDIT_MENU].addElement(deleteNets); - menuItems[MainFrame.HELP_MENU].addElement(addressHelp); - - // Listen for selections events, manipulate menu item state as needed - addressTable.getSelectionModel().addListSelectionListener( - new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - if (addressTable.getSelectionModel().isSelectionEmpty()) { - // Disable menu items - releaseAddrs.setEnabled(false); - } else { - // Enable menu items - releaseAddrs.setEnabled(true); - } - // Notify listeners that our selection state may have changed - notifySelectionListeners(); - } - }); - } - - public String getName() { - return ResourceStrings.getString("address_view_name"); - } - - // Return custom menus for this view, which is nothing at this time - public Enumeration menus() { - return null; - } - - // Return custom menu items for each menu as requested. - public Enumeration menuItems(int menu) { - return menuItems[menu].elements(); - } - - public Component getDisplay() { - return displayPanel; - } - - public void setActive(boolean state) { - if (state) { - if (firstActivation) { - // Find frame we're in for use when creating dialogs - myFrame = (Frame)SwingUtilities.getAncestorOfClass( - MainFrame.class, addressTable); - if (networkListModel.getSize() != 0) { - networkList.setSelectedIndex(0); - } - firstActivation = false; - } else { - // Clear any messages left from other views - MainFrame.setStatusText(""); - } - } - } - - // Handle a find - public void find(String s) { - int startRow = addressTable.getSelectedRow() + 1; - for (int i = startRow; i < sortedTableModel.getRowCount(); ++i) { - DhcpClientRecord rec = - addressTableModel.getClientAt(sortedTableModel.mapRowAt(i)); - if (rec.getClientName().indexOf(s) != -1 || - rec.toString().indexOf(s) != -1) { - addressTable.setRowSelectionInterval(i, i); - addressTable.scrollRectToVisible( - addressTable.getCellRect(i, 0, false)); - return; - } - } - // Got to the end, wrap around - for (int i = 0; i < startRow; ++i) { - DhcpClientRecord rec = - addressTableModel.getClientAt(sortedTableModel.mapRowAt(i)); - if (rec.getClientName().indexOf(s) != -1 || - rec.toString().indexOf(s) != -1) { - addressTable.setRowSelectionInterval(i, i); - addressTable.scrollRectToVisible( - addressTable.getCellRect(i, 0, false)); - return; - } - } - } - - public void handleCreate() { - if (networkList.getSelectedIndex() == -1) { - // Tell user to use Network Wizard - JOptionPane.showMessageDialog(myFrame, - ResourceStrings.getString("run_network_wizard"), - ResourceStrings.getString("error_message"), - JOptionPane.ERROR_MESSAGE); - } else { - CreateAddressDialog d = new CreateAddressDialog(myFrame, - CreateAddressDialog.CREATE, new DhcpClientRecord(), - networkListModel.getNetworkAt(networkList.getSelectedIndex())); - d.addActionListener(new DialogListener()); - d.pack(); - d.setVisible(true); - } - } - - public void handleDelete() { - int [] rows = addressTable.getSelectedRows(); - if (rows.length == 0) { - return; - } - DhcpClientRecord [] recs = new DhcpClientRecord[rows.length]; - for (int i = 0; i < rows.length; ++i) { - recs[i] = addressTableModel.getClientAt( - sortedTableModel.mapRowAt(rows[i])); - } - DeleteAddressDialog d = new DeleteAddressDialog(myFrame, recs, - (String)networkListModel.getElementAt( - networkList.getSelectedIndex())); - d.addActionListener(new DialogListener()); - d.pack(); - d.setVisible(true); - } - - public void handleDuplicate() { - int row = addressTable.getSelectedRow(); - if (row == -1) { - return; - } - DhcpClientRecord rec = - addressTableModel.getClientAt(sortedTableModel.mapRowAt(row)); - if (rec == null) { - return; - } - CreateAddressDialog d = new CreateAddressDialog(myFrame, - CreateAddressDialog.DUPLICATE, (DhcpClientRecord)rec.clone(), - networkListModel.getNetworkAt(networkList.getSelectedIndex())); - d.addActionListener(new DialogListener()); - d.pack(); - d.setVisible(true); - } - - public void handleProperties() { - int [] rows = addressTable.getSelectedRows(); - if (rows.length == 0) { - return; - } - DhcpClientRecord [] recs = new DhcpClientRecord[rows.length]; - for (int i = 0; i < rows.length; ++i) { - recs[i] = - addressTableModel.getClientAt( - sortedTableModel.mapRowAt(rows[i])); - } - if (recs.length == 1) { - // Edit a single address - CreateAddressDialog d = new CreateAddressDialog(myFrame, - CreateAddressDialog.EDIT, (DhcpClientRecord)recs[0].clone(), - networkListModel.getNetworkAt(networkList.getSelectedIndex())); - d.addActionListener(new DialogListener()); - d.pack(); - d.setVisible(true); - } else { - // Edit a group of addresses - ModifyAddressesDialog d = new ModifyAddressesDialog(myFrame, recs, - (String)networkListModel.getElementAt( - networkList.getSelectedIndex())); - d.addActionListener(new DialogListener()); - d.pack(); - d.setVisible(true); - } - } - - public void handleUpdate() { - reload(); - } - - protected void reload() { - Object value = networkList.getSelectedValue(); - networkListModel.reload(); - networkList.clearSelection(); - networkList.setSelectedValue(value, true); - if (networkListModel.getSize() != 0 && - networkList.getSelectedIndex() == -1) { - // Didn't get selected, must be gone. Select first item in list - networkList.setSelectedIndex(0); - } - } - - public void addSelectionListener(SelectionListener listener) { - selectionListeners.addElement(listener); - } - - public void removeSelectionListener(SelectionListener listener) { - selectionListeners.removeElement(listener); - } - - private void notifySelectionListeners() { - Enumeration en = selectionListeners.elements(); - while (en.hasMoreElements()) { - SelectionListener l = (SelectionListener)en.nextElement(); - l.valueChanged(); - } - } - - public boolean isSelectionEmpty() { - return addressTable.getSelectionModel().isSelectionEmpty(); - } - - public boolean isSelectionMultiple() { - return (addressTable.getSelectedRowCount() > 1); - } - - public void startAddressWizard() { - addAddrs.doClick(); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/AddressWizard.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/AddressWizard.java deleted file mode 100644 index aa52424417..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/AddressWizard.java +++ /dev/null @@ -1,1044 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.bridge.BridgeException; -import com.sun.dhcpmgr.bridge.NoEntryException; -import com.sun.dhcpmgr.bridge.ExistsException; -import com.sun.dhcpmgr.bridge.HostExistsException; -import com.sun.dhcpmgr.bridge.NoTableException; -import com.sun.dhcpmgr.server.DhcpNetMgr; - -import javax.swing.*; -import javax.swing.table.*; -import javax.swing.event.*; -import javax.swing.border.*; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.text.MessageFormat; -import java.net.*; - -/** - * A wizard to configure a group of addresses. - */ -public class AddressWizard extends Wizard { - private Network network; - private int number = 10; - private String comment = ""; - private String server = DataManager.get().getShortServerName(); - private IPAddress serverIP; - private IPAddress startAddress; - private String macro = DataManager.get().getShortServerName(); - private boolean unusable = false; - private boolean dynamic = true; - private WizardTableModel addressTableModel; - private Macro noMacro; - - class Address { - IPAddress addr; - String name; - - public Address() { - addr = null; - name = ""; - } - - public Address(int a, String n) { - name = n; - setAddr(a); - } - - public Address(String a, String n) { - name = n; - setAddr(a); - } - - public void setAddr(int a) { - addr = new IPAddress(a); - } - - public void setAddr(String a) { - try { - addr = new IPAddress(a); - } catch (ValidationException e) { - // Do nothing - } - } - - public String toString() { - return addr.getHostAddress(); - } - } - - class WizardTableModel extends AbstractTableModel { - private Vector addrs = new Vector(); - - public int getRowCount() { - return addrs.size(); - } - - public int getColumnCount() { - return 2; - } - - public Object getValueAt(int row, int column) { - if (column == 0) { - return ((Address)addrs.elementAt(row)).addr; - } else { - return ((Address)addrs.elementAt(row)).name; - } - } - - public Class getColumnClass(int column) { - if (column == 0) { - return IPAddress.class; - } else { - return String.class; - } - } - - public String getColumnName(int column) { - if (column == 0) { - return ResourceStrings.getString("address_column"); - } else { - return ResourceStrings.getString("client_name_column"); - } - } - - public long generateAddresses() { - if (!network.containsAddress(startAddress)) { - return 0; - } - - int net = network.getAddress().intValue(); - int mask = network.getMask().intValue(); - int start = startAddress.intValue(); - - addrs.removeAllElements(); - long max = (long)(net + ~mask) & 0xffffffffL; - int count = 0; - int index = start - net; - if (index == 0) { - // Don't try allocating the network address as a client address - ++index; - } - DhcpClientRecord [] clients = null; - try { - /* - * Sort the data so we can generate the list of addresses - * with a minimal number of comparisons here. First, though, - * clone the array so that sorting won't affect the original - * data set and throw off the main display. - */ - clients = (DhcpClientRecord [])DataManager.get().getClients( - network.getAddress().toString(), false).clone(); - Arrays.sort(clients); - } catch (Throwable e) { - // XXX What to do here??? - e.printStackTrace(); - } - int base = 0; - long searchAddress = 0; - while (count < number) { - long address = (long)(net + index) & 0xffffffffL; - if (address == max) { - // We finished searching before satisfying the request - break; - } - /* - * If clients == null then this is an empty network, - * so searching for holes is unnecessary - */ - if (clients != null) { - // Advance search pointer past lower-numbered addresses - while ((base < clients.length) - && ((searchAddress = - clients[base].getBinaryAddress()) < address)) { - ++base; - } - } - if (searchAddress != address) { - // found an empty slot; create the address - addrs.addElement(new Address((int)address, "")); - ++count; - } - ++index; - } - - // Inform UI that the data is ready. - fireTableDataChanged(); - return count; - } - - public Address getAddressAt(int index) { - return (Address)addrs.elementAt(index); - } - } - - // This step selects the number of addresses and a comment - class NumberStep implements WizardStep { - private Box stepBox; - private IntegerField addressCount; - private JTextField commentField; - - public NumberStep() { - stepBox = Box.createVerticalBox(); - - // Explanatory text at the top - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("add_wiz_explain"), 4, 45)); - stepBox.add(Box.createVerticalStrut(10)); - stepBox.add(Box.createVerticalGlue()); - - // Get the number of addresses to create - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("add_wiz_count_explain"), 1, 45)); - - Mnemonic mnCount = - new Mnemonic(ResourceStrings.getString("add_wiz_count_label")); - JLabel label = new JLabel(mnCount.getString()); - addressCount = new IntegerField(); // Ensure numeric input - addressCount.setMaximumSize(addressCount.getPreferredSize()); - - label.setLabelFor(addressCount); - label.setToolTipText(mnCount.getString()); - label.setDisplayedMnemonic(mnCount.getMnemonic()); - - Box box = Box.createHorizontalBox(); - box.add(Box.createHorizontalStrut(10)); - box.add(label); - box.add(Box.createHorizontalStrut(5)); - box.add(addressCount); - box.add(Box.createHorizontalGlue()); - stepBox.add(box); - - stepBox.add(Box.createVerticalStrut(10)); - stepBox.add(Box.createVerticalGlue()); - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("add_wiz_comment_explain"), 2, 45)); - - // Let user supply a comment - Mnemonic mnComm = - new Mnemonic(ResourceStrings.getString( - "add_wiz_comment_label")); - label = new JLabel(mnComm.getString()); - commentField = new JTextField("", 20); - - label.setLabelFor(commentField); - label.setToolTipText(mnComm.getString()); - label.setDisplayedMnemonic(mnComm.getMnemonic()); - - commentField.setMaximumSize(commentField.getPreferredSize()); - box = Box.createHorizontalBox(); - box.add(Box.createHorizontalStrut(10)); - box.add(label); - box.add(Box.createHorizontalStrut(5)); - box.add(commentField); - stepBox.add(box); - stepBox.add(Box.createVerticalGlue()); - - /* - * This listener ensures that the forward button is enabled only - * when there is a count of addresses in the addressCount field. - */ - addressCount.getDocument().addDocumentListener( - new DocumentListener() { - public void insertUpdate(DocumentEvent e) { - setForwardEnabled(e.getDocument().getLength() != 0); - } - public void changedUpdate(DocumentEvent e) { - insertUpdate(e); - } - public void removeUpdate(DocumentEvent e) { - insertUpdate(e); - } - }); - } - - public String getDescription() { - return ResourceStrings.getString("add_wiz_number_desc"); - } - - public Component getComponent() { - return stepBox; - } - - public void setActive(int direction) { - addressCount.setValue(number); - commentField.setText(comment); - setForwardEnabled(addressCount.getValue() != 0); - } - - public boolean setInactive(int direction) { - number = addressCount.getValue(); - if (number == 0) { - /* - * Going forward with 0 addresses makes no sense, - * display error and veto the move. - */ - JOptionPane.showMessageDialog(AddressWizard.this, - ResourceStrings.getString("add_wiz_count_error"), - ResourceStrings.getString("error_message"), - JOptionPane.ERROR_MESSAGE); - return false; - } - comment = commentField.getText(); - return true; - } - } - - // This step selects the server and starting address - class ServerStep implements WizardStep { - private Box stepBox; - private IPAddressField startField; - private HostnameField serverField; - - public ServerStep() { - stepBox = Box.createVerticalBox(); - - // Explanatory text at the top - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("add_wiz_server_explain"), 1, 45)); - - // Server to own these addresses - Mnemonic mnMan = - new Mnemonic(ResourceStrings.getString("add_wiz_server_label")); - JLabel jl = new JLabel(mnMan.getString()); - Box box = Box.createHorizontalBox(); - box.add(jl); - box.add(Box.createHorizontalStrut(5)); - serverField = new HostnameField("", 15); - jl.setLabelFor(serverField); - jl.setToolTipText(mnMan.getString()); - jl.setDisplayedMnemonic(mnMan.getMnemonic()); - - serverField.setMaximumSize(serverField.getPreferredSize()); - box.add(serverField); - box.add(Box.createHorizontalGlue()); - stepBox.add(box); - - // Add some spacing - stepBox.add(Box.createVerticalStrut(5)); - stepBox.add(Box.createVerticalGlue()); - - // Starting address - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("add_wiz_start_explain"), 2, 45)); - box = Box.createHorizontalBox(); - - Mnemonic mnStart = - new Mnemonic(ResourceStrings.getString("add_wiz_start_label")); - JLabel startLbl = new JLabel(mnStart.getString()); - box.add(startLbl); - box.add(Box.createHorizontalStrut(5)); - startField = new IPAddressField(); // Ensure it's an IP address - startLbl.setLabelFor(startField); - startLbl.setToolTipText(mnStart.getString()); - startLbl.setDisplayedMnemonic(mnStart.getMnemonic()); - - startField.setMaximumSize(startField.getPreferredSize()); - box.add(startField); - stepBox.add(box); - - DocumentListener docListener = new DocumentListener() { - public void insertUpdate(DocumentEvent e) { - setForwardEnabled((startField.getText().length() != 0) - && (serverField.getText().length() != 0)); - } - public void changedUpdate(DocumentEvent e) { - insertUpdate(e); - } - public void removeUpdate(DocumentEvent e) { - insertUpdate(e); - } - }; - - startField.getDocument().addDocumentListener(docListener); - serverField.getDocument().addDocumentListener(docListener); - } - - public String getDescription() { - return ResourceStrings.getString("add_wiz_server_desc"); - } - - public Component getComponent() { - return stepBox; - } - - public void setActive(int direction) { - serverField.setText(server); - startField.setValue(startAddress); - setForwardEnabled(true); - } - - public boolean setInactive(int direction) { - if (direction == FORWARD) { - // Validate that address is on the network we're working on - IPAddress a = startField.getValue(); - if (a == null) { - // Not a valid address at all - MessageFormat form = new MessageFormat( - ResourceStrings.getString("add_wiz_invalid_address")); - Object [] args = new Object[1]; - args[0] = startField.getText(); - JOptionPane.showMessageDialog(AddressWizard.this, - form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return false; - } else if (!network.containsAddress(a)) { - // Address is not on network - MessageFormat form = new MessageFormat( - ResourceStrings.getString("bad_network_address")); - Object [] args = new Object[2]; - args[0] = startField.getText(); - args[1] = network.getAddress(); - JOptionPane.showMessageDialog(AddressWizard.this, - form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return false; - } - try { - serverIP = new IPAddress(serverField.getText()); - } catch (Throwable e) { - /* - * Unknown hostname, probably, so put up the message and - * decline to continue - */ - MessageFormat form = new MessageFormat( - ResourceStrings.getString("bad_server_name")); - Object [] args = new Object[1]; - args[0] = serverField.getText(); - JOptionPane.showMessageDialog(AddressWizard.this, - form.format(args), - ResourceStrings.getString("error_message"), - JOptionPane.ERROR_MESSAGE); - return false; - } - } - server = serverField.getText(); - startAddress = startField.getValue(); - return true; - } - } - - // This step confirms the list of addresses to be generated - class ConfirmStep implements WizardStep { - private JPanel stepPanel; - private JTable addressTable; - - public ConfirmStep() { - stepPanel = new JPanel(new BorderLayout(10, 10)); - - // Explanatory text at the top - stepPanel.add(Wizard.createTextArea( - ResourceStrings.getString("add_wiz_confirm_explain"), 3, 45), - BorderLayout.NORTH); - - // Label the table - JPanel panel = new JPanel(new BorderLayout()); - panel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); - Mnemonic mnIP = - new Mnemonic(ResourceStrings.getString( - "add_wiz_confirm_label")); - JLabel label = new JLabel(mnIP.getString()); - panel.add(label, BorderLayout.NORTH); - - // Display the addresses in a table - addressTable = new JTable(addressTableModel); - - label.setLabelFor(addressTable); - label.setToolTipText(mnIP.getString()); - label.setDisplayedMnemonic(mnIP.getMnemonic()); - - addressTable.setDefaultRenderer(IPAddress.class, - new ExtendedCellRenderer()); - - // Table is not selectable in any way - addressTable.setRowSelectionAllowed(false); - addressTable.setColumnSelectionAllowed(false); - addressTable.setCellSelectionEnabled(false); - - // Wrap in a scroll pane so column headings display - JScrollPane scrollPane = new JScrollPane(addressTable); - panel.add(scrollPane, BorderLayout.CENTER); - stepPanel.add(panel, BorderLayout.CENTER); - } - - public String getDescription() { - return ResourceStrings.getString("add_wiz_confirm_desc"); - } - - public Component getComponent() { - return stepPanel; - } - - public void setActive(int direction) { - /* - * If we're activating coming from the previous step, - * generate the address list - */ - if (direction == FORWARD) { - long count = addressTableModel.generateAddresses(); - // Error if no addresses could be generated - if (count == 0) { - JOptionPane.showMessageDialog(AddressWizard.this, - ResourceStrings.getString("add_wiz_none_available"), - ResourceStrings.getString("error_message"), - JOptionPane.ERROR_MESSAGE); - setForwardEnabled(false); - } else { - if (count != number) { - /* - * Warn if we couldn't generate the number of addresses - * requested - */ - MessageFormat form = new MessageFormat( - ResourceStrings.getString( - "generate_addresses_warning")); - Object [] args = new Object[2]; - args[0] = new Long(count); - args[1] = new Long(number); - JOptionPane.showMessageDialog(AddressWizard.this, - form.format(args), - ResourceStrings.getString("warning"), - JOptionPane.WARNING_MESSAGE); - } - setForwardEnabled(true); - } - } else { - setForwardEnabled(true); - } - } - - public boolean setInactive(int direction) { - return true; // Nothing to do when leaving - } - } - - // This step selects the macro and flags - class ConfigureStep implements WizardStep { - - // Model class for the macro list - class MacroListModel extends AbstractListModel - implements ComboBoxModel { - private Object currentValue; - private Macro data[] = null; - - public int getSize() { - if (data == null) { - try { - // If we don't have data yet, grab currently cached list - data = DataManager.get().getMacros(false); - } catch (NoTableException e) { - // can function without table - } catch (Throwable e) { - e.printStackTrace(); - } - } - - if (data == null || data.length == 0) { - return 1; - } else { - return data.length+1; - } - } - - public Object getElementAt(int index) { - if (data == null) { - try { - // If we don't have data yet, grab currently cached list - data = DataManager.get().getMacros(false); - } catch (NoTableException e) { - // can function without table - } catch (Throwable e) { - e.printStackTrace(); - } - } - if (index == 0) { - return noMacro.getKey(); - } else { - return data[index-1].getKey(); - } - } - - public void setSelectedItem(Object anItem) { - currentValue = noMacro.getKey(); - for (int i = 0; data != null && i < data.length; i++) { - if (((String)(anItem)).equals(((Macro)data[i]).getKey())) { - currentValue = anItem; - } - } - fireContentsChanged(this, -1, -1); - } - - public Object getSelectedItem() { - return currentValue; - } - - public Macro getMacroAt(int index) { - if (index == 0) { - return noMacro; - } else { - return data[index-1]; - } - } - } - - private Box stepBox; - private JComboBox macroBox; - private MacroListModel macroBoxModel; - private JButton viewButton; - private JCheckBox unusableBox; - - public ConfigureStep() { - stepBox = Box.createVerticalBox(); - - // Start with some explanatory text - JComponent component = Wizard.createTextArea( - ResourceStrings.getString("add_wiz_macro_explain"), 3, 45); - component.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(component); - // Add some spacing - stepBox.add(Box.createVerticalStrut(10)); - - // Let 'em select the macro to use - Mnemonic mnConf = - new Mnemonic(ResourceStrings.getString("add_wiz_macro_label")); - JLabel label = new JLabel(mnConf.getString()); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(label); - JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - macroBoxModel = new MacroListModel(); - macroBox = new JComboBox(macroBoxModel); - - label.setLabelFor(macroBox); - label.setToolTipText(mnConf.getString()); - label.setDisplayedMnemonic(mnConf.getMnemonic()); - - panel.add(macroBox); - // Button to view the contents of the selected macro - - Mnemonic mnView = - new Mnemonic(ResourceStrings.getString("add_wiz_view_button")); - viewButton = new JButton(mnView.getString()); - viewButton.setToolTipText(mnView.getString()); - viewButton.setMnemonic(mnView.getMnemonic()); - - panel.add(viewButton); - panel.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(panel); - - // Give the option to mark them unusable for now - component = Wizard.createTextArea( - ResourceStrings.getString("add_wiz_flag_explain"), 2, 45); - component.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(component); - unusableBox = new JCheckBox( - ResourceStrings.getString("add_wiz_unusable_label")); - unusableBox.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(unusableBox); - stepBox.add(Box.createVerticalGlue()); - - // When user presses View, show the macro's contents - viewButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - /* - * viewButton is passed as component relative to which the - * dialog should be displayed, keeping user more in - * context with the task. - */ - ViewMacroDialog d = new ViewMacroDialog( - AddressWizard.this, viewButton, - macroBoxModel.getMacroAt(macroBox.getSelectedIndex())); - d.pack(); - d.setVisible(true); - } - }); - } - - public String getDescription() { - return ResourceStrings.getString("add_wiz_configure_desc"); - } - - public Component getComponent() { - return stepBox; - } - - public void setActive(int direction) { - macroBox.setSelectedItem(macro); - unusableBox.setSelected(unusable); - setForwardEnabled(true); - } - - public boolean setInactive(int direction) { - macro = (String)macroBox.getSelectedItem(); - unusable = unusableBox.isSelected(); - return true; - } - } - - // This step selects the lease type - class LeaseStep implements WizardStep { - private Box stepBox; - private JRadioButton dynamicButton, permanentButton; - private ButtonGroup buttonGroup; - - public LeaseStep() { - stepBox = Box.createVerticalBox(); - - // Start with explanatory text - JComponent component = Wizard.createTextArea( - ResourceStrings.getString("add_wiz_lease_explain"), 0, 45); - component.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(component); - stepBox.add(Box.createVerticalStrut(10)); - - // User has choice of dynamic or permanent leases - Mnemonic mnLease = - new Mnemonic(ResourceStrings.getString("add_wiz_lease_label")); - JLabel label = new JLabel(mnLease.getString()); - JPanel panel = new JPanel(new FieldLayout(10, 0)); - label.setToolTipText(mnLease.getString()); - label.setDisplayedMnemonic(mnLease.getMnemonic()); - - panel.add(FieldLayout.LABEL, label); - buttonGroup = new ButtonGroup(); - dynamicButton = new JRadioButton( - ResourceStrings.getString("dynamic"), true); - buttonGroup.add(dynamicButton); - permanentButton = new JRadioButton( - ResourceStrings.getString("permanent"), false); - buttonGroup.add(permanentButton); - label.setLabelFor(dynamicButton); - panel.add(FieldLayout.FIELD, dynamicButton); - panel.add(FieldLayout.LABEL, new JLabel("")); - panel.add(FieldLayout.FIELD, permanentButton); - panel.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(panel); - stepBox.add(Box.createVerticalGlue()); - } - - public String getDescription() { - return ResourceStrings.getString("add_wiz_lease_desc"); - } - - public Component getComponent() { - return stepBox; - } - - public void setActive(int direction) { - dynamicButton.setSelected(dynamic); - setForwardEnabled(true); - } - - public boolean setInactive(int direction) { - dynamic = dynamicButton.isSelected(); - return true; - } - } - - // Last chance to check work before committing to it - class ReviewStep implements WizardStep { - private Box stepBox; - private JPanel panel; - private JTable addressTable; - private JLabel numberLabel; - private JLabel commentLabel; - private JLabel serverLabel; - private JLabel macroLabel; - private JLabel flagLabel; - private JLabel leaseLabel; - - public ReviewStep() { - stepBox = Box.createVerticalBox(); - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("add_wiz_review_explain"), 4, 45)); - - panel = new JPanel(new FieldLayout()); - JLabel tmpL; - - tmpL = addLabelMnemonic("add_wiz_count_label"); - numberLabel = addField("20"); - tmpL.setLabelFor(numberLabel); - - tmpL = addLabelMnemonic("add_wiz_comment_label"); - commentLabel = addField("Marketing"); - tmpL.setLabelFor(commentLabel); - - tmpL = addLabelMnemonic("add_wiz_server_label"); - serverLabel = addField("atlantic"); - tmpL.setLabelFor(serverLabel); - - tmpL = addLabelMnemonic("add_wiz_macro_label"); - macroLabel = addField("atlantic"); - tmpL.setLabelFor(macroLabel); - - tmpL = addLabel("add_wiz_review_unusable"); - flagLabel = addField("Yes"); - tmpL.setLabelFor(flagLabel); - tmpL.setToolTipText( - ResourceStrings.getString("add_wiz_review_unusable")); - - tmpL = addLabelMnemonic("add_wiz_lease_label"); - leaseLabel = addField(ResourceStrings.getString("dynamic")); - tmpL.setLabelFor(leaseLabel); - - panel.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(panel); - - stepBox.add(Box.createVerticalStrut(5)); - - Mnemonic mnAdd = - new Mnemonic(ResourceStrings.getString( - "add_wiz_confirm_label")); - JLabel label = new JLabel(mnAdd.getString()); - stepBox.add(label); - stepBox.add(Box.createVerticalStrut(2)); - addressTable = new JTable(addressTableModel); - label.setLabelFor(addressTable); - label.setToolTipText(mnAdd.getString()); - label.setDisplayedMnemonic(mnAdd.getMnemonic()); - - addressTable.setDefaultRenderer(IPAddress.class, - new ExtendedCellRenderer()); - - // Table should not be selectable in any way - addressTable.setRowSelectionAllowed(false); - addressTable.setColumnSelectionAllowed(false); - addressTable.setCellSelectionEnabled(false); - JScrollPane scrollPane = new JScrollPane(addressTable); - Dimension d = addressTable.getPreferredScrollableViewportSize(); - d.height = 50; - addressTable.setPreferredScrollableViewportSize(d); - stepBox.add(scrollPane); - stepBox.add(Box.createVerticalGlue()); - } - - private JLabel addLabel(String s) { - JLabel l = new JLabel(ResourceStrings.getString(s)); - panel.add(FieldLayout.LABEL, l); - return l; - } - - private JLabel addLabelMnemonic(String s) { - Mnemonic mnStr = - new Mnemonic(ResourceStrings.getString(s)); - JLabel l = new JLabel(mnStr.getString()); - l.setToolTipText(mnStr.getString()); - panel.add(FieldLayout.LABEL, l); - return l; - } - - private JLabel addField(String s) { - JLabel l = new JLabel(s); - l.setForeground(Color.black); - panel.add(FieldLayout.FIELD, l); - return l; - } - - public String getDescription() { - return ResourceStrings.getString("add_wiz_review_desc"); - } - - public Component getComponent() { - return stepBox; - } - - public void setActive(int direction) { - // Use number of addresses actually generated, not requested - numberLabel.setText( - String.valueOf(addressTableModel.getRowCount())); - commentLabel.setText(comment); - serverLabel.setText(server); - macroLabel.setText(macro); - if (unusable) { - flagLabel.setText(ResourceStrings.getString("yes")); - } else { - flagLabel.setText(ResourceStrings.getString("no")); - } - if (dynamic) { - leaseLabel.setText(ResourceStrings.getString("dynamic")); - } else { - leaseLabel.setText(ResourceStrings.getString("permanent")); - } - setFinishEnabled(true); - } - - public boolean setInactive(int direction) { - // Nothing to do - return true; - } - } - - public AddressWizard(Frame owner, Network net) { - super(owner, ""); - setTitle(MessageFormat.format( - ResourceStrings.getString("address_wizard_title"), net.toString())); - - network = net; - startAddress = network.getAddress(); - - try { - noMacro = new Macro(ResourceStrings.getString("no_macro_item")); - } catch (ValidationException e) { - // this should never happen! - System.err.println(e.getMessage()); - } - addressTableModel = new WizardTableModel(); - - // Create steps in order of appearance - addStep(new NumberStep()); - addStep(new ServerStep()); - addStep(new ConfirmStep()); - addStep(new ConfigureStep()); - addStep(new LeaseStep()); - addStep(new ReviewStep()); - showFirstStep(); - } - - public void doFinish() { - /* - * Method here is as follows: - * 1. Create a ProgressManager which will apprise user of our progress - * 2. Create a background thread to execute the add operations - * 3. Within the background thread, update the progress monitor - * as each address is created. - * 4. At completion, the background thread displays the error - * output, if any, before it invokes one last runnable which pops - * down and cleans up. - */ - // final so that ProgressUpdater can access it - final ProgressManager progress = new ProgressManager(this, - ResourceStrings.getString("add_wiz_progress"), "", 0, - addressTableModel.getRowCount()); - final Runnable finisher = new Runnable() { - public void run() { - reallyFinish(); - } - }; - - // Here's the thread which does the adds - Thread addThread = new Thread() { - public void run() { - DhcpNetMgr server = DataManager.get().getDhcpNetMgr(); - // Create a template object which we'll use for all the adds - DhcpClientRecord rec = new DhcpClientRecord(); - rec.setExpiration(new Date(0)); - rec.setUnusable(unusable); - rec.setPermanent(!dynamic); - try { - rec.setServerIP(serverIP); - } catch (ValidationException e) { - // Should never happen as we have a valid IP already - } - if (macro.equals(noMacro.getKey())) { - rec.setMacro(""); - } else { - rec.setMacro(macro); - } - rec.setComment(comment); - - // This is final so it can be used in the errorDisplay Runnable - final ErrorTable failedTable = new ErrorTable( - ResourceStrings.getString("address_column"), - IPAddress.class); - - /* - * For each address, create a client record and possibly a - * hosts record, log any errors for later consumption. - */ - for (int i = 0; i < addressTableModel.getRowCount(); ++i) { - Address addr = addressTableModel.getAddressAt(i); - try { - rec.setClientIP(addr.addr); - rec.setClientName(addr.name); - server.addClient(rec, network.toString()); - progress.update(i+1, addr.addr.toString()); - } catch (InterruptedException e) { - SwingUtilities.invokeLater(finisher); - return; - } catch (Throwable e) { - // Pick the best message for the exception thrown - String msg; - if (e instanceof ExistsException) { - msg = ResourceStrings.getString("address_exists"); - } else if (e instanceof HostExistsException) { - msg = ResourceStrings.getString("host_exists"); - } else { - msg = e.getMessage(); - } - failedTable.addError(addr.addr, msg); - } - } - - // If any errors occurred, display them all at once. - if (!failedTable.isEmpty()) { - Runnable errorDisplay = new Runnable() { - public void run() { - Object [] objs = new Object[2]; - objs[0] = - ResourceStrings.getString("add_wiz_error"); - JScrollPane scrollPane = - new JScrollPane(failedTable); - // Resize the table to something kind of small - Dimension d = - failedTable. - getPreferredScrollableViewportSize(); - d.height = 80; - failedTable.setPreferredScrollableViewportSize(d); - objs[1] = scrollPane; - JOptionPane.showMessageDialog(AddressWizard.this, - objs, - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - }; - try { - SwingUtilities.invokeAndWait(errorDisplay); - } catch (Throwable e) { - e.printStackTrace(); - } - } - SwingUtilities.invokeLater(finisher); - } - }; - addThread.start(); - } - - protected void reallyFinish() { - super.doFinish(); - } - - public void doHelp() { - DhcpmgrApplet.showHelp("address_wizard"); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ConfigWizard.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ConfigWizard.java deleted file mode 100644 index 0f240cb654..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ConfigWizard.java +++ /dev/null @@ -1,1187 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.text.MessageFormat; -import java.net.*; - -import javax.swing.*; -import javax.swing.table.*; -import javax.swing.event.*; -import javax.swing.border.*; - -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.bridge.BridgeException; -import com.sun.dhcpmgr.bridge.ExistsException; - -/** - * This wizard configures the DHCP service. It also has a mode switch so - * that it is also usable for just adding a single network, so that in - * the tool it actually performs the Network Wizard function as well. - */ -public class ConfigWizard extends DSWizard { - private boolean fullConfig; - private DhcpServiceMgr server; - private int leaseLength = 3600*24; - private boolean leaseNegotiable = true; - private String dnsDomain; - private Vector dnsServs; - private Network network; - private boolean isLan = true; - private boolean routerDiscovery = true; - private IPAddress router = null; - private String nisDomain; - private Vector nisServs; - private static final String [] unitChoices = { - ResourceStrings.getString("cfg_wiz_hours"), - ResourceStrings.getString("cfg_wiz_days"), - ResourceStrings.getString("cfg_wiz_weeks") }; - private static final int [] unitMultiples = { 60*60, 24*60*60, 7*24*60*60 }; - - // This step specifies lease length and renewal policies for the server - class LeaseStep implements WizardStep { - private IntegerField length; - private JComboBox units; - private JCheckBox negotiable; - private Box stepBox; - - public LeaseStep() { - stepBox = Box.createVerticalBox(); - - // Explanatory text - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("cfg_wiz_lease_explain"), 3, 45)); - - // Need to input a number together with units - JPanel flowPanel = new JPanel(); - - Mnemonic mnLease = - new Mnemonic(ResourceStrings.getString("cfg_wiz_lease_length")); - JLabel lblLeaseLen = new JLabel( - mnLease.getString()); - - flowPanel.add(lblLeaseLen); - - // Use a box for the value and units to keep together in layout - Box leaseBox = Box.createHorizontalBox(); - length = new IntegerField(); - leaseBox.add(length); - leaseBox.add(Box.createHorizontalStrut(5)); - - lblLeaseLen.setLabelFor(length); - lblLeaseLen.setToolTipText(mnLease.getString()); - lblLeaseLen.setDisplayedMnemonic(mnLease.getMnemonic()); - - units = new JComboBox(unitChoices); - leaseBox.add(units); - flowPanel.add(leaseBox); - stepBox.add(flowPanel); - stepBox.add(Box.createVerticalStrut(10)); - - // Explain negotiable, provide selection for it - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("cfg_wiz_negotiable_explain"), 6, - 45)); - - negotiable = new JCheckBox( - ResourceStrings.getString("cfg_wiz_negotiable"), true); - negotiable.setToolTipText( - ResourceStrings.getString("cfg_wiz_negotiable")); - negotiable.setAlignmentX(Component.CENTER_ALIGNMENT); - stepBox.add(negotiable); - stepBox.add(Box.createVerticalGlue()); - } - - public String getDescription() { - return ResourceStrings.getString("cfg_wiz_lease_desc"); - } - - public Component getComponent() { - return stepBox; - } - - public void setActive(int direction) { - setForwardEnabled(true); - // Set the units field to the maximum unit this value expresses - int lengthVal = 0; - int i; - for (i = unitMultiples.length - 1; i >= 0; --i) { - lengthVal = leaseLength / unitMultiples[i]; - if (lengthVal != 0) { - if (leaseLength % unitMultiples[i] == 0) { - break; - } - } - } - if (i == -1) { - i = 0; - } - units.setSelectedIndex(i); - length.setValue(lengthVal); - negotiable.setSelected(leaseNegotiable); - } - - public boolean setInactive(int direction) { - // Leases cannot be zero length - long lease = (long)length.getValue(); - if (lease == 0) { - JOptionPane.showMessageDialog(ConfigWizard.this, - ResourceStrings.getString("cfg_wiz_zero_lease"), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return false; - } - int multiplier = unitMultiples[units.getSelectedIndex()]; - lease *= multiplier; - if (lease > Integer.MAX_VALUE) { - // Value is too large - MessageFormat form = new MessageFormat( - ResourceStrings.getString("cfg_wiz_lease_overflow")); - Object args = new Object[] { - new Integer(Integer.MAX_VALUE / multiplier), - units.getSelectedItem() - }; - JOptionPane.showMessageDialog(ConfigWizard.this, - form.format(args), ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return false; - } - leaseLength = (int)lease; - leaseNegotiable = negotiable.isSelected(); - return true; - } - } - - // Step to configure DNS - class DnsStep implements WizardStep { - private NoSpaceField domain; - private IPAddressList serverList; - private Box stepBox; - private boolean firstActive = true; - - public DnsStep() { - stepBox = Box.createVerticalBox(); - - // Explanatory text - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("cfg_wiz_dns_explain"), 5, 45)); - stepBox.add(Box.createVerticalStrut(10)); - - // Domain first - JPanel fieldPanel = new JPanel(new FieldLayout()); - - Mnemonic mnDNS = - new Mnemonic(ResourceStrings.getString("cfg_wiz_dns_domain")); - JLabel jlDNSDomain = new JLabel(mnDNS.getString()); - fieldPanel.add(FieldLayout.LABEL, jlDNSDomain); - - domain = new NoSpaceField(); - jlDNSDomain.setLabelFor(domain); - jlDNSDomain.setToolTipText(mnDNS.getString()); - jlDNSDomain.setDisplayedMnemonic(mnDNS.getMnemonic()); - fieldPanel.add(FieldLayout.FIELD, domain); - stepBox.add(fieldPanel); - - serverList = new IPAddressList(); - Border tb = BorderFactory.createTitledBorder( - BorderFactory.createLineBorder(Color.black), - ResourceStrings.getString("cfg_wiz_dns_servers")); - serverList.setBorder(BorderFactory.createCompoundBorder(tb, - BorderFactory.createEmptyBorder(5, 5, 5, 5))); - stepBox.add(serverList); - } - - public String getDescription() { - return ResourceStrings.getString("cfg_wiz_dns_desc"); - } - - public Component getComponent() { - return stepBox; - } - - public void setActive(int direction) { - setForwardEnabled(true); - - // First time through, ask the server for the defaults - if (firstActive) { - firstActive = false; - try { - domain.setText( - server.getStringOption(StandardOptions.CD_DNSDOMAIN, - "")); - serverList.setAddressList( - server.getIPOption(StandardOptions.CD_DNSSERV, "")); - } catch (Throwable e) { - // Ignore errors, we're just supplying defaults - } - } - } - - public boolean setInactive(int direction) { - if (direction == FORWARD) { - /* - * Either must supply both a domain and a list of servers, or - * neither - */ - if ((domain.getText().length() == 0) - != (serverList.getListSize() == 0)) { - JOptionPane.showMessageDialog(ConfigWizard.this, - ResourceStrings.getString("cfg_wiz_dns_both"), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return false; - } - } - dnsDomain = domain.getText(); - dnsServs = serverList.getAddressList(); - return true; - } - } - - // Select the network to configure - class NetworkStep implements WizardStep { - private JComboBox networkBox; - private NetworkListModel networkListModel; - private IPAddressField mask; - private Box stepBox; - private boolean firstActive = true; - private Hashtable maskTable; - - // Model for the list of networks - class NetworkListModel extends AbstractListModel - implements ComboBoxModel { - private Object currentValue; - private String [] data = null; - - public int getSize() { - if (data == null) { - return 0; - } else { - return data.length; - } - } - - public Object getElementAt(int index) { - if (data == null) { - return null; - } else { - return data[index]; - } - } - - public void setSelectedItem(Object anItem) { - currentValue = anItem; - fireContentsChanged(this, -1, -1); - } - - public Object getSelectedItem() { - return currentValue; - } - - public void setData(Vector addrs) { - data = new String[addrs.size()]; - addrs.copyInto(data); - fireContentsChanged(this, 0, data.length); - } - } - - /* - * Editor for the Network combo box, ensures that a valid IP address - * is entered. This implementation cribbed from Swing's - * BasicComboBoxEditor in plaf/basic - */ - class NetworkComboBoxEditor implements ComboBoxEditor, FocusListener { - private IPAddressField editor; - - public NetworkComboBoxEditor() { - editor = new IPAddressField(); - editor.addFocusListener(this); - } - - public Component getEditorComponent() { - return editor; - } - - public void setItem(Object obj) { - if (obj != null) { - editor.setText((String)obj); - } else { - editor.setText(""); - } - } - - public Object getItem() { - return editor.getText(); - } - - public void selectAll() { - editor.selectAll(); - editor.requestFocus(); - } - - public void focusGained(FocusEvent e) { - } - - public void focusLost(FocusEvent e) { - } - - public void addActionListener(ActionListener l) { - editor.addActionListener(l); - } - - public void removeActionListener(ActionListener l) { - editor.removeActionListener(l); - } - } - - public NetworkStep() { - stepBox = Box.createVerticalBox(); - - // Start with intro text, depending on mode. - if (fullConfig) { - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("cfg_wiz_network_explain"), 4, - 45)); - } else { - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("net_wiz_net_explain"), 6, 45)); - } - stepBox.add(Box.createVerticalStrut(10)); - - JPanel panel = new JPanel(new FieldLayout()); - Mnemonic mnAddr = - new Mnemonic(ResourceStrings.getString("cfg_wiz_network")); - JLabel jlNetworkAddr = new JLabel(mnAddr.getString()); - panel.add(FieldLayout.LABEL, jlNetworkAddr); - networkListModel = new NetworkListModel(); - networkBox = new JComboBox(networkListModel); - networkBox.setEditable(true); - networkBox.setEditor(new NetworkComboBoxEditor()); - panel.add(FieldLayout.FIELD, networkBox); - jlNetworkAddr.setLabelFor(networkBox); - jlNetworkAddr.setToolTipText(mnAddr.getString()); - jlNetworkAddr.setDisplayedMnemonic(mnAddr.getMnemonic()); - - // Label and text field for subnet mask - Mnemonic mnMask = - new Mnemonic(ResourceStrings.getString("cfg_wiz_mask")); - JLabel addrLbl = - new JLabel(mnMask.getString()); - addrLbl.setToolTipText(mnMask.getString()); - panel.add(FieldLayout.LABEL, addrLbl); - mask = new IPAddressField(); - addrLbl.setLabelFor(mask); - addrLbl.setDisplayedMnemonic(mnMask.getMnemonic()); - - panel.add(FieldLayout.FIELD, mask); - stepBox.add(panel); - - stepBox.add(Box.createVerticalStrut(10)); - - if (fullConfig) { - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("cfg_wiz_network_explainmore"), 4, - 45)); - } - stepBox.add(Box.createVerticalGlue()); - - /* - * Listen to selection changes on the network box and change the - * netmask accordingly. - */ - networkBox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - String s = (String)e.getItem(); - IPAddress a = (IPAddress)maskTable.get(s); - if (a != null) { - // We know the correct value, so set it - mask.setValue(a); - } - } - } - }); - } - - public String getDescription() { - return ResourceStrings.getString("cfg_wiz_network_desc"); - } - - public Component getComponent() { - return stepBox; - } - - public void setActive(int direction) { - setForwardEnabled(true); - if (firstActive) { - firstActive = false; - maskTable = new Hashtable(); - try { - /* - * Initialize list to all networks directly attached to - * the server - */ - IPInterface[] ifs = new IPInterface[0]; - try { - ifs = server.getInterfaces(); - } catch (BridgeException e) { - // we're not configured yet, apparently - ifs = null; - } - Vector addrs = new Vector(); - - // Get list of already-configured networks - Network [] nets = new Network[0]; - try { - nets = DataManager.get().getNetworks(true); - } catch (BridgeException e) { - // Ignore; we're not configured yet, apparently - } - /* - * Now filter the list so only unconfigured networks - * show up in the selection list. - */ - if (ifs != null) { - for (int i = 0; i < ifs.length; ++i) { - boolean alreadyConfigured = false; - for (int j = 0; j < nets.length; ++j) { - if (ifs[i].getNetwork().equals(nets[j])) { - alreadyConfigured = true; - break; - } - } - if (!alreadyConfigured) { - // Add to list - String s = ifs[i].getNetwork(). - getNetworkNumber().getHostAddress(); - addrs.addElement(s); - // Save netmask for retrieval later - maskTable.put(s, ifs[i].getNetwork().getMask()); - } - } - } - networkListModel.setData(addrs); - if (networkBox.getItemCount() > 0) { - networkBox.setSelectedIndex(0); - } - } catch (Throwable e) { - // Do nothing, we're just setting defaults - e.printStackTrace(); - } - } - } - - public boolean setInactive(int direction) { - if (direction == FORWARD) { - try { - network = new Network((String)networkBox.getSelectedItem()); - if (mask.getValue() == null) { - /* - * Check for empty, in which case we just let the - * default happen - */ - if (mask.getText().length() != 0) { - // Not a valid subnet mask - MessageFormat form = new MessageFormat( - ResourceStrings.getString("cfg_wiz_bad_mask")); - Object [] args = new Object[1]; - args[0] = mask.getText(); - JOptionPane.showMessageDialog(ConfigWizard.this, - form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return false; - } - } else { - network.setMask(mask.getValue()); - } - - // Check for network already configured, error if so - Network [] nets = new Network[0]; - try { - nets = DataManager.get().getNetworks(false); - } catch (BridgeException e) { - // Ignore; must not be configured yet - } - for (int i = 0; i < nets.length; ++i) { - if (network.equals(nets[i])) { - MessageFormat form = new MessageFormat( - ResourceStrings.getString( - "cfg_wiz_network_configured")); - Object [] args = new Object[1]; - args[0] = network.getAddress().getHostAddress(); - JOptionPane.showMessageDialog(ConfigWizard.this, - form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return false; - } - } - } catch (ValidationException e) { - // Not a valid IP address - MessageFormat form = new MessageFormat( - ResourceStrings.getString("cfg_wiz_bad_network")); - Object [] args = new Object[1]; - args[0] = (String)networkBox.getSelectedItem(); - if (args[0] == null) { - args[0] = ""; - } - JOptionPane.showMessageDialog(ConfigWizard.this, - form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return false; - } catch (Throwable e) { - e.printStackTrace(); - // Ignore other exceptions - } - } - return true; - } - } - - // Get the type of network and routing policy - class NetTypeStep implements WizardStep { - private JRadioButton lan, ptp; - private ButtonGroup typeGroup, routingGroup; - private JRadioButton discover, specify; - private IPAddressField address; - private Box stepBox; - private boolean firstTime = true; - - public NetTypeStep() { - stepBox = Box.createVerticalBox(); - - // Explanatory text at the top - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("cfg_wiz_nettype_explain"), 2, 45)); - stepBox.add(Box.createVerticalStrut(10)); - - // Label and radio buttons for type of network - JPanel panel = new JPanel(new GridLayout(2, 1)); - /* - * Create a compound border with empty space on the outside and - * a line border on the inside, then title it amd put a space - * around the outside. - */ - Border b = BorderFactory.createCompoundBorder( - BorderFactory.createEmptyBorder(0, 5, 0, 5), - BorderFactory.createLineBorder(Color.black)); - Border tb = BorderFactory.createTitledBorder(b, - ResourceStrings.getString("cfg_wiz_nettype_label")); - panel.setBorder(BorderFactory.createCompoundBorder(tb, - BorderFactory.createEmptyBorder(0, 5, 0, 5))); - - lan = new JRadioButton(ResourceStrings.getString("cfg_wiz_lan"), - true); - lan.setToolTipText(ResourceStrings.getString("cfg_wiz_lan")); - typeGroup = new ButtonGroup(); - typeGroup.add(lan); - panel.add(lan); - ptp = new JRadioButton(ResourceStrings.getString("cfg_wiz_point"), - false); - ptp.setToolTipText(ResourceStrings.getString("cfg_wiz_point")); - typeGroup.add(ptp); - panel.add(ptp); - stepBox.add(panel); - stepBox.add(Box.createVerticalStrut(20)); - - // Routing policy - panel = new JPanel(new GridLayout(2, 1)); - tb = BorderFactory.createTitledBorder(b, - ResourceStrings.getString("cfg_wiz_routing_label")); - panel.setBorder(BorderFactory.createCompoundBorder(tb, - BorderFactory.createEmptyBorder(0, 5, 0, 5))); - - discover = new JRadioButton( - ResourceStrings.getString("cfg_wiz_router_discovery"), true); - discover.setToolTipText(ResourceStrings.getString( - "cfg_wiz_router_discovery")); - routingGroup = new ButtonGroup(); - routingGroup.add(discover); - panel.add(discover); - - Box routerBox = Box.createHorizontalBox(); - specify = new JRadioButton( - ResourceStrings.getString("cfg_wiz_router_specify"), false); - specify.setToolTipText(ResourceStrings.getString( - "cfg_wiz_router_specify")); - routingGroup.add(specify); - routerBox.add(specify); - routerBox.add(Box.createHorizontalStrut(2)); - address = new IPAddressField(); - address.setEnabled(false); // Start off disabled - address.setMaximumSize(address.getPreferredSize()); - - // Box is sensitive to alignment, make sure they all agree - address.setAlignmentY(specify.getAlignmentY()); - - routerBox.add(address); - panel.add(routerBox); - stepBox.add(panel); - - stepBox.add(Box.createVerticalStrut(10)); - stepBox.add(Box.createVerticalGlue()); - - /* - * Enable forward if router discovery, or if specifying router and - * address is not empty. - */ - specify.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - address.setEnabled(specify.isSelected()); - setForwardEnabled(!specify.isSelected() - || (address.getText().length() != 0)); - } - }); - - // Enable forward when address is not empty. - address.getDocument().addDocumentListener(new DocumentListener() { - public void insertUpdate(DocumentEvent e) { - setForwardEnabled(address.getText().length() != 0); - } - public void changedUpdate(DocumentEvent e) { - insertUpdate(e); - } - public void removeUpdate(DocumentEvent e) { - insertUpdate(e); - } - }); - } - - public String getDescription() { - return ResourceStrings.getString("cfg_wiz_nettype_desc"); - } - - public Component getComponent() { - return stepBox; - } - - public void setActive(int direction) { - setForwardEnabled(true); - lan.setSelected(isLan); - discover.setSelected(routerDiscovery); - address.setValue(router); - } - - public boolean setInactive(int direction) { - isLan = lan.isSelected(); - if (direction == FORWARD) { - routerDiscovery = discover.isSelected(); - if (!routerDiscovery) { - IPAddress addr = address.getValue(); - if (addr == null) { - // Invalid IP address - MessageFormat form = new MessageFormat( - ResourceStrings.getString( - "cfg_wiz_router_addr_err")); - Object [] args = new Object[1]; - args[0] = address.getText(); - JOptionPane.showMessageDialog(ConfigWizard.this, - form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return false; - } else if (!network.containsAddress(addr)) { - // Router is not on the network we're configuring - MessageFormat form = new MessageFormat( - ResourceStrings.getString( - "cfg_wiz_router_net_err")); - Object [] args = new Object[2]; - args[0] = address.getText(); - args[1] = network.toString(); - JOptionPane.showMessageDialog(ConfigWizard.this, - form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return false; - } - router = addr; - } - } - return true; - } - } - - // Get the NIS configuration - class NisStep implements WizardStep { - private NoSpaceField domain; - private Box stepBox; - private IPAddressField address; - private JButton add, delete, moveUp, moveDown; - private IPAddressList serverList; - boolean firstActive = true; - - public NisStep() { - stepBox = Box.createVerticalBox(); - - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("cfg_wiz_nis_explain"), 6, 45)); - stepBox.add(Box.createVerticalStrut(10)); - - JPanel fieldPanel = new JPanel(new FieldLayout()); - Mnemonic mnNis = - new Mnemonic(ResourceStrings.getString("cfg_wiz_nis_domain")); - JLabel jlNISDomain = - new JLabel(mnNis.getString()); - fieldPanel.add(FieldLayout.LABEL, jlNISDomain); - domain = new NoSpaceField(); - jlNISDomain.setLabelFor(domain); - jlNISDomain.setToolTipText(mnNis.getString()); - jlNISDomain.setDisplayedMnemonic(mnNis.getMnemonic()); - fieldPanel.add(FieldLayout.FIELD, domain); - stepBox.add(fieldPanel); - - serverList = new IPAddressList(); - Border tb = BorderFactory.createTitledBorder( - BorderFactory.createLineBorder(Color.black), - ResourceStrings.getString("cfg_wiz_nis_servers")); - serverList.setBorder(BorderFactory.createCompoundBorder(tb, - BorderFactory.createEmptyBorder(5, 5, 5, 5))); - stepBox.add(serverList); - } - - public String getDescription() { - return ResourceStrings.getString("cfg_wiz_nis_desc"); - } - - public Component getComponent() { - return stepBox; - } - - public void setActive(int direction) { - setForwardEnabled(true); - if (firstActive) { - firstActive = false; - try { - /* - * Order here is important; do the servers first because if - * there's an error, we don't retrieve a domain name, which - * appears to never fail. - */ - serverList.setAddressList( - server.getIPOption(StandardOptions.CD_NIS_SERV, "")); - domain.setText( - server.getStringOption(StandardOptions.CD_NIS_DOMAIN, - "")); - } catch (Throwable e) { - // Do nothing, just setting defaults - } - } - } - - public boolean setInactive(int direction) { - if (direction == FORWARD) { - /* - * Either must supply both a domain and a list of servers, or - * neither - */ - if ((domain.getText().length() == 0) - != (serverList.getListSize() == 0)) { - JOptionPane.showMessageDialog(ConfigWizard.this, - ResourceStrings.getString("cfg_wiz_nis_both"), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return false; - } - } - nisDomain = domain.getText(); - nisServs = serverList.getAddressList(); - return true; - } - } - - class ReviewStep implements WizardStep { - private JLabel storeLabel; - private JLabel leaseLabel; - private JLabel networkLabel; - private JLabel netTypeLabel; - private JLabel netmaskLabel; - private JLabel routerLabel; - private JLabel dnsLabel; - private JLabel dnsServLabel; - private JLabel nisLabel; - private JLabel nisServLabel; - private JPanel panel; - private JScrollPane scrollPane; - - public ReviewStep() { - Box stepBox = Box.createVerticalBox(); - if (fullConfig) { - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("cfg_wiz_review_explain"), 3, - 45)); - } else { - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("net_wiz_review_explain"), 3, - 45)); - } - - panel = new JPanel(new FieldLayout()); - JLabel jlTmp; - - if (fullConfig) { - addLabel("cfg_wiz_datastore"); - storeLabel = addField("uninitialized"); - - jlTmp = addLabelMnemonic("cfg_wiz_lease_length"); - leaseLabel = addField("1 day"); - - jlTmp = addLabelMnemonic("cfg_wiz_dns_domain"); - dnsLabel = addField("Bar.Sun.COM"); - - addLabel("cfg_wiz_dns_servers"); - dnsServLabel = addField("109.151.1.15, 109.148.144.2"); - } - - jlTmp = addLabelMnemonic("cfg_wiz_network"); - networkLabel = addField("109.148.21.0"); - jlTmp.setLabelFor(networkLabel); - - jlTmp = addLabelMnemonic("cfg_wiz_mask"); - netmaskLabel = addField("255.255.255.0"); - jlTmp.setLabelFor(netmaskLabel); - - addLabel("cfg_wiz_nettype"); - netTypeLabel = addField(ResourceStrings.getString("cfg_wiz_lan")); - - addLabel("cfg_wiz_router"); - routerLabel = addField( - ResourceStrings.getString("cfg_wiz_router_discovery")); - - jlTmp = addLabelMnemonic("cfg_wiz_nis_domain"); - nisLabel = addField("Foo.Bar.Sun.COM"); - jlTmp.setLabelFor(nisLabel); - - addLabel("cfg_wiz_nis_servers"); - nisServLabel = addField("109.148.21.21, 109.148.21.44"); - - stepBox.add(panel); - stepBox.add(Box.createVerticalGlue()); - - scrollPane = new JScrollPane(stepBox, - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - } - - private void addLabel(String s) { - JLabel jl; - jl = new JLabel(ResourceStrings.getString(s)); - panel.add(FieldLayout.LABEL, jl); - jl.setLabelFor(panel); - jl.setToolTipText(ResourceStrings.getString(s)); - } - - private JLabel addLabelMnemonic(String s) { - JLabel jl; - Mnemonic mnStr = - new Mnemonic(ResourceStrings.getString(s)); - jl = new JLabel(mnStr.getString()); - panel.add(FieldLayout.LABEL, jl); - jl.setToolTipText(mnStr.getString()); - return jl; - } - - private JLabel addField(String s) { - JLabel l = new JLabel(s); - l.setForeground(Color.black); - panel.add(FieldLayout.FIELD, l); - l.setLabelFor(panel); - l.setToolTipText(s); - return l; - } - - public String getDescription() { - return ResourceStrings.getString("cfg_wiz_review_desc"); - } - - public Component getComponent() { - return scrollPane; - } - - public void setActive(int direction) { - StringBuffer b = new StringBuffer(); - setFinishEnabled(true); - if (fullConfig) { - storeLabel.setText(getDsconf().getModule().getDescription()); - - // Display lease length, reducing to largest units possible - int lengthVal = 0; - int i; - for (i = unitMultiples.length - 1; i >= 0; --i) { - lengthVal = leaseLength / unitMultiples[i]; - if ((lengthVal != 0) - && (leaseLength % unitMultiples[i] == 0)) { - break; - } - } - if (i == -1) { - i = 0; - } - Object [] objs = new Object[3]; - objs[0] = new Integer(lengthVal); - objs[1] = unitChoices[i]; - if (leaseNegotiable) { - objs[2] = ResourceStrings.getString("cfg_wiz_renewable"); - } else { - objs[2] = ResourceStrings.getString("cfg_wiz_nonrenewable"); - } - leaseLabel.setText(MessageFormat.format( - ResourceStrings.getString("cfg_wiz_lease_fmt"), objs)); - - // Set DNS info - dnsLabel.setText(dnsDomain); - b.setLength(0); - Enumeration en = dnsServs.elements(); - while (en.hasMoreElements()) { - IPAddress a = (IPAddress)en.nextElement(); - if (b.length() != 0) { - b.append(", "); - } - b.append(a.getHostAddress()); - } - dnsServLabel.setText(b.toString()); - } - - // Set network address - networkLabel.setText(network.toString()); - // Set subnet mask - netmaskLabel.setText(network.getMask().getHostAddress()); - - // Set network type - if (isLan) { - netTypeLabel.setText(ResourceStrings.getString("cfg_wiz_lan")); - } else { - netTypeLabel.setText( - ResourceStrings.getString("cfg_wiz_point")); - } - - // Set router - if (routerDiscovery) { - routerLabel.setText( - ResourceStrings.getString("cfg_wiz_router_discovery")); - } else { - routerLabel.setText(router.getHostAddress()); - } - - // Set NIS info - nisLabel.setText(nisDomain); - b.setLength(0); - Enumeration en = nisServs.elements(); - while (en.hasMoreElements()) { - IPAddress a = (IPAddress)en.nextElement(); - if (b.length() != 0) { - b.append(", "); - } - b.append(a.getHostAddress()); - } - nisServLabel.setText(b.toString()); - } - - public boolean setInactive(int direction) { - return true; - } - } - - public ConfigWizard(Frame owner, String title, boolean fullConfig) { - super(owner, title); - - try { - server = DataManager.get().getDhcpServiceMgr(); - if (fullConfig) { - dsconfList = new DSConfList(); - dsconfList.init(server); - } - } catch (Throwable e) { - e.printStackTrace(); // XXX Need to do something to handle this... - return; - } - - this.fullConfig = fullConfig; - - // If running as Config Wizard, put in the initial steps. - if (fullConfig) { - addStep(new DatastoreStep( - ResourceStrings.getString("cfg_wiz_explain"), - ResourceStrings.getString("cfg_wiz_store_explain"))); - addStep(new DatastoreModuleStep()); - addStep(new LeaseStep()); - addStep(new DnsStep()); - } - // Now the steps that are common to both wizards. - addStep(new NetworkStep()); - addStep(new NetTypeStep()); - addStep(new NisStep()); - addStep(new ReviewStep()); - showFirstStep(); - } - - public void doFinish() { - /* - * To activate the server, we have to do the following items: - * 1. Create the location/path if necessary. - * 2. Create the defaults file. - * 3. Create the dhcptab; ignore errors if it already exists - * (as in NIS+ case) - * 4. Create the Locale macro; ignore the error if it already exists - * 5. Create the server macro; if it exists we just overwrite it - * 6. Create the network macro; - * 7. Create the network table - * 8. Start the service - */ - if (fullConfig) { - getDsconf().setConfig(); - getDsconf().setLocation(); - // Create the location/path. - try { - server.makeLocation(getDsconf().getDS()); - } catch (ExistsException e) { - // this is o.k. - } catch (Throwable e) { - MessageFormat form = new MessageFormat( - ResourceStrings.getString("create_location_error")); - Object [] args = new Object[1]; - args[0] = getDsconf().getDS().getLocation(); - String msg = form.format(args); - JOptionPane.showMessageDialog(ConfigWizard.this, - msg, - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - return; - } - - // Create the defaults file. - DhcpdOptions options = new DhcpdOptions(); - options.setDaemonEnabled(true); - options.setDhcpDatastore(getDsconf().getDS()); - try { - server.writeDefaults(options); - } catch (Throwable e) { - e.printStackTrace(); - return; - } - - // Create the dhcptab - try { - DataManager.get().getDhcptabMgr().createDhcptab(); - } catch (Throwable e) { - // Not an error; some data stores are shared by multiple servers - } - } - - if (fullConfig) { - try { - DataManager.get().getDhcptabMgr().createLocaleMacro(); - } catch (Throwable e) { - /* - * Ignore this error, if one's already there we'll assume - * it's correct - */ - } - - // Create the Server macro - try { - String svrName = - DataManager.get().getDhcpServiceMgr().getShortServerName(); - InetAddress svrAddress = - DataManager.get().getDhcpServiceMgr().getServerAddress(); - DataManager.get().getDhcptabMgr().createServerMacro(svrName, - svrAddress, leaseLength, leaseNegotiable, dnsDomain, - dnsServs); - } catch (Throwable e) { - // Couldn't create it; inform user because this is serious - Object [] args = new Object[2]; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("create_macro_error")); - args[0] = DataManager.get().getShortServerName(); - args[1] = e.getMessage(); - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - return; - } - } - - // Create the network macro - IPAddress [] routers = null; - if (router != null) { - routers = new IPAddress[] { router }; - } - try { - DataManager.get().getDhcptabMgr().createNetworkMacro(network, - routers, isLan, nisDomain, nisServs); - } catch (Throwable e) { - // Ignore this error? dhcpconfig gives a merge option - } - - // Create the network table - try { - DataManager.get().getDhcpNetMgr().createNetwork(network.toString()); - } catch (BridgeException e) { - // This indicates table existed; no error - } catch (Throwable e) { - Object [] args = new Object[2]; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("create_network_table_error")); - args[0] = network.toString(); - args[1] = e.getMessage(); - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - return; - } - - // Start the server in the initial configuration case - if (fullConfig) { - try { - DataManager.get().getDhcpServiceMgr().startup(); - } catch (Throwable e) { - // Just warn user; this isn't disastrous - Object [] args = new Object[1]; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("startup_server_error")); - args[0] = e.getMessage(); - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.WARNING_MESSAGE); - } - } - - super.doFinish(); - } - - public void doHelp() { - if (fullConfig) { - DhcpmgrApplet.showHelp("config_wizard"); - } else { - DhcpmgrApplet.showHelp("network_wizard"); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ConfigureChoiceDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ConfigureChoiceDialog.java deleted file mode 100644 index 6cd7ec9df0..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ConfigureChoiceDialog.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.border.*; -import java.awt.event.*; -import java.awt.*; - -import com.sun.dhcpmgr.ui.*; - -/** - * Dialog to select which type of server we want: full DHCP or just a BOOTP - * relay. This is implemented as a singleton modal so the caller can't do - * anything until it returns a selection. - */ -public class ConfigureChoiceDialog extends JDialog - implements ButtonPanelListener { - private ButtonPanel buttonPanel; - private ButtonGroup buttonGroup; - private JRadioButton dhcp, bootp; - /** - * Returned if user decides choice is "none of the above" - */ - public static final int CANCELLED = 0; - /** - * Return value if user wants DHCP service - */ - public static final int DHCP = 1; - /** - * Return value if user wants BOOTP relay - */ - public static final int BOOTP = 2; - private static int value = CANCELLED; - - // Must use the showDialog method to get one of these. - private ConfigureChoiceDialog(Frame f) { - super(f, true); - setTitle(ResourceStrings.getString("configure_choice_title")); - setLocationRelativeTo(f); - - getContentPane().setLayout(new BorderLayout()); - - JPanel panel = new JPanel(new BorderLayout()); - panel.setBorder( - BorderFactory.createCompoundBorder( - BorderFactory.createEtchedBorder(), - BorderFactory.createEmptyBorder(10, 20, 10, 20))); - - // Explanatory text at the top - panel.add(Wizard.createTextArea( - ResourceStrings.getString("configure_choice_explain"), 5, 30), - BorderLayout.NORTH); - - // Just show the choices as a set of radio buttons - buttonGroup = new ButtonGroup(); - dhcp = new JRadioButton( - ResourceStrings.getString("configure_dhcp_server"), true); - dhcp.setToolTipText(ResourceStrings.getString("configure_dhcp_server")); - buttonGroup.add(dhcp); - Box box = Box.createVerticalBox(); - box.add(dhcp); - box.add(Box.createVerticalStrut(5)); - bootp = new JRadioButton( - ResourceStrings.getString("configure_bootp_relay"), false); - bootp.setToolTipText( - ResourceStrings.getString("configure_bootp_relay")); - buttonGroup.add(bootp); - box.add(bootp); - panel.add(box, BorderLayout.SOUTH); - getContentPane().add(panel, BorderLayout.NORTH); - - buttonPanel = new ButtonPanel(false); - buttonPanel.addButtonPanelListener(this); - buttonPanel.setOkEnabled(true); - getContentPane().add(buttonPanel, BorderLayout.SOUTH); - } - - public void buttonPressed(int buttonId) { - switch (buttonId) { - case OK: - if (dhcp.isSelected()) { - value = DHCP; - } else { - value = BOOTP; - } - setVisible(false); - break; - case CANCEL: - value = CANCELLED; - setVisible(false); - break; - case HELP: - DhcpmgrApplet.showHelp("server_config"); - break; - } - } - - public static int showDialog(Frame f) { - ConfigureChoiceDialog d = new ConfigureChoiceDialog(f); - d.pack(); - d.setVisible(true); - d.dispose(); - return value; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ConfigureRelayDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ConfigureRelayDialog.java deleted file mode 100644 index f92f17129c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ConfigureRelayDialog.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.table.*; -import javax.swing.border.*; -import javax.swing.event.*; - -import java.awt.*; -import java.awt.event.*; -import java.text.*; -import java.util.*; -import java.net.*; - -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; - -/** - * Dialog to configure the server as a BOOTP relay. - */ -public class ConfigureRelayDialog extends DhcpmgrDialog { - private IPAddressList serverList; - - public ConfigureRelayDialog(Frame f) { - super(f, false); - - setTitle(ResourceStrings.getString("configure_relay_title")); - buttonPanel.setOkEnabled(true); - } - - protected JPanel getMainPanel() { - JPanel panel = new JPanel(new BorderLayout()); - panel.setBorder( - BorderFactory.createCompoundBorder( - BorderFactory.createEtchedBorder(), - BorderFactory.createEmptyBorder(10, 20, 10, 20))); - - // Put some explanatory text at the top. - panel.add(Wizard.createTextArea( - ResourceStrings.getString("configure_relay_explain"), 3, 30), - BorderLayout.NORTH); - - // Control for entering a list of servers - serverList = new IPAddressList(); - Border tb = BorderFactory.createTitledBorder( - BorderFactory.createLineBorder(Color.black), - ResourceStrings.getString("dhcp_servers")); - serverList.setBorder(BorderFactory.createCompoundBorder(tb, - BorderFactory.createEmptyBorder(5, 5, 5, 5))); - panel.add(serverList, BorderLayout.SOUTH); - - return panel; - } - - protected void doOk() { - if (serverList.getListSize() == 0) { - // Must enter at least one DHCP server - JOptionPane.showMessageDialog(this, - ResourceStrings.getString("configure_relay_err_server_list"), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return; - } - DhcpdOptions options = new DhcpdOptions(); - options.setDaemonEnabled(true); - options.setRelay(true, serverList.getAddressListString()); - /* - * Now write the options to the defaults file, enable the relay, - * and start it up. - */ - try { - DataManager.get().getDhcpServiceMgr().writeDefaults(options); - DataManager.get().getDhcpServiceMgr().startup(); - fireActionPerformed(this, DialogActions.OK); - setVisible(false); - dispose(); - } catch (Throwable e) { - e.printStackTrace(); - } - } - - protected void doCancel() { - fireActionPerformed(this, DialogActions.CANCEL); - super.doCancel(); - } - - protected String getHelpKey() { - return "configure_relay"; - } - - protected void fireActionPerformed() { - // Do nothing; this is here just to satisfy the abstractness in super - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ConvertWizard.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ConvertWizard.java deleted file mode 100644 index 23636aec16..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ConvertWizard.java +++ /dev/null @@ -1,672 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2001-2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.text.MessageFormat; -import java.net.*; - -import javax.swing.*; -import javax.swing.table.*; -import javax.swing.event.*; -import javax.swing.border.*; - -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.bridge.BridgeException; -import com.sun.dhcpmgr.bridge.ExistsException; - -/** - * This wizard converts the DHCP service data store. - */ -public class ConvertWizard extends DSWizard { - - /** - * Handle to the service server. - */ - private DhcpServiceMgr svcServer; - - /** - * Handle to the dhcptab table server. - */ - private DhcptabMgr dhcptabServer; - - /** - * Handle to the network tables server. - */ - private DhcpNetMgr netServer; - - /** - * The DHCP defaults. - */ - private DhcpdOptions dhcpdOptions; - - /** - * The old data store config. - */ - private DSConf defaultDsconf; - - /** - * The save tables wizard step - */ - private SaveTablesStep saveTablesStep; - - /** - * List of networks to be converted. - */ - private Network[] networks = null; - - /** - * This class is the wizard step that presents the user with - * the option to save the tables after conversion. - */ - protected class SaveTablesStep implements WizardStep { - - /** - * The component provided to the wizard. - */ - private Box stepBox; - - /** - * The checkbox that determines whether the DHCP tables should be - * saved after conversion. - */ - private JCheckBox saveTables; - - /** - * Basic constructor. - */ - public SaveTablesStep() { - - stepBox = Box.createVerticalBox(); - - // Explanatory text at the top - // - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("cvt_wiz_save_explain"), 4, 45)); - stepBox.add(Box.createVerticalStrut(10)); - stepBox.add(Box.createVerticalGlue()); - - // Add the checkbox. - // - saveTables = new JCheckBox( - ResourceStrings.getString("cvt_wiz_save_label"), false); - saveTables.setToolTipText( - ResourceStrings.getString("cvt_wiz_save_label")); - saveTables.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(saveTables); - stepBox.add(Box.createVerticalGlue()); - - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("cvt_wiz_save_note"), 4, 45)); - stepBox.add(Box.createVerticalStrut(10)); - stepBox.add(Box.createVerticalGlue()); - - } // constructor - - public String getDescription() { - return ResourceStrings.getString("cvt_wiz_save_tables_desc"); - } // getDescription - - public Component getComponent() { - return stepBox; - } // getComponent - - public void setActive(int direction) { - setForwardEnabled(true); - } // setActive - - public boolean setInactive(int direction) { - return true; - } // setInactive - - public boolean isSaveTablesSelected() { - return saveTables.isSelected(); - } - - } // SaveTablesStep - - /** - * This class provides the review step for the conversion wizard. - */ - class ReviewStep implements WizardStep { - - /** - * The label for the old data store. - */ - private JLabel oldStoreLabel; - - /** - * The label for the new data store. - */ - private JLabel newStoreLabel; - - /** - * The label for saving tables. - */ - private JLabel saveLabel; - - /** - * The component to provide to the conversion wizard. - */ - private Box stepBox; - - /** - * The panel used to create the review information. - */ - private JPanel panel; - - /** - * The constructor for the step. - */ - public ReviewStep() { - - stepBox = Box.createVerticalBox(); - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("cvt_wiz_review_explain"), - 3, 45)); - - panel = new JPanel(new FieldLayout()); - - addLabel("cvt_wiz_old_datastore").setToolTipText( - ResourceStrings.getString("cvt_wiz_old_datastore")); - oldStoreLabel = addField("uninitialized"); - - addLabel("cvt_wiz_new_datastore").setToolTipText( - ResourceStrings.getString("cvt_wiz_new_datastore")); - newStoreLabel = addField("uninitialized"); - - addLabel("cvt_wiz_save_tables").setToolTipText( - ResourceStrings.getString("cvt_wiz_save_tables")); - saveLabel = addField("uninitialized"); - - stepBox.add(panel); - stepBox.add(Box.createVerticalGlue()); - - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("cvt_wiz_review_note"), 4, 45)); - stepBox.add(Box.createVerticalStrut(10)); - stepBox.add(Box.createVerticalGlue()); - - } // constructor - - /** - * Adds a label to the review panel. - * @param s the label string. - */ - private JLabel addLabel(String s) { - JLabel addLbl = - new JLabel(ResourceStrings.getString(s)); - panel.add(FieldLayout.LABEL, addLbl); - return addLbl; - } // addLabel - - /** - * Adds a field to the review panel. - * @param s the field value. - * @return the label of which the field consists. - */ - private JLabel addField(String s) { - JLabel l = new JLabel(s); - l.setForeground(Color.black); - panel.add(FieldLayout.FIELD, l); - return l; - } // addField - - public String getDescription() { - return ResourceStrings.getString("cvt_wiz_review_desc"); - } // getDescription - - public Component getComponent() { - return stepBox; - } // getComponent - - public void setActive(int direction) { - - setFinishEnabled(true); - - /** - * If no bean exists for the default data store, then use the - * name of the data store as the description. - */ - String description = null; - if (defaultDsconf != null) { - description = defaultDsconf.getModule().getDescription(); - } else { - description = dhcpdOptions.getResource(); - } - - oldStoreLabel.setText(description); - newStoreLabel.setText(getDsconf().getModule().getDescription()); - - String message = null; - if (saveTablesStep.isSaveTablesSelected()) { - message = ResourceStrings.getString("yes"); - } else { - message = ResourceStrings.getString("no"); - } - saveLabel.setText(message); - - } // setActive - - public boolean setInactive(int direction) { - return true; - } // setInactive - - } // ReviewStep - - /** - * Constructor for the ConvertWizard. - * @param owner owner of the wizard. - * @param title title of the wizard. - */ - public ConvertWizard(Frame owner, String title) { - - super(owner, title); - - // Go ahead and grab handles to the different servers and - // read the server defaults. - // - try { - svcServer = DataManager.get().getDhcpServiceMgr(); - dhcptabServer = DataManager.get().getDhcptabMgr(); - netServer = DataManager.get().getDhcpNetMgr(); - dhcpdOptions = svcServer.readDefaults(); - } catch (Throwable e) { - e.printStackTrace(); - return; - } - - // Create the DSConfList and determine the default. Note that - // if the current data store has no management bean, then the - // defaultDsconf is null. - // - dsconfList = new DSConfList(); - dsconfList.init(svcServer); - defaultDsconf = - dsconfList.findDsconf(dhcpdOptions.getResource()); - - // If no bean exists for the default data store, then use the - // name of the data store as the description. - // - String description = null; - if (defaultDsconf != null) { - description = defaultDsconf.getModule().getDescription(); - } else { - description = dhcpdOptions.getResource(); - } - - - // Build the wizard explanation message. - // - Object [] args = new Object[1]; - args[0] = description; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("cvt_wiz_explain")); - String wizExplain = form.format(args); - - // Add the steps for the wizard. - // - DatastoreStep datastoreStep = new DatastoreStep(wizExplain, - ResourceStrings.getString("cvt_wiz_store_explain")); - addStep(datastoreStep); - addStep(new DatastoreModuleStep()); - addStep(saveTablesStep = new SaveTablesStep()); - addStep(new ReviewStep()); - showFirstStep(); - } - - public void doFinish() { - /* - * To convert the data store, we have to do the following items: - * 1. Create the new location/path - * 2. Convert the dhcptab - * 3. Convert the network tables - * 4. Modify the DHCP defaults - * 5. Delete old tables if necessary - */ - - getDsconf().setLocation(); - getDsconf().setConfig(); - final DhcpDatastore newDhcpDatastore = getDsconf().getDS(); - final DhcpDatastore oldDhcpDatastore = dhcpdOptions.getDhcpDatastore(); - - if (newDhcpDatastore.equals(oldDhcpDatastore)) { - JOptionPane.showMessageDialog(ConvertWizard.this, - ResourceStrings.getString("cvt_wiz_same_datastore_error"), - ResourceStrings.getString("cvt_wiz_error"), - JOptionPane.ERROR_MESSAGE); - return; - } - - // Create the new location if it does not exist. - // - try { - svcServer.makeLocation(newDhcpDatastore); - } catch (ExistsException e) { - // this is o.k. - } catch (Throwable e) { - MessageFormat form = new MessageFormat( - ResourceStrings.getString("cvt_wiz_location_error")); - Object [] args = new Object[1]; - args[0] = newDhcpDatastore.getLocation(); - String msg = form.format(args); - JOptionPane.showMessageDialog(ConvertWizard.this, - msg, - ResourceStrings.getString("cvt_wiz_error"), - JOptionPane.ERROR_MESSAGE); - - return; - } - - // Go get a list of the network tables to convert. - // - try { - networks = netServer.getNetworks(oldDhcpDatastore); - if (networks == null) { - networks = new Network[0]; - } - } catch (Throwable e) { - MessageFormat form = new MessageFormat( - ResourceStrings.getString("cvt_wiz_networks_error")); - Object [] args = new Object[1]; - args[0] = e.getMessage(); - String msg = form.format(args); - JOptionPane.showMessageDialog(ConvertWizard.this, - msg, - ResourceStrings.getString("cvt_wiz_error"), - JOptionPane.ERROR_MESSAGE); - - reallyFinish(); - return; - } - - // Add 1 to tables count for dhcptab - final int tables = networks.length + 1; - // One update per table, plus one per table if deleting - int updates = - !saveTablesStep.isSaveTablesSelected() ? tables * 2 : tables; - // Add: one for shutdown, one for updating dhcpsvc.conf - updates += 2; - // If daemon will be restarted, then add 1 for start - if (dhcpdOptions.isDaemonEnabled()) { - ++updates; - } - final ProgressManager progress = new ProgressManager(this, - ResourceStrings.getString("cvt_wiz_progress"), - "", 0, updates); - - // Called when doFinish() is really finished - // (i.e., the thread completes). - // - final Runnable finisher = new Runnable() { - public void run() { - reallyFinish(); - } - }; - - - // Here's the thread which does the conversion. - // - Thread convertThread = new Thread() { - public void run() { - - String message = null; - MessageFormat form; - MessageFormat errForm; - Object [] args = new Object[1]; - boolean saveTables = - saveTablesStep.isSaveTablesSelected(); - - // This is final so it can be used in the - // errorDisplay Runnable. - // - final ErrorTable failedTable = new ErrorTable( - ResourceStrings.getString("cvt_wiz_table"), - String.class); - - // Shutdown the server. - // - int counter = 0; - try { - svcServer.shutdown(); - message = ResourceStrings.getString( - "cvt_wiz_server_shutdown"); - } catch (Throwable e) { - message = - ResourceStrings.getString("cvt_wiz_shutdown_err"); - failedTable.addError("", e.getMessage()); - saveTables = true; - } finally { - try { - progress.update(++counter, message); - } catch (InterruptedException e) { - SwingUtilities.invokeLater(finisher); - return; - } - } - - // Convert the dhcptab. - // - try { - dhcptabServer.cvtDhcptab(newDhcpDatastore); - message = ResourceStrings.getString( - "cvt_wiz_progress_dhcptab_cvt"); - } catch (Throwable e) { - message = ResourceStrings.getString( - "cvt_wiz_progress_dhcptab_cvt_err"); - failedTable.addError(ResourceStrings.getString( - "cvt_wiz_dhcptab"), e.getMessage()); - saveTables = true; - } finally { - try { - progress.update(++counter, message); - } catch (InterruptedException e) { - SwingUtilities.invokeLater(finisher); - return; - } - } - - // Convert the network tables. - // - form = new MessageFormat(ResourceStrings.getString( - "cvt_wiz_progress_network_cvt")); - errForm = new MessageFormat(ResourceStrings.getString( - "cvt_wiz_progress_network_cvt_err")); - - for (int i = 0; i < networks.length; ++i) { - String netString = networks[i].toString(); - args[0] = netString; - try { - netServer.cvtNetwork(netString, newDhcpDatastore); - message = form.format(args); - } catch (Throwable e) { - message = errForm.format(args); - failedTable.addError(netString, e.getMessage()); - saveTables = true; - } finally { - try { - progress.update(++counter, message); - } catch (InterruptedException e) { - SwingUtilities.invokeLater(finisher); - return; - } - } - } - - // Update the DHCP defaults file with the new values. - // - dhcpdOptions.setDhcpDatastore(newDhcpDatastore); - try { - svcServer.writeDefaults(dhcpdOptions); - message = ResourceStrings.getString( - "cvt_wiz_progress_defaults"); - } catch (Throwable e) { - message = ResourceStrings.getString( - "cvt_wiz_progress_defaults_err"); - failedTable.addError(ResourceStrings.getString( - "cvt_wiz_defaults"), e.getMessage()); - saveTables = true; - } finally { - try { - progress.update(++counter, message); - } catch (InterruptedException e) { - SwingUtilities.invokeLater(finisher); - return; - } - } - - if (!saveTables) { - // Delete the network tables - // - form = new MessageFormat(ResourceStrings.getString( - "cvt_wiz_progress_network_del")); - errForm = new MessageFormat(ResourceStrings.getString( - "cvt_wiz_progress_network_del_err")); - - for (int i = 0; i < networks.length; ++i) { - String netString = networks[i].toString(); - args[0] = netString; - try { - netServer.deleteNetwork(netString, false, - oldDhcpDatastore); - message = form.format(args); - } catch (Throwable e) { - message = errForm.format(args); - failedTable.addError(netString, e.getMessage()); - } finally { - try { - progress.update(++counter, message); - } catch (InterruptedException e) { - SwingUtilities.invokeLater(finisher); - return; - } - } - } - - // Delete the dhcptab - // - try { - dhcptabServer.deleteDhcptab(oldDhcpDatastore); - message = ResourceStrings.getString( - "cvt_wiz_progress_dhcptab_del"); - } catch (Throwable e) { - message = ResourceStrings.getString( - "cvt_wiz_progress_dhcptab_del_err"); - failedTable.addError(ResourceStrings.getString( - "cvt_wiz_dhcptab"), e.getMessage()); - } finally { - try { - progress.update(++counter, message); - } catch (InterruptedException e) { - SwingUtilities.invokeLater(finisher); - return; - } - } - } else if (!saveTablesStep.isSaveTablesSelected()) { - try { - counter += tables; - progress.update(counter, ""); - } catch (InterruptedException e) { - SwingUtilities.invokeLater(finisher); - return; - } - } - - // Start the server. - // - if (dhcpdOptions.isDaemonEnabled()) { - try { - svcServer.startup(); - message = ResourceStrings.getString( - "cvt_wiz_server_started"); - } catch (Throwable e) { - message = - ResourceStrings.getString("cvt_wiz_start_err"); - failedTable.addError("", e.getMessage()); - } finally { - try { - progress.update(++counter, message); - } catch (InterruptedException e) { - SwingUtilities.invokeLater(finisher); - return; - } - } - } - - // If any errors occurred, display them all at once. - // - if (!failedTable.isEmpty()) { - Runnable errorDisplay = new Runnable() { - public void run() { - Object [] objs = new Object[2]; - objs[0] = - ResourceStrings.getString("cvt_wiz_errors"); - JScrollPane scrollPane = - new JScrollPane(failedTable); - - // Resize the table to something kind of small - // - Dimension d = - failedTable. - getPreferredScrollableViewportSize(); - d.height = 80; - failedTable.setPreferredScrollableViewportSize(d); - objs[1] = scrollPane; - JOptionPane.showMessageDialog(ConvertWizard.this, - objs, - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - }; - try { - SwingUtilities.invokeAndWait(errorDisplay); - } catch (Throwable e) { - e.printStackTrace(); - } - } - SwingUtilities.invokeLater(finisher); - } - }; - convertThread.start(); - } - - public void doHelp() { - DhcpmgrApplet.showHelp("convert_wizard"); - } - - /** - * Called by the worker thread upon completion to exec the Wizard - * doFinish(). - */ - protected void reallyFinish() { - super.doFinish(); - } // reallyFinish - -} // ConvertWizard diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/CreateAddressDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/CreateAddressDialog.java deleted file mode 100644 index 883999f516..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/CreateAddressDialog.java +++ /dev/null @@ -1,603 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.event.*; - -import java.awt.*; -import java.awt.event.*; -import java.text.*; -import java.util.*; -import java.net.*; - -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.bridge.ExistsException; -import com.sun.dhcpmgr.bridge.NoEntryException; -import com.sun.dhcpmgr.bridge.HostExistsException; -import com.sun.dhcpmgr.bridge.NoHostsEntryException; -import com.sun.dhcpmgr.bridge.NoTableException; -import com.sun.dhcpmgr.bridge.BridgeException; - -/** - * This dialog is used to create/duplicate/modify a DHCP address record. - */ -public class CreateAddressDialog extends JDialog - implements ButtonPanelListener { - - // Model class for the drop-down list of macros user may select from - class MacroListModel extends AbstractListModel implements ComboBoxModel { - private Object currentValue; - private Macro [] data = null; - private String noMacro; - - public MacroListModel() { - try { - noMacro = ResourceStrings.getString("no_macro_item"); - DhcptabMgr server = DataManager.get().getDhcptabMgr(); - data = server.getMacros(); - } catch (NoTableException e) { - // can function without table - } catch (Throwable e) { - e.printStackTrace(); - } - } - - public int getSize() { - if (data == null) - return 1; - else - return data.length+1; - } - - public Object getElementAt(int index) { - if (index == 0) { - return noMacro; - } else { - return data[index-1].getKey(); - } - } - - public void setSelectedItem(Object anItem) { - currentValue = anItem; - fireContentsChanged(this, -1, -1); - } - - public Object getSelectedItem() { - return currentValue; - } - } - - public static final int CREATE = 0; - public static final int EDIT = 1; - public static final int DUPLICATE = 2; - - private int mode = EDIT; - private Network network; - private IPAddressField address; - private JTextField server; - private JComboBox macro; - private JTextField clientId; - private JTextField comment; - private JTextField expirationDate; - private JCheckBox unusable; - private JCheckBox bootp; - private JCheckBox manual; - private JRadioButton temporary; - private JRadioButton permanent; - private ButtonGroup buttonGroup; - private ButtonPanel buttonPanel; - private DhcpClientRecord client, originalClient; - private Vector listeners; - private DateFormat dateFormat = - DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); - - public CreateAddressDialog(Frame f, int mode, DhcpClientRecord rec, - Network net) { - super(f); - setLocationRelativeTo(f); - - listeners = new Vector(); - this.mode = mode; - network = net; - switch (mode) { - case CREATE: - setTitle(ResourceStrings.getString("create_address_title")); - break; - case EDIT: - setTitle(ResourceStrings.getString("edit_address_title")); - break; - case DUPLICATE: - setTitle(ResourceStrings.getString("duplicate_address_title")); - break; - default: - break; - } - - getContentPane().setLayout(new BorderLayout()); - - JTabbedPane tabbedPane = new JTabbedPane(); - - GridBagLayout bag = new GridBagLayout(); - JPanel mainPanel = new JPanel(bag); - GridBagConstraints c = new GridBagConstraints(); - c.gridx = c.gridy = 0; - c.gridwidth = c.gridheight = 1; - c.fill = GridBagConstraints.HORIZONTAL; - c.insets = new Insets(5, 5, 5, 5); - c.weightx = c.weighty = 1.0; - - // Label and text field for address - Mnemonic mnIP = - new Mnemonic(ResourceStrings.getString("ip_address_label")); - JLabel l = new JLabel(mnIP.getString(), SwingConstants.RIGHT); - bag.setConstraints(l, c); - mainPanel.add(l); - address = new IPAddressField(); - l.setLabelFor(address); - l.setToolTipText(mnIP.getString()); - l.setDisplayedMnemonic(mnIP.getMnemonic()); - - if (mode == EDIT) { - address.setEditable(false); - } - ++c.gridx; - bag.setConstraints(address, c); - mainPanel.add(address); - - // label and field for owning server - Mnemonic mnOwn = - new Mnemonic(ResourceStrings.getString("owning_server_label")); - l = new JLabel(mnOwn.getString(), SwingConstants.RIGHT); - ++c.gridy; - c.gridx = 0; - bag.setConstraints(l, c); - mainPanel.add(l); - server = new JTextField(20); - - l.setLabelFor(server); - l.setToolTipText(mnOwn.getString()); - l.setDisplayedMnemonic(mnOwn.getMnemonic()); - - ++c.gridx; - bag.setConstraints(server, c); - mainPanel.add(server); - - // label and combo box for macro - Mnemonic mnMacro = - new Mnemonic(ResourceStrings.getString("config_macro_label")); - l = new JLabel(mnMacro.getString(), SwingConstants.RIGHT); - ++c.gridy; - c.gridx = 0; - bag.setConstraints(l, c); - mainPanel.add(l); - MacroListModel macroListModel = new MacroListModel(); - macro = new JComboBox(macroListModel); - - l.setLabelFor(macro); - l.setToolTipText(mnMacro.getString()); - l.setDisplayedMnemonic(mnMacro.getMnemonic()); - - macro.setEditable(false); - ++c.gridx; - bag.setConstraints(macro, c); - mainPanel.add(macro); - - // Comment - Mnemonic mnComm = - new Mnemonic(ResourceStrings.getString("comment_label")); - l = new JLabel(mnComm.getString(), SwingConstants.RIGHT); - ++c.gridy; - c.gridx = 0; - bag.setConstraints(l, c); - mainPanel.add(l); - comment = new JTextField(20); - - l.setLabelFor(comment); - l.setToolTipText(mnComm.getString()); - l.setDisplayedMnemonic(mnComm.getMnemonic()); - - ++c.gridx; - bag.setConstraints(comment, c); - mainPanel.add(comment); - - // Create first panel of tabs - tabbedPane.addTab(ResourceStrings.getString("address_tab_label"), - mainPanel); - - mainPanel = new JPanel(new BorderLayout(5, 5)); - - // Client ID - Mnemonic mnID = - new Mnemonic(ResourceStrings.getString("client_id_label")); - JPanel idPanel = new JPanel(); - l = new JLabel(mnID.getString()); - idPanel.add(l); - clientId = new JTextField(20); - - l.setLabelFor(clientId); - l.setToolTipText(mnID.getString()); - l.setDisplayedMnemonic(mnID.getMnemonic()); - idPanel.add(clientId); - - manual = new JCheckBox(ResourceStrings.getString("manual_checkbox")); - idPanel.add(manual); - manual.setToolTipText( - ResourceStrings.getString("manual_checkbox")); - - mainPanel.add(idPanel, BorderLayout.NORTH); - - // radio buttons for lease state - bag = new GridBagLayout(); - JPanel leasePanel = new JPanel(bag); - /* - * Create a compound border with empty space on the outside and line - * border on the inside, then title it. - */ - Border b = BorderFactory.createCompoundBorder( - BorderFactory.createEmptyBorder(0, 5, 0, 5), - BorderFactory.createLineBorder(Color.black)); - leasePanel.setBorder(BorderFactory.createTitledBorder(b, - ResourceStrings.getString("lease_policy_label"))); - - // Reset constraints - c.gridx = c.gridy = 0; - c.gridwidth = 1; - - buttonGroup = new ButtonGroup(); - temporary = new JRadioButton(); - buttonGroup.add(temporary); - c.weightx = 0.0; - bag.setConstraints(temporary, c); - leasePanel.add(temporary); - - Mnemonic mnDyn = - new Mnemonic(ResourceStrings.getString("leased_label")); - l = new JLabel(mnDyn.getString()); - ++c.gridx; - c.weightx = 1.0; - bag.setConstraints(l, c); - leasePanel.add(l); - - expirationDate = new JTextField(30); - - l.setLabelFor(expirationDate); - l.setToolTipText(mnDyn.getString()); - l.setDisplayedMnemonic(mnDyn.getMnemonic()); - - ++c.gridy; - bag.setConstraints(expirationDate, c); - leasePanel.add(expirationDate); - - permanent = new JRadioButton(); - buttonGroup.add(permanent); - ++c.gridy; - c.gridx = 0; - c.weightx = 0.0; - bag.setConstraints(permanent, c); - leasePanel.add(permanent); - - Mnemonic mnPerm = - new Mnemonic(ResourceStrings.getString("permanent_label")); - l = new JLabel(mnPerm.getString()); - l.setLabelFor(leasePanel); - l.setToolTipText(mnPerm.getString()); - l.setDisplayedMnemonic(mnPerm.getMnemonic()); - - ++c.gridx; - c.weightx = 1.0; - bag.setConstraints(l, c); - leasePanel.add(l); - - mainPanel.add(leasePanel, BorderLayout.CENTER); - - // Flag checkboxes - JPanel southPanel = new JPanel(new BorderLayout(5, 5)); - southPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); - bootp = new JCheckBox(ResourceStrings.getString("bootp_checkbox")); - - bootp.setToolTipText( - ResourceStrings.getString("bootp_checkbox")); - - bootp.setHorizontalAlignment(SwingConstants.LEFT); - southPanel.add(bootp, BorderLayout.CENTER); - - unusable = new JCheckBox( - ResourceStrings.getString("unusable_checkbox")); - - unusable.setToolTipText( - ResourceStrings.getString("unusable_checkbox")); - - unusable.setHorizontalAlignment(SwingConstants.LEFT); - southPanel.add(unusable, BorderLayout.SOUTH); - - mainPanel.add(southPanel, BorderLayout.SOUTH); - - tabbedPane.addTab(ResourceStrings.getString("lease_tab_label"), - mainPanel); - JPanel borderPanel = new JPanel(new BorderLayout()); - borderPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - borderPanel.add(tabbedPane, BorderLayout.CENTER); - - getContentPane().add(borderPanel, BorderLayout.CENTER); - - buttonPanel = new ButtonPanel(true); - buttonPanel.addButtonPanelListener(this); - getContentPane().add(buttonPanel, BorderLayout.SOUTH); - - setClient(rec); - - DocumentListener docListener = new DocumentListener() { - public void insertUpdate(DocumentEvent e) { - buttonPanel.setOkEnabled(address.getDocument().getLength() != 0 - && server.getDocument().getLength() != 0); - } - public void changedUpdate(DocumentEvent e) { - insertUpdate(e); - } - public void removeUpdate(DocumentEvent e) { - insertUpdate(e); - } - }; - - address.getDocument().addDocumentListener(docListener); - server.getDocument().addDocumentListener(docListener); - - if (mode == EDIT) { - buttonPanel.setOkEnabled(true); - } - } - - public void setClient(DhcpClientRecord c) { - originalClient = (DhcpClientRecord)c.clone(); - client = c; - resetValues(); - } - - private void resetValues() { - if (mode == DUPLICATE) { - address.setText(""); - } else { - address.setText(client.getClientIPAddress()); - } - if (mode == CREATE && (client.getServerName() == null || - client.getServerName().length() == 0)) { - server.setText(DataManager.get().getShortServerName()); - } else { - server.setText(client.getServerName()); - } - if (mode == CREATE) { - macro.setSelectedItem(DataManager.get().getShortServerName()); - } else { - macro.setSelectedItem(client.getMacro()); - } - comment.setText(client.getComment()); - clientId.setText(client.getClientId()); - manual.setSelected(client.isManual()); - if (client.isPermanent()) { - permanent.setSelected(true); - } else { - temporary.setSelected(true); - } - bootp.setSelected(client.isBootp()); - unusable.setSelected(client.isUnusable()); - Date d = client.getExpiration(); - if (d == null || d.getTime() == 0) { - expirationDate.setText(""); - } else { - expirationDate.setText(dateFormat.format(d)); - } - } - - public void buttonPressed(int buttonId) { - switch (buttonId) { - case OK: - IPAddress addr = address.getValue(); - if (addr == null) { - // Bad IP address - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_address")); - Object [] args = new Object[] { address.getText() }; - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return; - } - if (!network.containsAddress(addr)) { - // Address is not on the network we're editing - MessageFormat form = new MessageFormat( - ResourceStrings.getString("bad_network_address")); - Object [] args = new Object[] { - addr.getHostAddress(), - network.getAddress() - }; - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return; - } - try { - client.setClientIP(address.getValue()); - } catch (ValidationException e) { - // This shouldn't happen, should have caught any problem already - } - - try { - if (!server.getText().equals(client.getServerName())) { - // Don't bother resetting if it hasn't changed - client.setServerIP(new IPAddress(server.getText())); - } - } catch (ValidationException e) { - // Bad server name - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_server")); - Object [] args = new Object[] { server.getText() }; - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return; - } - int i = macro.getSelectedIndex(); - if (i == 0) { - client.setMacro(""); - } else { - client.setMacro((String)macro.getItemAt(i)); - } - client.setComment(comment.getText()); - try { - client.setClientId(clientId.getText()); - } catch (ValidationException e) { - // Bad client ID - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_client_id")); - Object [] args = new Object[] { clientId.getText() }; - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return; - } - client.setManual(manual.isSelected()); - client.setPermanent(permanent.isSelected()); - client.setBootp(bootp.isSelected()); - client.setUnusable(unusable.isSelected()); - try { - if (expirationDate.getText().length() == 0) { - client.setExpiration(new Date(0)); - } else { - Date d = dateFormat.parse(expirationDate.getText()); - client.setExpiration(d); - } - } catch (ParseException e) { - // Bad date/time entered - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_date")); - Object [] args = new Object[] { - expirationDate.getText(), - dateFormat.format(new Date()) - }; - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return; - } - // Got all the data, now update the data store - try { - DhcpNetMgr server = DataManager.get().getDhcpNetMgr(); - if (mode == EDIT) { - server.modifyClient(originalClient, client, - network.toString()); - } else { - server.addClient(client, network.toString()); - } - fireActionPerformed(); - setVisible(false); - dispose(); - } catch (Exception e) { - /* - * Display an error message dialog. However, if the error - * related to editing the hosts table, we merely consider it - * a warning as the network table stuff actually was done. - */ - String msg = e.getMessage(); - int msgType = JOptionPane.ERROR_MESSAGE; - if (e instanceof ExistsException) { - msg = ResourceStrings.getString("address_exists"); - } else if (e instanceof NoEntryException) { - msg = ResourceStrings.getString("address_missing"); - } else if (e instanceof HostExistsException) { - msg = ResourceStrings.getString("host_exists"); - msgType = JOptionPane.ERROR_MESSAGE; - } else if (e instanceof NoHostsEntryException) { - msg = ResourceStrings.getString("host_missing"); - msgType = JOptionPane.WARNING_MESSAGE; - } - JOptionPane.showMessageDialog(this, msg, - ResourceStrings.getString("server_error_title"), msgType); - if (msgType == JOptionPane.WARNING_MESSAGE) { - fireActionPerformed(); - setVisible(false); - dispose(); - } - } - break; - case CANCEL: - setVisible(false); - dispose(); - break; - case HELP: - String helpTag = null; - switch (mode) { - case CREATE: - helpTag = "create_address"; - break; - case DUPLICATE: - helpTag = "duplicate_address"; - break; - case EDIT: - helpTag = "modify_address"; - break; - } - DhcpmgrApplet.showHelp(helpTag); - break; - case RESET: - setClient(originalClient); - break; - } - } - - public void addActionListener(ActionListener l) { - listeners.addElement(l); - } - - public void removeActionListener(ActionListener l) { - listeners.removeElement(l); - } - - protected void fireActionPerformed() { - String command = null; - switch (mode) { - case CREATE: - command = DialogActions.CREATE; - break; - case DUPLICATE: - command = DialogActions.DUPLICATE; - break; - case EDIT: - command = DialogActions.EDIT; - break; - } - ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, - command); - Enumeration en = listeners.elements(); - while (en.hasMoreElements()) { - ActionListener l = (ActionListener)en.nextElement(); - l.actionPerformed(e); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/CreateMacroDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/CreateMacroDialog.java deleted file mode 100644 index fbf35a9376..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/CreateMacroDialog.java +++ /dev/null @@ -1,763 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.event.*; -import javax.swing.table.*; - -import java.awt.*; -import java.awt.event.*; -import java.text.MessageFormat; -import java.util.*; - -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.bridge.NotRunningException; - -/** - * Dialog to create/duplicate/edit a macro. - */ -public class CreateMacroDialog extends JDialog implements ButtonPanelListener { - - // Model for the table that displays the macro's contents - class MacroTableModel extends AbstractTableModel { - Macro macro; - - public MacroTableModel() { - setMacro(new Macro()); - } - - public MacroTableModel(Macro m) { - super(); - setMacro(m); - } - - public void setMacro(Macro m) { - macro = m; - fireTableDataChanged(); - } - - public int getRowCount() { - return macro.optionCount(); - } - - public int getColumnCount() { - return 2; - } - - public Object getValueAt(int row, int column) { - OptionValue v = null; - try { - v = macro.getOptionAt(row); - } catch (ArrayIndexOutOfBoundsException e) { - return null; - } - if (v == null) { - return null; - } - switch (column) { - case 0: - return v.getName(); - case 1: - return v.getValue(); - default: - return null; - } - } - - public Class getColumnClass(int column) { - switch (column) { - case 0: - case 1: - return String.class; - default: - return super.getColumnClass(column); - } - } - - public String getColumnName(int column) { - switch (column) { - case 0: - return ResourceStrings.getString("option_column"); - case 1: - return ResourceStrings.getString("value_column"); - default: - super.getColumnName(column); - } - return null; - } - - public boolean isCellEditable(int row, int column) { - return false; - } - - public void moveRowUp(int row) { - OptionValue v = macro.getOptionAt(row); - macro.deleteOptionAt(row); - macro.insertOptionAt(v, row-1); - fireTableRowsUpdated(row-1, row); - } - - public void moveRowDown(int row) { - OptionValue v = macro.getOptionAt(row); - macro.deleteOptionAt(row); - macro.insertOptionAt(v, row+1); - fireTableRowsUpdated(row, row+1); - } - - public void deleteRow(int row) { - macro.deleteOptionAt(row); - fireTableRowsDeleted(row, row); - } - - public void setOptionAt(OptionValue v, int row) { - macro.setOptionAt(v, row); - fireTableDataChanged(); - } - - public int findRowForOption(String opt) { - for (int i = 0; i < getRowCount(); ++i) { - OptionValue v = macro.getOptionAt(i); - if (opt.equals(v.getName())) { - return i; - } - } - return -1; - } - } - - public static final int CREATE = 0; - public static final int EDIT = 1; - public static final int DUPLICATE = 2; - - private int mode = CREATE; - private Macro originalMacro = null; - private MacroNameField name; - private JTextField optionName; - private JTextField optionValue; - private AutosizingTable macroTable; - private MacroTableModel macroTableModel; - private ButtonPanel buttonPanel; - private JButton deleteButton, addButton, modifyButton, selectButton; - private UpButton upButton; - private DownButton downButton; - private JCheckBox signalBox; - private Vector listeners; - private String savedOptionName = ""; - - /* - * Listener for the editing buttons which are used to manipulate the - * table's contents - */ - ActionListener listener = new ActionListener() { - public void actionPerformed(ActionEvent e) { - int row = macroTable.getSelectedRow(); - int lastRow = macroTable.getRowCount() - 1; - - Object src = e.getSource(); - if (src == upButton) { - if (row == 0) { - return; // Can't move the first row up - } - macroTableModel.moveRowUp(row); - /* - * Keep the row we moved selected so that repeated move up's - * affect the same data - */ - macroTable.clearSelection(); - macroTable.addRowSelectionInterval(row-1, row-1); - } else if (src == downButton) { - if (row == lastRow) { - return; // Can't move the last row down - } - macroTableModel.moveRowDown(row); - /* - * Keep the row we moved selected so that repeated move down's - * affect the same data - */ - macroTable.clearSelection(); - macroTable.addRowSelectionInterval(row+1, row+1); - } else if (src == deleteButton) { - macroTableModel.deleteRow(row); - /* - * Keep the same row selected so that repeated delete presses - * can be used to delete a series of options - */ - macroTable.clearSelection(); - if (row == lastRow) { - row = macroTableModel.getRowCount()-1; - } - if (macroTableModel.getRowCount() > 0) { - macroTable.addRowSelectionInterval(row, row); - } - if (macroTableModel.getRowCount() <= 0) { - modifyButton.setEnabled(false); - } - } else if (src == selectButton) { - // Show dialog that allows selection of options - String s = SelectOptionDialog.showDialog(selectButton); - - /* - * User selected something, put it in the name field - * set the focus to the value field - */ - if (s != null) { - optionName.setText(s); - optionValue.requestFocus(); - } - } else if ((src == addButton) || (src == modifyButton)) { - // Update the table from the field contents - OptionValue v = null; - v = OptionValueFactory.newOptionValue(optionName.getText()); - if (v instanceof BogusOptionValue) { - optionName.requestFocus(); - // bad option name - MessageFormat form = null; - Object [] args = new Object[1]; - args[0] = optionName.getText(); - form = new MessageFormat( - ResourceStrings.getString("bad_option_name")); - JOptionPane.showMessageDialog(macroTable, form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return; - } - try { - /* - * Catch an empty value field, which is only legal for - * a boolean option - */ - String s = optionValue.getText(); - if (s.length() == 0 && !(v instanceof BooleanOptionValue)) { - throw new ValidationException(); - } - v.setValue(s); - } catch (ValidationException ex) { - // bad option value - optionValue.requestFocus(); - MessageFormat form = null; - Object [] args = new Object[2]; - form = new MessageFormat( - ResourceStrings.getString("bad_option_value")); - args[0] = optionValue.getText(); - args[1] = optionName.getText(); - JOptionPane.showMessageDialog(macroTable, form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return; - } - /* - * Don't allow a second instance of any option other than - * Include in a macro, but only check if we're doing an add - * or if it's a modify and the name has changed. - */ - if ((!(v instanceof IncludeOptionValue) - && (src == addButton)) - || ((src == modifyButton) - && !savedOptionName.equals(v.getName()))) { - if (macroTableModel.macro.getOption(v.getName()) != null) { - optionName.requestFocus(); - MessageFormat form = new MessageFormat( - ResourceStrings.getString("macro_contains_option")); - Object [] args = new Object[1]; - args[0] = v.getName(); - JOptionPane.showMessageDialog(macroTable, - form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return; - } - } - // If adding, append it at the end - if (src == addButton) { - row = macroTableModel.getRowCount(); - } - macroTableModel.setOptionAt(v, row); - macroTable.clearSelection(); - macroTable.addRowSelectionInterval(row, row); - macroTable.scrollRectToVisible( - macroTable.getCellRect(row, 0, false)); - } - } - }; - - public CreateMacroDialog(Frame f, int mode) { - super(f); - setLocationRelativeTo(f); - - listeners = new Vector(); - - this.mode = mode; - switch (mode) { - case CREATE: - setTitle(ResourceStrings.getString("create_macro_title")); - break; - case EDIT: - setTitle(ResourceStrings.getString("edit_macro_title")); - break; - case DUPLICATE: - setTitle(ResourceStrings.getString("duplicate_macro_title")); - break; - default: - break; - } - - getContentPane().setLayout(new BoxLayout(getContentPane(), - BoxLayout.Y_AXIS)); - JPanel mainPanel = new JPanel(new BorderLayout()); - mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - - // Name cannot have blanks in it so use a control which disallows them - name = new MacroNameField("", 30); - JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - - Mnemonic mnName = - new Mnemonic(ResourceStrings.getString("md_name_label")); - JLabel nameLbl = new JLabel(mnName.getString()); - nameLbl.setLabelFor(name); - nameLbl.setToolTipText(mnName.getString()); - nameLbl.setDisplayedMnemonic(mnName.getMnemonic()); - panel.add(nameLbl); - - panel.add(name); - mainPanel.add(panel, BorderLayout.NORTH); - - JPanel contentsPanel = new JPanel(); - contentsPanel.setLayout(new BorderLayout()); - // Put a titled border on the contents panel - Border b = BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(Color.black), - BorderFactory.createEmptyBorder(5, 10, 5, 10)); - contentsPanel.setBorder(BorderFactory.createTitledBorder(b, - ResourceStrings.getString("contents_label"))); - - /* - * Create a panel using a couple of text fields to edit the options - * included in the macro - */ - JPanel fieldPanel = new JPanel(new FieldLayout()); - // Field for option name - - panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); - optionName = new JTextField("", 20); - Mnemonic mnOptName = - new Mnemonic(ResourceStrings.getString("md_option_name")); - JLabel optNameLbl = - new JLabel(mnOptName.getString()); - fieldPanel.add(FieldLayout.LABEL, optNameLbl); - optNameLbl.setLabelFor(optionName); - optNameLbl.setToolTipText(mnOptName.getString()); - optNameLbl.setDisplayedMnemonic(mnOptName.getMnemonic()); - - panel.add(optionName); - panel.add(Box.createHorizontalStrut(5)); - - Mnemonic mnSelect = - new Mnemonic(ResourceStrings.getString("select")); - selectButton = new JButton(mnSelect.getString()); - selectButton.setToolTipText(mnSelect.getString()); - selectButton.setMnemonic(mnSelect.getMnemonic()); - - selectButton.addActionListener(listener); - panel.add(selectButton); - fieldPanel.add(FieldLayout.FIELD, panel); - - // Field for option value - - optionValue = new JTextField(); - - Mnemonic mnOptVal = - new Mnemonic(ResourceStrings.getString("md_option_value")); - JLabel optValLbl = new JLabel(mnOptVal.getString()); - fieldPanel.add(FieldLayout.LABEL, optValLbl); - optValLbl.setLabelFor(optionValue); - optValLbl.setToolTipText(mnOptVal.getString()); - optValLbl.setDisplayedMnemonic(mnOptVal.getMnemonic()); - - fieldPanel.add(FieldLayout.FIELD, optionValue); - - // Buttons for add/modify - - Mnemonic mnAdd = - new Mnemonic(ResourceStrings.getString("add")); - addButton = new JButton(mnAdd.getString()); - addButton.setToolTipText(mnAdd.getString()); - addButton.setMnemonic(mnAdd.getMnemonic()); - - addButton.addActionListener(listener); - addButton.setEnabled(false); - - Mnemonic mnModify = - new Mnemonic(ResourceStrings.getString("modify")); - modifyButton = new JButton(mnModify.getString()); - modifyButton.setToolTipText(mnModify.getString()); - modifyButton.setMnemonic(mnModify.getMnemonic()); - - modifyButton.addActionListener(listener); - modifyButton.setEnabled(false); - panel = new JPanel(new VerticalButtonLayout()); - panel.add(addButton); - panel.add(modifyButton); - - JPanel editPanel = new JPanel(new BorderLayout()); - editPanel.add(fieldPanel, BorderLayout.WEST); - editPanel.add(panel, BorderLayout.EAST); - contentsPanel.add(editPanel, BorderLayout.NORTH); - - // Use a table to display the contents of the macro - macroTableModel = new MacroTableModel(); - macroTable = new AutosizingTable(macroTableModel); - macroTable.getTableHeader().setReorderingAllowed(false); - macroTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - JScrollPane macroTablePane = new JScrollPane(macroTable); - // Resize table as otherwise it asks for a huge area - Dimension d = macroTable.getPreferredScrollableViewportSize(); - d.height = 100; - d.width = 300; - macroTable.setPreferredScrollableViewportSize(d); - - contentsPanel.add(macroTablePane, BorderLayout.CENTER); - - // Create buttons for controlling table - JPanel editButtonPanel = new JPanel(new VerticalButtonLayout()); - - upButton = new UpButton(); - upButton.setEnabled(false); - upButton.addActionListener(listener); - editButtonPanel.add(upButton); - - downButton = new DownButton(); - downButton.setEnabled(false); - downButton.addActionListener(listener); - editButtonPanel.add(downButton); - - Mnemonic mnDelete = - new Mnemonic(ResourceStrings.getString("delete")); - deleteButton = new JButton(mnDelete.getString()); - deleteButton.setToolTipText(mnDelete.getString()); - deleteButton.setMnemonic(mnDelete.getMnemonic()); - - deleteButton.setEnabled(false); - deleteButton.addActionListener(listener); - editButtonPanel.add(deleteButton); - contentsPanel.add(editButtonPanel, BorderLayout.EAST); - - mainPanel.add(contentsPanel, BorderLayout.CENTER); - - signalBox = new JCheckBox(ResourceStrings.getString("signal_server"), - true); - signalBox.setToolTipText( - ResourceStrings.getString("signal_server")); - signalBox.setHorizontalAlignment(SwingConstants.CENTER); - mainPanel.add(signalBox, BorderLayout.SOUTH); - - getContentPane().add(mainPanel); - getContentPane().add(new JSeparator()); - - buttonPanel = new ButtonPanel(true); - buttonPanel.addButtonPanelListener(this); - getContentPane().add(buttonPanel); - - // Listen to table selection state and set state of buttons accordingly - macroTable.getSelectionModel().addListSelectionListener( - new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - int index = macroTable.getSelectedRow(); - if (index == -1) { - // Nothing selected, disable all - upButton.setEnabled(false); - downButton.setEnabled(false); - deleteButton.setEnabled(false); - // Clear the option name we saved - savedOptionName = ""; - } else { - if (macroTable.getRowCount() > 0) { - /* - * Only allow deleteButton to be activated when - * the table is not empty regardless of selection - * method, mouse or keyboard - */ - deleteButton.setEnabled(true); - } - if (index == 0) { - // First row can't move up - upButton.setEnabled(false); - } else { - upButton.setEnabled(true); - } - if (index == (macroTable.getRowCount() - 1)) { - // Last row can't move down - downButton.setEnabled(false); - } else { - if (macroTable.getRowCount() > 0) { - /* - * Only allow downButton to be activated when the - * table is not empty regardless of selection - * method, mouse or keyboard - */ - downButton.setEnabled(true); - } - } - // Save editing name so we can detect name change - savedOptionName = - (String)macroTableModel.getValueAt(index, 0); - optionName.setText(savedOptionName); - optionValue.setText( - (String)macroTableModel.getValueAt(index, 1)); - } - } - }); - - // Only enable OK if the name is not empty - name.getDocument().addDocumentListener(new DocumentListener() { - public void insertUpdate(DocumentEvent e) { - buttonPanel.setOkEnabled(e.getDocument().getLength() != 0); - } - public void changedUpdate(DocumentEvent e) { - insertUpdate(e); - } - public void removeUpdate(DocumentEvent e) { - insertUpdate(e); - } - }); - - // Only enable add/modify when option name is non-empty - optionName.getDocument().addDocumentListener(new DocumentListener() { - public void insertUpdate(DocumentEvent e) { - boolean state = (optionName.getDocument().getLength() != 0); - addButton.setEnabled(state); - if (state == false) { - modifyButton.setEnabled(state); - } else if (macroTable.getSelectedRowCount() > 0) { - modifyButton.setEnabled(state); - } - } - public void changedUpdate(DocumentEvent e) { - insertUpdate(e); - } - public void removeUpdate(DocumentEvent e) { - insertUpdate(e); - } - }); - - if (mode == EDIT) { - buttonPanel.setOkEnabled(true); - } - setMacro(new Macro()); - } - - /** - * Display this dialog, and auto-validate its contents to start with - */ - public void setVisible(boolean visible) { - super.setVisible(visible); - /* - * If we're being hidden, then just return - */ - if (!visible) - return; - /* - * Validate the current contents of the macro so we can tell the user - * about any syntax errors in the existing definition. - */ - try { - macroTableModel.macro.validate(); - } catch (ValidationException e) { - // Errors; advise user by putting up a dialog - MessageFormat form = new MessageFormat( - ResourceStrings.getString("bad_option_value")); - Object [] args = new Object[2]; - OptionValue ov = macroTableModel.macro.getOption(e.getMessage()); - if (ov == null) { - args[0] = ""; - } else { - args[0] = ov.getValue(); - } - args[1] = e.getMessage(); - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - int row = macroTableModel.findRowForOption(e.getMessage()); - if (row != -1) { - macroTable.clearSelection(); - macroTable.addRowSelectionInterval(row, row); - macroTable.scrollRectToVisible( - macroTable.getCellRect(row, 0, false)); - } - } - } - - public void setMacro(Macro m) { - originalMacro = (Macro)m.clone(); // Keep a copy so we can do a reset - if (mode != DUPLICATE) { - name.setText(m.getKey()); - } - macroTableModel.setMacro(m); - } - - public void buttonPressed(int buttonId) { - switch (buttonId) { - case OK: - // A macro with no options is not useful, so don't allow it - if (macroTableModel.getRowCount() == 0) { - JOptionPane.showMessageDialog(this, - ResourceStrings.getString("empty_macro_error"), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - return; - } - try { - macroTableModel.macro.setKey(name.getText()); - } catch (ValidationException e) { - // Not a valid macro name - MessageFormat form = new MessageFormat( - ResourceStrings.getString("bad_macro_name")); - Object [] args = new Object[] { name.getText() }; - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - return; - } - try { - // Validate the macro - macroTableModel.macro.validate(); - DhcptabMgr server = DataManager.get().getDhcptabMgr(); - if ((mode == CREATE) || (mode == DUPLICATE)) { - server.createRecord(macroTableModel.macro, - signalBox.isSelected()); - } else if (mode == EDIT) { - server.modifyRecord(originalMacro, macroTableModel.macro, - signalBox.isSelected()); - } - fireActionPerformed(); - setVisible(false); - dispose(); - } catch (ValidationException ve) { - MessageFormat form = new MessageFormat( - ResourceStrings.getString("bad_option_value")); - Object [] args = new Object[2]; - OptionValue ov = - macroTableModel.macro.getOption(ve.getMessage()); - if (ov == null) { - args[0] = ""; - } else { - args[0] = ov.getValue(); - } - args[1] = ve.getMessage(); - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } catch (NotRunningException e) { - // Server not running, put up a warning - JOptionPane.showMessageDialog(this, - ResourceStrings.getString("server_not_running"), - ResourceStrings.getString("warning"), - JOptionPane.WARNING_MESSAGE); - fireActionPerformed(); - setVisible(false); - dispose(); - } catch (Exception e) { - MessageFormat form = null; - Object [] args = new Object[2]; - switch (mode) { - case CREATE: - case DUPLICATE: - form = new MessageFormat( - ResourceStrings.getString("create_macro_error")); - args[0] = macroTableModel.macro.getKey(); - break; - case EDIT: - form = new MessageFormat( - ResourceStrings.getString("edit_macro_error")); - args[0] = originalMacro.getKey(); - break; - } - args[1] = e.getMessage(); - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - break; - case CANCEL: - setVisible(false); - dispose(); - break; - case HELP: - String helpTag = null; - switch (mode) { - case CREATE: - helpTag = "create_macro"; - break; - case DUPLICATE: - helpTag = "duplicate_macro"; - break; - case EDIT: - helpTag = "modify_macro"; - break; - } - DhcpmgrApplet.showHelp(helpTag); - break; - case RESET: - setMacro(originalMacro); - signalBox.setSelected(true); - break; - } - } - - public void addActionListener(ActionListener l) { - listeners.addElement(l); - } - - public void removeActionListener(ActionListener l) { - listeners.removeElement(l); - } - - protected void fireActionPerformed() { - String command = null; - switch (mode) { - case CREATE: - command = DialogActions.CREATE; - case DUPLICATE: - command = DialogActions.DUPLICATE; - break; - case EDIT: - command = DialogActions.EDIT; - break; - } - ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, - command); - Enumeration en = listeners.elements(); - while (en.hasMoreElements()) { - ActionListener l = (ActionListener)en.nextElement(); - l.actionPerformed(e); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/CreateOptionDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/CreateOptionDialog.java deleted file mode 100644 index f485cbf448..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/CreateOptionDialog.java +++ /dev/null @@ -1,716 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.event.*; -import javax.swing.table.*; - -import java.awt.*; -import java.awt.event.*; -import java.text.MessageFormat; -import java.util.*; - -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.bridge.NotRunningException; - - -/** - * Dialog to create/duplicate/edit an option. - */ -public class CreateOptionDialog extends JDialog implements ButtonPanelListener { - public static final int CREATE = 0; - public static final int EDIT = 1; - public static final int DUPLICATE = 2; - - private int mode = CREATE; - private OptionNameField name; - private JComboBox category; - private IntegerField code; - private JComboBox type; - private JList classList; - private JTextField clientClass; - private IntegerField granularity; - private IntegerField maximum; - private JCheckBox signalBox; - private Vector listeners; - private Option option, originalOption; - private ButtonPanel buttonPanel; - private ClassListModel classListModel; - private JButton add, delete; - private UpButton moveUp; - private DownButton moveDown; - private OptionContext [] categories = { - Option.ctxts[Option.EXTEND], - Option.ctxts[Option.VENDOR], - Option.ctxts[Option.SITE] - }; - - // Model for the list of vendor classes - class ClassListModel extends AbstractListModel { - - public ClassListModel() { - super(); - } - - public int getSize() { - return option.getVendorCount(); - } - - public Object getElementAt(int index) { - return option.getVendorAt(index); - } - - public void addElement(String v) throws ValidationException { - option.addVendor(v); - fireIntervalAdded(this, option.getVendorCount()-1, - option.getVendorCount()-1); - } - - public void removeElementAt(int index) { - option.removeVendorAt(index); - fireIntervalRemoved(this, index, index); - } - - public void moveUp(int index) { - String t = (String)option.getVendorAt(index-1); - option.setVendorAt(option.getVendorAt(index), index-1); - option.setVendorAt(t, index); - fireContentsChanged(this, index-1, index); - } - - public void moveDown(int index) { - String t = (String)option.getVendorAt(index+1); - option.setVendorAt(option.getVendorAt(index), index+1); - option.setVendorAt(t, index); - fireContentsChanged(this, index, index+1); - } - - public void reset() { - fireContentsChanged(this, 0, getSize()); - } - } - - public CreateOptionDialog(Frame f, int mode) { - super(f); - setLocationRelativeTo(f); - JPanel classPanel; - - listeners = new Vector(); - - this.mode = mode; - switch (mode) { - case CREATE: - setTitle(ResourceStrings.getString("create_option_title")); - break; - case EDIT: - setTitle(ResourceStrings.getString("edit_option_title")); - break; - case DUPLICATE: - setTitle(ResourceStrings.getString("duplicate_option_title")); - break; - default: - break; - } - - getContentPane().setLayout(new BoxLayout(getContentPane(), - BoxLayout.Y_AXIS)); - - JPanel mainPanel = new JPanel(new BorderLayout()); - mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - - JPanel fieldPanel = new JPanel(); - GridBagLayout bag = new GridBagLayout(); - fieldPanel.setLayout(bag); - - // Initialize constraints - GridBagConstraints c = new GridBagConstraints(); - c.gridx = c.gridy = 0; - c.gridwidth = c.gridheight = 1; - c.fill = GridBagConstraints.HORIZONTAL; - c.insets = new Insets(5, 5, 5, 5); - c.weightx = c.weighty = 1.0; - - // Label and text field for name - Mnemonic mnOname = - new Mnemonic(ResourceStrings.getString("op_name")); - JLabel l = new JLabel(mnOname.getString(), SwingConstants.RIGHT); - - bag.setConstraints(l, c); - fieldPanel.add(l); - name = new OptionNameField(""); - - l.setLabelFor(name); - l.setToolTipText(mnOname.getString()); - l.setDisplayedMnemonic(mnOname.getMnemonic()); - - l.setLabelFor(name); - ++c.gridx; - bag.setConstraints(name, c); - fieldPanel.add(name); - - // Label and combo box for category - Mnemonic mnCat = - new Mnemonic(ResourceStrings.getString("category_label")); - l = new JLabel(mnCat.getString(), SwingConstants.RIGHT); - - c.gridx = 0; - ++c.gridy; - bag.setConstraints(l, c); - fieldPanel.add(l); - category = new JComboBox(categories); - - l.setLabelFor(category); - l.setToolTipText(mnCat.getString()); - l.setDisplayedMnemonic(mnCat.getMnemonic()); - - category.setEditable(false); - ++c.gridx; - bag.setConstraints(category, c); - fieldPanel.add(category); - - // Label and text field for code - Mnemonic mnCode = - new Mnemonic(ResourceStrings.getString("option_code_label")); - l = new JLabel(mnCode.getString(), SwingConstants.RIGHT); - - c.gridx = 0; - ++c.gridy; - bag.setConstraints(l, c); - fieldPanel.add(l); - code = new IntegerField(); - - l.setLabelFor(code); - l.setToolTipText(mnCode.getString()); - l.setDisplayedMnemonic(mnCode.getMnemonic()); - - ++c.gridx; - bag.setConstraints(code, c); - fieldPanel.add(code); - - // Label and combo box for data type - Mnemonic mnType = - new Mnemonic(ResourceStrings.getString("data_type_label")); - l = new JLabel(mnType.getString(), SwingConstants.RIGHT); - - c.gridx = 0; - ++c.gridy; - bag.setConstraints(l, c); - fieldPanel.add(l); - type = new JComboBox(Option.types); - - l.setLabelFor(type); - l.setToolTipText(mnType.getString()); - l.setDisplayedMnemonic(mnType.getMnemonic()); - - type.setEditable(false); - ++c.gridx; - bag.setConstraints(type, c); - fieldPanel.add(type); - - // Label and text field for granularity - Mnemonic mnGran = - new Mnemonic(ResourceStrings.getString("granularity_label")); - l = new JLabel(mnGran.getString(), SwingConstants.RIGHT); - - c.gridx = 0; - ++c.gridy; - bag.setConstraints(l, c); - fieldPanel.add(l); - granularity = new IntegerField(5); - - l.setLabelFor(granularity); - l.setToolTipText(mnGran.getString()); - l.setDisplayedMnemonic(mnGran.getMnemonic()); - - ++c.gridx; - bag.setConstraints(granularity, c); - fieldPanel.add(granularity); - - // Label and text field for maximum - Mnemonic mnMax = - new Mnemonic(ResourceStrings.getString("maximum_label")); - l = new JLabel(mnMax.getString(), SwingConstants.RIGHT); - - c.gridx = 0; - ++c.gridy; - bag.setConstraints(l, c); - fieldPanel.add(l); - maximum = new IntegerField(5); - - l.setLabelFor(maximum); - l.setToolTipText(mnMax.getString()); - l.setDisplayedMnemonic(mnMax.getMnemonic()); - - ++c.gridx; - bag.setConstraints(maximum, c); - fieldPanel.add(maximum); - - mainPanel.add(fieldPanel, BorderLayout.WEST); - - // Editing controls for client classes - bag = new GridBagLayout(); - classPanel = new JPanel(bag); - Border tb = BorderFactory.createTitledBorder( - BorderFactory.createLineBorder(Color.black), - ResourceStrings.getString("client_classes_label")); - classPanel.setBorder(BorderFactory.createCompoundBorder(tb, - BorderFactory.createEmptyBorder(5, 5, 5, 5))); - - c = new GridBagConstraints(); - c.gridx = c.gridy = 0; - c.weightx = c.weighty = 1.0; - c.gridheight = 1; - c.gridwidth = 1; - - // Field to type in new classes - clientClass = new JTextField("", 20); - c.fill = GridBagConstraints.HORIZONTAL; - bag.setConstraints(clientClass, c); - classPanel.add(clientClass); - - // Button for Add operation - Mnemonic mnAdd = - new Mnemonic(ResourceStrings.getString("add")); - add = new JButton(mnAdd.getString()); - add.setToolTipText(mnAdd.getString()); - add.setMnemonic(mnAdd.getMnemonic()); - - c.fill = GridBagConstraints.NONE; - ++c.gridx; - c.weightx = 0.5; - bag.setConstraints(add, c); - classPanel.add(add); - - // List for classes - classListModel = new ClassListModel(); - classList = new JList(classListModel); - - // Make sure it's approximately wide enough for our purposes, 20 chars - classList.setPrototypeCellValue("abcdefghijklmnopqrst"); - classList.setSelectionMode( - ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - JScrollPane scrollPane = new JScrollPane(classList); - c.fill = GridBagConstraints.BOTH; - c.gridx = 0; - ++c.gridy; - c.weightx = 1.0; - bag.setConstraints(scrollPane, c); - classPanel.add(scrollPane); - - // Buttons to manipulate the list contents - JPanel editButtonPanel = new JPanel(new VerticalButtonLayout()); - moveUp = new UpButton(); - editButtonPanel.add(moveUp); - moveDown = new DownButton(); - editButtonPanel.add(moveDown); - - Mnemonic mnDelete = - new Mnemonic(ResourceStrings.getString("delete")); - delete = new JButton(mnDelete.getString()); - delete.setToolTipText(mnDelete.getString()); - delete.setMnemonic(mnDelete.getMnemonic()); - - editButtonPanel.add(delete); - ++c.gridx; - c.weightx = 0.5; - bag.setConstraints(editButtonPanel, c); - classPanel.add(editButtonPanel); - - /* - * Disable all buttons to start; selection changes will adjust button - * state as necessary - */ - add.setEnabled(false); - delete.setEnabled(false); - moveUp.setEnabled(false); - moveDown.setEnabled(false); - - // Create listener for button presses, take action as needed - ActionListener al = new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (e.getSource() == add || e.getSource() == clientClass) { - try { - classListModel.addElement(clientClass.getText()); - } catch (ValidationException ex) { - // Something wrong with class name - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_client_class")); - Object [] args = new Object[] { clientClass.getText() }; - JOptionPane.showMessageDialog(CreateOptionDialog.this, - form.format(args), - ResourceStrings.getString("input_error"), - JOptionPane.ERROR_MESSAGE); - return; - } - } else if (e.getSource() == delete) { - int [] indices = classList.getSelectedIndices(); - if (indices.length > 1) { - /* - * Need to sort them so that the delete's don't - * interfere with each other - */ - for (int i = 0; i < indices.length; ++i) { - for (int j = i; j < indices.length; ++j) { - if (indices[i] > indices[j]) { - int k = indices[i]; - indices[i] = indices[j]; - indices[j] = k; - } - } - } - } - // Now delete from high index to low - for (int i = indices.length - 1; i >= 0; --i) { - classListModel.removeElementAt(indices[i]); - } - if (indices.length > 1) { - // Clear selection if multiple deleted - classList.clearSelection(); - /* - * XXX We don't get a selection event for some reason, - * make it work for now - */ - delete.setEnabled(false); - } else { - // Make sure to select something in the list - if (classListModel.getSize() == 0) { - // List is empty, so disable delete - delete.setEnabled(false); - } else if (indices[0] >= classListModel.getSize()) { - // Select last one if we're off the end - classList.setSelectedIndex( - classListModel.getSize()-1); - } else { - // Select next one in list - classList.setSelectedIndex(indices[0]); - } - } - } else if (e.getSource() == moveUp) { - int i = classList.getSelectedIndex(); - classListModel.moveUp(i); - // Keep item selected so repeated moveUp's affect same item - classList.setSelectedIndex(i-1); - } else if (e.getSource() == moveDown) { - int i = classList.getSelectedIndex(); - classListModel.moveDown(i); - // Keep item selected so repeated moveDowns affect same item - classList.setSelectedIndex(i+1); - } - } - }; - clientClass.addActionListener(al); - add.addActionListener(al); - delete.addActionListener(al); - moveUp.addActionListener(al); - moveDown.addActionListener(al); - - // Put a selection listener on the list to enable buttons appropriately - classList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - int [] indices = classList.getSelectedIndices(); - switch (indices.length) { - case 0: - // Nothing selected; disable them all - delete.setEnabled(false); - moveUp.setEnabled(false); - moveDown.setEnabled(false); - break; - case 1: - delete.setEnabled(true); - // Can't move first one up - moveUp.setEnabled(indices[0] != 0); - // Can't move last one down - if (indices[0] == (classListModel.getSize() - 1)) { - moveDown.setEnabled(false); - } else { - moveDown.setEnabled(true); - } - break; - default: - // More than one; only delete is allowed - delete.setEnabled(true); - moveUp.setEnabled(false); - moveDown.setEnabled(false); - } - } - }); - // Enable Add when class is not empty. - clientClass.getDocument().addDocumentListener(new DocumentListener() { - public void insertUpdate(DocumentEvent e) { - add.setEnabled(clientClass.getText().length() != 0); - } - public void changedUpdate(DocumentEvent e) { - insertUpdate(e); - } - public void removeUpdate(DocumentEvent e) { - insertUpdate(e); - } - }); - - mainPanel.add(classPanel, BorderLayout.CENTER); - - signalBox = new JCheckBox(ResourceStrings.getString("signal_server"), - true); - signalBox.setToolTipText( - ResourceStrings.getString("signal_server")); - signalBox.setHorizontalAlignment(SwingConstants.CENTER); - JPanel signalPanel = new JPanel(); - signalPanel.add(signalBox); - mainPanel.add(signalPanel, BorderLayout.SOUTH); - - getContentPane().add(mainPanel); - getContentPane().add(new JSeparator()); - - buttonPanel = new ButtonPanel(true); - buttonPanel.addButtonPanelListener(this); - getContentPane().add(buttonPanel); - - setOption(new Option()); - - if (mode == EDIT) { - buttonPanel.setOkEnabled(true); - } - - // Enable OK when there is data in the name field - name.getDocument().addDocumentListener(new DocumentListener() { - public void insertUpdate(DocumentEvent e) { - buttonPanel.setOkEnabled(e.getDocument().getLength() != 0); - } - public void changedUpdate(DocumentEvent e) { - insertUpdate(e); - } - public void removeUpdate(DocumentEvent e) { - insertUpdate(e); - } - }); - - // If category != VENDOR you can't mess with the client class data - category.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - OptionContext ctxt = categories[category.getSelectedIndex()]; - boolean isVendor = - (ctxt.getCode() == Option.ctxts[Option.VENDOR].getCode()); - if (!isVendor) { - option.clearVendors(); - clientClass.setText(""); - } - clientClass.setEnabled(isVendor); - classList.setEnabled(isVendor); - } - }); - - // Update state of granularity & maximum depending on data type selected - type.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - OptionType stype = Option.types[type.getSelectedIndex()]; - byte code = stype.getCode(); - // Set granularity to correct minimum for type - if (code == Option.types[Option.BOOLEAN].getCode()) { - granularity.setText("0"); - } else if ("0".equals(granularity.getText())) { - granularity.setText("1"); - } - // Now set editability of the granularity and max fields - if (code == Option.types[Option.ASCII].getCode() || - code == Option.types[Option.OCTET].getCode()) { - granularity.setEditable(false); - maximum.setEditable(true); - } else if (code == Option.types[Option.BOOLEAN].getCode()) { - granularity.setEditable(false); - // Also reset maximum value in this case - maximum.setText("0"); - maximum.setEditable(false); - } else if (code == Option.types[Option.NUMBER].getCode() || - code == Option.types[Option.UNUMBER8].getCode() || - code == Option.types[Option.UNUMBER16].getCode() || - code == Option.types[Option.UNUMBER32].getCode() || - code == Option.types[Option.UNUMBER64].getCode() || - code == Option.types[Option.SNUMBER8].getCode() || - code == Option.types[Option.SNUMBER16].getCode() || - code == Option.types[Option.SNUMBER32].getCode() || - code == Option.types[Option.SNUMBER64].getCode() || - code == Option.types[Option.IP].getCode()) { - granularity.setEditable(true); - maximum.setEditable(true); - } - } - }); - } - - public void setOption(Option o) { - originalOption = o; // Keep a copy so reset will work - option = (Option)o.clone(); - resetValues(); - } - - private void resetValues() { - if (mode == DUPLICATE) { - name.setText(""); - } else { - name.setText(option.getKey()); - } - for (int i = 0; i < categories.length; i++) { - if (categories[i].getCode() == option.getContext()) { - category.setSelectedIndex(i); - break; - } - } - - for (int i = 0; i < Option.types.length; i++) { - if (Option.types[i].getCode() == option.getType()) { - type.setSelectedIndex(i); - break; - } - } - - code.setValue(option.getCode()); - granularity.setValue(option.getGranularity()); - maximum.setValue(option.getMaximum()); - classListModel.reset(); - signalBox.setSelected(true); - } - - public void buttonPressed(int buttonId) { - switch (buttonId) { - case OK: - try { - OptionContext sctxt = categories[category.getSelectedIndex()]; - OptionType stype = Option.types[type.getSelectedIndex()]; - option.setKey(name.getText()); - option.setContext(sctxt.getCode()); - option.setCode((short)code.getValue()); - option.setType(stype.getCode()); - option.setGranularity(granularity.getValue()); - option.setMaximum(maximum.getValue()); - if (sctxt.getCode() == Option.ctxts[Option.VENDOR].getCode() && - option.getVendorCount() == 0) { - JOptionPane.showMessageDialog(this, - ResourceStrings.getString("empty_vendor_error"), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - return; - } - DhcptabMgr server = DataManager.get().getDhcptabMgr(); - if ((mode == CREATE) || (mode == DUPLICATE)) { - server.createRecord(option, signalBox.isSelected()); - } else if (mode == EDIT) { - server.modifyRecord(originalOption, option, - signalBox.isSelected()); - } - fireActionPerformed(); - setVisible(false); - dispose(); - } catch (NotRunningException e) { - // Server not running, put up a warning - JOptionPane.showMessageDialog(this, - ResourceStrings.getString("server_not_running"), - ResourceStrings.getString("warning"), - JOptionPane.WARNING_MESSAGE); - fireActionPerformed(); - setVisible(false); - dispose(); - } catch (Exception e) { - MessageFormat form = null; - Object [] args = new Object[2]; - switch (mode) { - case CREATE: - case DUPLICATE: - form = new MessageFormat( - ResourceStrings.getString("create_option_error")); - args[0] = option.getKey(); - break; - case EDIT: - form = new MessageFormat( - ResourceStrings.getString("edit_option_error")); - args[0] = originalOption.getKey(); - break; - } - args[1] = e.getMessage(); - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - break; - case CANCEL: - setVisible(false); - dispose(); - break; - case HELP: - String helpTag = null; - switch (mode) { - case CREATE: - helpTag = "create_option"; - break; - case DUPLICATE: - helpTag = "duplicate_option"; - break; - case EDIT: - helpTag = "modify_option"; - break; - } - DhcpmgrApplet.showHelp(helpTag); - break; - case RESET: - setOption(originalOption); - break; - } - } - - public void addActionListener(ActionListener l) { - listeners.addElement(l); - } - - public void removeActionListener(ActionListener l) { - listeners.removeElement(l); - } - - protected void fireActionPerformed() { - String command = null; - switch (mode) { - case CREATE: - command = DialogActions.CREATE; - case DUPLICATE: - command = DialogActions.DUPLICATE; - break; - case EDIT: - command = DialogActions.EDIT; - break; - } - ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, - command); - Enumeration en = listeners.elements(); - while (en.hasMoreElements()) { - ActionListener l = (ActionListener)en.nextElement(); - l.actionPerformed(e); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DSModule.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DSModule.java deleted file mode 100644 index b4999bb1b4..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DSModule.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import java.awt.*; -import java.util.*; -import javax.swing.event.EventListenerList; - -/** - * This class provides a skeletal implementation of the data store module - * management interface to minimize the effort required to implement a - * data store management class. - */ -public abstract class DSModule { - - /** - * Listeners registered with the DSModule. - */ - private EventListenerList DSMListeners = new EventListenerList(); - - /** - * Attribute that signifies whether or not the data store has been - * configured well enough to allow the data store to be managed. - */ - private boolean forwardEnabled = false; - - /** - * Returns the path that is used by the data store (i.e., the PATH value - * in the DHCP config file). - * @return the path that is used by the data store (i.e., the PATH value - * in the DHCP config file) or null if not set. - */ - public abstract String getPath(); - - /** - * Returns additional datastore specific information (i.e., the - * RESOURCE_CONFIG value in the DHCP config file). - * @return additional datastore specific information (i.e., the - * RESOURCE_CONFIG value in the DHCP config file) or null if not set. - */ - public abstract String getAdditionalInfo(); - - /** - * Returns the description that will be used by the DHCP configuration - * wizard when adding the data store to the list of data store radio - * buttons. - * @return the description that will be used by the DHCP configuration - * wizard when adding the data store to the list of data store radio - * buttons. - */ - public abstract String getDescription(); - - /** - * Returns the component that will be used by the DHCP configuration - * wizard to manage obtaining the data store parameters. - * @return the component that will be used by the DHCP configuration - * wizard to manage obtaining the data store parameters. - */ - public abstract Component getComponent(); - - /** - * Adds a listener to the DSModule listener list. - * @param l the listener. - */ - public void addDSMListener(DSModuleListener l) { - DSMListeners.add(DSModuleListener.class, l); - } // addDSMListener - - /** - * Removes a listener from the DSModule listener list. - * @param l the listener. - */ - public void removeDSMListener(DSModuleListener l) { - DSMListeners.remove(DSModuleListener.class, l); - } // removeDSMListener - - /** - * Fires a DSModuleEvent to all DSModule listeners on the listener list. - * @param e the DSModuleEvent to be fired. - */ - private void fireDSMEvent(DSModuleEvent e) { - // Guaranteed to return a non-null array - Object[] listeners = DSMListeners.getListenerList(); - - // Process the listeners last to first, notifying - // those that are interested in this event - for (int i = listeners.length - 2; i >= 0; i -= 2) { - if (listeners[i] == DSModuleListener.class) { - ((DSModuleListener)listeners[i + 1]).stateChanged(e); - } - } - } // fireDSMEvent - - /** - * Returns the modules readiness state (i.e., can the DHCP config wizard - * continue forward if the user wishes). - * @return the modules readiness state - */ - public final boolean getForwardEnabled() { - return forwardEnabled; - } // getForwardEnabled - - /** - * Sets the forwardEnabled attribute and fires a DSModuleEvent to the DHCP - * configuration wizard to let it know that the module's state has changed. - * @param enable value to which forwardEnabled should be set. - */ - public final void setForwardEnabled(boolean enable) { - - forwardEnabled = enable; - - int state = DSModuleEvent.DATA_VALID; - if (!enable) { - state = DSModuleEvent.DATA_INVALID; - } - - fireDSMEvent(new DSModuleEvent(this, state)); - } // setForwardEnabled - -} // DSModule diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DSModuleEvent.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DSModuleEvent.java deleted file mode 100644 index 35b43a041c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DSModuleEvent.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import java.util.*; - -/** - * This class defines a DSModule event. These events are the means by which - * a DSModule communicates with the DHCP configuration wizard. - */ -public class DSModuleEvent extends EventObject { - - /** - * Signifies that the DSModule configuration data is valid. - */ - public static final int DATA_VALID = 0; - - /** - * Signifies that the DSModule configuration data is not valid. - */ - public static final int DATA_INVALID = 1; - - /** - * Set to DATA_VALID or DATA_INVALID. - */ - private int state; - - /** - * Constructs a DSModuleEvent from a source and state. - * @param source module that is source of the event. - * @param state DATA_VALID or DATA_INVALID. - */ - public DSModuleEvent(Object source, int state) { - super(source); - this.state = state; - } // constructor - - /** - * Returns the state of the event. - * @return the state of the event. - */ - public int getState() { - return state; - }// getState - -} // DSModuleEvent diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DSModuleListener.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DSModuleListener.java deleted file mode 100644 index 785b11eb93..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DSModuleListener.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import java.util.*; - -/** - * This class defines a listener interface such that events may be received - * from the DSModule classes. - */ -public interface DSModuleListener extends EventListener { - - /** - * Method called when the state of a DSModule changes. - * @param e the event - */ - public void stateChanged(DSModuleEvent e); - -} // DSModuleListner diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DSWizard.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DSWizard.java deleted file mode 100644 index 2ab789a1ce..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DSWizard.java +++ /dev/null @@ -1,436 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.text.MessageFormat; - -import javax.swing.*; - -import com.sun.dhcpmgr.data.DhcpDatastore; -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.ui.*; - -/** - * This class defines a Wizard that configures a data store. - */ -public abstract class DSWizard extends Wizard implements DSModuleListener { - - /** - * The collection of valid DSConf objects. - */ - protected DSConfList dsconfList = null; - - /** - * The selected DSConf - */ - private DSConf dsconf = null; - - /** - * This class is a holder for the set of DSConf objects. - */ - protected class DSConfList extends ArrayList { - - /** - * Initializes the set of supported DSConfList. - * @param server handle to a service manager server - */ - public void init(DhcpServiceMgr server) { - - DhcpDatastore [] dsArray = null; - - try { - dsArray = server.getDataStores(); - } catch (Throwable e) { - // ignore for now - } - - for (int i = 0; - dsArray != null && i < dsArray.length; i++) { - String dsResource = dsArray[i].getResource(); - try { - - String className = server.getDataStoreClassname(dsResource); - DSConf dsconf = new DSConf(dsArray[i], className); - dsconfList.add(dsconf); - } catch (Throwable e) { - MessageFormat form = new MessageFormat( - ResourceStrings.getString("ds_wiz_init_error")); - Object args = new Object[] { - dsResource, - e.getMessage() - }; - JOptionPane.showMessageDialog(DSWizard.this, - form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - } - } // init - - /** - * Finds and returns a DSConf by resource. - * @param resource the resource of the DSConf. - * @return the DSConf if found or null if not found. - */ - public DSConf findDsconf(String resource) { - - DSConf entry = null; - for (int i = 0; i < size(); i++) { - DSConf dsconf = (DSConf) get(i); - if (dsconf.getDS().getResource().equals(resource)) { - entry = dsconf; - break; - } - } - - return entry; - - } // findDSConf - - } // DSConfList - - /** - * This class is a simple holder for a data store - * and the module used to manage the data store. - */ - protected class DSConf { - - /** - * DHCP datastore information. - */ - private DhcpDatastore ds = null; - - /** - * The module used to manage the data store. - */ - private DSModule dsm = null; - - /** - * Constructs a DSConf from a name and a classname. - * @param ds DHCP data store. - * @param className of the DSModule classname. - */ - public DSConf(DhcpDatastore ds, String className) - throws Exception { - - Class dataStoreClass = Class.forName(className); - - dsm = (DSModule)dataStoreClass.newInstance(); - this.ds = ds; - } // constructor - - /** - * Returns the DhcpDatastore for this DSConf - * @return the DhcpDatastore for this DSConf - */ - public DhcpDatastore getDS() { - return ds; - } // getDS - - /** - * Returns the module used to manage the data store. - * @return the module used to manage the data store. - */ - public DSModule getModule() { - return dsm; - } // getModule - - - /** - * Sets the location from the module into the DhcpDatastore. - */ - public void setLocation() { - ds.setLocation(dsm.getPath()); - } // setLocation - - /** - * Sets the location from the module into the DhcpDatastore. - */ - public void setConfig() { - ds.setConfig(dsm.getAdditionalInfo()); - } // setConfig - - } // DSConf - - /** - * This class maps a radio button and a DSConf. - */ - private class DSConfButton extends JRadioButton { - - /** - * The data store to link to the radio button. - */ - DSConf dsconf = null; - - /** - * Constructs a DSConfButton from a DSConf and determines - * whether the button should be selected using the boolean argument. - * @param dsconf the data store to map to the radio button. - * @param selected select the radio button? - */ - public DSConfButton(DSConf dsconf, boolean selected) { - super(dsconf.getModule().getDescription(), selected); - setEnabled(dsconf.getDS().isEnabled()); - this.dsconf = dsconf; - } // constructor - - /** - * Returns the DSConf mapped to the radio button. - * @return the DSConf mapped to the radio button. - */ - public DSConf getDsconf() { - return dsconf; - } // getDsconf - - } // DSConfButton - - - /** - * This class is the wizard step that presents the choice of - * data stores to the user for selection. - */ - protected class DatastoreStep implements WizardStep { - - /** - * The component provided to the wizard. - */ - private Box stepBox; - - /** - * The group of DSConfButton objects. - */ - private ButtonGroup buttonGroup; - - /** - * The basic constructor for the wizard step. - * @param wizardText the main explanatory text for the wizard. - * @param stepText the explanatory text for the step. - */ - public DatastoreStep(String wizardText, String stepText) { - - super(); - - stepBox = Box.createVerticalBox(); - - // Explanatory wizard intro text - // - JComponent c = Wizard.createTextArea(wizardText, 2, 45); - c.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(c); - stepBox.add(Box.createVerticalStrut(5)); - - // Explanatory step text - // - c = Wizard.createTextArea(stepText, 3, 45); - c.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(c); - stepBox.add(Box.createVerticalStrut(5)); - - // Create button listener, that will set the selected - // data store when the button is selected. - // - ActionListener buttonListener = new ActionListener() { - public void actionPerformed(ActionEvent e) { - DSConfButton button = (DSConfButton)e.getSource(); - if (button.isSelected()) { - setDsconf(button.getDsconf()); - } - } - }; - - // Create panel that will contain the buttons. - // - JPanel boxPanel = new JPanel(); - boxPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - boxPanel.setLayout(new BoxLayout(boxPanel, BoxLayout.Y_AXIS)); - boxPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20)); - - // List data store choices. - // - buttonGroup = new ButtonGroup(); - for (int i = 0; i < dsconfList.size(); ++i) { - DSConf dsconf = (DSConf)dsconfList.get(i); - DSConfButton radioButton = - new DSConfButton(dsconf, false); - radioButton.setAlignmentX(Component.LEFT_ALIGNMENT); - radioButton.addActionListener(buttonListener); - buttonGroup.add(radioButton); - boxPanel.add(radioButton); - } - - // Add the panel to the stepBox component. - // - stepBox.add(boxPanel); - stepBox.add(Box.createVerticalStrut(20)); - stepBox.add(Box.createVerticalGlue()); - - } // constructor - - public String getDescription() { - return ResourceStrings.getString("ds_wiz_datastore_desc"); - } // getDescription - - public Component getComponent() { - return stepBox; - } // getComponent - - public void setActive(int direction) { - if (getDsconf() != null) { - setForwardEnabled(true); - } else { - setForwardEnabled(false); - } - } // setActive - - public boolean setInactive(int direction) { - return true; - } // setInactive - - - public void enableButton(String resource, boolean enable) { - - DSConfButton button = null; - Enumeration en = buttonGroup.getElements(); - while (en.hasMoreElements()) { - DSConfButton enButton = (DSConfButton)en.nextElement(); - DSConf DSConf = enButton.getDsconf(); - if (dsconf.getDS().getResource().equals(resource)) { - button = enButton; - break; - } - } - - if (button != null) { - button.setEnabled(enable); - } - - } // enableButton - - } // DatastoreStep - - /** - * This class is the wizard step that presents the data store module - * bean to the user for data store configuration. - */ - protected class DatastoreModuleStep implements WizardStep { - - /** - * The component provided to the wizard. - */ - private Box stepBox; - - /** - * Basic constructor. The component for the step will actually be - * built in the setActive method, as this step is dependant upon - * the data store selection made by the user in the DatastoreStep - * wizard step. - */ - public DatastoreModuleStep() { - stepBox = Box.createVerticalBox(); - stepBox.add(Box.createVerticalGlue()); - } // constructor - - public String getDescription() { - return ResourceStrings.getString("ds_wiz_datastore_parm_desc"); - } // getDescription - - public Component getComponent() { - return stepBox; - } // getComponent - - public void setActive(int direction) { - if (direction > 0) { - stepBox.removeAll(); - Component component = - getDsconf().getModule().getComponent(); - if (component != null) { - stepBox.add(component); - stepBox.add(Box.createVerticalGlue()); - validate(); - } - } - - if (getDsconf().getModule().getForwardEnabled()) { - setForwardEnabled(true); - } else { - setForwardEnabled(false); - } - } // setActive - - public boolean setInactive(int direction) { - return true; - } // setInactive - - } // DatastoreModuleStep - - /** - * Simple constructor. - * @param owner frame for wizard. - * @param title title of the wizard. - */ - public DSWizard(Frame owner, String title) { - super(owner, title); - } // constructor - - /** - * Sets dsconf. - * @param dsconf the data store config value. - */ - public void setDsconf(DSConf dsconf) { - if (this.dsconf != null) { - this.dsconf.getModule().removeDSMListener(this); - } - setForwardEnabled(true); - this.dsconf = dsconf; - this.dsconf.getModule().addDSMListener(this); - } // setDsconf - - /** - * Returns the dsconf. - * @return the dsconf. - */ - public DSConf getDsconf() { - return dsconf; - } // getDsconf - - /** - * Invoked when the DSModule has changed its state. - * @param e the event. - */ - public void stateChanged(DSModuleEvent e) { - if (e.getState() == DSModuleEvent.DATA_VALID) { - setForwardEnabled(true); - } else { - setForwardEnabled(false); - } - } // stateChanged - -} // DSWizard diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DataManager.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DataManager.java deleted file mode 100644 index 34360778a0..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DataManager.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import java.util.Arrays; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.text.MessageFormat; - -import javax.swing.*; - -import com.sun.dhcpmgr.bridge.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.server.*; - -/** - * DataManager implements a central point of contact between the client and the - * server components; the client obtains all server object references through - * this class which allows us to cache information as much as possible, - * improving users' perception of the performance of the tool. - */ -public class DataManager { - private DhcpMgr server; - private DhcpNetMgr netMgr; - private DhcptabMgr dhcptabMgr; - private DhcpServiceMgr dhcpServiceMgr; - private Network [] networks; - private DhcpClientRecord [] clients; - private String clientNet; - private Macro [] macros; - private Option [] options; - private String serverName; - private String shortServerName; - private InetAddress serverAddress; - private static DataManager mgr = null; - - private DataManager() { - reset(); - } - - public synchronized void reset() { - // Clear the data references; used by the applet to re-initialize - server = new DhcpMgrImpl(); - netMgr = null; - dhcptabMgr = null; - dhcpServiceMgr = null; - /* - * The arrays aren't nulled so that we can use them as the lock objects - * in the synchronized blocks below - */ - networks = new Network[0]; - clients = new DhcpClientRecord[0]; - clientNet = null; - macros = new Macro[0]; - options = new Option[0]; - try { - serverAddress = InetAddress.getLocalHost(); - setServerName(serverAddress.getHostName()); - } catch (UnknownHostException e) { - serverName = shortServerName = ""; - } - - try { - StandardOptions.setAllOptions( - getDhcpServiceMgr().getInittabOptions( - Option.ctxts[Option.STANDARD].getCode())); - } catch (Throwable e) { - MessageFormat form = new MessageFormat( - ResourceStrings.getString("stdopts_init_error")); - Object [] args = new Object[1]; - if (e instanceof BridgeException) { - args[0] = e.getMessage(); - } else { - args[0] = e.toString(); - } - JOptionPane.showMessageDialog(null, - form.format(args), - ResourceStrings.getString("init_error"), - JOptionPane.ERROR_MESSAGE); - } - } - - private void setServerName(String name) { - serverName = name; - int i = serverName.indexOf('.'); - if (i == -1) { - shortServerName = serverName; - } else { - shortServerName = serverName.substring(0, i); - } - } - - /* - * Threading note: the following methods are all synchronized on the - * class so that server references and names are always set & retrieved - * in a consistent state. - */ - public synchronized static DataManager get() { - if (mgr == null) { - mgr = new DataManager(); - } - return mgr; - } - - public synchronized void setServer(String name) throws Exception { - setServerName(name); - serverAddress = null; - } - - public synchronized DhcpMgr getServer() { - return server; - } - - public synchronized String getServerName() { - return serverName; - } - - public synchronized String getShortServerName() { - return shortServerName; - } - - public synchronized InetAddress getServerAddress() { - return serverAddress; - } - - public synchronized DhcpNetMgr getDhcpNetMgr() { - if (netMgr == null) { - netMgr = getServer().getNetMgr(); - } - return netMgr; - } - - public synchronized DhcptabMgr getDhcptabMgr() { - if (dhcptabMgr == null) { - dhcptabMgr = getServer().getDhcptabMgr(); - } - return dhcptabMgr; - } - - public synchronized DhcpServiceMgr getDhcpServiceMgr() { - if (dhcpServiceMgr == null) { - dhcpServiceMgr = getServer().getDhcpServiceMgr(); - } - return dhcpServiceMgr; - } - - /* - * End of class-synchronized methods. Remaining methods are synchronized - * at a data item level. - */ - - public Network [] getNetworks(boolean forceUpdate) throws BridgeException { - synchronized (networks) { - if (forceUpdate || networks.length == 0) { - networks = getDhcpNetMgr().getNetworks(); - if (networks == null) { - networks = new Network[0]; - } else { - Arrays.sort(networks); - } - } - } - return networks; - } - - public DhcpClientRecord [] getClients(String net, boolean forceUpdate) - throws BridgeException { - synchronized (clients) { - if (forceUpdate || clients.length == 0 || !net.equals(clientNet)) { - clients = getDhcpNetMgr().loadNetwork(net); - if (clients == null) { - clients = new DhcpClientRecord[0]; - } - clientNet = net; - } - } - return clients; - } - - public Macro [] getMacros(boolean forceUpdate) throws BridgeException { - synchronized (macros) { - if (forceUpdate || macros.length == 0) { - macros = getDhcptabMgr().getMacros(); - if (macros == null) { - macros = new Macro[0]; - } - } - } - return macros; - } - - public Option [] getOptions(boolean forceUpdate) throws BridgeException { - synchronized (options) { - if (forceUpdate || options.length == 0) { - options = getDhcptabMgr().getOptions(); - if (options == null) { - options = new Option[0]; - } - /* - * Reload the site/vendor options portion of the global options - * table with the data we just loaded so that macro validation - * can be handled properly. - */ - OptionsTable.getTable().add(options); - } - } - return options; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DeleteAddressDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DeleteAddressDialog.java deleted file mode 100644 index e388cf9178..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DeleteAddressDialog.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1998-2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import java.awt.*; -import java.awt.event.*; -import java.text.MessageFormat; -import java.util.*; -import javax.swing.*; -import javax.swing.table.*; - -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.bridge.BridgeException; - -/** - * This dialog is used to delete one or more addresses from a network - */ - -public class DeleteAddressDialog extends MultipleOperationDialog { - private DhcpClientRecord [] recs; - private String table; - - // Model for the list of addresses to be deleted - class AddressTableModel extends AbstractTableModel { - public int getRowCount() { - if (recs == null) { - return 0; - } else { - return recs.length; - } - } - - public int getColumnCount() { - return 2; - } - - public Object getValueAt(int row, int column) { - if (column == 0) { - return recs[row].getClientIP(); - } else { - if (recs[row].getClientName().equals( - recs[row].getClientIPAddress())) { - // Name returned is IP address, so there is no name - return ""; - } else { - return recs[row].getClientName(); - } - } - } - - public Class getColumnClass(int column) { - if (column == 0) { - return IPAddress.class; - } else { - return String.class; - } - } - - public String getColumnName(int column) { - if (column == 0) { - return ResourceStrings.getString("address_column"); - } else { - return ResourceStrings.getString("client_name_column"); - } - } - } - - public DeleteAddressDialog(Frame f, DhcpClientRecord [] clients, - String table) { - // Create the dialog without a reset button - super(f, false); - recs = clients; - this.table = table; - } - - public String getTitle() { - return ResourceStrings.getString("delete_address_title"); - } - - protected JPanel getMainPanel() { - JPanel mainPanel = new JPanel(new BorderLayout(10, 10)); - mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - - // Place a message at the top of the display - JLabel message = new JLabel( - ResourceStrings.getString("delete_address_confirm")); - - message.setLabelFor(mainPanel); - message.setToolTipText( - ResourceStrings.getString("delete_address_confirm")); - - mainPanel.add(message, BorderLayout.NORTH); - - // Now show the list of addresses to be deleted in a table in the middle - JTable addressTable = new JTable(new AddressTableModel()); - JScrollPane scrollPane = new JScrollPane(addressTable); - Dimension d = addressTable.getPreferredScrollableViewportSize(); - d.height = 100; - addressTable.setPreferredScrollableViewportSize(d); - addressTable.setDefaultRenderer(IPAddress.class, - new ExtendedCellRenderer()); - mainPanel.add(scrollPane, BorderLayout.CENTER); - - buttonPanel.setOkEnabled(true); - return mainPanel; - } - - protected String getProgressMessage() { - return ResourceStrings.getString("delete_addr_progress"); - } - - protected int getProgressLength() { - return recs.length; - } - - protected String getErrorHeading() { - return ResourceStrings.getString("address_column"); - } - - protected Class getErrorClass() { - return IPAddress.class; - } - - protected Thread getOperationThread() { - // Create the thread we'll use - return new Thread() { - public void run() { - DhcpNetMgr server = DataManager.get().getDhcpNetMgr(); - for (int i = 0; i < recs.length; ++i) { - try { - server.deleteClient(recs[i], table); - updateProgress(i+1, recs[i].getClientIPAddress()); - } catch (InterruptedException e) { - // User asked us to stop - closeDialog(); - return; - } catch (Throwable e) { - addError(recs[i].getClientIP(), e.getMessage()); - } - } - // Errors occurred, display them - if (errorsOccurred()) { - displayErrors( - ResourceStrings.getString("delete_address_error")); - } - closeDialog(); - } - }; - } - - protected String getHelpKey() { - return "delete_address"; - } - - protected void fireActionPerformed() { - fireActionPerformed(this, DialogActions.DELETE); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DeleteMacroDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DeleteMacroDialog.java deleted file mode 100644 index b43b95d0e5..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DeleteMacroDialog.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import java.awt.*; -import java.awt.event.*; -import java.text.MessageFormat; -import java.util.*; -import javax.swing.*; - -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.bridge.NotRunningException; - -/** - * This dialog allows the user to delete a macro. - */ -public class DeleteMacroDialog extends DhcpmgrDialog { - private JCheckBox signalBox; - private Macro macro; - private JLabel message; - - public DeleteMacroDialog(Frame f, Macro m) { - super(f, false); - setTitle(ResourceStrings.getString("delete_macro_title")); - macro = m; - message.setText(MessageFormat.format( - ResourceStrings.getString("delete_macro_confirm"), macro.getKey())); - message.setToolTipText(MessageFormat.format( - ResourceStrings.getString("delete_macro_confirm"), macro.getKey())); - } - - public JPanel getMainPanel() { - JPanel mainPanel = new JPanel(new BorderLayout()); - - JPanel flowPanel = new JPanel(); - - message = new JLabel(); - flowPanel.add(message); - mainPanel.add(flowPanel, BorderLayout.NORTH); - - flowPanel = new JPanel(); - signalBox = new JCheckBox(ResourceStrings.getString("signal_server"), - true); - signalBox.setToolTipText( - ResourceStrings.getString("signal_server")); - flowPanel.add(signalBox); - mainPanel.add(flowPanel, BorderLayout.CENTER); - - buttonPanel.setOkEnabled(true); - return mainPanel; - } - - protected void doOk() { - try { - DhcptabMgr server = DataManager.get().getDhcptabMgr(); - server.deleteRecord(macro, signalBox.isSelected()); - fireActionPerformed(); - setVisible(false); - dispose(); - } catch (NotRunningException e) { - // Server not running, put up a warning - JOptionPane.showMessageDialog(this, - ResourceStrings.getString("server_not_running"), - ResourceStrings.getString("warning"), - JOptionPane.WARNING_MESSAGE); - fireActionPerformed(); - setVisible(false); - dispose(); - } catch (Exception e) { - MessageFormat form = null; - Object [] args = new Object[2]; - form = new MessageFormat( - ResourceStrings.getString("delete_macro_error")); - args[0] = macro.getKey(); - args[1] = e.getMessage(); - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - } - - protected String getHelpKey() { - return "delete_macro"; - } - - protected void fireActionPerformed() { - fireActionPerformed(this, DialogActions.DELETE); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DeleteNetworksDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DeleteNetworksDialog.java deleted file mode 100644 index 2b12f83b5f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DeleteNetworksDialog.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1998-2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.event.*; -import javax.swing.table.*; - -import java.awt.*; -import java.awt.event.*; -import java.text.*; -import java.util.*; - -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.bridge.BridgeException; - -/** - * A dialog to remove one or more networks from the DHCP configuration. - */ -public class DeleteNetworksDialog extends MultipleOperationDialog { - - class NetworkListModel extends AbstractListModel { - private Vector networks; - - public NetworkListModel() { - networks = new Vector(); - } - - public void setNetworks(Network [] nets) { - networks.removeAllElements(); - addNetworks(nets); - } - - public void addNetworks(Object [] nets) { - if (nets != null) { - for (int i = 0; i < nets.length; ++i) { - networks.addElement((Network)nets[i]); - } - } - fireContentsChanged(this, 0, networks.size()-1); - } - - public void deleteNetworks(Object [] nets) { - for (int i = 0; i < nets.length; ++i) { - networks.removeElement((Network)nets[i]); - } - fireContentsChanged(this, 0, networks.size()-1); - } - - public Object getElementAt(int index) { - return networks.elementAt(index); - } - - public int getSize() { - return networks.size(); - } - } - - private JList keepNets, deleteNets; - private LeftButton leftButton; - private RightButton rightButton; - - public DeleteNetworksDialog(Frame f) { - // We want a reset button - super(f, true); - } - - public String getTitle() { - return ResourceStrings.getString("delete_networks_title"); - } - - protected JPanel getMainPanel() { - JPanel mainPanel = new JPanel(new BorderLayout()); - mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - - JPanel netBox = new JPanel(new ProportionalLayout()); - JPanel panel = new JPanel(new BorderLayout(5, 5)); - - Mnemonic mnKeep = - new Mnemonic(ResourceStrings.getString("delete_networks_keep")); - JLabel delNetsLbl = new JLabel(mnKeep.getString()); - panel.add(delNetsLbl, BorderLayout.NORTH); - delNetsLbl.setToolTipText(mnKeep.getString()); - keepNets = new JList(new NetworkListModel()); - delNetsLbl.setLabelFor(keepNets); - delNetsLbl.setDisplayedMnemonic(mnKeep.getMnemonic()); - - keepNets.setSelectionMode( - ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - JScrollPane scrollPane = new JScrollPane(keepNets); - panel.add(scrollPane, BorderLayout.CENTER); - netBox.add("2", panel); - - panel = new JPanel(new VerticalButtonLayout()); - leftButton = new LeftButton(); - rightButton = new RightButton(); - rightButton.setEnabled(false); - leftButton.setEnabled(false); - panel.add(rightButton); - panel.add(leftButton); - netBox.add("1", panel); - - panel = new JPanel(new BorderLayout(5, 5)); - - Mnemonic mnDel = - new Mnemonic(ResourceStrings.getString("delete_networks_delete")); - JLabel delNets = new JLabel(mnDel.getString()); - panel.add(delNets, BorderLayout.NORTH); - - deleteNets = new JList(new NetworkListModel()); - deleteNets.setSelectionMode( - ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - - delNets.setLabelFor(deleteNets); - delNets.setToolTipText(mnDel.getString()); - delNets.setDisplayedMnemonic(mnDel.getMnemonic()); - - scrollPane = new JScrollPane(deleteNets); - panel.add(scrollPane, BorderLayout.CENTER); - netBox.add("2", panel); - - mainPanel.add(netBox, BorderLayout.CENTER); - - // Handle enable and disable of buttons based on selection state - keepNets.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - rightButton.setEnabled(!keepNets.isSelectionEmpty()); - if (!keepNets.isSelectionEmpty()) { - deleteNets.clearSelection(); - } - } - }); - - deleteNets.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - leftButton.setEnabled(!deleteNets.isSelectionEmpty()); - if (!deleteNets.isSelectionEmpty()) { - keepNets.clearSelection(); - } - } - }); - - // Handle button presses - rightButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Object [] nets = keepNets.getSelectedValues(); - ((NetworkListModel)deleteNets.getModel()).addNetworks(nets); - ((NetworkListModel)keepNets.getModel()).deleteNetworks(nets); - if (deleteNets.getModel().getSize() != 0) { - buttonPanel.setOkEnabled(true); - } - /* - * Clear the selection; prevents exceptions from selection - * having been deleted - */ - keepNets.clearSelection(); - } - }); - - leftButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Object [] nets = deleteNets.getSelectedValues(); - ((NetworkListModel)keepNets.getModel()).addNetworks(nets); - ((NetworkListModel)deleteNets.getModel()).deleteNetworks(nets); - /* - * Clear the selection; prevents exceptions from selection - * having been deleted - */ - deleteNets.clearSelection(); - if (deleteNets.getModel().getSize() == 0) { - buttonPanel.setOkEnabled(false); - } - } - }); - - doReset(); - - return mainPanel; - } - - protected void doReset() { - try { - buttonPanel.setOkEnabled(false); - ((NetworkListModel)deleteNets.getModel()).setNetworks(null); - ((NetworkListModel)keepNets.getModel()).setNetworks( - DataManager.get().getNetworks(false)); - } catch (Throwable e) { - e.printStackTrace(); - // Do nothing - } - } - - protected String getProgressMessage() { - return ResourceStrings.getString("delete_networks_progress"); - } - - protected int getProgressLength() { - return deleteNets.getModel().getSize(); - } - - protected String getErrorHeading() { - return ResourceStrings.getString("network_column"); - } - - protected Thread getOperationThread() { - return new Thread() { - public void run() { - NetworkListModel model = - (NetworkListModel)deleteNets.getModel(); - for (int i = 0; i < model.getSize(); ++i) { - Network net = (Network)model.getElementAt(i); - try { - DataManager.get().getDhcpNetMgr().deleteNetwork( - net.toString(), true); - updateProgress(i+1, net.toString()); - } catch (InterruptedException e) { - // User asked us to stop - closeDialog(); - return; - } catch (Throwable e) { - addError(net.toString(), e.getMessage()); - } - } - if (errorsOccurred()) { - displayErrors( - ResourceStrings.getString("delete_networks_error")); - } - closeDialog(); - } - }; - } - - protected String getHelpKey() { - return "delete_network"; - } - - protected void fireActionPerformed() { - fireActionPerformed(this, DialogActions.OK); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DeleteOptionDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DeleteOptionDialog.java deleted file mode 100644 index 27a4b059ff..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DeleteOptionDialog.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import java.awt.*; -import java.awt.event.*; -import java.text.MessageFormat; -import java.util.*; -import javax.swing.*; - -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.bridge.NotRunningException; - -/** - * This dialog allows the user to delete an option definition - */ -public class DeleteOptionDialog extends DhcpmgrDialog { - private JCheckBox signalBox; - private Option option; - private JLabel message; - - public DeleteOptionDialog(Frame f, Option o) { - super(f, false); - setTitle(ResourceStrings.getString("delete_option_title")); - option = o; - message.setText(MessageFormat.format( - ResourceStrings.getString("delete_option_confirm"), o.getKey())); - message.setToolTipText(MessageFormat.format( - ResourceStrings.getString("delete_option_confirm"), o.getKey())); - } - - protected JPanel getMainPanel() { - JPanel mainPanel = new JPanel(new BorderLayout()); - JPanel flowPanel = new JPanel(); - - message = new JLabel(); - flowPanel.add(message); - mainPanel.add(flowPanel, BorderLayout.NORTH); - - flowPanel = new JPanel(); - signalBox = new JCheckBox(ResourceStrings.getString("signal_server"), - true); - signalBox.setToolTipText( - ResourceStrings.getString("signal_server")); - flowPanel.add(signalBox); - mainPanel.add(flowPanel, BorderLayout.CENTER); - - buttonPanel.setOkEnabled(true); - return mainPanel; - } - - protected void doOk() { - try { - DhcptabMgr server = DataManager.get().getDhcptabMgr(); - server.deleteRecord(option, signalBox.isSelected()); - fireActionPerformed(); - setVisible(false); - dispose(); - } catch (NotRunningException e) { - // Server not running, put up a warning - JOptionPane.showMessageDialog(this, - ResourceStrings.getString("server_not_running"), - ResourceStrings.getString("warning"), - JOptionPane.WARNING_MESSAGE); - fireActionPerformed(); - setVisible(false); - dispose(); - } catch (Exception e) { - MessageFormat form = null; - Object [] args = new Object[2]; - form = new MessageFormat( - ResourceStrings.getString("delete_option_error")); - args[0] = option.getKey(); - args[1] = e.getMessage(); - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - } - - protected String getHelpKey() { - return "delete_option"; - } - - protected void fireActionPerformed() { - fireActionPerformed(this, DialogActions.DELETE); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DhcpmgrApplet.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DhcpmgrApplet.java deleted file mode 100644 index ea7e7d6676..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DhcpmgrApplet.java +++ /dev/null @@ -1,662 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.net.*; -import java.rmi.RemoteException; -import java.rmi.NotBoundException; -import javax.swing.*; -import java.text.MessageFormat; -import java.applet.AppletContext; - -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.server.DhcpMgr; -import com.sun.dhcpmgr.server.DhcpServiceMgr; -import com.sun.dhcpmgr.bridge.BridgeException; -import com.sun.dhcpmgr.bridge.NotRunningException; - -/** - * Main class for DHCP Manager. It is theoretically possible to run this - * application as a command managing the local system, a command managing a - * remote system using RMI, or as an applet managing the system from which it - * was downloaded. We presently only support the first option, but there is - * vestigial code here from when the other options were supported as they may - * be again. That's why we extend JApplet. - */ -public class DhcpmgrApplet extends JApplet { - private static MainFrame frame = null; - private JButton button; - public static boolean modeIsRelay; - private static HelpIds helpIds = null; - private static URL docBase = null; - private static AppletContext appletContext = null; - private AddressView addressView; - private RestartAction restartAction; - private StopAction stopAction; - private StartAction startAction; - private DisableAction disableAction; - private EnableAction enableAction; - - // Handler for Help->Overview menu item - class OverviewAction extends MnemonicAction { - public OverviewAction() { - super(ResourceStrings.getString("overview_item")); - } - - public void actionPerformed(ActionEvent e) { - showHelp("overview"); - } - } - - // Handler for Help->How To menu item - class HowToAction extends MnemonicAction { - public HowToAction() { - super(ResourceStrings.getString("howto_item")); - } - - public void actionPerformed(ActionEvent e) { - showHelp("howto"); - } - } - - // Handler for Help->Index menu item - class IndexAction extends MnemonicAction { - public IndexAction() { - super(ResourceStrings.getString("index_item")); - } - - public void actionPerformed(ActionEvent e) { - showHelp("index"); - } - } - - // Handler for Help->On Service menu item - class ServiceAction extends MnemonicAction { - public ServiceAction() { - super(ResourceStrings.getString("on_service_item")); - } - - public void actionPerformed(ActionEvent e) { - showHelp("service_reference"); - } - } - - // Handler for the Service->Restart menu item - class RestartAction extends MnemonicAction { - public RestartAction() { - super(ResourceStrings.getString("restart_item")); - } - - public void actionPerformed(ActionEvent e) { - try { - DataManager.get().getDhcpServiceMgr().reload(); - frame.setStatusText( - ResourceStrings.getString("service_restarted")); - } catch (NotRunningException ex) { - // Server not running, ignore the error and just start it - startAction.actionPerformed(e); - } catch (Throwable t) { - Object [] args = new Object[1]; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("restart_server_error")); - args[0] = t.getMessage(); - JOptionPane.showMessageDialog(frame, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - } - } - - // Handler for the Service->Stop menu item - class StopAction extends MnemonicAction { - public StopAction() { - super(ResourceStrings.getString("stop_item")); - } - - public void actionPerformed(ActionEvent e) { - try { - DataManager.get().getDhcpServiceMgr().shutdown(); - frame.setStatusText( - ResourceStrings.getString("service_stopped")); - startAction.setEnabled(true); - restartAction.setEnabled(false); - setEnabled(false); - } catch (Throwable t) { - Object [] args = new Object[1]; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("shutdown_server_error")); - args[0] = t.getMessage(); - JOptionPane.showMessageDialog(frame, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - } - } - - // Handler for the Service->Restart menu item - class StartAction extends MnemonicAction { - public StartAction() { - super(ResourceStrings.getString("start_item")); - } - - public void actionPerformed(ActionEvent e) { - try { - DataManager.get().getDhcpServiceMgr().startup(); - frame.setStatusText( - ResourceStrings.getString("service_started")); - stopAction.setEnabled(true); - restartAction.setEnabled(true); - setEnabled(false); - } catch (Throwable t) { - Object [] args = new Object[1]; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("startup_server_error")); - args[0] = t.getMessage(); - JOptionPane.showMessageDialog(frame, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - } - } - - // handler for the Service->Disable service menu item - class DisableAction extends MnemonicAction { - public DisableAction() { - super(ResourceStrings.getString("disable_item")); - } - - public void actionPerformed(ActionEvent e) { - DisableServiceDialog d = new DisableServiceDialog(frame, true); - d.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - // Update menu item state once we've disabled it - enableAction.setEnabled(true); - disableAction.setEnabled(false); - stopAction.setEnabled(false); - startAction.setEnabled(false); - restartAction.setEnabled(false); - } - }); - d.pack(); - d.setVisible(true); - } - } - - // handler for the Service->Enable service menu item - class EnableAction extends MnemonicAction { - public EnableAction() { - super(ResourceStrings.getString("enable_item")); - } - - public void actionPerformed(ActionEvent e) { - DisableServiceDialog d = new DisableServiceDialog(frame, false); - d.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - // Update menu item state once we've enabled it - disableAction.setEnabled(true); - enableAction.setEnabled(false); - stopAction.setEnabled(true); - startAction.setEnabled(false); - restartAction.setEnabled(true); - } - }); - d.pack(); - d.setVisible(true); - } - } - - // handler for the Service->Modify service menu item - class ModifyServiceAction extends MnemonicAction { - public ModifyServiceAction() { - super(ResourceStrings.getString("modify_service_item")); - } - - public void actionPerformed(ActionEvent e) { - try { - DhcpdOptions opts = - DataManager.get().getDhcpServiceMgr().readDefaults(); - ServerOptionsDialog d = new ServerOptionsDialog(frame, opts); - d.pack(); - d.setVisible(true); - } catch (BridgeException ex) { - // Error reading options - MessageFormat form = new MessageFormat( - ResourceStrings.getString("err_reading_options")); - Object [] args = new Object[] { ex.getMessage() }; - JOptionPane.showMessageDialog(frame, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - } - } - - // handler for the Service->Convert service menu item - class ConvertAction extends MnemonicAction { - public ConvertAction() { - super(ResourceStrings.getString("cvt_service_item")); - - } - - public void actionPerformed(ActionEvent e) { - ConvertWizard wiz = new ConvertWizard(frame, - ResourceStrings.getString("cvt_wiz_title")); - wiz.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("finished")) { - frame.refreshAllViews(); - showFrame(); - } - } - }); - wiz.pack(); - wiz.setModal(true); - wiz.setVisible(true); - } - - public void setEnabled(boolean b) { - if (!modeIsRelay) { - super.setEnabled(b); - } else { - super.setEnabled(false); - } - } - } - - // handler for the Service->Unconfigure service menu item - class UnconfigureServiceAction extends MnemonicAction { - public UnconfigureServiceAction() { - super(ResourceStrings.getString("unconfigure_service_item")); - } - - public void actionPerformed(ActionEvent e) { - UnconfigureDialog d = new UnconfigureDialog(frame); - d.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals(DialogActions.OK)) { - /* - * User unconfigured the service; there's nothing - * else to do so just get rid of the frame which - * will as a side effect shut us down. - */ - frame.setVisible(false); - frame.dispose(); - frame = null; - } - } - }); - d.pack(); - d.setVisible(true); - } - } - - // Action for Service->Export data - class ExportAction extends MnemonicAction { - public ExportAction() { - super(ResourceStrings.getString("export_item")); - } - public void actionPerformed(ActionEvent e) { - ExportWizard wiz = new ExportWizard(frame); - wiz.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("finished")) { - frame.refreshAllViews(); - showFrame(); - } - } - }); - wiz.pack(); - wiz.setVisible(true); - } - } - - // Action for Service->Import data - class ImportAction extends MnemonicAction { - public ImportAction() { - super(ResourceStrings.getString("import_item")); - } - - public void actionPerformed(ActionEvent e) { - ImportWizard wiz = new ImportWizard(frame); - wiz.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("finished")) { - frame.refreshAllViews(); - showFrame(); - } - } - }); - wiz.pack(); - wiz.setVisible(true); - } - } - - /* - * This class provides a transition dialog which allows the user - * to initiate the address wizard immediately upon startup. It's - * done this way so that the startMeUp() method can use invokeLater() - * to cause it to be displayed after the config wizard exit event - * has been processed rather than during that event's processing; - * otherwise the wizard doesn't disappear until after the user presses - * Yes or No in this dialog. - */ - class WizardTransition implements Runnable { - public void run() { - // Now transition to configuring addresses - int status = JOptionPane.showConfirmDialog(frame, - ResourceStrings.getString("start_address_wizard"), - ResourceStrings.getString("start_address_wizard_title"), - JOptionPane.YES_NO_OPTION); - if (status == JOptionPane.YES_OPTION) { - addressView.startAddressWizard(); - } - } - } - - /* - * This class provides a transition dialog which allows the user - * to initiate the conversion wizard immediately upon startup if a - * version mismatch exists (a data store upgrade is necessary). - */ - class ConversionTransition implements Runnable { - public void run() { - try { - DhcpServiceMgr svcMgr = DataManager.get().getDhcpServiceMgr(); - while (!svcMgr.isVersionCurrent()) { - int status = JOptionPane.showConfirmDialog(frame, - ResourceStrings.getString("start_cvt_wizard"), - ResourceStrings.getString("start_cvt_wizard_title"), - JOptionPane.YES_NO_OPTION); - if (status == JOptionPane.YES_OPTION) { - ConvertAction converter = new ConvertAction(); - ActionEvent e = new ActionEvent(this, - ActionEvent.ACTION_PERFORMED, ""); - converter.actionPerformed(e); - } else { - frame = null; - DataManager.get().reset(); - requestExit(); - } - } - } catch (Throwable e) { - System.err.println( - ResourceStrings.getString("err_initializing_program")); - System.err.println(e.getMessage()); - requestExit(); - } - } - } - - // Create the frame within which the UI will live - private void createFrame() { - if (frame == null) { - - frame = new MainFrame(ResourceStrings.getString("dhcp_manager")); - - // Create the views for this tool - if (modeIsRelay) { - frame.addView(new RelayView(), true); - } else { - addressView = new AddressView(); - frame.addView(addressView, true); - frame.addView(new MacroView(), false); - frame.addView(new OptionView(), false); - } - - // Set up the services menu - frame.addMenuAction(MainFrame.ACTIONS_MENU, - (restartAction = new RestartAction())); - frame.addMenuAction(MainFrame.ACTIONS_MENU, - (stopAction = new StopAction())); - frame.addMenuAction(MainFrame.ACTIONS_MENU, - (startAction = new StartAction())); - frame.addMenuAction(MainFrame.ACTIONS_MENU, - (disableAction = new DisableAction())); - frame.addMenuAction(MainFrame.ACTIONS_MENU, - (enableAction = new EnableAction())); - frame.addMenuAction(MainFrame.ACTIONS_MENU, - new ModifyServiceAction()); - if (!modeIsRelay) { - frame.addMenuAction(MainFrame.ACTIONS_MENU, - new ExportAction()); - frame.addMenuAction(MainFrame.ACTIONS_MENU, - new ImportAction()); - frame.addMenuAction(MainFrame.ACTIONS_MENU, - new ConvertAction()); - } - frame.addMenuAction(MainFrame.ACTIONS_MENU, - new UnconfigureServiceAction()); - - // Set up the Help menu - frame.addMenuAction(MainFrame.HELP_MENU, new OverviewAction()); - frame.addMenuAction(MainFrame.HELP_MENU, new HowToAction()); - frame.addMenuAction(MainFrame.HELP_MENU, new IndexAction()); - frame.addMenuAction(MainFrame.HELP_MENU, new ServiceAction()); - - // In relay mode, let it size itself (quite small) - if (modeIsRelay) { - frame.pack(); - } else { - /* - * Normal mode set it to a reasonable size. This ought to be - * a user preference, but until we run as something other than - * root it's not really a useful idea. - */ - frame.setSize(800, 600); - } - - // Listen for closing events - frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - /* - * This is here to work around the Close selection frame - * menu on Solaris not causing the closed function to be - * called - */ - windowClosed(e); - } - public void windowClosed(WindowEvent e) { - // Dispose of all data and exit when window goes away. - frame = null; - DataManager.get().reset(); - requestExit(); - } - }); - } - } - - // Show the frame - private void showFrame() { - if (frame == null) { - createFrame(); - } - frame.initialize(); - if (modeIsRelay) { - // Disable edit & view menus in the relay case - frame.setMenuEnabled(MainFrame.EDIT_MENU, false); - frame.setMenuEnabled(MainFrame.VIEW_MENU, false); - } - try { - // Set status of service menu options based on server state - DhcpdOptions opts = - DataManager.get().getDhcpServiceMgr().readDefaults(); - boolean enabled = opts.isDaemonEnabled(); - enableAction.setEnabled(!enabled); - disableAction.setEnabled(enabled); - boolean running = - DataManager.get().getDhcpServiceMgr().isServerRunning(); - restartAction.setEnabled(running && enabled); - stopAction.setEnabled(running); - startAction.setEnabled(!running && enabled); - } catch (Throwable e) { - // Enable all the menu items, as something went wrong - restartAction.setEnabled(true); - stopAction.setEnabled(true); - startAction.setEnabled(true); - enableAction.setEnabled(true); - disableAction.setEnabled(true); - } - frame.setVisible(true); - } - - /* - * main startup code; checks whether server is already configured, and if - * not runs through the config wizard sequence in order to get the server - * configured. - */ - private void startMeUp() { - try { - if (DataManager.get().getServer() == null) { - DataManager.get().setServer(getCodeBase().getHost()); - } - - // See if server is already configured, and start up - DhcpServiceMgr svcMgr = DataManager.get().getDhcpServiceMgr(); - DhcpdOptions opts = svcMgr.readDefaults(); - modeIsRelay = opts.isRelay(); - // If server mode, ensure RESOURCE and PATH were set - if (!modeIsRelay) { - if ((opts.getResource() == null) || (opts.getPath() == null)) { - System.err.println( - ResourceStrings.getString("err_initializing_options")); - requestExit(); - } - } - - showFrame(); - - // Check to make sure that the data store version is up to date. - // If not, inform the user and present them with the conversion - // wizard so that they can upgrade. - if (!modeIsRelay && !svcMgr.isVersionCurrent()) { - SwingUtilities.invokeLater(new ConversionTransition()); - } - - } catch (BridgeException e) { - // Let user select which type of service to configure - int choice = ConfigureChoiceDialog.showDialog(frame); - if (choice == ConfigureChoiceDialog.DHCP) { - // DHCP; run the wizard - ConfigWizard wiz = new ConfigWizard(frame, - ResourceStrings.getString("cfg_wiz_title"), true); - wiz.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("finished")) { - // Service config completed, start up - modeIsRelay = false; - showFrame(); - // Now transition to configuring addresses - SwingUtilities.invokeLater(new WizardTransition()); - } else { - // User cancelled the wizard, exit - requestExit(); - } - } - }); - wiz.pack(); - wiz.setVisible(true); - } else if (choice == ConfigureChoiceDialog.BOOTP) { - // Wants to configure a relay, show the dialog for that - ConfigureRelayDialog d = new ConfigureRelayDialog(frame); - d.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals(DialogActions.OK)) { - // Relay configuration completed, start up - modeIsRelay = true; - showFrame(); - } else { - // User cancelled, exit - requestExit(); - } - } - }); - d.pack(); - d.setVisible(true); - } else { - // User cancelled; exit - requestExit(); - } - } catch (Throwable e) { - // Couldn't really get started, dump the stack and exit - System.err.println( - ResourceStrings.getString("err_initializing_program")); - System.err.println(e.getMessage()); - e.printStackTrace(); - requestExit(); - } - } - - // Show a help file referenced by tag - public static void showHelp(String helpId) { - // If help tag mapping table not loaded yet, then load it - if (helpIds == null) { - try { - helpIds = new HelpIds("com.sun.dhcpmgr.client.HelpBundle"); - } catch (Throwable e) { - // Error initializing help system - JOptionPane.showMessageDialog(frame, - ResourceStrings.getString("err_initializing_help"), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - return; - } - } - // Ask browser to display - try { - Runtime.getRuntime().exec( - "/usr/sfw/bin/mozilla file:" - + helpIds.getFilePath(helpId)); - } catch (java.io.IOException e) { - JOptionPane.showMessageDialog(frame, - ResourceStrings.getString("err_starting_help"), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - } - - // Exit the application - private void requestExit() { - System.exit(0); - } - - // Main function when we're run as an application - public static void main(String [] args) { - - // Ensure that we're running as root; exit if not - if (!System.getProperty("user.name").equals("root")) { - System.err.println(ResourceStrings.getString("err_must_be_root")); - System.exit(0); - } - - DhcpmgrApplet applet = new DhcpmgrApplet(); - applet.startMeUp(); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DhcpmgrDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DhcpmgrDialog.java deleted file mode 100644 index 10736c2881..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DhcpmgrDialog.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.JDialog; -import javax.swing.BoxLayout; -import javax.swing.JSeparator; -import javax.swing.JPanel; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.Frame; -import java.util.Vector; -import java.util.Enumeration; - -import com.sun.dhcpmgr.ui.ButtonPanel; -import com.sun.dhcpmgr.ui.ButtonPanelListener; - -/** - * This abstract class provides a framework for building all of the dialogs - * used by DHCP Mgr. Subclasses must implement the abstract methods defined - * here as well as override any other appropriate methods. Most of these - * methods are declared protected because they are implementation details - * which need not be visible outside the dialog we're actually implementing. - */ -public abstract class DhcpmgrDialog extends JDialog - implements ButtonPanelListener { - // Listeners receive action events when user presses OK - private Vector listeners; - // ButtonPanel is protected so subclasses can manipulate directly - protected ButtonPanel buttonPanel; - - public DhcpmgrDialog(Frame f, boolean allowsReset) { - super(f); - listeners = new Vector(); - // Layout is subclass main panel, then a separator, then buttons - getContentPane().setLayout(new BoxLayout(getContentPane(), - BoxLayout.Y_AXIS)); - // Create buttonPanel first so subclasses can modify it if need be - buttonPanel = new ButtonPanel(allowsReset); - buttonPanel.addButtonPanelListener(this); - getContentPane().add(getMainPanel()); - getContentPane().add(new JSeparator()); - getContentPane().add(buttonPanel); - // Position relative to our owning frame - setLocationRelativeTo(f); - } - - /** - * Return the main display panel - */ - protected abstract JPanel getMainPanel(); - - public void addActionListener(ActionListener l) { - listeners.addElement(l); - } - - public void removeActionListener(ActionListener l) { - listeners.removeElement(l); - } - - /** - * fire the action event - */ - protected abstract void fireActionPerformed(); - - protected void fireActionPerformed(Object source, String command) { - ActionEvent e = new ActionEvent(source, ActionEvent.ACTION_PERFORMED, - command); - Enumeration en = listeners.elements(); - while (en.hasMoreElements()) { - ActionListener l = (ActionListener)en.nextElement(); - l.actionPerformed(e); - } - } - - /** - * Handle user clicks on the dialog buttons - */ - public void buttonPressed(int buttonId) { - switch (buttonId) { - case OK: - doOk(); - break; - case CANCEL: - doCancel(); - break; - case HELP: - doHelp(); - break; - case RESET: - doReset(); - break; - default: - break; - } - } - - /** - * Handle user pressing OK button - */ - protected abstract void doOk(); - - /** - * Handle user pressing Cancel button, default is to disappear - */ - protected void doCancel() { - setVisible(false); - dispose(); - } - - /** - * Handle user pressing Reset; this default implementation does - * nothing, subclasses should override. - */ - protected void doReset() { - // Do nothing - } - - /** - * Handle user pressing Help - */ - protected void doHelp() { - DhcpmgrApplet.showHelp(getHelpKey()); - } - - /** - * Return the help key - */ - protected abstract String getHelpKey(); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DhcptabNameField.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DhcptabNameField.java deleted file mode 100644 index b18f11e2b0..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DhcptabNameField.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.text.*; - -/** - * A text field which enforces the syntax rules for the name field in the - * dhcptab. At present, all characters must be printable ASCII, but not the - * comment introduction character '#'. - */ -public class DhcptabNameField extends JTextField { - - /** - * Constructs a field initialized to the provided text. Defaults to - * 20 characters wide. - * @param text the text to display initially - */ - public DhcptabNameField(String text) { - this(text, 20); - } - - /** - * Constructs a field initialized to the provided text with the requested - * size. - * @param text the text to display initially - * @param length the length in characters the field should size itself to - */ - public DhcptabNameField(String text, int length) { - super(text, length); - } - - protected Document createDefaultModel() { - return new DhcptabNameDocument(); - } -} - -/** - * This is the recommended way to validate input, as opposed to trapping - * KeyEvents because this will actually catch paste operations as well. - */ -class DhcptabNameDocument extends PlainDocument { - public void insertString(int offs, String str, AttributeSet a) - throws BadLocationException { - if (str != null) { - char [] chars = str.toCharArray(); - for (int i = 0; i < chars.length; ++i) { - // Must be a printable ASCII char, but not the comment character - if (chars[i] < ' ' || chars[i] > '~' || chars[i] == '#') { - throw new BadLocationException("", offs); - } - } - } - super.insertString(offs, str, a); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DialogActions.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DialogActions.java deleted file mode 100644 index 9b535453a6..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DialogActions.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -/** - * This interface defines the strings used to differentiate the - * action events generated by the dialogs. - */ -public interface DialogActions { - public static final String OK = "ok"; - public static final String CANCEL = "cancel"; - public static final String CREATE = "create"; - public static final String DUPLICATE = "duplicate"; - public static final String EDIT = "edit"; - public static final String DELETE = "delete"; - public static final String DISABLE = "disable"; - public static final String ENABLE = "enable"; -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DisableServiceDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DisableServiceDialog.java deleted file mode 100644 index a411a6f021..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/DisableServiceDialog.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import java.awt.*; -import java.awt.event.*; -import java.text.MessageFormat; -import java.util.*; -import javax.swing.*; - -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; - -/** - * This dialog handles enabling and disabling the service, with user - * confirmation - */ -public class DisableServiceDialog extends DhcpmgrDialog { - private boolean disable; - private JLabel message; - - public DisableServiceDialog(Frame f, boolean disable) { - super(f, false); - - this.disable = disable; - - String name = DataManager.get().getShortServerName(); - if (disable) { - setTitle(ResourceStrings.getString("disable_service_title")); - if (DhcpmgrApplet.modeIsRelay) { - message.setText(MessageFormat.format( - ResourceStrings.getString("disable_relay_confirm"), name)); - message.setToolTipText(MessageFormat.format( - ResourceStrings.getString("disable_relay_confirm"), name)); - } else { - message.setText(MessageFormat.format( - ResourceStrings.getString("disable_service_confirm"), - name)); - message.setToolTipText(MessageFormat.format( - ResourceStrings.getString("disable_service_confirm"), - name)); - } - } else { - setTitle(ResourceStrings.getString("enable_service_title")); - if (DhcpmgrApplet.modeIsRelay) { - message.setText(MessageFormat.format( - ResourceStrings.getString("enable_relay_confirm"), name)); - message.setToolTipText(MessageFormat.format( - ResourceStrings.getString("enable_relay_confirm"), name)); - } else { - message.setText(MessageFormat.format( - ResourceStrings.getString("enable_service_confirm"), name)); - message.setToolTipText(MessageFormat.format( - ResourceStrings.getString("enable_service_confirm"), name)); - } - } - } - - protected JPanel getMainPanel() { - JPanel panel = new JPanel(); - panel.setBorder(BorderFactory.createEmptyBorder(20, 10, 20, 10)); - message = new JLabel(); - panel.add(message); - - buttonPanel.setOkEnabled(true); - return panel; - } - - protected void doOk() { - try { - DhcpServiceMgr server = DataManager.get().getDhcpServiceMgr(); - DhcpdOptions opts = - DataManager.get().getDhcpServiceMgr().readDefaults(); - if (disable) { - // Shutdown the server and disable the daemon. - server.shutdown(); - opts.setDaemonEnabled(false); - DataManager.get().getDhcpServiceMgr().writeDefaults(opts); - } else { - // Enable = reverse the process - opts.setDaemonEnabled(true); - DataManager.get().getDhcpServiceMgr().writeDefaults(opts); - server.startup(); - } - fireActionPerformed(); - setVisible(false); - dispose(); - } catch (Exception e) { - e.printStackTrace(); - MessageFormat form = null; - Object [] args = new Object[1]; - if (disable) { - form = new MessageFormat( - ResourceStrings.getString("disable_service_error")); - } else { - form = new MessageFormat( - ResourceStrings.getString("enable_service_error")); - } - args[0] = e.getMessage(); - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - } - - protected String getHelpKey() { - if (disable) { - return "disable_service"; - } else { - return "enable_service"; - } - } - - /** - * Notify listeners that enable or disable has been done. - */ - protected void fireActionPerformed() { - String cmd; - if (disable) { - cmd = DialogActions.DISABLE; - } else { - cmd = DialogActions.ENABLE; - } - fireActionPerformed(this, cmd); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ErrorTable.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ErrorTable.java deleted file mode 100644 index 1cb70f1139..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ErrorTable.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.table.AbstractTableModel; -import java.util.Vector; -import java.util.Date; - -import com.sun.dhcpmgr.ui.AutosizingTable; -import com.sun.dhcpmgr.ui.ExtendedCellRenderer; -import com.sun.dhcpmgr.data.IPAddress; -import com.sun.dhcpmgr.data.ActionError; - -/* - * The model for the error table. - */ -class ErrorTableModel extends AbstractTableModel { - private String column0Label; - private Class column0Class; - private Vector rows; - - public ErrorTableModel(String column0Label, Class column0Class) { - this.column0Label = column0Label; - this.column0Class = column0Class; - rows = new Vector(); - } - - public int getRowCount() { - return rows.size(); - } - - public int getColumnCount() { - return 2; - } - - public Object getValueAt(int row, int column) { - Object [] ro = (Object [])rows.elementAt(row); - return ro[column]; - } - - public Class getColumnClass(int column) { - if (column == 0) { - return column0Class; - } else { - return String.class; - } - } - - public String getColumnName(int column) { - if (column == 0) { - return column0Label; - } else { - return ResourceStrings.getString("error_message"); - } - } - - public void addError(Object o, String msg) { - Object [] row = new Object[] { o, msg }; - rows.addElement(row); - } -} - -/** - * A table for displaying errors which occurred while acting on multiple - * objects. - */ -public class ErrorTable extends AutosizingTable { - ErrorTableModel model; - - public ErrorTable(String column0Label, Class column0Class) { - super(); - model = new ErrorTableModel(column0Label, column0Class); - setModel(model); - ExtendedCellRenderer renderer = new ExtendedCellRenderer(); - setDefaultRenderer(Date.class, renderer); - setDefaultRenderer(IPAddress.class, renderer); - } - - public ErrorTable(String column0Label) { - this(column0Label, String.class); - } - - public void addError(Object o, String msg) { - model.addError(o, msg); - } - - public void setErrors(ActionError [] errs) { - for (int i = 0; i < errs.length; ++i) { - model.addError(errs[i].getName(), - errs[i].getException().getMessage()); - } - } - - public boolean isEmpty() { - return (model.getRowCount() == 0); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ExportWizard.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ExportWizard.java deleted file mode 100644 index b9c6db116d..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ExportWizard.java +++ /dev/null @@ -1,630 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.event.*; -import java.awt.*; -import java.text.MessageFormat; -import java.lang.reflect.InvocationTargetException; - -import com.sun.dhcpmgr.server.DhcpMgr; -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.common.*; -import com.sun.dhcpmgr.bridge.ExistsException; - -/** - * ExportWizard provides an easy-to-use interface for exporting the data - * from one DHCP server to be later imported by another DHCP server, typically - * because the administrator wishes to repartition the workload among DHCP - * servers. - */ -public class ExportWizard extends Wizard { - - // Step to collect the networks to be exported - class NetworkStep implements WizardStep { - Box stepBox; - ListPair networkLists; - - public NetworkStep() { - stepBox = Box.createVerticalBox(); - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("exp_wiz_net_explain"), 9, 45)); - stepBox.add(Box.createVerticalStrut(10)); - // XXX This try/catch goes away at Snakebite integration - try { - networkLists = new ListPair( - ResourceStrings.getString("exp_wiz_dont_export"), - DataManager.get().getNetworks(false), - ResourceStrings.getString("exp_wiz_export"), networks); - } catch (Throwable t) { - t.printStackTrace(); - } - stepBox.add(networkLists); - stepBox.add(Box.createVerticalGlue()); - } - - public String getDescription() { - return ResourceStrings.getString("exp_wiz_net_desc"); - } - - public Component getComponent() { - return stepBox; - } - - public void setActive(int direction) { - setForwardEnabled(true); - } - - public boolean setInactive(int direction) { - networks = - (Network [])networkLists.getRightContents(new Network[0]); - return true; - } - } - - // Step to collect the macros to be exported - class MacroStep implements WizardStep { - Box stepBox; - ListPair macroLists; - - public MacroStep() { - stepBox = Box.createVerticalBox(); - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("exp_wiz_macros_explain"), 4, 45)); - stepBox.add(Box.createVerticalStrut(10)); - // XXX This try/catch will go away at Snakebite integration - try { - Macro [] macros = DataManager.get().getMacros(false); - macroNames = new String[macros.length]; - for (int i = 0; i < macros.length; ++i) { - macroNames[i] = macros[i].getKey(); - } - macroLists = new ListPair( - ResourceStrings.getString("exp_wiz_dont_export"), macroNames, - ResourceStrings.getString("exp_wiz_export"), null); - } catch (Throwable t) { - t.printStackTrace(); - } - stepBox.add(macroLists); - stepBox.add(Box.createVerticalGlue()); - } - - public String getDescription() { - return ResourceStrings.getString("exp_wiz_macro_desc"); - } - - public Component getComponent() { - return stepBox; - } - - public void setActive(int direction) { - setForwardEnabled(true); - } - - public boolean setInactive(int direction) { - macroNames = (String [])macroLists.getRightContents(new String[0]); - return true; - } - } - - // Step to collect the options to be exported - class OptionStep implements WizardStep { - Box stepBox; - ListPair optionLists; - - public OptionStep() { - stepBox = Box.createVerticalBox(); - stepBox.add(Wizard.createTextArea( - ResourceStrings.getString("exp_wiz_options_explain"), 4, 45)); - stepBox.add(Box.createVerticalStrut(10)); - // XXX This try/catch will go away at Snakebite integration - try { - Option[] options = DataManager.get().getOptions(false); - optionNames = new String[options.length]; - for (int i = 0; i < options.length; ++i) { - optionNames[i] = options[i].getKey(); - } - optionLists = new ListPair( - ResourceStrings.getString("exp_wiz_dont_export"), optionNames, - ResourceStrings.getString("exp_wiz_export"), null); - } catch (Throwable t) { - t.printStackTrace(); - } - stepBox.add(optionLists); - stepBox.add(Box.createVerticalGlue()); - } - - public String getDescription() { - return ResourceStrings.getString("exp_wiz_option_desc"); - } - - public Component getComponent() { - return stepBox; - } - - public void setActive(int direction) { - setForwardEnabled(true); - } - - public boolean setInactive(int direction) { - optionNames = - (String [])optionLists.getRightContents(new String[0]); - return true; - } - } - - // Step to collect the name of the file to which data is exported - class FileStep implements WizardStep { - JPanel stepPanel; - NoSpaceField pathField; - JCheckBox deleteBox; - - public FileStep() { - GridBagLayout bag = new GridBagLayout(); - GridBagConstraints con = new GridBagConstraints(); - con.insets = new Insets(2, 2, 2, 2); - con.gridx = con.gridy = 0; - con.gridwidth = 2; - con.gridheight = 1; - con.weightx = 0; - con.weighty = 0.5; - con.fill = GridBagConstraints.BOTH; - con.anchor = GridBagConstraints.NORTHWEST; - stepPanel = new JPanel(bag); - Component c = Wizard.createTextArea( - ResourceStrings.getString("exp_wiz_file_explain"), 4, 45); - bag.setConstraints(c, con); - stepPanel.add(c); - - Mnemonic mnFile = - new Mnemonic(ResourceStrings.getString("exp_wiz_file_label")); - JLabel l = new JLabel(mnFile.getString()); - l.setLabelFor(stepPanel); - l.setToolTipText(mnFile.getString()); - l.setDisplayedMnemonic(mnFile.getMnemonic()); - - con.gridwidth = con.gridheight = 1; - con.fill = GridBagConstraints.NONE; - con.weighty = 0; - ++con.gridy; - bag.setConstraints(l, con); - stepPanel.add(l); - - pathField = new NoSpaceField(exportPath); - l.setLabelFor(pathField); - ++con.gridx; - con.weightx = 1.0; - con.fill = GridBagConstraints.HORIZONTAL; - bag.setConstraints(pathField, con); - stepPanel.add(pathField); - - c = Box.createVerticalStrut(10); - ++con.gridy; - con.gridx = 0; - con.weightx = 0; - bag.setConstraints(c, con); - stepPanel.add(c); - - c = Wizard.createTextArea( - ResourceStrings.getString("exp_wiz_delete_explain"), 4, 45); - ++con.gridy; - con.gridx = 0; - con.weightx = 1.0; - con.weighty = 0.5; - con.gridwidth = 2; - con.fill = GridBagConstraints.BOTH; - bag.setConstraints(c, con); - stepPanel.add(c); - - deleteBox = new JCheckBox( - ResourceStrings.getString("exp_wiz_delete_exported"), false); - deleteBox.setToolTipText( - ResourceStrings.getString("exp_wiz_delete_exported")); - con.gridx = 0; - ++con.gridy; - con.fill = GridBagConstraints.HORIZONTAL; - bag.setConstraints(deleteBox, con); - stepPanel.add(deleteBox); - - c = Box.createVerticalGlue(); - ++con.gridy; - con.weighty = 1.0; - bag.setConstraints(c, con); - stepPanel.add(c); - - // Enable forward only if something is entered in the file field - pathField.getDocument().addDocumentListener(new DocumentListener() { - public void insertUpdate(DocumentEvent e) { - setForwardEnabled(pathField.getText().length() != 0); - } - public void changedUpdate(DocumentEvent e) { - insertUpdate(e); - } - public void removeUpdate(DocumentEvent e) { - insertUpdate(e); - } - }); - - } - - public String getDescription() { - return ResourceStrings.getString("exp_wiz_file_desc"); - } - - public Component getComponent() { - return stepPanel; - } - - public void setActive(int direction) { - pathField.setText(exportPath); - deleteBox.setSelected(deleteData); - } - - public boolean setInactive(int direction) { - exportPath = pathField.getText(); - deleteData = deleteBox.isSelected(); - return true; - } - } - - // Review everything before doing it - class ReviewStep implements WizardStep { - JPanel mainPanel; - JList networkList, macroList, optionList; - JLabel exportLabel, deleteLabel; - - public ReviewStep() { - mainPanel = new JPanel(new BorderLayout()); - mainPanel.add(Wizard.createTextArea( - ResourceStrings.getString("exp_wiz_review_explain"), 6, 45), - BorderLayout.NORTH); - JPanel fieldPanel = new JPanel(new FieldLayout()); - - Mnemonic mnNets = - new Mnemonic(ResourceStrings.getString("exp_wiz_review_nets")); - JLabel revNetsLbl = new JLabel(mnNets.getString()); - revNetsLbl.setToolTipText(mnNets.getString()); - fieldPanel.add(revNetsLbl, FieldLayout.LABELTOP); - networkList = new JList(); - revNetsLbl.setLabelFor(networkList); - JScrollPane scrollPane = new JScrollPane(networkList); - fieldPanel.add(scrollPane, FieldLayout.FIELD); - revNetsLbl.setDisplayedMnemonic(mnNets.getMnemonic()); - - Mnemonic mnMacros = - new Mnemonic(ResourceStrings.getString( - "exp_wiz_review_macros")); - JLabel revMacLbl = new JLabel(mnMacros.getString()); - revMacLbl.setToolTipText(mnMacros.getString()); - fieldPanel.add(revMacLbl, FieldLayout.LABELTOP); - macroList = new JList(); - revMacLbl.setLabelFor(macroList); - scrollPane = new JScrollPane(macroList); - fieldPanel.add(scrollPane, FieldLayout.FIELD); - revMacLbl.setDisplayedMnemonic(mnMacros.getMnemonic()); - - Mnemonic mnOpt = - new Mnemonic(ResourceStrings.getString( - "exp_wiz_review_options")); - JLabel optLbl = new JLabel(mnOpt.getString()); - fieldPanel.add(optLbl, FieldLayout.LABELTOP); - optLbl.setToolTipText(mnOpt.getString()); - optionList = new JList(); - optLbl.setLabelFor(optionList); - scrollPane = new JScrollPane(optionList); - fieldPanel.add(scrollPane, FieldLayout.FIELD); - optLbl.setDisplayedMnemonic(mnOpt.getMnemonic()); - - Mnemonic mnFileRvw = - new Mnemonic(ResourceStrings.getString("exp_wiz_file_label")); - JLabel fileLbl = - new JLabel(mnFileRvw.getString()); - fileLbl.setLabelFor(fieldPanel); - fileLbl.setToolTipText(mnFileRvw.getString()); - fieldPanel.add(fileLbl, FieldLayout.LABEL); - exportLabel = new JLabel(); - exportLabel.setForeground(Color.black); - fieldPanel.add(exportLabel, FieldLayout.FIELD); - - JLabel delLbl = - new JLabel(ResourceStrings.getString("exp_wiz_delete_label")); - delLbl.setLabelFor(fieldPanel); - delLbl.setToolTipText(ResourceStrings.getString( - "exp_wiz_delete_label")); - fieldPanel.add(delLbl, FieldLayout.LABEL); - - deleteLabel = new JLabel(); - deleteLabel.setForeground(Color.black); - fieldPanel.add(deleteLabel, FieldLayout.FIELD); - - mainPanel.add(fieldPanel, BorderLayout.CENTER); - } - - public String getDescription() { - return ResourceStrings.getString("exp_wiz_review_desc"); - } - - public Component getComponent() { - return mainPanel; - } - - public void setActive(int direction) { - networkList.setListData(networks); - macroList.setListData(macroNames); - optionList.setListData(optionNames); - exportLabel.setText(exportPath); - if (deleteData) { - deleteLabel.setText(ResourceStrings.getString("yes")); - } else { - deleteLabel.setText(ResourceStrings.getString("no")); - } - setFinishEnabled(true); - } - - public boolean setInactive(int direction) { - // Nothing to do here - return true; - } - } - - /* - * Display an error message in its own thread. This allows a task running - * in a non-GUI thread to get the message displayed by the toolkit. - */ - class ErrorDisplay implements Runnable { - Object [] objs; - - public ErrorDisplay(Object [] objs) { - this.objs = objs; - } - - public void run() { - JOptionPane.showMessageDialog(ExportWizard.this, objs, - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - } - - /* - * Display a warning message in its own thread. This allows a task running - * in a non-GUI thread to get the message displayed by the toolkit. - */ - class WarningDisplay implements Runnable { - Object [] objs; - - public WarningDisplay(Object [] objs) { - this.objs = objs; - } - - public void run() { - JOptionPane.showMessageDialog(ExportWizard.this, objs, - ResourceStrings.getString("server_warning_title"), - JOptionPane.WARNING_MESSAGE); - } - } - - /* - * Class to ask the user whether the export file should be forcibly - * overwritten if it already exists. We default to not overwriting - * export files. This is a Runnable in order to allow it to be displayed - * by the export thread, which is a non-GUI thread. - */ - class OverwritePrompter implements Runnable { - /* - * overwrite member is public so we can access it directly since run() - * can't return the user's input. - */ - public boolean overwrite; - - public OverwritePrompter() { - overwrite = false; - } - - public void run() { - int ret = JOptionPane.showConfirmDialog( - ExportWizard.this, - ResourceStrings.getString("exp_overwrite"), - ResourceStrings.getString("exp_overwrite_title"), - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); - // Return true if the user clicked Yes - overwrite = (ret == JOptionPane.YES_OPTION); - } - } - - private Network [] networks = new Network[0]; - private String [] macroNames = new String[0]; - private String [] optionNames = new String[0]; - private boolean deleteData = false; - private String exportPath = ""; - - public ExportWizard(Frame owner) { - super(owner, ""); - setTitle(ResourceStrings.getString("export_wiz_title")); - - // Insert steps in order of execution - addStep(new NetworkStep()); - addStep(new MacroStep()); - addStep(new OptionStep()); - addStep(new FileStep()); - addStep(new ReviewStep()); - - showFirstStep(); - } - - /* - * Execute the export. This is relatively complicated because we want to - * run the actual export in a background thread so that the whole GUI isn't - * tied up during the export. Also, the actual export logic is implemented - * by the ExportController, and we provide an Exporter implementation - * which allows it to interact with the user. So, the ExportController is - * executed in a background thread, and the callbacks implemented in the - * Exporter must each use SwingUtilities.invoke* methods to ask for the - * UI updates to happen. In the case of the progress display, the - * ProgressManager class already implements that logic so it's simpler - * than the rest of the interactions. - */ - public void doFinish() { - /* - * This runnable serves merely to allow the background thread used for - * export to tell the GUI that it's done. - */ - final Runnable finisher = new Runnable() { - public void run() { - reallyFinish(); - } - }; - - /* - * Create callback interface used by ExportController to interact with - * the user. - */ - Exporter exporter = new Exporter() { - ProgressManager progress; - String [] errObjs = new String[] { - ResourceStrings.getString("exp_error_occurred"), - "" - }; - - // Set up the progress display - public void initializeProgress(int length) { - progress = new ProgressManager(ExportWizard.this, - ResourceStrings.getString("exp_progress_title"), "", 0, - length); - } - - // Update progress to current point, updating message - public void updateProgress(int done, String message) - throws InterruptedException { - progress.update(done, message); - } - - // Display an error message - public void displayError(String message) { - errObjs[1] = message; - try { - SwingUtilities.invokeAndWait(new ErrorDisplay(errObjs)); - } catch (InvocationTargetException ex2) { - // ErrorDisplay threw an exception; give up! - ex2.printStackTrace(); - } catch (InterruptedException ex2) { - // ErrorDisplay was interrupted; give up! - ex2.printStackTrace(); - } - } - - // Display a bunch of error messages in a table - public void displayErrors(String msg, String label, - ActionError [] errs) { - ErrorTable errTable = new ErrorTable(label); - errTable.setErrors(errs); - JScrollPane scrollPane = new JScrollPane(errTable); - Object [] warnObjs = new Object [] { msg, scrollPane }; - try { - SwingUtilities.invokeAndWait(new WarningDisplay(warnObjs)); - } catch (InvocationTargetException e) { - // WarningDisplay threw an exception; just dump it - e.printStackTrace(); - } catch (InterruptedException e) { - // WarningDisplay was interrupted; just dump it - e.printStackTrace(); - } - } - }; - - /* - * Create the export controller and set parameters. Use final so - * that the exportThread can reference it. - */ - final ExportController exportController = new ExportController(exporter, - DataManager.get().getServer()); - exportController.setUser(System.getProperty("user.name")); - exportController.setFile(exportPath); - exportController.setOptions(optionNames); - exportController.setMacros(macroNames); - exportController.setNetworks(networks); - - // Now create the thread that does the exporting - Thread exportThread = new Thread() { - public void run() { - OverwritePrompter prompter = new OverwritePrompter(); - while (true) { - try { - /* - * Controller will return true if it completed - * successfully, in which case we want to exit the - * wizard; if it returns false, just exit this - * thread but leave the wizard up. - */ - if (exportController.exportData(deleteData, - prompter.overwrite)) { - SwingUtilities.invokeLater(finisher); - } - return; - } catch (ExistsException e) { - // Export file already existed and overwrite was false - try { - SwingUtilities.invokeAndWait(prompter); - /* - * If user said not to overwrite, then exit - * this thread but leave wizard up. Otherwise just - * let the while loop try the export again. - */ - if (!prompter.overwrite) { - return; - } - } catch (Throwable t) { - /* - * We can get an interrupt or prompter could - * throw an exception; the only reasonable - * thing to do at this point is just display - * the stack and return. - */ - t.printStackTrace(); - return; - } - } - } - } - }; - - // Now run the export thread - exportThread.start(); - } - - protected void reallyFinish() { - super.doFinish(); - } - - public void doHelp() { - DhcpmgrApplet.showHelp("export_wizard"); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/HelpBundle.properties b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/HelpBundle.properties deleted file mode 100644 index c7f99b95fe..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/HelpBundle.properties +++ /dev/null @@ -1,107 +0,0 @@ -# -#ident "%W% %E% SMI" -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Resources for locating the correct help file for a particular window -# -# L10N instructions -# ----------------- -# Each line of this file is of the form: -# -# key=value -# -# The key portion must not be localized, as it is a constant in the program. -# The value portion should be modified appropriately for each locale to point -# to the location of the localized version of the html file relative to the -# directory: -# -# /usr/share/lib/locale/com/sun/dhcpmgr/client/help -# -# So that for the "de" locale the first entry in this file should look like: -# -# create_address=de/dhcp_addr_create.html -# -# resulting in that help file being located at: -# -# /usr/share/lib/locale/com/sun/dhcpmgr/client/help/de/dhcp_addr_create.html -# -# And the corresponding name of THIS file would be: -# -# /usr/share/lib/locale/com/sun/dhcpmgr/client/HelpBundle_de.properties -# -# At the present time it is a requirement that the above convention be followed -# with respect to the relative path name as the l10n code in HelpIds.java -# uses the presence of a '/' in the value as the indicator of whether a -# localized instance of this file is being used. See bug 4177489 if you -# want to understand why this is so. -# -create_address=dhcp_addr_create.html -delete_address=dhcp_addr_del.html -duplicate_address=dhcp_addr_dup.html -XXX1=dhcp_addr_how.html -modify_address=dhcp_addr_mod.html -modify_multiple_addresses=dhcp_addr_multi.html -addresses_reference=dhcp_addr_ref.html -release_addresses=dhcp_addr_rel.html -XXX3=dhcp_addr_view.html -address_wizard=dhcp_addr_wiz.html -config_wizard=dhcp_config_wiz.html -create_macro=dhcp_macro_create.html -delete_macro=dhcp_macro_del.html -duplicate_macro=dhcp_macro_dup.html -XXX4=dhcp_macro_how.html -modify_macro=dhcp_macro_mod.html -macros_reference=dhcp_macro_ref.html -XXX6=dhcp_macro_view.html -XXX7=dhcp_macros_about.html -XXX8=dhcp_main_hlp.html -howto=dhcp_main_how.html -index=dhcp_main_idx.html -XXX11=dhcp_main_menus.html -overview=dhcp_main_top.html -delete_network=dhcp_net_del.html -XXX13=dhcp_net_ref.html -network_wizard=dhcp_net_wiz.html -create_option=dhcp_option_create.html -delete_option=dhcp_option_del.html -duplicate_option=dhcp_option_dup.html -XXX14=dhcp_option_how.html -modify_option=dhcp_option_mod.html -options_reference=dhcp_option_ref.html -XXX16=dhcp_option_view.html -server_config=dhcp_relay_choose.html -configure_relay=dhcp_relay_config.html -XXX17=dhcp_relay_how.html -service_reference=dhcp_relay_ref.html -modify_relay=dhcp_relay_serv.html -unconfigure_relay=dhcp_relay_unconfig.html -modify_server=dhcp_server_serv.html -unconfigure_server=dhcp_server_unconfig.html -XXX19=dhcp_solaris_about.html -enable_service=dhcp_relay_enable.html -disable_service=dhcp_relay_dis.html -convert_wizard=dhcp_convert_wiz.html -export_wizard=dhcp_export_wiz.html -import_wizard=dhcp_import_wiz.html diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ImportWizard.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ImportWizard.java deleted file mode 100644 index 6d3d51d0a4..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ImportWizard.java +++ /dev/null @@ -1,437 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.event.*; -import java.awt.*; -import java.util.Date; -import java.text.SimpleDateFormat; -import java.text.MessageFormat; -import java.lang.reflect.InvocationTargetException; -import java.io.FileNotFoundException; - -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.data.ActionError; -import com.sun.dhcpmgr.data.ExportHeader; -import com.sun.dhcpmgr.common.*; - -/** - * ImportWizard provides an easy-to-use interface for importing configuration - * data from one DHCP server to another. - * - * @see ExportWizard - */ -public class ImportWizard extends Wizard { - - // Step to get the location of the export file - class LocationStep implements WizardStep { - JPanel stepPanel; - JTextField pathField; - JCheckBox overrideBox; - - public LocationStep() { - GridBagLayout bag = new GridBagLayout(); - GridBagConstraints con = new GridBagConstraints(); - con.insets = new Insets(2, 2, 2, 2); - con.gridx = con.gridy = 0; - con.gridwidth = 2; - con.gridheight = 1; - con.weightx = 0; - con.weighty = 1.0; - con.fill = GridBagConstraints.BOTH; - con.anchor = GridBagConstraints.NORTHWEST; - - stepPanel = new JPanel(bag); - - Component c = Wizard.createTextArea( - ResourceStrings.getString("imp_wiz_location_explain"), 8, 45); - bag.setConstraints(c, con); - stepPanel.add(c); - - Mnemonic mnFile = - new Mnemonic(ResourceStrings.getString("imp_wiz_file_label")); - JLabel l = new JLabel(mnFile.getString()); - l.setToolTipText(mnFile.getString()); - l.setDisplayedMnemonic(mnFile.getMnemonic()); - - ++con.gridy; - con.gridwidth = 1; - con.weighty = 0; - con.fill = GridBagConstraints.HORIZONTAL; - bag.setConstraints(l, con); - stepPanel.add(l); - - pathField = new JTextField(importPath); - l.setLabelFor(pathField); - ++con.gridx; - con.weightx = 1.0; - bag.setConstraints(pathField, con); - stepPanel.add(pathField); - - c = Wizard.createTextArea( - ResourceStrings.getString("imp_wiz_override_explain"), 4, 45); - con.gridx = 0; - ++con.gridy; - con.weighty = 0.5; - con.weightx = 0; - con.fill = GridBagConstraints.BOTH; - con.gridwidth = 2; - bag.setConstraints(c, con); - stepPanel.add(c); - - overrideBox = new JCheckBox( - ResourceStrings.getString("imp_wiz_override_data"), false); - overrideBox.setToolTipText( - ResourceStrings.getString("imp_wiz_override_data")); - con.gridx = 0; - ++con.gridy; - con.gridwidth = 2; - con.weighty = 0; - con.weightx = 1.0; - con.fill = GridBagConstraints.HORIZONTAL; - bag.setConstraints(overrideBox, con); - stepPanel.add(overrideBox); - - c = Box.createVerticalGlue(); - ++con.gridy; - con.weighty = 1.0; - con.weightx = 0; - con.fill = GridBagConstraints.VERTICAL; - bag.setConstraints(c, con); - stepPanel.add(c); - - // Enable forward only if something is entered in the file field - pathField.getDocument().addDocumentListener(new DocumentListener() { - public void insertUpdate(DocumentEvent e) { - setForwardEnabled(pathField.getText().length() != 0); - } - public void changedUpdate(DocumentEvent e) { - insertUpdate(e); - } - public void removeUpdate(DocumentEvent e) { - insertUpdate(e); - } - }); - } - - public String getDescription() { - return ResourceStrings.getString("imp_wiz_file_desc"); - } - - public Component getComponent() { - return stepPanel; - } - - public void setActive(int direction) { - pathField.setText(importPath); - overrideBox.setSelected(conflictImport); - setForwardEnabled(importPath.length() != 0); - } - - public boolean setInactive(int direction) { - importPath = pathField.getText(); - conflictImport = overrideBox.isSelected(); - /* - * Read the file header for display in next step; if we can't read - * it, display the errors and veto the forward step. - */ - if (direction == FORWARD) { - importController.setFile(importPath); - try { - header = importController.getHeader(); - if (header == null) { - // Something wrong, but controller already displayed err - return false; - } - } catch (FileNotFoundException e) { - JOptionPane.showMessageDialog(ImportWizard.this, - ResourceStrings.getString("imp_err_file_not_found"), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - return false; - } catch (Exception e) { - String [] msgs = new String [] { - ResourceStrings.getString("imp_err_reading_header"), - e.getMessage() - }; - JOptionPane.showMessageDialog(ImportWizard.this, msgs, - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - return false; - } - } - return true; - } - } - - // Allow user to review summary of file contents before proceeding. - class ReviewStep implements WizardStep { - private Box stepBox; - private JLabel fileLabel, srcLabel, userLabel, dateLabel, overrideLabel; - private JLabel infoLabel; - private SimpleDateFormat dateFormat = new SimpleDateFormat(); - private MessageFormat infoFormat = - new MessageFormat(ResourceStrings.getString("imp_wiz_review_info")); - - public ReviewStep() { - stepBox = Box.createVerticalBox(); - JComponent jc = Wizard.createTextArea( - ResourceStrings.getString("imp_wiz_review_explain"), 6, 45); - jc.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(jc); - - Mnemonic mnFl = - new Mnemonic(ResourceStrings.getString("imp_wiz_file_label")); - JPanel fieldPanel = new JPanel(new FieldLayout()); - JLabel l = new JLabel(mnFl.getString()); - l.setLabelFor(fieldPanel); - l.setToolTipText(mnFl.getString()); - fieldPanel.add(l, FieldLayout.LABEL); - - fileLabel = new JLabel(); - fileLabel.setForeground(Color.black); - fieldPanel.add(fileLabel, FieldLayout.FIELD); - - l = new JLabel( - ResourceStrings.getString("imp_wiz_review_override")); - fieldPanel.add(l, FieldLayout.LABEL); - l.setToolTipText( - ResourceStrings.getString("imp_wiz_review_override")); - - overrideLabel = new JLabel(); - l.setLabelFor(overrideLabel); - overrideLabel.setForeground(Color.black); - fieldPanel.add(overrideLabel, FieldLayout.FIELD); - - fieldPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(fieldPanel); - - stepBox.add(Box.createVerticalStrut(5)); - - infoLabel = new JLabel(); - infoLabel.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(infoLabel); - - l = new JLabel( - ResourceStrings.getString("imp_wiz_review_src")); - fieldPanel = new JPanel(new FieldLayout()); - fieldPanel.add(l, FieldLayout.LABEL); - l.setToolTipText(ResourceStrings.getString("imp_wiz_review_src")); - - srcLabel = new JLabel(); - l.setLabelFor(srcLabel); - fieldPanel.add(srcLabel, FieldLayout.FIELD); - - l = new JLabel( - ResourceStrings.getString("imp_wiz_review_user")); - fieldPanel.add(l, FieldLayout.LABEL); - l.setToolTipText(ResourceStrings.getString("imp_wiz_review_user")); - - userLabel = new JLabel(); - l.setLabelFor(userLabel); - fieldPanel.add(userLabel, FieldLayout.FIELD); - - l = new JLabel( - ResourceStrings.getString("imp_wiz_review_date")); - fieldPanel.add(l, FieldLayout.LABEL); - l.setToolTipText(ResourceStrings.getString("imp_wiz_review_date")); - - dateLabel = new JLabel(dateFormat.format(new Date())); - l.setLabelFor(dateLabel); - fieldPanel.add(dateLabel, FieldLayout.FIELD); - - fieldPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - stepBox.add(fieldPanel); - - stepBox.add(Box.createVerticalGlue()); - } - - public String getDescription() { - return ResourceStrings.getString("imp_wiz_review_desc"); - } - - public Component getComponent() { - return stepBox; - } - - public void setActive(int direction) { - fileLabel.setText(importPath); - if (conflictImport) { - overrideLabel.setText(ResourceStrings.getString("yes")); - } else { - overrideLabel.setText(ResourceStrings.getString("no")); - } - Object [] objs = new Object [] { importPath }; - infoLabel.setText(infoFormat.format(objs)); - // Set values from file header - srcLabel.setText(header.getServer()); - userLabel.setText(header.getUser()); - dateLabel.setText(dateFormat.format(header.getDate())); - - setFinishEnabled(true); - } - - public boolean setInactive(int direction) { - return true; - } - } - - /* - * Display an error message inside a separate thread so that background - * threads may interact with the user via SwingUtilities.invoke* - */ - class ErrorDisplay implements Runnable { - Object [] objs; - - public ErrorDisplay(Object [] objs) { - this.objs = objs; - } - - public void run() { - JOptionPane.showMessageDialog(ImportWizard.this, objs, - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - } - - private String importPath = ""; - private boolean conflictImport = false; - private ImportController importController; - private ExportHeader header; - /* - * The Importer allows the ImportController, which contains all of the - * actual import logic, to interact with the user as the import proceeds. - * Since we run the import in a background thread to keep the GUI live, - * the interactions must use SwingUtilities.invoke* to control the GUI. - * Progress updates via ProgressManager don't need special logic here as - * ProgressManager already handles the threading work for us. - */ - private Importer importer = new Importer() { - ProgressManager progress; - String [] errObjs = new String [] { - ResourceStrings.getString("imp_error"), "" - }; - - // Create progress display - public void initializeProgress(int length) { - progress = new ProgressManager(ImportWizard.this, - ResourceStrings.getString("imp_progress_title"), "", 0, - length); - } - - // Update progress display with current completion level and message - public void updateProgress(int done, String message) - throws InterruptedException { - progress.update(done, message); - } - - // Display a single error message - public void displayError(String message) { - errObjs[1] = message; - displayError(errObjs); - } - - // Display a group of error messages using a table. - public void displayErrors(String msg, String label, - ActionError [] errors) { - ErrorTable errTable = new ErrorTable(label); - errTable.setErrors(errors); - JScrollPane scrollPane = new JScrollPane(errTable); - Object [] errObjs = new Object [] { msg, scrollPane }; - displayError(errObjs); - } - - // Display an error in the GUI - private void displayError(Object [] errObjs) { - // If we're on the event dispatch thread already then display now - ErrorDisplay ed = new ErrorDisplay(errObjs); - if (SwingUtilities.isEventDispatchThread()) { - ed.run(); - } else { - try { - SwingUtilities.invokeAndWait(ed); - } catch (Exception e) { - // Errors here are fairly serious; dump the stack - e.printStackTrace(); - } - } - } - }; - - public ImportWizard(Frame owner) { - super(owner, ""); - setTitle(ResourceStrings.getString("import_wiz_title")); - - addStep(new LocationStep()); - addStep(new ReviewStep()); - - importController = new ImportController(importer, - DataManager.get().getServer()); - showFirstStep(); - } - - public void doFinish() { - /* - * Runnable which the importThread can call to tear down the display - * when it's completed. - */ - final Runnable finisher = new Runnable() { - public void run() { - reallyFinish(); - } - }; - - // Create the thread in which to execute the import - Thread importThread = new Thread() { - public void run() { - if (importController.importData(conflictImport)) { - // Only exit if import successful - SwingUtilities.invokeLater(finisher); - } - } - }; - // Run the import thread - importThread.start(); - } - - public void doCancel() { - // Close file if there is one open - importController.closeFile(); - super.doCancel(); - } - - protected void reallyFinish() { - super.doFinish(); - } - - public void doHelp() { - DhcpmgrApplet.showHelp("import_wizard"); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/MacroNameField.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/MacroNameField.java deleted file mode 100644 index 476722bdb7..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/MacroNameField.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.text.*; -import com.sun.dhcpmgr.data.Macro; - -/** - * A text field which enforces the syntax rules for a macro name. These - * are all the rules for DhcptabNameField, plus a limit on the length. - */ -public class MacroNameField extends DhcptabNameField { - - /** - * Constructs a field initialized to the provided text. Defaults to - * 20 characters wide. - * @param text the text to display initially - */ - public MacroNameField(String text) { - this(text, 20); - } - - /** - * Constructs a field initialized to the provided text with the requested - * size. - * @param text the text to display initially - * @param length the length in characters the field should size itself to - */ - public MacroNameField(String text, int length) { - super(text, length); - } - - protected Document createDefaultModel() { - return new MacroNameDocument(); - } - - /* - * This is the recommended way to validate input, as opposed to trapping - * KeyEvents because this will actually catch paste operations as well. - */ - class MacroNameDocument extends DhcptabNameDocument { - public void insertString(int offs, String str, AttributeSet a) - throws BadLocationException { - if (str != null) { - if ((getLength() + str.length()) > Macro.MAX_NAME_SIZE) { - throw new BadLocationException("", offs); - } - } - super.insertString(offs, str, a); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/MacroView.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/MacroView.java deleted file mode 100644 index 44f46cf451..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/MacroView.java +++ /dev/null @@ -1,673 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.table.*; -import javax.swing.tree.*; -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.text.*; - -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.bridge.BridgeException; - -// Background thread for doing retrieval while keeping GUI live -class MacroLoader extends com.sun.dhcpmgr.ui.SwingWorker { - public Object construct() { - try { - return DataManager.get().getMacros(true); - } catch (final BridgeException e) { - // Since we're in a background thread, ask Swing to run ASAP. - SwingUtilities.invokeLater(new Runnable() { - Object [] args = new Object[] { e.getMessage() }; - public void run() { - MessageFormat form = new MessageFormat( - ResourceStrings.getString("error_loading_macros")); - JOptionPane.showMessageDialog(null, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - }); - } - return null; - } - - public void finished() { - Macro [] macros = (Macro [])get(); - if (macros == null) { - macros = new Macro[0]; - } - - MacroView.macroTreeModel.getRootNode().setMacros(macros); - } -} - -/** - * Implements a display of the macro hierarchy contained in the dhcptab - */ -public class MacroView implements View { - - // A node in the tree of macros - class MacroTreeNode extends DefaultMutableTreeNode { - private boolean scannedIncludes = false; - private boolean isScanning = false; - - public MacroTreeNode(Object o) { - super(o); - } - - public String toString() { - Macro m = (Macro)getUserObject(); - return m.getKey(); - } - - public int getChildCount() { - /* - * scannedIncludes is used so that we only build the tree once; - * isScanning prevents us from recursing infinitely because add() - * ends up coming right back here - */ - if (!scannedIncludes && !isScanning) { - isScanning = true; - Macro m = (Macro)getUserObject(); - Enumeration e = m.elements(); - while (e.hasMoreElements()) { - OptionValue o = (OptionValue)e.nextElement(); - if (o instanceof IncludeOptionValue) { - Macro m2 = - macroTreeModel.getRootNode().getMacro( - (String)o.getValue()); - if (m2 != null) { - add(new MacroTreeNode(m2)); - } - } - } - scannedIncludes = true; - isScanning = false; - } - return super.getChildCount(); - } - - public Macro getMacro() { - return (Macro)getUserObject(); - } - } - - /* - * Special class for the root node; this handles retrieving the data from - * the server - */ - class MacroTreeRootNode extends MacroTreeNode { - private Macro [] macros = null; - - public MacroTreeRootNode() { - super(new Macro()); - } - - public MacroTreeRootNode(Object o) { - super(o); - } - - protected void setMacros(Macro [] newmacros) { - macros = newmacros; - if (newmacros != null) { - for (int i = 0; i < macros.length; ++i) { - add(new MacroTreeNode(macros[i])); - } - } - macroTreeModel.reload(); - reloadCompleted(); - } - - public String toString() { - return ResourceStrings.getString("macros"); - } - - public int getChildCount() { - if (macros == null) { - return 0; - } - return super.getChildCount(); - } - - public void load() { - // Display starting message and clear tree - MainFrame.setStatusText( - ResourceStrings.getString("loading_macros")); - removeAllChildren(); - macroTreeModel.reload(); - // Kick off background loader - MacroLoader loader = new MacroLoader(); - } - - public Macro getMacro() { - return null; - } - - // Find a particular macro by name - public Macro getMacro(String name) { - if (macros != null) { - for (int i = 0; i < macros.length; ++i) { - if (name.equals(macros[i].getKey())) { - return macros[i]; - } - } - } - return null; - } - } - - // Model for data contained in macro tree - class MacroTreeModel extends DefaultTreeModel { - public MacroTreeModel(MacroTreeRootNode n) { - super(n); - } - - public void load() { - getRootNode().load(); - } - - public Macro getMacro(String name) { - return getRootNode().getMacro(name); - } - - public MacroTreeRootNode getRootNode() { - return (MacroTreeRootNode)super.getRoot(); - } - } - - // Model for table displaying contents of a macro - class MacroTableModel extends AbstractTableModel { - private Macro macro = null; - - public MacroTableModel() { - super(); - } - - public void display(Macro m) { - macro = m; - fireTableDataChanged(); - } - - public int getRowCount() { - if (macro == null) { - return 0; - } else { - return macro.optionCount(); - } - } - - public int getColumnCount() { - return 2; - } - - public Object getValueAt(int row, int column) { - if (macro == null) { - return null; - } - switch (column) { - case 0: - return macro.getOptionAt(row).getName(); - case 1: - return macro.getOptionAt(row).getValue(); - default: - return null; - } - } - - public Class getColumnClass(int column) { - switch (column) { - case 0: - case 1: - return String.class; - default: - super.getColumnClass(column); - } - return null; - } - - public String getColumnName(int column) { - switch (column) { - case 0: - return ResourceStrings.getString("option_column"); - case 1: - return ResourceStrings.getString("value_column"); - default: - super.getColumnName(column); - } - return null; - } - } - - // Recipient of update messages sent when the macro editing dialogs exit - class DialogListener implements ActionListener { - public void actionPerformed(ActionEvent e) { - if (!e.getActionCommand().equals(DialogActions.CANCEL)) { - reload(); - } - } - } - - private JTree macroTree; - protected static MacroTreeModel macroTreeModel = null; - private AutosizingTable macroTable; - private JScrollPane treePane; - private JScrollPane macroTablePane; - private JSplitPane splitPane; - private boolean firstActivation = true; - private MacroTableModel macroTableModel; - private JCheckBoxMenuItem showGrid; - private JMenuItem macroHelp; - private Vector[] menuItems; - private Frame myFrame; - private boolean firstview = true; - private Vector selectionListeners = new Vector(); - - public MacroView() { - // Create tree for macro display - macroTreeModel = new MacroTreeModel(new MacroTreeRootNode()); - macroTree = new JTree(macroTreeModel); - // Listen for selection events, load selected macro into table - macroTree.addTreeSelectionListener(new TreeSelectionListener() { - public void valueChanged(TreeSelectionEvent e) { - TreePath selPath = macroTree.getSelectionPath(); - if (selPath != null) { - TreeNode node = (TreeNode)selPath.getLastPathComponent(); - if (node instanceof MacroTreeNode) { - macroTableModel.display( - ((MacroTreeNode)node).getMacro()); - } else { - macroTableModel.display(null); - } - } else { - macroTableModel.display(null); - } - // Notify listeners that our selection state may have changed - notifySelectionListeners(); - } - }); - // Single selection for now - macroTree.getSelectionModel().setSelectionMode( - TreeSelectionModel.SINGLE_TREE_SELECTION); - // Make a scroll pane for it - treePane = new JScrollPane(); - treePane.getViewport().add(macroTree); - // Make double-clicks the same as Edit->Properties - macroTree.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) { - // Don't do anything if it's the root node - TreePath selPath = - macroTree.getClosestPathForLocation(e.getX(), e.getY()); - macroTree.addSelectionPath(selPath); - if (selPath.getPathCount() != 1) { - handleProperties(); - } - } - } - }); - - // Create table to display in data area - macroTableModel = new MacroTableModel(); - macroTable = new AutosizingTable(macroTableModel); - - // Can't mess with the column order, or select any data - macroTable.getTableHeader().setReorderingAllowed(false); - macroTable.setRowSelectionAllowed(false); - macroTable.setColumnSelectionAllowed(false); - - // Now wrap it with scrollbars - macroTablePane = new JScrollPane(macroTable); - - // Create split pane containing the tree & table, side-by-side - splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePane, - macroTablePane); - - // Create menu items - Mnemonic mnShowGrid = - new Mnemonic(ResourceStrings.getString("show_grid")); - showGrid = new JCheckBoxMenuItem(mnShowGrid.getString(), - true); - showGrid.setMnemonic(mnShowGrid.getMnemonic()); - showGrid.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - macroTable.setShowGrid(showGrid.getState()); - } - }); - - Mnemonic mnOnMacros = - new Mnemonic(ResourceStrings.getString("on_macros_item")); - macroHelp = new JMenuItem(mnOnMacros.getString()); - macroHelp.setMnemonic(mnOnMacros.getMnemonic()); - macroHelp.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - DhcpmgrApplet.showHelp("macros_reference"); - } - }); - - - /* - * Construct lists of menu items custom to this view. - */ - menuItems = new Vector[MainFrame.MENU_COUNT]; - for (int i = 0; i < menuItems.length; ++i) { - menuItems[i] = new Vector(); - } - menuItems[MainFrame.VIEW_MENU].addElement(showGrid); - menuItems[MainFrame.HELP_MENU].addElement(macroHelp); - } - - public String getName() { - return ResourceStrings.getString("macro_view_name"); - } - - // Return menus that we wish to add to MainFrame, in our case none - public Enumeration menus() { - return null; - } - - // Return menu items for each menu as requested by MainFrame - public Enumeration menuItems(int menu) { - return menuItems[menu].elements(); - } - - public Component getDisplay() { - return splitPane; - } - - private void reload() { - macroTreeModel.load(); - } - - // Callback from model when loading completed to update display - private void reloadCompleted() { - // Doesn't display correctly without this - splitPane.resetToPreferredSizes(); - String s = MessageFormat.format( - ResourceStrings.getString("macro_status_message"), - macroTreeModel.getRootNode().getChildCount()); - MainFrame.setStatusText(s); - macroTree.clearSelection(); - macroTable.clearSelection(); - /* - * Check for syntax errors. - */ - MacroTreeRootNode rootNode = macroTreeModel.getRootNode(); - Vector errs = new Vector(); - for (int i = 0; i < rootNode.macros.length; ++i) { - try { - rootNode.macros[i].validate(); - } catch (ValidationException e) { - errs.addElement(rootNode.macros[i].getKey()); - } - } - if (errs.size() != 0) { - // Found some errors; warn user - Object [] objs = new Object[2]; - objs[0] = ResourceStrings.getString("macro_validation_warning"); - JList macroList = new JList(errs); - JScrollPane scrollPane = new JScrollPane(macroList); - macroList.setVisibleRowCount(4); - objs[1] = scrollPane; - JOptionPane.showMessageDialog(macroTable, objs, - ResourceStrings.getString("warning"), - JOptionPane.WARNING_MESSAGE); - } - macroTree.setSelectionRow(1); - } - - public void setActive(boolean state) { - if (state) { - // We only do an automatic load the first time we're displayed - if (firstview) { - myFrame = (Frame)SwingUtilities.getAncestorOfClass( - MainFrame.class, macroTree); - reload(); - firstview = false; - } - } - } - - /* - * Handle a find operation. - * Algorithm used here searches nodes in the order they appear in the - * displayed tree. This requires traversing the entire tree starting at - * an arbitrary point with some special twists. - */ - public void find(String s) { - // Clear status if we had an old message lying there - MainFrame.setStatusText(""); - MacroTreeNode startNode = - (MacroTreeNode)macroTree.getLastSelectedPathComponent(); - if (startNode == null) { - // Nothing selected so start at root - startNode = macroTreeModel.getRootNode(); - } - // Start by searching children of selected node - MacroTreeNode result = searchUnderNode(startNode, s); - if (result != null) { - selectNode(result); // Found one, select it and return - return; - } - // Get all ancestor nodes of selected - TreeNode [] path = macroTreeModel.getPathToRoot(startNode); - MacroTreeNode pathNode = null; - - // Walk up towards root of tree, at each level search all children - for (int i = path.length - 1; i >= 0; --i) { - result = searchNodeLevel((MacroTreeNode)path[i], startNode, s); - if (result != null) { - selectNode(result); // Found one, select it and return - return; - } - // Move up a level - startNode = (MacroTreeNode)path[i]; - /* - * If it's not the root node and it matches, remember it. We don't - * return immediately because this is actually about last in the - * display order. - */ - if (startNode.getMacro() != null) { - if (startNode.getMacro().getKey().indexOf(s) != -1) { - pathNode = startNode; - } - } - } - // We found one on the path to the root, select and return - if (pathNode != null) { - selectNode(pathNode); - return; - } - // Nothing found; show an error - MessageFormat form = null; - Object [] args = new Object[1]; - form = new MessageFormat(ResourceStrings.getString("find_macro_error")); - args[0] = s; - MainFrame.setStatusText(form.format(args)); - } - - // Search a particular level of a tree in the order a user would expect - private MacroTreeNode searchNodeLevel(MacroTreeNode n, - MacroTreeNode startNode, String s) { - // Skip all children prior to the startNode in display order - Enumeration e = n.children(); - while (e.hasMoreElements()) { - MacroTreeNode cn = (MacroTreeNode)e.nextElement(); - if (cn == startNode) { - break; - } - } - // Now search those after the startNode in the display order - while (e.hasMoreElements()) { - MacroTreeNode cn = (MacroTreeNode)e.nextElement(); - MacroTreeNode result = searchNode(cn, s); - if (result != null) { - return result; - } - } - // Got to the end of this level and didn't find it, so wrap to beginning - e = n.children(); - while (e.hasMoreElements()) { - MacroTreeNode cn = (MacroTreeNode)e.nextElement(); - if (cn == startNode) { - break; - } - MacroTreeNode result = searchNode(cn, s); - if (result != null) { - return result; - } - } - return null; - } - - // Search a node and all its children for a particular string - private MacroTreeNode searchNode(MacroTreeNode n, String s) { - if (n.getMacro().getKey().indexOf(s) != -1 - || n.getMacro().getValue().indexOf(s) != -1) { - return n; - } - return searchUnderNode(n, s); - } - - // Search all children, recursively, of a node for a particular string - private MacroTreeNode searchUnderNode(MacroTreeNode n, String s) { - Enumeration e = n.children(); - while (e.hasMoreElements()) { - MacroTreeNode cn = (MacroTreeNode)e.nextElement(); - if (cn.getMacro().getKey().indexOf(s) != -1 - || cn.getMacro().getValue().indexOf(s) != -1) { - return cn; - } - MacroTreeNode result = searchUnderNode(cn, s); - if (result != null) { - return result; - } - } - return null; - } - - // Select a node and make sure it's visible - private void selectNode(MacroTreeNode n) { - macroTree.clearSelection(); - TreePath selPath = new TreePath(macroTreeModel.getPathToRoot(n)); - macroTree.addSelectionPath(selPath); - macroTree.scrollPathToVisible(selPath); - } - - // Return the macro currently selected - private Macro getSelectedMacro() { - TreePath selPath = macroTree.getSelectionPath(); - if (selPath != null) { - TreeNode node = (TreeNode)selPath.getLastPathComponent(); - if (node instanceof MacroTreeNode) { - return ((MacroTreeNode)node).getMacro(); - } - } - return null; - } - - public void handleCreate() { - CreateMacroDialog d = new CreateMacroDialog(myFrame, - CreateMacroDialog.CREATE); - d.addActionListener(new DialogListener()); - d.pack(); - d.setVisible(true); - } - - public void handleDelete() { - Macro m = getSelectedMacro(); - if (m == null) { - return; - } - DeleteMacroDialog d = new DeleteMacroDialog(myFrame, m); - d.addActionListener(new DialogListener()); - d.pack(); - d.setVisible(true); - } - - public void handleDuplicate() { - Macro m = getSelectedMacro(); - if (m == null) { - return; - } - CreateMacroDialog d = new CreateMacroDialog(myFrame, - CreateMacroDialog.DUPLICATE); - d.addActionListener(new DialogListener()); - d.setMacro((Macro)m.clone()); - d.pack(); - d.setVisible(true); - } - - public void handleProperties() { - Macro m = getSelectedMacro(); - if (m == null) { - return; - } - CreateMacroDialog d = new CreateMacroDialog(myFrame, - CreateMacroDialog.EDIT); - d.addActionListener(new DialogListener()); - d.setMacro((Macro)m.clone()); - d.pack(); - d.setVisible(true); - } - - public void handleUpdate() { - reload(); - } - - public void addSelectionListener(SelectionListener listener) { - selectionListeners.addElement(listener); - } - - public void removeSelectionListener(SelectionListener listener) { - selectionListeners.removeElement(listener); - } - - private void notifySelectionListeners() { - Enumeration en = selectionListeners.elements(); - while (en.hasMoreElements()) { - SelectionListener l = (SelectionListener)en.nextElement(); - l.valueChanged(); - } - } - - public boolean isSelectionEmpty() { - TreePath path = macroTree.getSelectionPath(); - // If empty or the root of the tree is selected, then we call it empty - return ((path == null) || (path.getPathCount() == 1)); - } - - public boolean isSelectionMultiple() { - return false; // We don't allow multiple selection - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/Makefile deleted file mode 100644 index d65d3a6c44..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/Makefile +++ /dev/null @@ -1,122 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/Makefile -# - -# Place high-level classes first in order to minimize build time. -CLASSFILES = DhcpmgrApplet.class \ - AddressView.class \ - OptionView.class \ - MacroView.class \ - RelayView.class \ - CreateMacroDialog.class \ - DeleteMacroDialog.class \ - CreateOptionDialog.class \ - DeleteOptionDialog.class \ - CreateAddressDialog.class \ - DeleteAddressDialog.class \ - AddressWizard.class \ - ModifyAddressesDialog.class \ - ReleaseAddressDialog.class \ - DisableServiceDialog.class \ - ConfigureRelayDialog.class \ - ConfigureChoiceDialog.class \ - ConfigWizard.class \ - ServerOptionsDialog.class \ - DeleteNetworksDialog.class \ - UnconfigureDialog.class \ - ExportWizard.class \ - ImportWizard.class \ - ConvertWizard.class \ - DSWizard.class \ - SUNWModule.class \ - DSModule.class \ - DSModuleListener.class \ - DSModuleEvent.class \ - MacroNameField.class \ - OptionNameField.class \ - DhcptabNameField.class \ - SelectOptionDialog.class \ - DataManager.class \ - MultipleOperationDialog.class \ - DhcpmgrDialog.class \ - ViewMacroDialog.class \ - ErrorTable.class \ - ResourceStrings.class - -SUBDIRS = SUNWbinfiles SUNWfiles - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -include $(SRC)/Makefile.master - -CLASSPATH= $(SRC)/cmd/cmd-inet/usr.sadm/dhcpmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -MSGDIR= $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/client -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr \ - $(MSGDIR) - -MSGFILES= ResourceBundle.properties \ - OptionDescriptions.properties -MSGS= $(MSGFILES:%=$(MSGDIR)/%) - -CLEANFILES= *.class -CLOBBERFILES= - -.KEEP_STATE: - -all: $(CLASSFILES) $(SUBDIRS) - -install: all $(SUBDIRS) - -_msg: $(MSGDIRS) $(MSGS) $(SUBDIRS) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - -lint: - -clean: $(SUBDIRS) FRC - $(RM) $(CLEANFILES) - -clobber: clean - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ModifyAddressesDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ModifyAddressesDialog.java deleted file mode 100644 index 26afcc538a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ModifyAddressesDialog.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.table.*; -import java.util.*; -import java.awt.*; -import java.awt.event.*; -import java.net.*; - -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.server.DhcpNetMgr; - -/** - * This dialog allows the user to modify multiple addresses - */ -public class ModifyAddressesDialog extends MultipleOperationDialog { - private DhcpClientRecord [] recs; - private String table; - private JLabel numberLabel; - private JComboBox server; - private JTextField comment; - private JComboBox macro; - private JRadioButton bootpCurrent, bootpAll, bootpNone; - private JRadioButton unusableCurrent, unusableAll, unusableNone; - private JRadioButton leaseCurrent, leaseDynamic, leasePermanent; - private static final String keepString = - ResourceStrings.getString("modify_multiple_keep"); - - class ServerListModel extends AbstractListModel implements ComboBoxModel { - private String [] servers; - private Object currentValue; - - public ServerListModel() { - servers = new String[2]; - servers[0] = keepString; - servers[1] = DataManager.get().getShortServerName(); - } - - public int getSize() { - return servers.length; - } - - public Object getElementAt(int index) { - return servers[index]; - } - - public void setSelectedItem(Object anItem) { - currentValue = anItem; - fireContentsChanged(this, -1, -1); - } - - public Object getSelectedItem() { - return currentValue; - } - } - - class MacroListModel extends AbstractListModel implements ComboBoxModel { - private String [] macros; - private Object currentValue; - - public MacroListModel() { - Macro [] macs = new Macro[0]; - try { - macs = DataManager.get().getMacros(false); - macros = new String[macs.length + 1]; - } catch (Throwable e) { - macros = new String[1]; - } - macros[0] = keepString; - for (int i = 0; i < macs.length; ++i) { - macros[i+1] = macs[i].getKey(); - } - } - - public int getSize() { - return macros.length; - } - - public Object getElementAt(int index) { - return macros[index]; - } - - public void setSelectedItem(Object anItem) { - currentValue = anItem; - fireContentsChanged(this, -1, -1); - } - - public Object getSelectedItem() { - return currentValue; - } - } - - public ModifyAddressesDialog(Frame f, DhcpClientRecord [] clients, - String table) { - // Create dialog with reset button - super(f, true); - - this.table = table; - recs = clients; - numberLabel.setText(String.valueOf(recs.length)); - } - - public String getTitle() { - return ResourceStrings.getString("modify_multiple_addresses"); - } - - protected JPanel getMainPanel() { - JPanel mainPanel = new JPanel(); - mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - GridBagLayout bag = new GridBagLayout(); - mainPanel.setLayout(bag); - GridBagConstraints con = new GridBagConstraints(); - con.gridx = con.gridy = 0; - con.weightx = con.weighty = 1.0; - con.insets = new Insets(5, 5, 5, 5); - con.gridwidth = con.gridheight = 1; - - // Number of addresses - Mnemonic mnAddrSel = - new Mnemonic(ResourceStrings.getString("modify_multiple_number")); - JLabel label = new JLabel(mnAddrSel.getString()); - label.setLabelFor(mainPanel); - label.setDisplayedMnemonic(mnAddrSel.getMnemonic()); - label.setToolTipText(mnAddrSel.getString()); - - con.anchor = GridBagConstraints.EAST; - bag.setConstraints(label, con); - mainPanel.add(label); - - numberLabel = new JLabel("100"); - numberLabel.setForeground(Color.black); - ++con.gridx; - con.anchor = GridBagConstraints.WEST; - bag.setConstraints(numberLabel, con); - mainPanel.add(numberLabel); - - // Server - Mnemonic mnManServ = - new Mnemonic(ResourceStrings.getString("modify_multiple_server")); - label = new JLabel(mnManServ.getString()); - label.setDisplayedMnemonic(mnManServ.getMnemonic()); - label.setToolTipText(mnManServ.getString()); - con.anchor = GridBagConstraints.EAST; - con.gridx = 0; - con.gridy += 2; - bag.setConstraints(label, con); - mainPanel.add(label); - - server = new JComboBox(new ServerListModel()); - label.setLabelFor(server); - server.setEditable(true); - con.anchor = GridBagConstraints.WEST; - ++con.gridx; - bag.setConstraints(server, con); - mainPanel.add(server); - - // Comment - Mnemonic mnComm = - new Mnemonic(ResourceStrings.getString("modify_multiple_comment")); - label = new JLabel(mnComm.getString()); - label.setDisplayedMnemonic(mnComm.getMnemonic()); - label.setToolTipText(mnComm.getString()); - con.anchor = GridBagConstraints.EAST; - con.gridx = 0; - ++con.gridy; - bag.setConstraints(label, con); - mainPanel.add(label); - - comment = new JTextField(20); - label.setLabelFor(comment); - con.anchor = GridBagConstraints.WEST; - ++con.gridx; - bag.setConstraints(comment, con); - mainPanel.add(comment); - - // Macro - Mnemonic mnMac = - new Mnemonic(ResourceStrings.getString("modify_multiple_macro")); - label = new JLabel(mnMac.getString()); - label.setDisplayedMnemonic(mnMac.getMnemonic()); - label.setToolTipText(mnMac.getString()); - con.anchor = GridBagConstraints.EAST; - con.gridx = 0; - ++con.gridy; - bag.setConstraints(label, con); - mainPanel.add(label); - - macro = new JComboBox(new MacroListModel()); - label.setLabelFor(macro); - con.anchor = GridBagConstraints.WEST; - ++con.gridx; - bag.setConstraints(macro, con); - mainPanel.add(macro); - - // BootP - Mnemonic mnBootP = - new Mnemonic(ResourceStrings.getString("modify_multiple_bootp")); - label = new JLabel(mnBootP.getString()); - label.setDisplayedMnemonic(mnBootP.getMnemonic()); - label.setToolTipText(mnBootP.getString()); - con.anchor = GridBagConstraints.EAST; - con.gridx = 0; - con.gridy += 2; - bag.setConstraints(label, con); - mainPanel.add(label); - - ButtonGroup bootpGroup = new ButtonGroup(); - bootpCurrent = new JRadioButton(keepString); - label.setLabelFor(bootpCurrent); - bootpCurrent.setToolTipText(keepString); - bootpGroup.add(bootpCurrent); - con.anchor = GridBagConstraints.WEST; - ++con.gridx; - bag.setConstraints(bootpCurrent, con); - mainPanel.add(bootpCurrent); - - bootpAll = new JRadioButton( - ResourceStrings.getString("modify_multiple_bootp_all")); - bootpAll.setToolTipText( - ResourceStrings.getString("modify_multiple_bootp_all")); - bootpGroup.add(bootpAll); - ++con.gridy; - bag.setConstraints(bootpAll, con); - mainPanel.add(bootpAll); - - bootpNone = new JRadioButton( - ResourceStrings.getString("modify_multiple_bootp_none")); - bootpNone.setToolTipText( - ResourceStrings.getString("modify_multiple_bootp_none")); - bootpGroup.add(bootpNone); - ++con.gridy; - bag.setConstraints(bootpNone, con); - mainPanel.add(bootpNone); - - // Unusable - Mnemonic mnUnusable = - new Mnemonic(ResourceStrings.getString("modify_multiple_unusable")); - label = new JLabel(mnUnusable.getString()); - label.setDisplayedMnemonic(mnUnusable.getMnemonic()); - label.setToolTipText(mnUnusable.getString()); - con.anchor = GridBagConstraints.EAST; - con.gridx = 0; - con.gridy += 2; - bag.setConstraints(label, con); - mainPanel.add(label); - - ButtonGroup unusableGroup = new ButtonGroup(); - unusableCurrent = new JRadioButton(keepString); - label.setLabelFor(unusableCurrent); - unusableCurrent.setToolTipText(keepString); - unusableGroup.add(unusableCurrent); - con.anchor = GridBagConstraints.WEST; - ++con.gridx; - bag.setConstraints(unusableCurrent, con); - mainPanel.add(unusableCurrent); - - unusableAll = new JRadioButton( - ResourceStrings.getString("modify_multiple_unusable_all")); - unusableAll.setToolTipText( - ResourceStrings.getString("modify_multiple_unusable_all")); - unusableGroup.add(unusableAll); - ++con.gridy; - bag.setConstraints(unusableAll, con); - mainPanel.add(unusableAll); - - unusableNone = new JRadioButton( - ResourceStrings.getString("modify_multiple_unusable_none")); - unusableNone.setToolTipText( - ResourceStrings.getString("modify_multiple_unusable_none")); - unusableGroup.add(unusableNone); - ++con.gridy; - bag.setConstraints(unusableNone, con); - mainPanel.add(unusableNone); - - // Lease - Mnemonic mnLease = - new Mnemonic(ResourceStrings.getString("modify_multiple_lease")); - label = new JLabel(mnLease.getString()); - label.setDisplayedMnemonic(mnLease.getMnemonic()); - label.setToolTipText(mnLease.getString()); - con.anchor = GridBagConstraints.EAST; - con.gridx = 0; - con.gridy += 2; - bag.setConstraints(label, con); - mainPanel.add(label); - - ButtonGroup leaseGroup = new ButtonGroup(); - leaseCurrent = new JRadioButton(keepString); - label.setLabelFor(leaseCurrent); - leaseCurrent.setToolTipText(keepString); - leaseGroup.add(leaseCurrent); - con.anchor = GridBagConstraints.WEST; - ++con.gridx; - bag.setConstraints(leaseCurrent, con); - mainPanel.add(leaseCurrent); - - leaseDynamic = new JRadioButton( - ResourceStrings.getString("modify_multiple_dynamic")); - leaseDynamic.setToolTipText( - ResourceStrings.getString("modify_multiple_dynamic")); - leaseGroup.add(leaseDynamic); - ++con.gridy; - bag.setConstraints(leaseDynamic, con); - mainPanel.add(leaseDynamic); - - leasePermanent = new JRadioButton( - ResourceStrings.getString("modify_multiple_permanent")); - leasePermanent.setToolTipText( - ResourceStrings.getString("modify_multiple_permanent")); - leaseGroup.add(leasePermanent); - ++con.gridy; - bag.setConstraints(leasePermanent, con); - mainPanel.add(leasePermanent); - - buttonPanel.setOkEnabled(true); - doReset(); - - return mainPanel; - } - - protected void doReset() { - server.setSelectedIndex(0); - comment.setText(keepString); - macro.setSelectedIndex(0); - bootpCurrent.setSelected(true); - unusableCurrent.setSelected(true); - leaseCurrent.setSelected(true); - } - - protected String getProgressMessage() { - return ResourceStrings.getString("modify_multiple_progress"); - } - - protected int getProgressLength() { - return recs.length; - } - - protected String getErrorHeading() { - return ResourceStrings.getString("address_column"); - } - - protected Class getErrorClass() { - return IPAddress.class; - } - - protected Thread getOperationThread() { - return new Thread() { - public void run() { - DhcpNetMgr netMgr = DataManager.get().getDhcpNetMgr(); - for (int i = 0; i < recs.length; ++i) { - DhcpClientRecord client = (DhcpClientRecord)recs[i].clone(); - try { - String s = (String)server.getSelectedItem(); - if (!s.equals(keepString)) { - // Change server if necessary - client.setServerIP(new IPAddress(s)); - } - s = comment.getText(); - if (!s.equals(keepString)) { - client.setComment(s); - } - if (macro.getSelectedIndex() != 0) { - client.setMacro((String)macro.getSelectedItem()); - } - if (bootpAll.isSelected()) { - client.setBootp(true); - } else if (bootpNone.isSelected()) { - client.setBootp(false); - } - if (unusableAll.isSelected()) { - client.setUnusable(true); - } else if (unusableNone.isSelected()) { - client.setUnusable(false); - } - if (leaseDynamic.isSelected()) { - client.setPermanent(false); - } else if (leasePermanent.isSelected()) { - client.setPermanent(true); - } - netMgr.modifyClient(recs[i], client, table); - updateProgress(i+1, client.getClientIPAddress()); - } catch (InterruptedException e) { - closeDialog(); - return; - } catch (Throwable e) { - addError(recs[i].getClientIP(), e.getMessage()); - } - } - // Errors occurred, display them - if (errorsOccurred()) { - displayErrors( - ResourceStrings.getString("modify_multiple_error")); - } - closeDialog(); - } - }; - } - - protected String getHelpKey() { - return "modify_multiple_addresses"; - } - - protected void fireActionPerformed() { - fireActionPerformed(this, DialogActions.OK); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/MultipleOperationDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/MultipleOperationDialog.java deleted file mode 100644 index 44471b3f45..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/MultipleOperationDialog.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.SwingUtilities; -import javax.swing.JScrollPane; -import javax.swing.JOptionPane; -import java.awt.Frame; -import java.awt.Dimension; - -import com.sun.dhcpmgr.ui.ProgressManager; - -/** - * This abstract class provides a common implementation of the functions - * shared by the dialogs which perform multiple operations such as adding - * and deleting addresses or networks. It provides a framework within - * which subclasses may execute such operations in a background thread - * and use progress meters and capture and display multiple error messages. - * Nearly all of the methods here are defined as protected because they're - * really implementation details for the dialogs and need not be visible - * outside that context. - */ -public abstract class MultipleOperationDialog extends DhcpmgrDialog { - // Progress Manager provides convenient handling of progress dialogs - protected ProgressManager progManager; - // ErrorTable provides a convenient storehouse for sets of errors - protected ErrorTable messageTable; - - public MultipleOperationDialog(Frame f, boolean allowsReset) { - super(f, allowsReset); - } - - /** - * Initiate the action in a background thread when the user presses OK; - * subclasses should not need to override this, instead they provide - * an implementation of getOperationThread() where the actions needed - * are executed. - */ - protected void doOk() { - progManager = new ProgressManager(this, getProgressMessage(), "", 0, - getProgressLength()); - messageTable = new ErrorTable(getErrorHeading(), getErrorClass()); - getOperationThread().start(); - } - - /** - * Update progress meter; subclasses should call as each operation is - * completed. InterruptedException is thrown by the ProgressManager - * if user pressed Cancel in the progress dialog that was popped up. - * Typically the subclass should abort its operation thread when this - * occurs. - */ - protected void updateProgress(int progress, String msg) - throws InterruptedException { - progManager.update(progress, msg); - } - - /** - * Get thread which will perform the operation - */ - protected abstract Thread getOperationThread(); - - /** - * Get message to display in progress dialog - */ - protected abstract String getProgressMessage(); - - /** - * Get length of operation - */ - protected abstract int getProgressLength(); - - /** - * Get rid of dialog when we're done - */ - public void closeDialog() { - Runnable finisher = new Runnable() { - public void run() { - fireActionPerformed(); - setVisible(false); - dispose(); - } - }; - SwingUtilities.invokeLater(finisher); - } - - /** - * Display the errors - */ - protected void displayErrors(final String msg) { - /* - * Use a Runnable and invokeAndWait as we're usually called from - * the operation thread, not the AWT thread. - */ - Runnable errorDisplay = new Runnable() { - public void run() { - JScrollPane scrollPane = new JScrollPane(messageTable); - Dimension d = messageTable.getPreferredScrollableViewportSize(); - d.height = 80; - messageTable.setPreferredScrollableViewportSize(d); - Object [] objs = new Object[] { msg, scrollPane }; - JOptionPane.showMessageDialog(MultipleOperationDialog.this, - objs, ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - }; - try { - SwingUtilities.invokeAndWait(errorDisplay); - } catch (Throwable e) { - // If this failed we're basically in a bailout situation - e.printStackTrace(); - } - } - - /** - * Return the heading for the error table - */ - protected abstract String getErrorHeading(); - - /** - * Return the class for the error data; default to String, subclass can - * override as needed. - */ - protected Class getErrorClass() { - return String.class; - } - - /** - * Add an error to the error table; obj must be of the class returned by - * getErrorClass - */ - protected void addError(Object obj, String msg) { - messageTable.addError(obj, msg); - } - - /** - * Test for errors occurred - */ - protected boolean errorsOccurred() { - return !messageTable.isEmpty(); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/OptionDescriptions.properties b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/OptionDescriptions.properties deleted file mode 100644 index 398905e8bd..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/OptionDescriptions.properties +++ /dev/null @@ -1,109 +0,0 @@ -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Descriptions for DHCP standard options, taken from RFC 2132 & 2242 -# Note that the keys here must correspond exactly to those used in the -# /etc/dhcp/inittab file which defines the option tags we use for each -# option code. Note also that not all of the tags in /etc/dhcp/inittab -# will have descriptions here; only those which are defined to be consumed -# by the management tools need have descriptions in this file. - -Subnet=Client's subnet mask -UTCoffst=Client's time offset from UTC in seconds -Router=Routers on the client's subnet -Timeserv=RFC 868 time servers -IEN116ns=IEN 166 name servers -DNSserv=DNS servers -Logserv=MIT-LCS UDP log servers -Cookie=RFC 865 cookie servers -Lprserv=RFC 1179 line printer servers -Impress=Imagen Impress servers -Resource=RFC 887 Resource Location servers -Hostname=Host name of client -Bootsize=Boot file size in 512 byte blocks -Dumpfile=Pathname of client's crash dump file -DNSdmain=DNS domain name -Swapserv=Swap server address -Rootpath=Pathname of client's root disk -ExtendP=BOOTP extensions file -IpFwdF=IP forwarding flag -NLrouteF=Non-local source routing flag -PFilter=Policy filter for non-local source routing -MaxIpSiz=Maximum IP datagram reassembly size -IpTTL=Time-to-live for IP datagrams -PathTO=Path MTU aging timeout in seconds -PathTbl=Path MTU plateau table -MTU=Interface MTU -SameMtuF=All subnets are local flag -Broadcst=Broadcast address -MaskDscF=Perform mask discovery flag -MaskSupF=Mask supplier flag -RDiscvyF=Router discovery flag -RSolictS=Router solicitation address -StaticRt=Static routes -TrailerF=Trailer encapsulation flag -ArpTimeO=ARP cache timeout -EthEncap=Ethernet encapsulation flag -TcpTTL=TCP default TTL -TcpKaInt=TCP keepalive interval -TcpKaGbF=TCP keepalive garbage flag -NISdmain=Network Information Service domain name -NISservs=Network Information Service servers -NTPservs=Network Time Protocol servers -NetBNms=NetBIOS name servers -NetBDsts=NetBIOS datagram distribution servers -NetBNdT=NetBIOS node type -NetBScop=NetBIOS scope -XFontSrv=X Window System Font servers -XDispMgr=X Window System display managers -LeaseTim=Lease time in seconds -T1Time=Time until RENEWING state -T2Time=Time until REBINDING state -NW_dmain=NetWare/IP domain name -NWIPOpts=NetWare/IP information -NIS+dom=Network Information Service+ domain -NIS+serv=Network Information Service+ servers -TFTPsrvN=TFTP server name -OptBootF=Bootfile name -MblIPAgt=Mobile IP home agent -SMTPserv=Simple Mail Transport Protocol servers -POP3serv=Post Office Protocol 3 servers -NNTPserv=Network News Transport Protocol servers -WWWservs=World Wide Web servers -Fingersv=Finger servers -IRCservs=Internet Relay Chat servers -STservs=StreetTalk servers -STDAservs=StreetTalk Directory Assistance servers -SLP_DA=Service Location Protocol directory agent -SLP_SS=Service Location Protocol agent scope -SLP_NA=Service Location Protocol naming authority -FQDN=Use fully-qualified domain names in DHCP options -BootFile=Boot file -BootSrvA=Boot server address -BootSrvN=Boot server name -LeaseNeg=Lease negotiable flag -EchoVC=Echo vendor class to client -BootPath=Default path for BOOTP client boot files diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/OptionNameField.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/OptionNameField.java deleted file mode 100644 index 4d3f8fa444..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/OptionNameField.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.text.*; -import com.sun.dhcpmgr.data.Option; - -/** - * A text field which enforces the syntax rules for an option name. These - * are all the rules for DhcptabNameField, plus a limit on the length. - */ -public class OptionNameField extends DhcptabNameField { - - /** - * Constructs a field initialized to the provided text. Defaults to - * 10 characters wide. - * @param text the text to display initially - */ - public OptionNameField(String text) { - this(text, 10); - } - - /** - * Constructs a field initialized to the provided text with the requested - * size. - * @param text the text to display initially - * @param length the length in characters the field should size itself to - */ - public OptionNameField(String text, int length) { - super(text, length); - } - - protected Document createDefaultModel() { - return new OptionNameDocument(); - } - - /* - * This is the recommended way to validate input, as opposed to trapping - * KeyEvents because this will actually catch paste operations as well. - */ - class OptionNameDocument extends DhcptabNameDocument { - public void insertString(int offs, String str, AttributeSet a) - throws BadLocationException { - if (str != null) { - if ((getLength() + str.length()) > Option.MAX_NAME_SIZE) { - throw new BadLocationException("", offs); - } - } - super.insertString(offs, str, a); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/OptionView.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/OptionView.java deleted file mode 100644 index ab4d618a1e..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/OptionView.java +++ /dev/null @@ -1,469 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.table.*; -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.text.*; - -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.bridge.BridgeException; - -/** - * The view for options. Only displays locally defined options. - */ -public class OptionView implements View { - - // Model for the table displaying the options. - class OptionTableModel extends AbstractTableModel { - private Option [] data = null; - private boolean firstLoad; - - public OptionTableModel() { - firstLoad = true; - } - - public void load() { - data = null; - // Update status line - MainFrame.setStatusText( - ResourceStrings.getString("loading_options")); - fireTableDataChanged(); - - // Kick off background loading - OptionLoader loader = new OptionLoader(); - } - - protected void doneLoading() { - sortedTableModel.reallocateIndexes(); - if (firstLoad) { - sortedTableModel.sortByColumn(0); - firstLoad = false; - } - // Check for any ill-defined options, tell user about them - Vector errs = new Vector(); - for (int i = 0; i < data.length; ++i) { - if (!data[i].isValid()) { - errs.addElement(data[i].getKey()); - } - } - if (errs.size() != 0) { - Object [] objs = new Object[2]; - objs[0] = - ResourceStrings.getString("option_validation_warning"); - JList optionList = new JList(errs); - JScrollPane scrollPane = new JScrollPane(optionList); - optionList.setVisibleRowCount(4); - objs[1] = scrollPane; - JOptionPane.showMessageDialog(optionTable, objs, - ResourceStrings.getString("warning"), - JOptionPane.WARNING_MESSAGE); - } - fireTableDataChanged(); - } - - protected void setData(Option [] newdata) { - data = newdata; - } - - public int getRowCount() { - if (data == null) { - return 0; - } else { - return data.length; - } - } - - public int getColumnCount() { - return 6; - } - - public Object getValueAt(int row, int column) { - switch (column) { - case 0: - return data[row].getKey(); - case 1: - return Option.getContextString(data[row].getContext()); - case 2: - return new Integer(data[row].getCode()); - case 3: - return Option.getTypeString(data[row].getType()); - case 4: - return new Integer(data[row].getGranularity()); - case 5: - return new Integer(data[row].getMaximum()); - default: - return null; - } - } - - public Class getColumnClass(int column) { - switch (column) { - case 0: - case 1: - case 3: - return String.class; - case 2: - case 4: - case 5: - return Integer.class; - default: - super.getColumnClass(column); - } - return null; - } - - public String getColumnName(int column) { - switch (column) { - case 0: - return ResourceStrings.getString("name_column"); - case 1: - return ResourceStrings.getString("category_column"); - case 2: - return ResourceStrings.getString("code_column"); - case 3: - return ResourceStrings.getString("type_column"); - case 4: - return ResourceStrings.getString("granularity_column"); - case 5: - return ResourceStrings.getString("maximum_column"); - default: - super.getColumnName(column); - } - return null; - } - - public Option getOptionAt(int row) { - return data[row]; - } - } - - // Background loader for options. - class OptionLoader extends com.sun.dhcpmgr.ui.SwingWorker { - public Object construct() { - try { - return DataManager.get().getOptions(true); - } catch (final BridgeException e) { - // Since we're in a background thread, ask Swing to run ASAP. - SwingUtilities.invokeLater(new Runnable() { - Object [] args = new Object[] { e.getMessage() }; - public void run() { - MessageFormat form = new MessageFormat( - ResourceStrings.getString("error_loading_options")); - JOptionPane.showMessageDialog(null, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - }); - return null; - } - } - - public void finished() { - Option [] options = (Option [])get(); - if (options == null) { - options = new Option[0]; - } - OptionView.optionTableModel.setData(options); - OptionView.optionTableModel.doneLoading(); - MainFrame.setStatusText(MessageFormat.format( - ResourceStrings.getString("option_status_message"), - OptionView.optionTableModel.getRowCount())); - optionTable.clearSelection(); - } - } - - /* - * Reload data when any dialogs this view launches indicate they've - * changed the data - */ - class DialogListener implements ActionListener { - public void actionPerformed(ActionEvent e) { - if (!e.getActionCommand().equals(DialogActions.CANCEL)) { - reload(); - } - } - } - - private AutosizingTable optionTable; - private JScrollPane optionPane; - protected static OptionTableModel optionTableModel = null; - private JCheckBoxMenuItem showGrid; - private JMenuItem optionHelp; - private Vector[] menuItems; - private Frame myFrame; - private static boolean firstview = true; - private Vector selectionListeners = new Vector(); - private TableSorter sortedTableModel; - - public OptionView() { - // Create table to display in data area - optionTableModel = new OptionTableModel(); - sortedTableModel = new TableSorter(optionTableModel); - - // Use table which resizes columns to fit data - optionTable = new AutosizingTable(sortedTableModel); - sortedTableModel.addMouseListenerToHeaderInTable(optionTable); - optionTable.getTableHeader().setReorderingAllowed(true); - optionTable.getTableHeader().setResizingAllowed(true); - optionTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - - // Allow clicks in header to adjust sorting column - sortedTableModel.addActionListener(new ActionListener() { - private int sortModelIndex = -1; - private TableCellRenderer savedRenderer; - private SortedHeaderRenderer sortedRenderer = - new SortedHeaderRenderer(optionTable); - - public void actionPerformed(ActionEvent e) { - // Clear the selection if sorting is changed - optionTable.clearSelection(); - - // Change the header rendering to show sorting column - int modelIndex = Integer.parseInt(e.getActionCommand()); - int viewIndex = - optionTable.convertColumnIndexToView(modelIndex); - if (sortModelIndex != -1) { - int sortViewIndex = - optionTable.convertColumnIndexToView(sortModelIndex); - optionTable.getColumnModel().getColumn(sortViewIndex). - setHeaderRenderer(savedRenderer); - } - /* - * Save the column currently being sorted so we can restore - * the renderer later. We save model columns rather than - * view columns because model columns are invariant while - * view columns can be reordered with confusion resulting. - */ - TableColumn c = - optionTable.getColumnModel().getColumn(viewIndex); - savedRenderer = c.getHeaderRenderer(); - c.setHeaderRenderer(sortedRenderer); - sortModelIndex = modelIndex; - } - }); - - // Make it scrollable - optionPane = new JScrollPane(optionTable); - - // Make double-clicks the same as Edit->Properties - optionTable.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) { - handleProperties(); - } - } - }); - - // Create menu items - Mnemonic mnShowGrid = - new Mnemonic(ResourceStrings.getString("show_grid")); - showGrid = new JCheckBoxMenuItem(mnShowGrid.getString(), - true); - showGrid.setMnemonic(mnShowGrid.getMnemonic()); - showGrid.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - optionTable.setShowGrid(showGrid.getState()); - } - }); - - Mnemonic mnOnOptions = - new Mnemonic(ResourceStrings.getString("on_options_item")); - optionHelp = new JMenuItem(mnOnOptions.getString()); - optionHelp.setMnemonic(mnOnOptions.getMnemonic()); - optionHelp.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - DhcpmgrApplet.showHelp("options_reference"); - } - }); - - /* - * Build the sets of menu items which we'll return to - * MainFrame when it asks for them. - */ - menuItems = new Vector[MainFrame.MENU_COUNT]; - for (int i = 0; i < menuItems.length; ++i) { - menuItems[i] = new Vector(); - } - menuItems[MainFrame.VIEW_MENU].addElement(showGrid); - menuItems[MainFrame.HELP_MENU].addElement(optionHelp); - - // Listen for selections events, manipulate menu item state as needed - optionTable.getSelectionModel().addListSelectionListener( - new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - // Notify listeners that our selection state may have changed - notifySelectionListeners(); - } - }); - } - - public String getName() { - return ResourceStrings.getString("option_view_name"); - } - - // Return custom menus we want added, in our case none. - public Enumeration menus() { - return null; - } - - // Return menu items for each menu as requested by MainFrame - public Enumeration menuItems(int menu) { - return menuItems[menu].elements(); - } - - public Component getDisplay() { - return optionPane; - } - - public void setActive(boolean state) { - if (state) { - // Things we do only the first time we're displayed - if (firstview) { - myFrame = (Frame)SwingUtilities.getAncestorOfClass( - MainFrame.class, optionTable); - optionTableModel.load(); - String s = MessageFormat.format( - ResourceStrings.getString("option_status_message"), - sortedTableModel.getRowCount()); - MainFrame.setStatusText(s); - firstview = false; - } - } - } - - public void find(String s) { - int startRow = optionTable.getSelectedRow() + 1; - for (int i = startRow; i < sortedTableModel.getRowCount(); ++i) { - if (optionTableModel.getOptionAt( - sortedTableModel.mapRowAt(i)).toString().indexOf(s) != -1) { - optionTable.setRowSelectionInterval(i, i); - optionTable.scrollRectToVisible(optionTable.getCellRect(i, 0, - false)); - return; - } - } - // Got to the end, wrap around - for (int i = 0; i < startRow; ++i) { - if (optionTableModel.getOptionAt( - sortedTableModel.mapRowAt(i)).toString().indexOf(s) != -1) { - optionTable.setRowSelectionInterval(i, i); - optionTable.scrollRectToVisible(optionTable.getCellRect(i, 0, - false)); - return; - } - } - } - - public void handleCreate() { - CreateOptionDialog d = new CreateOptionDialog(myFrame, - CreateOptionDialog.CREATE); - d.addActionListener(new DialogListener()); - d.pack(); - d.setVisible(true); - } - - public void handleDelete() { - int selectedRow = optionTable.getSelectedRow(); - if (selectedRow == -1) { - return; - } - DeleteOptionDialog d = new DeleteOptionDialog(myFrame, - optionTableModel.getOptionAt( - sortedTableModel.mapRowAt(selectedRow))); - d.addActionListener(new DialogListener()); - d.pack(); - d.setVisible(true); - } - - public void handleDuplicate() { - int selectedRow = optionTable.getSelectedRow(); - if (selectedRow == -1) { - return; - } - CreateOptionDialog d = new CreateOptionDialog(myFrame, - CreateOptionDialog.DUPLICATE); - d.setOption(optionTableModel.getOptionAt( - sortedTableModel.mapRowAt(selectedRow))); - d.addActionListener(new DialogListener()); - d.pack(); - d.setVisible(true); - } - - public void handleProperties() { - int selectedRow = optionTable.getSelectedRow(); - if (selectedRow == -1) { - return; - } - CreateOptionDialog d = new CreateOptionDialog(myFrame, - CreateOptionDialog.EDIT); - d.setOption(optionTableModel.getOptionAt( - sortedTableModel.mapRowAt(selectedRow))); - d.addActionListener(new DialogListener()); - d.pack(); - d.setVisible(true); - } - - public void handleUpdate() { - reload(); - } - - private void reload() { - optionTableModel.load(); - } - - public void addSelectionListener(SelectionListener listener) { - selectionListeners.addElement(listener); - } - - public void removeSelectionListener(SelectionListener listener) { - selectionListeners.removeElement(listener); - } - - private void notifySelectionListeners() { - Enumeration en = selectionListeners.elements(); - while (en.hasMoreElements()) { - SelectionListener l = (SelectionListener)en.nextElement(); - l.valueChanged(); - } - } - - public boolean isSelectionEmpty() { - return optionTable.getSelectionModel().isSelectionEmpty(); - } - - public boolean isSelectionMultiple() { - return false; // Multiple selection is not allowed. - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/RelayView.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/RelayView.java deleted file mode 100644 index 28059441af..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/RelayView.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import java.awt.Component; -import java.util.Enumeration; -import javax.swing.*; - -import com.sun.dhcpmgr.ui.*; - -/** - * The view displayed when we're in relay mode. - */ -public class RelayView implements View { - private Component display; - - public RelayView() { - display = Wizard.createTextArea( - ResourceStrings.getString("relay_view_text"), 4, 45); - } - - public String getName() { - return ResourceStrings.getString("relay_view_name"); - } - - public Enumeration menus() { - return null; - } - - public Enumeration menuItems(int menu) { - return null; - } - - public Component getDisplay() { - return display; - } - - public void find(String s) { - // nothing to search - } - - public void setActive(boolean state) { - // Nothing to do - } - - public void handleCreate() { - // Nothing to do - } - - public void handleDelete() { - // Nothing to do - } - - public void handleDuplicate() { - // Nothing to do - } - - public void handleProperties() { - // Nothing to do - } - - public void handleUpdate() { - // Nothing to do - } - - public void addSelectionListener(SelectionListener listener) { - // Nothing to do - } - - public void removeSelectionListener(SelectionListener listener) { - // Nothing to do - } - - public boolean isSelectionEmpty() { - return true; // Nothing to select - } - - public boolean isSelectionMultiple() { - return false; // Nothing to select - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ReleaseAddressDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ReleaseAddressDialog.java deleted file mode 100644 index 78ef8d2250..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ReleaseAddressDialog.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import java.awt.*; -import java.awt.event.*; -import java.text.*; -import java.util.*; -import javax.swing.*; -import javax.swing.table.*; - -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; - -/** - * This dialog is used to release one or more addresses. Release is defined - * to mean resetting the client id to 00 and setting the lease date to 0. - */ -public class ReleaseAddressDialog extends MultipleOperationDialog { - private DhcpClientRecord [] recs; - private String table; - boolean showAddresses; - - class AddressTableModel extends AbstractTableModel { - - public int getRowCount() { - if (recs == null) { - return 0; - } else { - return recs.length; - } - } - - public int getColumnCount() { - return 3; - } - - public Object getValueAt(int row, int column) { - switch (column) { - case 0: - if (showAddresses) { - return recs[row].getClientIP(); - } else { - return recs[row].getClientName(); - } - case 1: - return recs[row].getClientId(); - case 2: - return recs[row].getExpiration(); - default: - return null; - } - } - - public Class getColumnClass(int column) { - switch (column) { - case 0: - if (showAddresses) { - return IPAddress.class; - } else { - return String.class; - } - case 1: - return String.class; - case 2: - return Date.class; - default: - return Object.class; - } - } - - public String getColumnName(int column) { - switch (column) { - case 0: - if (showAddresses) { - return ResourceStrings.getString("address_column"); - } else { - return ResourceStrings.getString("client_name_column"); - } - case 1: - return ResourceStrings.getString("client_column"); - case 2: - return ResourceStrings.getString("expires_column"); - default: - return null; - } - } - } - - public ReleaseAddressDialog(Frame f, DhcpClientRecord [] clients, - String table, boolean showAddresses) { - super(f, false); - recs = clients; - this.table = table; - this.showAddresses = showAddresses; - } - - public String getTitle() { - return ResourceStrings.getString("release_address_title"); - } - - protected JPanel getMainPanel() { - JPanel mainPanel = new JPanel(new BorderLayout(10, 10)); - mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - - JLabel message = new JLabel( - ResourceStrings.getString("release_address_confirm")); - - message.setLabelFor(mainPanel); - message.setToolTipText( - ResourceStrings.getString("release_address_confirm")); - - mainPanel.add(message, BorderLayout.NORTH); - - JTable addressTable = new JTable(new AddressTableModel()); - JScrollPane scrollPane = new JScrollPane(addressTable); - Dimension d = addressTable.getPreferredScrollableViewportSize(); - d.height = 100; - addressTable.setPreferredScrollableViewportSize(d); - ExtendedCellRenderer renderer = new ExtendedCellRenderer(); - addressTable.setDefaultRenderer(Date.class, renderer); - addressTable.setDefaultRenderer(IPAddress.class, renderer); - - mainPanel.add(scrollPane, BorderLayout.CENTER); - buttonPanel.setOkEnabled(true); - return mainPanel; - } - - protected String getProgressMessage() { - return ResourceStrings.getString("release_addr_progress"); - } - - protected int getProgressLength() { - return recs.length; - } - - protected String getErrorHeading() { - return ResourceStrings.getString("address_column"); - } - - protected Class getErrorClass() { - return IPAddress.class; - } - - protected Thread getOperationThread() { - return new Thread() { - public void run() { - DhcpNetMgr server = DataManager.get().getDhcpNetMgr(); - for (int i = 0; i < recs.length; ++i) { - DhcpClientRecord client = (DhcpClientRecord)recs[i].clone(); - Date emptyDate = new Date(0); - try { - // Clear client id and lease date - client.setClientId(DhcpClientRecord.DEFAULT_CLIENT_ID); - client.setFlags(DhcpClientRecord.DEFAULT_FLAGS); - client.setExpiration(emptyDate); - server.modifyClient(recs[i], client, table); - // Update progress meter - updateProgress(i+1, recs[i].getClientIPAddress()); - } catch (InterruptedException e) { - // User asked to stop - closeDialog(); - return; - } catch (Throwable e) { - addError(recs[i].getClientIP(), e.getMessage()); - } - } - // Errors occurred, display them now - if (errorsOccurred()) { - displayErrors( - ResourceStrings.getString("release_address_error")); - } - closeDialog(); - } - }; - } - - protected String getHelpKey() { - return "release_addresses"; - } - - protected void fireActionPerformed() { - fireActionPerformed(this, DialogActions.OK); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ResourceBundle.properties b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ResourceBundle.properties deleted file mode 100644 index c83f34a533..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ResourceBundle.properties +++ /dev/null @@ -1,666 +0,0 @@ -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# General resources -# -yes=Yes -no=No - -delete=De&lete -add=&Add -modify=&Modify -select=&Select - -error_message=Error Message - -err_must_be_root=You must be root to run this program. - -err_initializing_help=Unable to initialize the help system. -err_starting_help=Could not start browser to view help. - -err_initializing_program=The following error occurred while starting this program: -err_initializing_options=The daemon's defaults file appears to be corrupt. Please see the dhcp(4) man page. -err_reading_options=The following error occurred while reading the server's options:\n{0} - -init_error=DHCP Manager Initialization Error - -dhcp_manager=DHCP Manager -server_error_title=Server Error -server_warning_title=Server Warning -server_not_running=The DHCP service is not running, so it could not be notified of this change. - -# -# Standard options initialization -# -stdopts_init_error=Error initializing standard options: {0} - -# -# Services menu items -# -restart_item=&Restart -stop_item=S&top -start_item=St&art -disable_item=&Disable -enable_item=E&nable -modify_service_item=&Modify -cvt_service_item=&Convert Data Store -export_item=E&xport Data -import_item=&Import Data - -# -# Service status messages -# -service_restarted=The server has been restarted -service_stopped=The server has been stopped -service_started=The server has been started - -# -# Help menu items -# -overview_item=&Overview -howto_item=How &To -index_item=&Index -on_service_item=On Se&rvice -on_addresses_item=On &Addresses -on_macros_item=On &Macros -on_options_item=On O&ptions - -# -# Address view resources -# -address_view_name=Addresses -network=Net&work: -no_networks=No networks -loading_networks=Loading network list -networks_loaded=Found {0,number} networks -address_status_message={0,number} addresses loaded -loading_addresses=Loading addresses for network {0} -run_network_wizard=You must configure a network for DHCP service\nusing the Network Wizard before creating any addresses. -error_loading_addrs=The following error was encountered while reading addresses:\n{0} - -address_column=IP Address -client_name_column=Client Name -flags_column=Status -expires_column=Expires -server_column=Server -macro_column=Macro -client_column=Client ID -comment_column=Comment - -show_addresses=Show &Addresses -show_grid=Show &Grid - -# -# Option view resources -# -option_view_name=Options -loading_options=Loading options -option_status_message={0,number} options loaded -error_loading_options=The following error was encountered while reading options:\n{0} -option_validation_warning=The following options contain errors: - -name_column=Name -category_column=Category -code_column=Code -type_column=Type -granularity_column=Granularity -maximum_column=Maximum - -# -# Macro view resources -# -macro_view_name=Macros -option_column=Option Name -value_column=Value -macros=Macros -loading_macros=Loading macros -macro_status_message={0,number} macros loaded -error_loading_macros=The following error was encountered while reading macros:\n{0} -macro_validation_warning=The following macros contain invalid option settings: - -# -# Create/duplicate/edit macro -# -create_macro_title=Create Macro -edit_macro_title=Macro Properties -duplicate_macro_title=Duplicate Macro -option_name=Option Name: -option_value=Option Value: - -input_error=Input Error -create_location_error=Error making location: {0} -create_macro_error=Error creating the macro {0}, message from server was: {1} -edit_macro_error=Error editing the macro {0}, message from server was: {1} -empty_macro_error=This macro contains no options -bad_macro_name={0} is not a legal DHCP macro name -bad_option_name={0} is not a legal DHCP option -bad_option_value={0} is not a legal value for the DHCP option {1} -macro_contains_option=This macro already contains the option {0} -option_code_exists_error=Option code is already assigned to another option - -signal_server=Notify DHCP server of change - -# -# Disable service resources -# -disable_service_title=Disable Service -disable_relay_confirm=OK to disable the BOOTP relay service on server {0}? -disable_service_confirm=OK to disable the DHCP service on server {0}? -disable_service_error=Error disabling the service, message from server was: {0} - -# -# Enable service resources -# -enable_service_title=Enable Service -enable_relay_confirm=OK to enable the BOOTP relay service on server {0}? -enable_service_confirm=OK to enable the DHCP service on server {0}? -enable_service_error=Error enabling the service, message from server was: {0} - -# -# Delete macro -# -delete_macro_title=Delete Macro -delete_macro_confirm=OK to delete the macro {0}? -delete_macro_error=Error deleting the macro {0}, message from server was: {1} - -# -# Server state manipulation messages -# -startup_server_error=Unable to start the DHCP service, message from server was: {0} -shutdown_server_error=Unable to stop the DHCP service, message from server was: {0} -restart_server_error=Unable to restart the DHCP service, message from server was: {0} - -# -# Find messages -# -find_macro_error=No macro containing {0} was found - -# -# Create/duplicate/edit option -# -create_option_title=Create Option -edit_option_title=Option Properties -duplicate_option_title=Duplicate Option -name_label=&Name: -contents_label=Contents -category_label=Categor&y: -data_type_label=Data &Type: -granularity_label=&Granularity: -maximum_label=&Maximum: -client_classes_label=Vendor Client Classes -option_code_label=Cod&e: -create_option_error=Error creating the option {0}: {1} -edit_option_error=Error editing the option {0}: {1} -empty_vendor_error=You must supply at least one vendor client class for a vendor option. -invalid_client_class=The vendor client class you entered, {0}, is not valid. - -# -# Delete option dialog -# -delete_option_title=Delete Option -delete_option_confirm=OK to delete the option {0}? -delete_option_error=Error deleting the option {0}, message from server was: {1} - -bootp=Bootp -unusable=Unusable -manual=Reserved -permanent=Permanent -dynamic=Dynamic - -# -# Create/duplicate/edit address -# -edit_address_title=Address Properties -duplicate_address_title=Duplicate Address -create_address_title=Create Address -address_exists=The address is already defined in the DHCP network table. -address_missing=The address was not found in the DHCP network table. -host_exists=A hosts table entry with this name already exists, the DHCP network table was not updated. -host_missing=There is no hosts table entry with this name, the DHCP network table was not updated. -invalid_address=The address you entered, {0}, is not a valid IP address. -invalid_server=The server you entered, {0}, does not exist. -invalid_client_id=The client ID you entered, {0}, is not valid. -invalid_date=The expiration date you entered, {0}, is not valid.\nDates must be entered in a format similar to {1}. - -address_tab_label=Address -lease_tab_label=Lease -ip_address_label=&IP Address: -owning_server_label=O&wned by Server: -config_macro_label=Configuration &Macro: -client_id_label=C&lient ID: -comment_label=Commen&t: -unusable_checkbox=Address is unusable -bootp_checkbox=Assign only to BOOTP clients -manual_checkbox=Reserved -leased_label=&Dynamic assignment expiring: -permanent_label=&Permanent assignment -lease_policy_label=Lease Policy -no_macro_item=(no macro assigned) - -# -# Delete address dialog -# -delete_address_title=Delete Address -delete_address_confirm=OK to delete the following addresses? - -delete_address_error=The following errors occurred while deleting addresses: -delete_addr_progress=Deleting address: - -# -# Address wizard resources -# -add_addresses=&Address Wizard -address_wizard_title=Add Addresses to Network {0} - -add_wiz_number_desc=Specify the number of IP addresses. -add_wiz_explain=This wizard will help you add IP addresses to a DHCP server in one operation. The wizard adds the IP addresses to the selected network table in the DHCP database. -add_wiz_count_explain=How many addresses do you want to add? -add_wiz_count_label=Number of IP &Addresses: -add_wiz_comment_explain=Why are you adding these addresses? Enter a comment, or leave this space blank. -add_wiz_comment_label=Co&mment: -add_wiz_count_error=You must enter a non-zero value for the number of IP addresses. - -add_wiz_server_desc=Select the server and starting IP address. -add_wiz_server_explain=Which DHCP server will manage these addresses? -add_wiz_server_label=&Managed by Server: -add_wiz_start_explain=What is the first IP number of the range of addresses you want to add? -add_wiz_start_label=S&tarting IP Address: -add_wiz_invalid_address={0} is not a valid IP address. Please enter a correctly formatted IP address. - -add_wiz_confirm_desc=Confirm the IP address list. -add_wiz_confirm_explain=Is this the list of addresses you want to add? If not, go back to the previous steps and change the number of addresses or starting address. -add_wiz_confirm_label=&IP Addresses To Be Added: - -add_wiz_configure_desc=Enter client configuration information. -add_wiz_macro_explain=How do you want to configure the new clients? Choose a configuration macro from the list below. Press "View" to see the contents of the macro. -add_wiz_macro_label=Configuration &Macro: -add_wiz_view_button=&View -add_wiz_flag_explain=Would you like to mark these addresses so they are unusable until you decide otherwise? -add_wiz_unusable_label=Addresses are unusable - -add_wiz_lease_desc=Select the lease type. -add_wiz_lease_explain=What type of lease do you want?\n\nA dynamic lease means that clients receive IP addresses as they become available, on a first-come, first-served basis. A permanent lease means that a client receives the same IP address every time that it connects to the network. -add_wiz_lease_label=&Lease Type: - -add_wiz_review_desc=Review. -add_wiz_review_explain=Is the following information correct? If not, you can change entries by going back to the corresponding wizard step. -add_wiz_review_unusable=Addresses are Unusable: - -generate_addresses_warning=Only {0,number} of the {1,number} requested addresses could be generated. -add_wiz_none_available=None of the addresses you requested are available. Try a different starting address. -warning=Warning - -add_wiz_progress=Adding address: - -add_wiz_error=The following errors were encountered while adding addresses: - -bad_network_address=The address you entered, {0}, is not part of the network {1}. -bad_server_name={0} is not a known server. Please enter a valid server name. - -# -# Definitions for the modify multiple addresses dialog -# -modify_multiple_addresses=Modify Multiple Addresses - -modify_multiple_number=&Number of Addresses Selected: -modify_multiple_server=Managing &Server: -modify_multiple_comment=Commen&t: -modify_multiple_macro=Configuration &Macro: -modify_multiple_bootp=&BootP: -modify_multiple_unusable=&Unusable: -modify_multiple_lease=&Lease Type: - -modify_multiple_keep=Keep current settings -modify_multiple_bootp_all=Assign all addresses only to BootP clients -modify_multiple_bootp_none=Do not assign addresses to BootP clients -modify_multiple_unusable_all=Mark all addresses unusable -modify_multiple_unusable_none=Mark all addresses usable -modify_multiple_dynamic=Dynamic -modify_multiple_permanent=Permanent - -modify_multiple_error=The following errors occurred while modifying addresses: -modify_multiple_progress=Modifying address: - -# -# Definitions for release address dialog -# -release_addresses=&Release Addresses -release_address_title=Release Addresses -release_address_confirm=OK to release the following addresses? -release_addr_progress=Releasing address: -release_address_error=The following errors occurred while releasing addresses: - -# -# Datastore Wizard -# -ds_wiz_datastore_desc=Select data storage format. -ds_wiz_datastore_parm_desc=Configure data store. -ds_wiz_init_error=Error initializing {0} data store: {1} - -# -# Configuration Wizard -# -cfg_wiz_title=DHCP Configuration Wizard -cfg_wiz_explain=This wizard will help you configure the system as a DHCP server. -cfg_wiz_store_explain=Where would you like to store the DHCP configuration data? - -cfg_wiz_lease_explain=How long can clients use the IP addresses assigned by this server? -cfg_wiz_lease_length=&Length of Lease: -cfg_wiz_negotiable_explain=Check the box below to enable clients to renew their leases prior to expiration. If you uncheck it, clients will be forced to reboot to obtain a new address when the lease expires. -cfg_wiz_negotiable=Clients can renew their leases -cfg_wiz_lease_desc=Specify lease policy. -cfg_wiz_hours=hours -cfg_wiz_days=days -cfg_wiz_weeks=weeks -cfg_wiz_zero_lease=You cannot specify a lease length of zero. Please enter a new lease length. -cfg_wiz_lease_overflow=The lease value you entered is too large.\nLeases must be no more than {0} {1} - -cfg_wiz_dns_explain=Edit the information below to supply the correct Domain Name Service (DNS) configuration for DHCP clients of this server. -cfg_wiz_dns_domain=&DNS Domain: -cfg_wiz_dns_servers=DNS Servers: -cfg_wiz_dns_desc=Specify DNS domain and servers. -cfg_wiz_dns_both=You must either supply both a DNS domain and list of servers, or neither. - -cfg_wiz_network_explain=Select a network from the list, or type in a network address, then type in a subnet mask if the displayed default is not correct. -cfg_wiz_network=Network &Address: -cfg_wiz_network_explainmore=The DHCP server will be configured to provide IP addresses to clients on this network. Later, you can configure this server to support additional networks with the Network Wizard. -cfg_wiz_network_desc=Specify network address and subnet mask. -cfg_wiz_mask=Subnet &Mask: -cfg_wiz_bad_network=The network you entered, {0}, is not a valid IP network address. -cfg_wiz_bad_mask=The subnet mask you entered, {0}, is not valid. -cfg_wiz_network_configured=The network you entered, {0}, is already configured on this server. - -cfg_wiz_nettype_explain=Please enter the following information for the network: -cfg_wiz_nettype=Network Type: -cfg_wiz_nettype_label=Network Type -cfg_wiz_routing_label=Routing -cfg_wiz_lan=Local-Area (LAN) -cfg_wiz_point=Point-to-Point -cfg_wiz_router_discovery=Use router discovery protocol -cfg_wiz_router_specify=Use router: -cfg_wiz_nettype_desc=Specify network type and router. -cfg_wiz_router_net_err=The router address you entered, {0}, is not on the network {1}.\nPlease enter a router address on that network. -cfg_wiz_router_addr_err=The router address you entered, {0}, is not a valid IP address. - -cfg_wiz_nis_explain=Edit the information below to supply the correct Network Information Service (NIS) configuration to DHCP clients on this network. -cfg_wiz_nis_domain=NIS &Domain: -cfg_wiz_nis_servers=NIS Servers: -cfg_wiz_nis_desc=Specify NIS domain and servers. -cfg_wiz_nis_both=You must either supply both a NIS domain and list of servers, or neither. - -cfg_wiz_datastore=Data Storage: -cfg_wiz_hosts_resource=Hosts Nameservice: -cfg_wiz_router=Router: -cfg_wiz_review_explain=The system will be configured as a DHCP server\nwith the following settings: -cfg_wiz_review_desc=Review. -cfg_wiz_lease_fmt={0,number} {1}, {2} -cfg_wiz_renewable=renewable -cfg_wiz_nonrenewable=non-renewable - -# -# Convert Wizard -# -cvt_wiz_title=Data Store Conversion -cvt_wiz_explain=This wizard enables you to convert the DHCP tables from the current data store format, {0}, to the data store format you specify. -cvt_wiz_store_explain=Select the new data store format: -cvt_wiz_save_explain=The existing DHCP tables are deleted by default after the data store is successfully converted. If you want to save the tables in the old data store, check the box below. -cvt_wiz_save_note=Note: If an error occurs during the conversion process, the old data store will not be deleted, and the DHCP server can continue to use it. -cvt_wiz_save_label=Save old tables? -cvt_wiz_save_tables_desc=Choose to save existing DHCP tables. -cvt_wiz_review_desc=Review. -cvt_wiz_review_explain=The DHCP data store will be converted, using the following settings: -cvt_wiz_review_note=Note: The DHCP service will be stopped and restarted as part of the conversion process. -cvt_wiz_old_datastore=Current data store: -cvt_wiz_new_datastore=New data store: -cvt_wiz_save_tables=Save old tables: -cvt_wiz_table=Table -cvt_wiz_dhcptab=dhcptab -cvt_wiz_defaults=DHCP defaults -cvt_wiz_progress=Converting Data Store: -cvt_wiz_progress_dhcptab_cvt=Converted dhcptab -cvt_wiz_progress_network_cvt=Converted {0} -cvt_wiz_progress_dhcptab_del=Deleted dhcptab -cvt_wiz_progress_network_del=Deleted {0} -cvt_wiz_progress_defaults=Updated the DHCP defaults file -cvt_wiz_progress_dhcptab_cvt_err=Error converting dhcptab -cvt_wiz_progress_network_cvt_err=Error converting {0} -cvt_wiz_progress_dhcptab_del_err=Error deleting dhcptab -cvt_wiz_progress_network_del_err=Error deleting {0} -cvt_wiz_progress_defaults_err=Error updating the DHCP defaults file -cvt_wiz_error=Error -cvt_wiz_same_datastore_error=The source data store is the same as destination data store. -cvt_wiz_location_error=Error making location: {0} -cvt_wiz_networks_error=Error getting networks: {0} -cvt_wiz_errors=The following errors were encountered during the conversion: -cvt_wiz_server_shutdown=Shutdown the service -cvt_wiz_shutdown_err=Error shutting down DHCP server -cvt_wiz_server_started=Started the service -cvt_wiz_start_err=Error starting the DHCP server - -# -# Definitions for the Network Wizard, which is really just a subset of the -# config wizard with some wording changes -# -net_wiz_title=Add a DHCP Network -add_network=Ne&twork Wizard -net_wiz_net_explain=This wizard will help you configure additional networks on your DHCP server. For each network, the wizard creates a network macro to supply clients with relevant network information and a network table to record IP address assignments.\n\nSelect a network from the list, or type in a network address, then type in a subnet mask if the displayed default is not correct. -net_wiz_review_explain=The following network will be added to the DHCP service: -create_network_table_error=Unable to create the table for network {0}, message from server was: {1} - -# -# Relay configuration -# -configure_relay_title=Configure BOOTP Relay -dhcp_servers=DHCP Servers -configure_relay_explain=Enter the IP addresses of the DHCP servers to which this BOOTP relay should forward requests. -configure_relay_err_server_list=You must enter the address of at least one DHCP server to which this relay should forward DHCP traffic. - -# -# Configuration choice dialog -# -configure_choice_title=Choose Server Configuration -configure_choice_explain=This server can be configured as either a DHCP server or a BOOTP relay. If you don't want to do either of these things, press Cancel and this tool will exit. -configure_dhcp_server=Configure as DHCP server -configure_bootp_relay=Configure as BOOTP relay -configure_relay_lookup_error=Unable to find a server named {0}.\nIf you know its IP address, you may enter that instead. - -# -# Service options dialog -# -service_options_title=Modify Service Options -service_options_verbose=Verbose log messages -service_options_hops=&Maximum number of relay agent hops: -service_options_bootp_compat=BOOTP Compatibility -service_options_bootp_none=None -service_options_bootp_auto=Automatic -service_options_bootp_manual=Manual -service_options_detect_duplicates=Detect duplicate IP addresses -service_options_reload_dhcptab=Reload dhcptab every -service_options_reload_minutes=m&inutes -service_options_owner_ip=Act as owner of the following server addresses -service_options_owner_ip_addresses=Server Addresses -service_options_update_dns=Update DNS host information upon client request -service_options_timeout_dns=&Timeout DNS update attempt after -service_options_cache=C&ache offers for -service_options_seconds=seconds -service_options_options=Options -service_options_interfaces=Interfaces -service_options_addresses=Addresses -service_options_restart=Restart Server -service_options_interface=Interface -service_options_network=Network -service_options_monitored=&Monitored Interfaces: -service_options_ignored=&Ignored Interfaces: -service_options_log_transactions=Log Transactions to syslog Facility: -service_options_error=Error modifying service options, message from server was: {0} - -# -# Delete Networks dialog -# -delete_networks=Delete &Networks -delete_networks_title=Delete Networks -delete_networks_keep=&Keep Networks: -delete_networks_delete=&Delete Networks: -delete_networks_error=The following networks were not deleted: -network_column=Network -delete_networks_progress=Deleting network: - -# -# Unconfigure dialog -# -unconfigure_service_item=&Unconfigure -unconfigure_title=Unconfigure Service -unconfigure_dhcp=Are you sure it is OK to unconfigure the DHCP service? If you are using a shared data store, removing the dhcptab and network tables may affect other DHCP servers. -unconfigure_bootp=Are you sure it is OK to unconfigure the BOOTP relay service? This may cause clients to be unable to access the network. -unconfigure_shutdown=DHCP Manager will exit once the service has been unconfigured. -unconfigure_delete_tables=Remove the dhcptab and all DHCP network tables - -unconfigure_progress=Unconfiguring the service -unconfigure_error_heading=Operation -unconfigure_error_messages=The following errors occurred while performing\nthe operations necessary to unconfigure the service - -unconfigure_error_shutdown=Shutdown -unconfigure_server_shutdown=Shutdown the service - -unconfigure_error_defaults=Removing defaults file -unconfigure_defaults_deleted=Defaults file removed - -unconfigure_error_macro=Removing server macro -unconfigure_macro_deleted=Server macro removed - -unconfigure_error_dhcptab=Removing dhcptab -unconfigure_dhcptab_deleted=Removed dhcptab - -unconfigure_error_network=Removing network {0} -unconfigure_network_progress=Removed network {0} - -# -# Transition dialog from config wizard to address wizard -# -start_address_wizard_title=Start Address Wizard? -start_address_wizard=The DHCP server cannot provide addresses to clients\nuntil you configure it with a list of addresses it may use.\nWould you like to run the Address Wizard\nto configure addresses for the server? - -# -# Transition dialog from config wizard to conversion wizard -# -start_cvt_wizard_title=Start Conversion Wizard? -start_cvt_wizard=A version mismatch exists between the DHCP\nmanagement software and the DHCP data stores\nconfigured for the server. Neither the dhcpmgr nor\n the DHCP server can function properly until the\n data stores are converted to the current version.\n Do you wish to convert the data stores now? - -# -# Dialog to view a macro while in the address wizard -# -view_macro_title=View Macro -ok=&OK - -# -# Dialog to select an option while editing/creating a macro -# -select_option_title=Select Option -description_column=Description - -# -# Relay view -# -relay_view_name=BOOTP Relay -relay_view_text=This server is configured as a BOOTP relay. You may manage the relay service status and configuration through the Service menu. - -# -# Export wizard resources -# -export_wiz_title=Export Data -exp_wiz_dont_export=Do Not Export -exp_wiz_export=Export - -exp_wiz_net_desc=Select networks -exp_wiz_net_explain=This wizard helps you export some or all of the DHCP data configured on this server to a file that can then be imported into another Solaris DHCP server's configuration.\n\nSelect networks to export from this server's configuration and move them to the Export column. - -exp_wiz_macro_desc=Select macros -exp_wiz_macros_explain=Select the macros to export and move them to the Export column. - -exp_wiz_option_desc=Select options -exp_wiz_options_explain=Select the options to export and move them to the Export column. - -exp_wiz_file_desc=Specify export file location -exp_wiz_file_explain=Type the full path name of the file to which the configuration data should be exported. -exp_wiz_delete_explain=Do you want to automatically delete the exported data from this server after the export is completed? -exp_wiz_file_label=&Export file: -exp_wiz_delete_exported=Delete exported data - -exp_wiz_review_desc=Review -exp_wiz_review_explain=Review your selections below. If you wish to make any changes, go back to the corresponding step and make the necessary corrections. -exp_wiz_review_nets=&Networks: -exp_wiz_review_macros=&Macros: -exp_wiz_review_options=&Options: -exp_wiz_delete_label=Delete Exported Data: - -exp_progress_title=Export Progress - -exp_error_occurred=The following error occurred while exporting: -exp_overwrite=The export file exists; OK to overwrite? -exp_overwrite_title=Overwrite File - -# -# Import wizard resources -# -import_wiz_title=Import Data -imp_progress_title=Import Progress - -imp_wiz_file_desc=Specify import file location -imp_wiz_location_explain=This wizard helps you import DHCP configuration data previously exported from a Solaris DHCP server.\n\nType the full pathname to the file of exported data, which you want to import to this server. -imp_wiz_file_label=&Import file: -imp_wiz_override_explain=Do you want to overwrite existing data on this server that conflicts with the data being imported? -imp_wiz_override_data=Overwrite existing data - -imp_wiz_review_explain=Review your selections below. If you wish to make any changes, go back to the corresponding step and make the necessary corrections. -imp_wiz_review_info=File {0} was exported -imp_wiz_review_src=From system: -imp_wiz_review_user=By user: -imp_wiz_review_date=On: -imp_wiz_review_override=Overwrite data: -imp_wiz_review_desc=Review - -imp_error=Import Error -imp_err_file_not_found=The import file could not be opened. -imp_err_reading_header=The import file header could not be read; the error message was:\n{0} - - -# Mnemonics added for accessibility conformance. These mnemonics are for -# labels that are associated with textfields, checkboxes, comboboxes etc. -# NB: We must take take to make sure that each mnemonic is unique within -# the dialog eg: OK, Cancel, Reset & help (O, C, R & H) should be avoided -# as mnemonics for other components in the dialog. Also NB, this is not the -# complete list of all Mnemonics but a list of additional ones, the original -# resource strings have been updated to support mnemonics where possible -# first i.e. `&` added to the string. -# -# Create Macro Dialog -# -md_name_label=&Name: -md_option_name=O&ption Name: -md_option_value=Option &Value: - -# Create Option Properties Dialog -# -op_name=&Name: diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ResourceStrings.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ResourceStrings.java deleted file mode 100644 index f2da6a675f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ResourceStrings.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import java.util.*; - -/** - * This class provides a convenient method to retrieve resources for - * the client package. - */ -public class ResourceStrings { - - /** - * The handle to the resource bundle for the module. - */ - private static ResourceBundle bundle = null; - - /** - * Return a string from the resource bundle. - * @param key the key to the resource bundle string. - * @return the resource bundle string. - */ - public static String getString(String key) { - String msg = null; - try { - if (bundle == null) { - bundle = ResourceBundle.getBundle( - "com.sun.dhcpmgr.client.ResourceBundle", - Locale.getDefault()); - } - msg = bundle.getString(key); - } catch (Throwable e) { - msg = new String(key); - } - return msg; - - } // getString - -} // ResourceStrings diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWModule.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWModule.java deleted file mode 100644 index 1874ae54ae..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWModule.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client; - -import java.awt.*; - -import javax.swing.*; -import javax.swing.text.*; -import javax.swing.event.*; - -import com.sun.dhcpmgr.ui.*; - -/** - * This class provides a skeletal implementation of a SUNW data store - * module to minimize the effort required to implement a SUNW data store. - */ -public abstract class SUNWModule extends DSModule { - - /** - * The default path for the module. - */ - protected String path; - - /** - * The description for the module. - */ - protected String description; - - /** - * The component for the module. - */ - protected Box box; - - /** - * The text field from which to retrieve the path. - */ - protected JTextField directory; - - /** - * The datastore specific stuff. - */ - protected String additionalInfo = null; - - // Defined in DSModule. - // - public String getDescription() { - return description; - } // getDescription - - // Defined in DSModule. - // - public Component getComponent() { - return box; - } // getComponent - - // Defined in DSModule. - // - public String getPath() { - return directory.getText(); - } // getPath - - // Defined in DSModule. - // - public String getAdditionalInfo() { - return additionalInfo; - } // getAdditionalInfo - - /** - * This class implements a listener for the directory text field and sets - * the foward enabled button when the text field is valid (non-empty). - */ - protected class PathListener implements DocumentListener { - - /** - * Empty constructor. - */ - public PathListener() { - } // constructor - - /** - * Called when a text update occurs in the text field. - * @param e the event. - */ - public void insertUpdate(DocumentEvent e) { - Document doc = e.getDocument(); - int length = doc.getLength(); - if (length == 0 && getForwardEnabled()) { - setForwardEnabled(false); - } else if (length != 0 && !getForwardEnabled()) { - setForwardEnabled(true); - } - } // insertUpdate - - /** - * Called when a text change occurs in the text field. - * @param e the event. - */ - public void changedUpdate(DocumentEvent e) { - insertUpdate(e); - } // changedUpdate - - /** - * Called when a text remove occurs in the text field. - * @param e the event. - */ public void removeUpdate(DocumentEvent e) { - insertUpdate(e); - } // insertUpdate - - } // PathListener - -} // SUNWModule diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWbinfiles/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWbinfiles/Makefile deleted file mode 100644 index a02176171a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWbinfiles/Makefile +++ /dev/null @@ -1,72 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWbinfiles/Makefile -# - -CLASSFILES = SUNWbinfiles.class \ - ResourceStrings.class - -include $(SRC)/Makefile.master - -CLASSPATH = $(SRC)/cmd/cmd-inet/usr.sadm/dhcpmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -MSGDIR= $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/client/SUNWbinfiles -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/client \ - $(MSGDIR) - -MSGFILES= ResourceBundle.properties -MSGS= $(MSGFILES:%=$(MSGDIR)/%) - -CLEANFILES= *.class -CLOBBERFILES= - -.KEEP_STATE: - -all: $(CLASSFILES) - -install: all - -_msg: $(MSGDIRS) $(MSGS) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - -lint: - -clean: - -$(RM) $(CLEANFILES) - -clobber: clean diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWbinfiles/ResourceBundle.properties b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWbinfiles/ResourceBundle.properties deleted file mode 100644 index dc351652a8..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWbinfiles/ResourceBundle.properties +++ /dev/null @@ -1,30 +0,0 @@ -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -description=Binary files -explanation=Specify configuration parameters for the new binary files data store. -path_label=Path: diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWbinfiles/ResourceStrings.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWbinfiles/ResourceStrings.java deleted file mode 100644 index e51e8d4b84..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWbinfiles/ResourceStrings.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client.SUNWbinfiles; - -import java.util.*; - -/** - * This class provides a convenient method to retrieve resources for - * the SUNWbinfiles module. - */ -public class ResourceStrings { - - /** - * The handle to the resource bundle for the module. - */ - private static ResourceBundle bundle = null; - - /** - * Return a string from the resource bundle. - * @param key the key to the resource bundle string. - * @return the resource bundle string. - */ - public static String getString(String key) { - String msg = null; - try { - if (bundle == null) { - bundle = ResourceBundle.getBundle( - "com.sun.dhcpmgr.client.SUNWbinfiles.ResourceBundle", - Locale.getDefault()); - } - msg = bundle.getString(key); - } catch (Throwable e) { - msg = new String(key); - } - return msg; - - } // getString - -} // ResourceStrings diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWbinfiles/SUNWbinfiles.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWbinfiles/SUNWbinfiles.java deleted file mode 100644 index 813ad9879e..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWbinfiles/SUNWbinfiles.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client.SUNWbinfiles; - -import java.awt.*; - -import javax.swing.*; -import javax.swing.text.*; -import javax.swing.event.*; - -import com.sun.dhcpmgr.client.*; -import com.sun.dhcpmgr.ui.*; - -/** - * This class makes the SUNWbinfiles data store manageable by the dhcpmgr. - */ -public class SUNWbinfiles extends SUNWModule { - - private static final String DEFAULT_PATH = "/var/dhcp"; - - /** - * The constructor for the SUNWbinfiles module. - */ - public SUNWbinfiles() { - - // Initialize the path and description attributes. - // - path = new String(DEFAULT_PATH); - description = ResourceStrings.getString("description"); - - box = Box.createVerticalBox(); - - // Explanatory text. - // - JComponent c = Wizard.createTextArea( - ResourceStrings.getString("explanation"), 3, 45); - box.add(c); - box.add(Box.createVerticalStrut(5)); - - // Path entry field. - // - JPanel fieldPanel = new JPanel(new FieldLayout()); - fieldPanel.add(FieldLayout.LABEL, - new JLabel(ResourceStrings.getString("path_label"))); - directory = new JTextField(path, 20); - fieldPanel.add(FieldLayout.FIELD, directory); - box.add(fieldPanel); - - // Add a listener to set forward button (or not). - // - directory.getDocument().addDocumentListener(new PathListener()); - - // By default forward button is enabled for this data store. - // - setForwardEnabled(true); - - } // constructor - -} // SUNWbinfiles diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWfiles/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWfiles/Makefile deleted file mode 100644 index 3c01a7bfb4..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWfiles/Makefile +++ /dev/null @@ -1,72 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWfiles/Makefile -# - -CLASSFILES = SUNWfiles.class \ - ResourceStrings.class - -include $(SRC)/Makefile.master - -CLASSPATH = $(SRC)/cmd/cmd-inet/usr.sadm/dhcpmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -MSGDIR= $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/client/SUNWfiles -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/client \ - $(MSGDIR) - -MSGFILES= ResourceBundle.properties -MSGS= $(MSGFILES:%=$(MSGDIR)/%) - -CLEANFILES= *.class -CLOBBERFILES= - -.KEEP_STATE: - -all: $(CLASSFILES) - -install: all - -_msg: $(MSGDIRS) $(MSGS) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - -lint: - -clean: - -$(RM) $(CLEANFILES) - -clobber: clean diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWfiles/ResourceBundle.properties b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWfiles/ResourceBundle.properties deleted file mode 100644 index 193d0f2242..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWfiles/ResourceBundle.properties +++ /dev/null @@ -1,30 +0,0 @@ -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -description=Text files -explanation=Specify configuration parameters for the new text files data store. -path_label=Path: diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWfiles/ResourceStrings.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWfiles/ResourceStrings.java deleted file mode 100644 index 1e542e5eaf..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWfiles/ResourceStrings.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client.SUNWfiles; - -import java.util.*; - -/** - * This class provides a convenient method to retrieve resources for - * the SUNWfiles module. - */ -public class ResourceStrings { - - /** - * The handle to the resource bundle for the module. - */ - private static ResourceBundle bundle = null; - - /** - * Return a string from the resource bundle. - * @param key the key to the resource bundle string. - * @return the resource bundle string. - */ - public static String getString(String key) { - String msg = null; - try { - if (bundle == null) { - bundle = ResourceBundle.getBundle( - "com.sun.dhcpmgr.client.SUNWfiles.ResourceBundle", - Locale.getDefault()); - } - msg = bundle.getString(key); - } catch (Throwable e) { - msg = new String(key); - } - return msg; - - } // getString - -} // ResourceStrings diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWfiles/SUNWfiles.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWfiles/SUNWfiles.java deleted file mode 100644 index f69f8523fb..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SUNWfiles/SUNWfiles.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.client.SUNWfiles; - -import java.awt.*; - -import javax.swing.*; -import javax.swing.text.*; -import javax.swing.event.*; - -import com.sun.dhcpmgr.client.*; -import com.sun.dhcpmgr.ui.*; - -/** - * This class makes the SUNWfiles data store manageable by the dhcpmgr. - */ -public class SUNWfiles extends SUNWModule { - - private static final String DEFAULT_PATH = "/var/dhcp"; - - /** - * The constructor for the SUNWfiles module. - */ - public SUNWfiles() { - - // Initialize the path and description attributes. - // - path = new String(DEFAULT_PATH); - description = ResourceStrings.getString("description"); - - box = Box.createVerticalBox(); - - // Explanatory text. - // - JComponent c = Wizard.createTextArea( - ResourceStrings.getString("explanation"), 3, 45); - box.add(c); - box.add(Box.createVerticalStrut(5)); - - // Path entry field. - // - JPanel fieldPanel = new JPanel(new FieldLayout()); - fieldPanel.add(FieldLayout.LABEL, - new JLabel(ResourceStrings.getString("path_label"))); - directory = new JTextField(path, 20); - fieldPanel.add(FieldLayout.FIELD, directory); - box.add(fieldPanel); - - // Add a listener to set forward button (or not). - // - directory.getDocument().addDocumentListener(new PathListener()); - - // By default forward button is enabled for this data store. - // - setForwardEnabled(true); - - } // constructor - -} // SUNWfiles diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SelectOptionDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SelectOptionDialog.java deleted file mode 100644 index 35c5a27466..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/SelectOptionDialog.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.event.*; -import javax.swing.table.*; - -import java.awt.*; -import java.awt.event.*; -import java.text.MessageFormat; -import java.util.*; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; - -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; - -/** - * Dialog to select an option for inclusion in a macro. - */ -public class SelectOptionDialog extends JComponent - implements ButtonPanelListener { - private JComboBox category; - private AutosizingTable optionTable; - private ButtonPanel buttonPanel; - private OptionTableModel optionTableModel; - private TableSorter sortedModel; - static final String SELECTED_OPTION = "selected_option"; - static String value = null; - static JDialog dialog; - private OptionContext [] categories = { - Option.ctxts[Option.STANDARD], - Option.ctxts[Option.EXTEND], - Option.ctxts[Option.VENDOR], - Option.ctxts[Option.SITE] - }; - - // Model for the table displaying option descriptions - class OptionTableModel extends AbstractTableModel { - private Option [] data; - private ResourceBundle bundle; - - public OptionTableModel() { - super(); - data = new Option[0]; - // Locate the resource bundle containing the localized descriptions - bundle = ResourceBundle.getBundle( - "com.sun.dhcpmgr.client.OptionDescriptions", - Locale.getDefault()); - } - - public void setCategory(OptionContext category) { - byte code = category.getCode(); - if (code == Option.ctxts[Option.STANDARD].getCode()) { - data = StandardOptions.getAllOptions(); - } else if (code == Option.ctxts[Option.EXTEND].getCode() || - code == Option.ctxts[Option.SITE].getCode() || - code == Option.ctxts[Option.VENDOR].getCode()) { - try { - // Get all locally defined options from DataManager - Option [] allOptions = DataManager.get().getOptions(false); - Vector v = new Vector(); - // Now filter by the selected type - for (int i = 0; i < allOptions.length; ++i) { - if (allOptions[i].getContext() == code) { - v.addElement(allOptions[i]); - } - } - // Convert to an array - data = new Option[v.size()]; - v.copyInto(data); - } catch (Exception e) { - data = new Option[0]; - } - } - // Tell the sorter things changed - sortedModel.reallocateIndexes(); - fireTableDataChanged(); - } - - public int getRowCount() { - return data.length; - } - - public int getColumnCount() { - return 2; - } - - public Object getValueAt(int row, int column) { - if (column == 0) { - return data[row].getKey(); - } else { - try { - /** - * Look up descriptions in the properties file indexed by - * option name - */ - return bundle.getString(data[row].getKey()); - } catch (Exception e) { - // Ignore; we just don't have a description for this one - return null; - - } - } - } - - public Class getColumnClass(int column) { - return String.class; - } - - public String getColumnName(int column) { - if (column == 0) { - return ResourceStrings.getString("option_column"); - } else { - return ResourceStrings.getString("description_column"); - } - } - - public boolean isCellEditable(int row, int column) { - return false; - } - } - - // Generate the dialog - public void createDialog() { - dialog = new JDialog((JFrame)null, - ResourceStrings.getString("select_option_title"), true); - - dialog.getContentPane().setLayout(new BoxLayout(dialog.getContentPane(), - BoxLayout.Y_AXIS)); - - // Label and combo box for selecting option category - JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - - Mnemonic mnCat = - new Mnemonic(ResourceStrings.getString("category_label")); - JLabel catLbl = - new JLabel(mnCat.getString()); - panel.add(catLbl); - category = new JComboBox(categories); - - catLbl.setLabelFor(category); - catLbl.setToolTipText(mnCat.getString()); - catLbl.setDisplayedMnemonic(mnCat.getMnemonic()); - - category.setEditable(false); - panel.add(category); - - dialog.getContentPane().add(panel); - - // Table for selecting the options in the given category - optionTableModel = new OptionTableModel(); - // Sort options by name, alphabetically - sortedModel = new TableSorter(optionTableModel); - sortedModel.sortByColumn(0); - // Use an auto-sizing table so descriptions get the space they need - optionTable = new AutosizingTable(sortedModel); - optionTable.getTableHeader().setReorderingAllowed(false); - optionTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - JScrollPane scrollPane = new JScrollPane(optionTable); - panel = new JPanel(); - panel.add(scrollPane); - dialog.getContentPane().add(panel); - - // Put in usual separator and buttons - dialog.getContentPane().add(new JSeparator()); - buttonPanel = new ButtonPanel(false, false); - buttonPanel.addButtonPanelListener(this); - dialog.getContentPane().add(buttonPanel); - - /* - * As user changes category selected, update table to view category - * contents - */ - category.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - updateTable(); - } - }); - - // Only enable OK when there is an option selected in the table - optionTable.getSelectionModel().addListSelectionListener( - new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - if (optionTable.getSelectedRow() == -1) { - buttonPanel.setOkEnabled(false); - } else { - buttonPanel.setOkEnabled(true); - } - } - }); - - // Ensure table displays data for initial selection - updateTable(); - } - - /** - * Update the table to the current category selection. - */ - private void updateTable() { - optionTableModel.setCategory(categories[category.getSelectedIndex()]); - optionTable.clearSelection(); - } - - public void buttonPressed(int buttonId) { - switch (buttonId) { - case OK: - firePropertyChange(SELECTED_OPTION, null, - (String)optionTableModel.getValueAt( - sortedModel.mapRowAt(optionTable.getSelectedRow()), 0)); - break; - case CANCEL: - firePropertyChange(SELECTED_OPTION, null, null); - break; - } - } - - /** - * Here's the way to display this dialog modally and retrieve the value - * selected - * @param c a component relative to which the dialog should be displayed - */ - public static String showDialog(Component c) { - SelectOptionDialog d = new SelectOptionDialog(); - d.createDialog(); - /* - * When user presses OK or Cancel, retrieve the value and kill the - * dialog - */ - d.addPropertyChangeListener(new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent e) { - dialog.setVisible(false); - dialog.dispose(); - value = (String)e.getNewValue(); - } - }); - dialog.setLocationRelativeTo(c); - dialog.pack(); - dialog.setVisible(true); - return value; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ServerOptionsDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ServerOptionsDialog.java deleted file mode 100644 index 82d31b3d52..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ServerOptionsDialog.java +++ /dev/null @@ -1,875 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.event.*; -import javax.swing.table.*; - -import java.awt.*; -import java.awt.event.*; -import java.text.*; -import java.util.*; - -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; -import com.sun.dhcpmgr.bridge.BridgeException; - -/** - * Dialog to edit the options for the server as stored in the startup script. - */ -public class ServerOptionsDialog extends DhcpmgrDialog { - private static int DEFAULT_RESCAN_INTERVAL = 60; - private DhcpdOptions options, originalOptions; - private JCheckBox verboseLogging, detectDuplicates, restartServer, - logTransactions, reloadEnabled, owneripEnabled, dnsUpdateEnabled; - private IntegerField relayHops, reloadInterval, cacheTime, dnsTimeout; - private JRadioButton noBootp, autoBootp, manualBootp; - private IPAddressList serverList; - private IPAddressList owneripList; - private JComboBox logFacility; - private JTable monitoredTable, ignoredTable; - private LeftButton leftButton; - private RightButton rightButton; - - /* - * Model for the tables which are used to edit the lists of - * interfaces which are monitored and ignored. - */ - class InterfaceTableModel extends AbstractTableModel { - private Vector interfaces; - - public InterfaceTableModel() { - interfaces = new Vector(); - } - - // Initialize the list of interfaces - public void setInterfaceList(IPInterface [] ifs) { - interfaces.removeAllElements(); - if (ifs != null) { - for (int i = 0; i < ifs.length; ++i) { - interfaces.addElement(ifs[i]); - } - } - fireTableDataChanged(); - } - - // Retrieve the interfacess as a comma-separated list - public String getInterfaceList() { - StringBuffer b = new StringBuffer(); - Enumeration e = interfaces.elements(); - while (e.hasMoreElements()) { - if (b.length() != 0) { - b.append(','); - } - IPInterface ipif = (IPInterface)e.nextElement(); - b.append(ipif.getName()); - } - return b.toString(); - } - - // Retrieve interface object for named interface - public IPInterface getInterface(String name) { - Enumeration e = interfaces.elements(); - while (e.hasMoreElements()) { - IPInterface ipif = (IPInterface)e.nextElement(); - if (name.equals(ipif.getName())) { - return ipif; - } - } - return null; - } - - // Retrieve the interface object at a particular row in the table - public IPInterface getInterfaceAt(int row) { - return (IPInterface)interfaces.elementAt(row); - } - - // Add an interface to the table - public void addInterface(IPInterface ipif) { - interfaces.addElement(ipif); - fireTableDataChanged(); - } - - // Delete an interface from the table - public void deleteInterface(IPInterface ipif) { - interfaces.removeElement(ipif); - fireTableDataChanged(); - } - - // Return number of rows - public int getRowCount() { - return interfaces.size(); - } - - // Always two columns: interface name and network - public int getColumnCount() { - return 2; - } - - // Return cell value at a particular coordinate - public Object getValueAt(int row, int column) { - IPInterface ipif = (IPInterface)interfaces.elementAt(row); - if (column == 0) { - return ipif.getName(); - } else { - return ipif.getNetwork().toString(); - } - } - - // All data is strings from the display's point of view - public Class getColumnClass(int column) { - return String.class; - } - - // Get headings for each column - public String getColumnName(int column) { - if (column == 0) { - return ResourceStrings.getString("service_options_interface"); - } else { - return ResourceStrings.getString("service_options_network"); - } - } - } - - public ServerOptionsDialog(Frame f, DhcpdOptions opts) { - super(f, true); // We want a reset button - setOptions(opts); - resetValues(); - } - - /** - * Provide a title to be displayed for the dialog - */ - public String getTitle() { - return ResourceStrings.getString("service_options_title"); - } - - /** - * Construct and return the main display for this dialog. - */ - protected JPanel getMainPanel() { - - JPanel mainPanel = new JPanel(new BorderLayout()); - - /* - * Start with a tabbed view; the top tab is the options for the - * daemon, the lower tab is the interfaces to be monitored. - */ - JTabbedPane tabbedPane = new JTabbedPane(); - JPanel optionsPanel = new JPanel(); - optionsPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - - // Use a gridbag with equal weights all around, cells anchored to west - GridBagLayout bag = new GridBagLayout(); - GridBagConstraints con = new GridBagConstraints(); - con.gridx = con.gridy = 0; - con.weightx = con.weighty = 1.0; - con.anchor = GridBagConstraints.WEST; - con.insets = new Insets(2, 2, 2, 2); - - optionsPanel.setLayout(bag); - - // Add control for number of hops allowed - Box box = Box.createHorizontalBox(); - - Mnemonic mnHops = - new Mnemonic(ResourceStrings.getString("service_options_hops")); - JLabel label = new JLabel(mnHops.getString()); - label.setToolTipText(mnHops.getString()); - label.setDisplayedMnemonic(mnHops.getMnemonic()); - - label.setForeground(Color.black); - box.add(label); - box.add(Box.createHorizontalStrut(5)); - relayHops = new IntegerField(); - label.setLabelFor(relayHops); - box.add(relayHops); - bag.setConstraints(box, con); - optionsPanel.add(box); - - // Add control for verbose logging - verboseLogging = new JCheckBox( - ResourceStrings.getString("service_options_verbose"), false); - verboseLogging.setToolTipText( - ResourceStrings.getString("service_options_verbose")); - ++con.gridy; - bag.setConstraints(verboseLogging, con); - optionsPanel.add(verboseLogging); - - // Add control for transaction logging on/off and facility to use - box = Box.createHorizontalBox(); - logTransactions = new JCheckBox( - ResourceStrings.getString("service_options_log_transactions"), - false); - logTransactions.setToolTipText( - ResourceStrings.getString("service_options_log_transactions")); - logTransactions.setAlignmentY((float)0.5); - box.add(logTransactions); - box.add(Box.createHorizontalStrut(5)); - logFacility = new JComboBox(DhcpdOptions.getLoggingFacilities()); - logFacility.setAlignmentY((float)0.5); - box.add(logFacility); - ++con.gridy; - bag.setConstraints(box, con); - optionsPanel.add(box); - // Enable logging facility choices only when logging is turned on - logTransactions.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - logFacility.setEnabled(logTransactions.isSelected()); - } - }); - - /* - * The main tab has two different displays depending on whether it's - * a relay or a full-fledged server. - */ - if (!DhcpmgrApplet.modeIsRelay) { - // Add control for duplicate detection using ICMP - detectDuplicates = new JCheckBox( - ResourceStrings.getString("service_options_detect_duplicates"), - true); - detectDuplicates.setToolTipText( - ResourceStrings.getString("service_options_detect_duplicates")); - ++con.gridy; - bag.setConstraints(detectDuplicates, con); - optionsPanel.add(detectDuplicates); - - // Add control for automatic reload of dhcptab and period - box = Box.createHorizontalBox(); - reloadEnabled = new JCheckBox( - ResourceStrings.getString("service_options_reload_dhcptab")); - reloadEnabled.setToolTipText(ResourceStrings.getString( - "service_options_reload_dhcptab")); - reloadEnabled.setAlignmentY((float)0.5); - box.add(reloadEnabled); - box.add(Box.createHorizontalStrut(5)); - reloadInterval = new IntegerField(); - reloadInterval.setAlignmentY((float)0.5); - box.add(reloadInterval); - box.add(Box.createHorizontalStrut(5)); - - Mnemonic mnMins = - new Mnemonic(ResourceStrings.getString( - "service_options_reload_minutes")); - label = new JLabel(mnMins.getString()); - label.setLabelFor(reloadInterval); - label.setToolTipText(mnMins.getString()); - label.setDisplayedMnemonic(mnMins.getMnemonic()); - - label.setForeground(Color.black); - label.setAlignmentY((float)0.5); - box.add(label); - ++con.gridy; - bag.setConstraints(box, con); - optionsPanel.add(box); - - // Add control for DNS dynamic update and timeout value - box = Box.createHorizontalBox(); - dnsUpdateEnabled = new JCheckBox( - ResourceStrings.getString("service_options_update_dns")); - dnsUpdateEnabled.setToolTipText( - ResourceStrings.getString("service_options_update_dns")); - dnsUpdateEnabled.setAlignmentY((float)0.5); - box.add(dnsUpdateEnabled); - box.add(Box.createHorizontalStrut(5)); - ++con.gridy; - bag.setConstraints(box, con); - optionsPanel.add(box); - - box = Box.createHorizontalBox(); - dnsTimeout = new IntegerField(); - dnsTimeout.setAlignmentY((float)0.10); - box.add(Box.createHorizontalStrut(25)); - - Mnemonic mnDNS = - new Mnemonic(ResourceStrings.getString( - "service_options_timeout_dns")); - label = new JLabel(mnDNS.getString()); - label.setLabelFor(dnsTimeout); - label.setToolTipText(mnDNS.getString()); - label.setDisplayedMnemonic(mnDNS.getMnemonic()); - - label.setForeground(Color.black); - label.setAlignmentY((float)0.5); - box.add(label); - box.add(Box.createHorizontalStrut(5)); - box.add(dnsTimeout); - box.add(Box.createHorizontalStrut(5)); - label = new JLabel( - ResourceStrings.getString("service_options_seconds")); - label.setLabelFor(box); - label.setToolTipText(ResourceStrings.getString( - "service_options_seconds")); - label.setForeground(Color.black); - label.setAlignmentY((float)0.5); - box.add(label); - ++con.gridy; - bag.setConstraints(box, con); - optionsPanel.add(box); - - // Add control for length of time to cache offers - box = Box.createHorizontalBox(); - - Mnemonic mnCache = - new Mnemonic(ResourceStrings.getString( - "service_options_cache")); - label = new JLabel(mnCache.getString()); - label.setToolTipText(mnCache.getString()); - label.setDisplayedMnemonic(mnCache.getMnemonic()); - - label.setForeground(Color.black); - box.add(label); - box.add(Box.createHorizontalStrut(5)); - cacheTime = new IntegerField(); - label.setLabelFor(cacheTime); - box.add(cacheTime); - box.add(Box.createHorizontalStrut(5)); - label = new JLabel( - ResourceStrings.getString("service_options_seconds")); - label.setLabelFor(box); - label.setToolTipText(ResourceStrings.getString( - "service_options_seconds")); - label.setForeground(Color.black); - box.add(label); - ++con.gridy; - bag.setConstraints(box, con); - optionsPanel.add(box); - - // Add choices for BOOTP compatibility behavior: none, auto, manual - JPanel panel = new JPanel(); - panel.setLayout(new GridLayout(3, 1)); - Border b = BorderFactory.createTitledBorder( - BorderFactory.createLineBorder(Color.black), - ResourceStrings.getString("service_options_bootp_compat")); - panel.setBorder(BorderFactory.createCompoundBorder(b, - BorderFactory.createEmptyBorder(5, 5, 5, 5))); - - ButtonGroup bootpCompat = new ButtonGroup(); - - noBootp = new JRadioButton( - ResourceStrings.getString("service_options_bootp_none"), true); - noBootp.setToolTipText( - ResourceStrings.getString("service_options_bootp_none")); - bootpCompat.add(noBootp); - panel.add(noBootp); - - autoBootp = new JRadioButton( - ResourceStrings.getString("service_options_bootp_auto"), false); - autoBootp.setToolTipText( - ResourceStrings.getString("service_options_bootp_auto")); - bootpCompat.add(autoBootp); - panel.add(autoBootp); - - manualBootp = new JRadioButton( - ResourceStrings.getString("service_options_bootp_manual"), - false); - manualBootp.setToolTipText( - ResourceStrings.getString("service_options_bootp_manual")); - bootpCompat.add(manualBootp); - panel.add(manualBootp); - - ++con.gridy; - con.fill = GridBagConstraints.HORIZONTAL; - bag.setConstraints(panel, con); - optionsPanel.add(panel); - - // Enable reload interval only when reload option is checked - reloadEnabled.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - reloadInterval.setEnabled(reloadEnabled.isSelected()); - } - }); - // Enable DNS timeout only when DNS update option is checked - dnsUpdateEnabled.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - dnsTimeout.setEnabled(dnsUpdateEnabled.isSelected()); - } - }); - } else { - /* - * In relay mode the only other thing we can control is list of - * servers which we forward requests to. - */ - serverList = new IPAddressList(); - Border tb = BorderFactory.createTitledBorder( - BorderFactory.createLineBorder(Color.black), - ResourceStrings.getString("dhcp_servers")); - serverList.setBorder(BorderFactory.createCompoundBorder(tb, - BorderFactory.createEmptyBorder(5, 5, 5, 5))); - ++con.gridy; - bag.setConstraints(serverList, con); - optionsPanel.add(serverList); - } - - tabbedPane.addTab(ResourceStrings.getString("service_options_options"), - optionsPanel); - - // Panel for interfaces - monitoredTable = new JTable(new InterfaceTableModel()); - ignoredTable = new JTable(new InterfaceTableModel()); - monitoredTable.setSelectionMode( - ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - ignoredTable.setSelectionMode( - ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - - Box interfaceBox = Box.createHorizontalBox(); - - // The list of interfaces we're monitoring goes on the left - JPanel panel = new JPanel(new BorderLayout(5, 5)); - - Mnemonic mnMon = - new Mnemonic(ResourceStrings.getString( - "service_options_monitored")); - JLabel servOptsLbl = new JLabel(mnMon.getString()); - servOptsLbl.setLabelFor(monitoredTable); - servOptsLbl.setToolTipText(mnMon.getString()); - servOptsLbl.setDisplayedMnemonic(mnMon.getMnemonic()); - - panel.add(servOptsLbl, BorderLayout.NORTH); - - JScrollPane scrollPane = new JScrollPane(monitoredTable); - Dimension d = monitoredTable.getPreferredScrollableViewportSize(); - d.height = 100; - d.width = 210; - monitoredTable.setPreferredScrollableViewportSize(d); - panel.add(scrollPane, BorderLayout.CENTER); - interfaceBox.add(panel); - interfaceBox.add(Box.createHorizontalStrut(10)); - - // The buttons to move items between the lists go in the middle - panel = new JPanel(new VerticalButtonLayout()); - leftButton = new LeftButton(); - rightButton = new RightButton(); - rightButton.setEnabled(false); - leftButton.setEnabled(false); - panel.add(rightButton); - panel.add(leftButton); - interfaceBox.add(panel); - interfaceBox.add(Box.createHorizontalStrut(10)); - - // The list of interfaces to ignore is on the right - panel = new JPanel(new BorderLayout(5, 5)); - - Mnemonic mnIg = - new Mnemonic(ResourceStrings.getString("service_options_ignored")); - JLabel optsIgnLbl = new JLabel(mnIg.getString()); - optsIgnLbl.setLabelFor(ignoredTable); - optsIgnLbl.setToolTipText(mnIg.getString()); - optsIgnLbl.setDisplayedMnemonic(mnIg.getMnemonic()); - - panel.add(optsIgnLbl, BorderLayout.NORTH); - - scrollPane = new JScrollPane(ignoredTable); - d = ignoredTable.getPreferredScrollableViewportSize(); - d.height = 100; - d.width = 210; - ignoredTable.setPreferredScrollableViewportSize(d); - panel.add(scrollPane, BorderLayout.CENTER); - interfaceBox.add(panel); - - // Now create the tab for the interface manipulation - panel = new JPanel(new BorderLayout()); - panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - panel.add(interfaceBox, BorderLayout.CENTER); - tabbedPane.addTab( - ResourceStrings.getString("service_options_interfaces"), panel); - - // tab for Addresses - if (!DhcpmgrApplet.modeIsRelay) { - JPanel addrsPanel = new JPanel(new BorderLayout()); - addrsPanel.setBorder( - BorderFactory.createEmptyBorder(10, 10, 10, 10)); - - // Add control for DHCP OWNER_IP option and values - box = Box.createHorizontalBox(); - owneripEnabled = new JCheckBox( - ResourceStrings.getString("service_options_owner_ip")); - owneripEnabled.setToolTipText( - ResourceStrings.getString("service_options_owner_ip")); - owneripEnabled.setAlignmentY((float)0.5); - box.add(owneripEnabled); - box.add(Box.createHorizontalStrut(5)); - addrsPanel.add(box, BorderLayout.NORTH); - - owneripList = new IPAddressList(); - Border tb = BorderFactory.createTitledBorder( - BorderFactory.createLineBorder(Color.black), - ResourceStrings.getString( - "service_options_owner_ip_addresses")); - owneripList.setBorder(BorderFactory.createCompoundBorder(tb, - BorderFactory.createEmptyBorder(5, 5, 5, 5))); - addrsPanel.add(owneripList, BorderLayout.CENTER); - // Enable OWNER_IP Addresses only when owner_ip option is checked - owneripEnabled.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - owneripList.setEnabled(owneripEnabled.isSelected()); - } - }); - // now add the tab for Addresses - tabbedPane.addTab( - ResourceStrings.getString("service_options_addresses"), - addrsPanel); - } - - JPanel borderPanel = new JPanel(new BorderLayout()); - borderPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - borderPanel.add(tabbedPane, BorderLayout.CENTER); - - mainPanel.add(borderPanel, BorderLayout.NORTH); - - /* - * Allow them to specify server should be restarted when these changes - * are applied - */ - restartServer = new JCheckBox( - ResourceStrings.getString("service_options_restart")); - restartServer.setToolTipText( - ResourceStrings.getString("service_options_restart")); - panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - panel.add(restartServer); - mainPanel.add(panel, BorderLayout.CENTER); - - buttonPanel.setOkEnabled(true); - - // Handle enable and disable of buttons based on selection state - monitoredTable.getSelectionModel().addListSelectionListener( - new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - if (monitoredTable.getSelectedRowCount() != 0 && - monitoredTable.getRowCount() > 0) { - rightButton.setEnabled(true); - ignoredTable.getSelectionModel().clearSelection(); - } else { - rightButton.setEnabled(false); - } - } - }); - - ignoredTable.getSelectionModel().addListSelectionListener( - new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - if (ignoredTable.getSelectedRowCount() != 0 && - ignoredTable.getRowCount() > 0) { - leftButton.setEnabled(true); - monitoredTable.getSelectionModel().clearSelection(); - } else { - leftButton.setEnabled(false); - } - } - }); - - // Handle button presses - rightButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - int [] rows = monitoredTable.getSelectedRows(); - if (rows == null) { - return; - } - InterfaceTableModel monitoredModel = - (InterfaceTableModel)monitoredTable.getModel(); - InterfaceTableModel ignoredModel = - (InterfaceTableModel)ignoredTable.getModel(); - /* - * Now do the adds, then the removes; otherwise the row numbers - * we just got might be wrong - */ - Vector removals = new Vector(); - for (int i = 0; i < rows.length; ++i) { - IPInterface ipif = monitoredModel.getInterfaceAt(rows[i]); - ignoredModel.addInterface(ipif); - removals.addElement(ipif); - } - Enumeration en = removals.elements(); - while (en.hasMoreElements()) { - monitoredModel.deleteInterface( - (IPInterface)en.nextElement()); - } - /* - * Clear the selection; this prevents exceptions from selection - * pointing at rows that are gone - */ - monitoredTable.getSelectionModel().clearSelection(); - } - }); - - leftButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - int [] rows = ignoredTable.getSelectedRows(); - if (rows == null) { - return; - } - InterfaceTableModel monitoredModel = - (InterfaceTableModel)monitoredTable.getModel(); - InterfaceTableModel ignoredModel = - (InterfaceTableModel)ignoredTable.getModel(); - /* - * Now do the adds, then the removes; otherwise the row numbers - * we just got might be wrong - */ - Vector removals = new Vector(); - for (int i = 0; i < rows.length; ++i) { - IPInterface ipif = ignoredModel.getInterfaceAt(rows[i]); - monitoredModel.addInterface(ipif); - removals.addElement(ipif); - } - Enumeration en = removals.elements(); - while (en.hasMoreElements()) { - ignoredModel.deleteInterface((IPInterface)en.nextElement()); - } - /* - * Clear the selection; this prevents exceptions from selection - * pointing at rows that are gone - */ - ignoredTable.getSelectionModel().clearSelection(); - } - }); - - - return mainPanel; - } - - // Save a copy of the option settings so reset can work - private void setOptions(DhcpdOptions o) { - originalOptions = (DhcpdOptions)o.clone(); - options = o; - } - - // Reset all controls to initial values - private void resetValues() { - // Main tab parameters; first verbose logging - verboseLogging.setSelected(options.isVerbose()); - // Relay hops - if (options.isRelayHops()) { - relayHops.setValue(options.getRelayHops()); - } else { - relayHops.setValue(DhcpdOptions.DSVC_CV_HOPS); - } - // Set logging controls - logTransactions.setSelected(options.isLogging()); - logFacility.setEnabled(options.isLogging()); - if (options.isLogging()) { - logFacility.setSelectedItem(options.getLogging()); - } else { - logFacility.setSelectedIndex(0); - } - - if (!DhcpmgrApplet.modeIsRelay) { - // Set bootp compat. controls - noBootp.setSelected(!options.isBootpCompatible()); - if (options.isBootpCompatible()) { - autoBootp.setSelected(options.isBootpAutomatic()); - manualBootp.setSelected(!options.isBootpAutomatic()); - } - detectDuplicates.setSelected(options.isICMPVerify()); - reloadEnabled.setSelected(options.isRescan()); - reloadInterval.setEnabled(options.isRescan()); - owneripEnabled.setSelected(options.isOwnerip()); - owneripList.setEnabled(options.isOwnerip()); - dnsUpdateEnabled.setSelected(options.isDnsUpdated()); - dnsTimeout.setEnabled(options.isDnsUpdated()); - - // Set rescan interval to default if it's not specified - if (options.isRescan()) { - reloadInterval.setValue(options.getRescan()); - } else { - reloadInterval.setValue(DEFAULT_RESCAN_INTERVAL); - } - - // Set owner_ip to default if it's not specified - if (options.isOwnerip()) { - owneripList.setAddressList(options.getOwnerip()); - } - // Set DNS timeout to default if it's not specified - if (options.isDnsUpdated()) { - dnsTimeout.setValue(options.getDnsTimeout()); - } else { - dnsTimeout.setValue(DhcpdOptions.DSVC_CV_NSU_TO); - } - if (options.isOfferTtl()) { - cacheTime.setValue(options.getOfferTtl()); - } else { - cacheTime.setValue(DhcpdOptions.DSVC_CV_OFFER_TTL); - } - } else { - // In relay case only the server list is available - serverList.setAddressList(options.getRelay()); - } - - // Interfaces tab - try { - IPInterface[] interfaces = new IPInterface[0]; - try { - interfaces = - DataManager.get().getDhcpServiceMgr().getInterfaces(); - } catch (BridgeException e) { - // we're not configured yet, apparently - interfaces = null; - } - InterfaceTableModel monitoredModel = - (InterfaceTableModel)monitoredTable.getModel(); - InterfaceTableModel ignoredModel = - (InterfaceTableModel)ignoredTable.getModel(); - if (options.isInterfaces()) { - ignoredModel.setInterfaceList(interfaces); - monitoredModel.setInterfaceList(null); - StringTokenizer st = - new StringTokenizer(options.getInterfaces(), ","); - while (st.hasMoreTokens()) { - IPInterface ipif = - ignoredModel.getInterface(st.nextToken()); - if (ipif != null) { - monitoredModel.addInterface(ipif); - ignoredModel.deleteInterface(ipif); - } - } - } else { - monitoredModel.setInterfaceList(interfaces); - ignoredModel.setInterfaceList(null); - } - } catch (Throwable e) { - e.printStackTrace(); - } - - // Default to restarting server - restartServer.setSelected(true); - } - - /** - * User pressed OK, do what we think is necessary - */ - protected void doOk() { - try { - options.setVerbose(verboseLogging.isSelected()); - if (relayHops.getValue() != DhcpdOptions.DSVC_CV_HOPS) { - options.setRelayHops(true, new Integer(relayHops.getValue())); - } else { - options.setRelayHops(false, null); - } - options.setLogging(logTransactions.isSelected(), - (Integer)logFacility.getSelectedItem()); - - if (!DhcpmgrApplet.modeIsRelay) { - options.setBootpCompatible(!noBootp.isSelected(), - autoBootp.isSelected()); - options.setICMPVerify(detectDuplicates.isSelected()); - if (reloadEnabled.isSelected() && - reloadInterval.getValue() != 0) { - options.setRescan(true, - new Integer(reloadInterval.getValue())); - } else { - options.setRescan(false, null); - } - - if (owneripEnabled.isSelected()) { - options.setOwnerip(true, - owneripList.getAddressListString()); - } else { - options.setOwnerip(false, null); - } - - if (dnsUpdateEnabled.isSelected()) { - options.setDnsTimeout(true, - new Integer(dnsTimeout.getValue())); - } else { - options.setDnsTimeout(false, null); - } - if (cacheTime.getValue() != DhcpdOptions.DSVC_CV_OFFER_TTL) { - options.setOfferTtl(true, - new Integer(cacheTime.getValue())); - } else { - options.setOfferTtl(false, null); - } - } else { - options.setRelay(true, serverList.getAddressListString()); - } - if (monitoredTable.getRowCount() == 0) { - // XXX Need to disable OK when this is the case - return; - } - if (ignoredTable.getRowCount() != 0) { - /* - * If nothing is ignored then let server default to all - * interfaces - */ - options.setInterfaces(true, ((InterfaceTableModel) - monitoredTable.getModel()).getInterfaceList()); - } else { - options.setInterfaces(false, null); - } - DataManager.get().getDhcpServiceMgr().writeDefaults(options); - if (restartServer.isSelected()) { - DataManager.get().getDhcpServiceMgr().shutdown(); - // Wait 5 secs for server to try to shutdown - Thread.sleep(5000); - DataManager.get().getDhcpServiceMgr().startup(); - } - fireActionPerformed(); - setVisible(false); - dispose(); - } catch (Exception e) { - MessageFormat form = null; - Object [] args = new Object[2]; - form = new MessageFormat( - ResourceStrings.getString("service_options_error")); - args[0] = e.getMessage(); - JOptionPane.showMessageDialog(this, form.format(args), - ResourceStrings.getString("server_error_title"), - JOptionPane.ERROR_MESSAGE); - } - } - - /** - * Return help system lookup key - */ - protected String getHelpKey() { - if (DhcpmgrApplet.modeIsRelay) { - return "modify_relay"; - } else { - return "modify_server"; - } - } - - /** - * User pressed reset; go back to starting value - */ - protected void doReset() { - setOptions(originalOptions); - resetValues(); - } - - /** - * Notify our invoker that we're done - */ - protected void fireActionPerformed() { - fireActionPerformed(this, DialogActions.OK); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/UnconfigureDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/UnconfigureDialog.java deleted file mode 100644 index 45f5a98564..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/UnconfigureDialog.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1998-2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.event.*; -import javax.swing.table.*; - -import java.awt.*; -import java.awt.event.*; -import java.text.*; -import java.util.*; -import java.net.*; - -import com.sun.dhcpmgr.bridge.*; -import com.sun.dhcpmgr.server.*; -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; - -/** - * A dialog to confirm the user's request to unconfigure the service. - */ -public class UnconfigureDialog extends MultipleOperationDialog { - private JCheckBox deleteTables; - private int networkCount = 0; - private Network [] nets = new Network[0]; - - public UnconfigureDialog(Frame f) { - // No reset button for us - super(f, false); - } - - public String getTitle() { - return ResourceStrings.getString("unconfigure_title"); - } - - protected JPanel getMainPanel() { - - JPanel mainPanel = new JPanel(); - mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - - Box box = Box.createVerticalBox(); - - if (!DhcpmgrApplet.modeIsRelay) { - JComponent c = Wizard.createTextArea( - ResourceStrings.getString("unconfigure_dhcp"), 4, 30); - c.setAlignmentX(Component.LEFT_ALIGNMENT); - box.add(c); - box.add(Box.createVerticalStrut(10)); - deleteTables = new JCheckBox( - ResourceStrings.getString("unconfigure_delete_tables"), false); - deleteTables.setToolTipText( - ResourceStrings.getString("unconfigure_delete_tables")); - deleteTables.setAlignmentX(Component.LEFT_ALIGNMENT); - box.add(deleteTables); - box.add(Box.createVerticalStrut(10)); - } else { - JComponent c = Wizard.createTextArea( - ResourceStrings.getString("unconfigure_bootp"), 4, 30); - c.setAlignmentX(Component.LEFT_ALIGNMENT); - box.add(c); - } - box.add(Box.createVerticalStrut(10)); - JComponent c = Wizard.createTextArea( - ResourceStrings.getString("unconfigure_shutdown"), 2, 30); - c.setAlignmentX(Component.LEFT_ALIGNMENT); - box.add(c); - mainPanel.add(box); - buttonPanel.setOkEnabled(true); - return mainPanel; - } - - protected String getProgressMessage() { - return ResourceStrings.getString("unconfigure_progress"); - } - - protected int getProgressLength() { - // Initialize to number of ops required even if only a relay - int length = 2; - if (!DhcpmgrApplet.modeIsRelay) { - // Add one for deleting defaults file, and one for deleting macro - length += 2; - if (deleteTables.isSelected()) { - try { - nets = DataManager.get().getNetworks(false); - } catch (Throwable t) { - // Ignore - } - length += nets.length + 1; // Add one for dhcptab - } - } - return length; - } - - protected String getErrorHeading() { - return ResourceStrings.getString("unconfigure_error_heading"); - } - - protected Thread getOperationThread() { - return new Thread() { - public void run() { - int checkpoint = 0; - DhcpServiceMgr serviceMgr = - DataManager.get().getDhcpServiceMgr(); - // Shut down the server - try { - serviceMgr.shutdown(); - } catch (Throwable e) { - addError( - ResourceStrings.getString("unconfigure_error_shutdown"), - e.getMessage()); - } - try { - updateProgress(++checkpoint, ResourceStrings.getString( - "unconfigure_server_shutdown")); - } catch (InterruptedException e) { - closeDialog(); - return; - } - - // If this was a relay we're done - if (!DhcpmgrApplet.modeIsRelay) { - // Remove the server macro - try { - DataManager.get().getDhcptabMgr().deleteRecord( - new Macro(DataManager.get().getShortServerName()), - false); - } catch (Throwable e) { - addError(ResourceStrings.getString( - "unconfigure_error_macro"), - e.getMessage()); - } - try { - updateProgress(++checkpoint, ResourceStrings.getString( - "unconfigure_macro_deleted")); - } catch (InterruptedException e) { - closeDialog(); - return; - } - - // Delete all the network tables and the dhcptab - if (deleteTables.isSelected()) { - if (nets != null && nets.length != 0) { - MessageFormat errForm = new MessageFormat( - ResourceStrings.getString( - "unconfigure_error_network")); - MessageFormat progForm = new MessageFormat( - ResourceStrings.getString( - "unconfigure_network_progress")); - Object [] args = new Object[1]; - for (int i = 0; i < nets.length; ++i) { - String netString = nets[i].toString(); - args[0] = netString; - try { - DataManager.get().getDhcpNetMgr(). - deleteNetwork(netString, true); - } catch (Throwable e) { - addError(errForm.format(args), - e.getMessage()); - } - try { - updateProgress(++checkpoint, - progForm.format(args)); - } catch (InterruptedException e) { - closeDialog(); - return; - } - } - } - try { - DataManager.get().getDhcptabMgr().deleteDhcptab(); - } catch (Throwable e) { - addError(ResourceStrings.getString( - "unconfigure_error_dhcptab"), - e.getMessage()); - } - try { - updateProgress(++checkpoint, - ResourceStrings.getString( - "unconfigure_dhcptab_deleted")); - } catch (InterruptedException e) { - closeDialog(); - return; - } - } - } - - // Remove the defaults file last, else stuff above may fail. - try { - serviceMgr.removeDefaults(); - } catch (Throwable e) { - addError(ResourceStrings.getString( - "unconfigure_error_defaults"), e.getMessage()); - } - try { - updateProgress(++checkpoint, ResourceStrings.getString( - "unconfigure_defaults_deleted")); - } catch (InterruptedException e) { - closeDialog(); - return; - } - - if (errorsOccurred()) { - displayErrors(ResourceStrings.getString( - "unconfigure_error_messages")); - } - closeDialog(); - } - }; - } - - protected String getHelpKey() { - if (DhcpmgrApplet.modeIsRelay) { - return "unconfigure_relay"; - } else { - return "unconfigure_server"; - } - } - - protected void fireActionPerformed() { - fireActionPerformed(this, DialogActions.OK); - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ViewMacroDialog.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ViewMacroDialog.java deleted file mode 100644 index 1fcbde3bf1..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/client/ViewMacroDialog.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.client; - -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.event.*; -import javax.swing.table.*; - -import java.awt.*; -import java.awt.event.*; -import java.util.*; - -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.ui.*; - -/** - * This dialog allows the user to view the contents of a macro, - */ -public class ViewMacroDialog extends JDialog { - - class MacroTableModel extends AbstractTableModel { - private Macro macro; - - public MacroTableModel() { - setMacro(new Macro()); - } - - public MacroTableModel(Macro m) { - super(); - setMacro(m); - } - - public void setMacro(Macro m) { - macro = m; - fireTableDataChanged(); - } - - public int getRowCount() { - return macro.optionCount(); - } - - public int getColumnCount() { - return 2; - } - - public Object getValueAt(int row, int column) { - OptionValue v = null; - try { - v = macro.getOptionAt(row); - } catch (ArrayIndexOutOfBoundsException e) { - return null; - } - if (v == null) { - return null; - } - switch (column) { - case 0: - return v.getName(); - case 1: - return v.getValue(); - default: - return null; - } - } - - public Class getColumnClass(int column) { - switch (column) { - case 0: - case 1: - return String.class; - default: - super.getColumnClass(column); - } - return null; - } - - public String getColumnName(int column) { - switch (column) { - case 0: - return ResourceStrings.getString("option_column"); - case 1: - return ResourceStrings.getString("value_column"); - default: - super.getColumnName(column); - } - return null; - } - } - - private JTextField name; - private AutosizingTable macroTable; - private MacroTableModel macroTableModel; - private JButton closeButton; - - /** - * Construct the dialog. - * @arg owner The owning dialog - * @arg c The component relative to which we should be positioned - * @arg macro The macro we're viewing - */ - public ViewMacroDialog(Dialog owner, Component c, Macro macro) { - super(owner); - setLocationRelativeTo(c); - - setTitle(ResourceStrings.getString("view_macro_title")); - - getContentPane().setLayout(new BoxLayout(getContentPane(), - BoxLayout.Y_AXIS)); - JPanel mainPanel = new JPanel(new BorderLayout()); - mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - - name = new JTextField(30); - name.setEditable(false); - JPanel panel = new JPanel(); - - Mnemonic mnName = - new Mnemonic(ResourceStrings.getString("name_label")); - JLabel nLbl = new JLabel(mnName.getString()); - nLbl.setLabelFor(panel); - nLbl.setToolTipText(mnName.getString()); - nLbl.setDisplayedMnemonic(mnName.getMnemonic()); - panel.add(nLbl); - panel.add(name); - mainPanel.add(panel, BorderLayout.NORTH); - - JPanel contentsPanel = new JPanel(); - contentsPanel.setLayout(new BorderLayout()); - Border b = BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(Color.black), - BorderFactory.createEmptyBorder(5, 10, 5, 10)); - contentsPanel.setBorder(BorderFactory.createTitledBorder(b, - ResourceStrings.getString("contents_label"))); - contentsPanel.setToolTipText( - ResourceStrings.getString("contents_label")); - macroTableModel = new MacroTableModel(); - macroTable = new AutosizingTable(macroTableModel); - macroTable.getTableHeader().setReorderingAllowed(false); - macroTable.getTableHeader().setResizingAllowed(false); - - JScrollPane macroTablePane = new JScrollPane(macroTable); - // Resize table as otherwise it asks for a huge area - Dimension d = macroTable.getPreferredScrollableViewportSize(); - d.height = 100; - d.width = 300; - macroTable.setPreferredScrollableViewportSize(d); - - contentsPanel.add(macroTablePane, BorderLayout.CENTER); - mainPanel.add(contentsPanel, BorderLayout.CENTER); - - getContentPane().add(mainPanel); - getContentPane().add(new JSeparator()); - - JPanel buttonPanel = new JPanel(); - - Mnemonic mnOK = - new Mnemonic(ResourceStrings.getString("ok")); - closeButton = new JButton(mnOK.getString()); - closeButton.setToolTipText(mnOK.getString()); - closeButton.setMnemonic(mnOK.getMnemonic()); - - buttonPanel.add(closeButton); - closeButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - setVisible(false); - dispose(); - } - }); - - getContentPane().add(buttonPanel); - - name.setText(macro.getKey()); - macroTableModel.setMacro(macro); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/ExportController.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/ExportController.java deleted file mode 100644 index a6edc3a52e..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/ExportController.java +++ /dev/null @@ -1,426 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.common; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.ArrayList; - -import com.sun.dhcpmgr.bridge.BridgeException; -import com.sun.dhcpmgr.bridge.ExistsException; -import com.sun.dhcpmgr.data.Network; -import com.sun.dhcpmgr.data.ActionError; -import com.sun.dhcpmgr.server.DhcpMgr; - -/** - * ExportController contains the logic to export the server's data to - * a file for later import on either this server or some other server. - * Users of this class must implement the Exporter interface in order - * to provide communication. - * @see Exporter - * @see ImportController - */ -public class ExportController { - Exporter exporter; - DhcpMgr server; - String user; - String file; - private boolean allNets = false, allMacros = false, allOptions = false; - // Statics used to ensure we never have null array references - private static final Network [] emptyNets = new Network[0]; - private static final String [] emptyMacros = new String[0]; - private static final String [] emptyOptions = new String[0]; - Network [] networks = emptyNets; - String [] macros = emptyMacros; - String [] options = emptyOptions; - /* - * The following constants are heuristics used to estimate the time - * required to complete each step of the export process; they're used to - * allow a GUI progress meter to pop up and behave relatively correctly. - * We can't afford from a performance point of view to be precise as it - * would defeat the purpose of our export architecture, so we try to - * make sure the user gets at least some idea of where we are in the - * process. The *OPS constants indicate an estimate of how expensive - * the delete operations are relative to the export operations. YMMV. - */ - private static final int OPTION_DELETE_OPS = 2; - private static final int MACRO_DELETE_OPS = 2; - private static final int NETWORK_DELETE_OPS = 2; - private static final int DEFAULT_OPTION_COUNT = 10; - private static final int DEFAULT_MACRO_COUNT = 50; - private static final int DEFAULT_CLIENTS_PER_NET = 150; - - /** - * Construct an ExportController with the given Exporter and a - * server-side to use to perform the export. Don't pass in "null" for - * either argument; the implementation does not validate these inputs. - * @param exporter The exporting object - * @param server The server which will do the work for us. - */ - public ExportController(Exporter exporter, DhcpMgr server) { - this.exporter = exporter; - this.server = server; - } - - /** - * Set the name of the user performing the export. This is - * recorded in the export file for reference at import. - * @param user The name of the user - */ - public void setUser(String user) { - this.user = user; - } - - /** - * Set the name of the file to which to export. - * @param file the full pathname of the file to export into - */ - public void setFile(String file) { - this.file = file; - } - - /** - * Specify that all networks are to be exported - */ - public void setAllNetworks() { - allNets = true; - networks = emptyNets; - } - - /** - * Specify the networks to be exported. - * @param networks An array of Network objects which should be exported - */ - public void setNetworks(Network [] networks) { - allNets = false; - // Never allow networks to be null - if (networks != null) { - this.networks = networks; - } else { - this.networks = emptyNets; - } - } - - /** - * Specify that all macros should be exported. - */ - public void setAllMacros() { - allMacros = true; - macros = emptyMacros; - } - - /** - * Specify the macros to be exported. - * @param macros An array of macro names - */ - public void setMacros(String [] macros) { - allMacros = false; - // Never allow macros to be null - if (macros != null) { - this.macros = macros; - } else { - this.macros = emptyMacros; - } - } - - /** - * Specify that all options should be exported - */ - public void setAllOptions() { - allOptions = true; - options = emptyOptions; - } - - /** - * Specify the options to be exported. - * @param options An array of option names - */ - public void setOptions(String [] options) { - allOptions = false; - // Never allow options to be null - if (options != null) { - this.options = options; - } else { - this.options = emptyOptions; - } - } - - /** - * Perform the actual export. - * @param deleteData True if data should be deleted after a successful - * export. - * @param overwrite True if file should be forcibly overwritten. An - * ExistsException will be thrown if the file exists and overwrite is - * false. - * @return true if the export succeeded, false on failure. - */ - public boolean exportData(boolean deleteData, boolean overwrite) - throws ExistsException { - - Object ref = null; - - // Value to return; default to false for failure - boolean retval = false; - - // Default to deleting the file on any errors - boolean deleteFile = true; - - if (allNets) { - try { - // Load network list - setNetworks(server.getNetMgr().getNetworks()); - } catch (Exception e) { - displayException(e, - ResourceStrings.getString("exp_err_loading_networks")); - return false; - } - } - - /* - * Number of records in the export file is number of networks, plus 1 - * for options, plus 1 for macros. - */ - int recCount = networks.length + 2; - - // Calculate total number of estimated ops for progress - int optionOps = allOptions ? DEFAULT_OPTION_COUNT : options.length; - int optionDelOps = 0; - int macroOps = allMacros ? DEFAULT_MACRO_COUNT : macros.length; - int macroDelOps = 0; - int netOps = DEFAULT_CLIENTS_PER_NET * networks.length; - int netDelOps = 0; - int totalOps = optionOps + macroOps + netOps; - if (totalOps == 0) { - // Nothing to export!!! - exporter.displayError(ResourceStrings.getString("exp_err_no_data")); - return false; - } - // If user wants to delete, add to number of ops required - if (deleteData) { - optionDelOps = optionOps * OPTION_DELETE_OPS; - macroDelOps = macroOps * MACRO_DELETE_OPS; - netDelOps = netOps * NETWORK_DELETE_OPS; - totalOps += optionDelOps + macroDelOps + netDelOps; - } - - /* - * Open the file; catch IO errors, but if we get an ExistsException we - * just let that through to the caller, who's supposed to deal with it - * appropriately. - */ - try { - ref = server.openExportFile(file, user, recCount, networks, - overwrite); - // If lock couldn't be obtained, display error and abort - if (ref == null) { - String [] args = new String[2]; - args[0] = server.getDhcpServiceMgr().getServerName(); - args[1] = server.getLockPath(); - MessageFormat form = new MessageFormat( - ResourceStrings.getString("lock_error")); - exporter.displayError(form.format(args)); - return false; - } - } catch (IOException e) { - displayException(e, ResourceStrings.getString("exp_err_io")); - return false; - } - - try { - - // Initialize progress with our expected number of operations - exporter.initializeProgress(totalOps); - int progress = 0; - - // Now export the options - if (optionOps != 0) { - // Only update progress if we're actually doing something here - exporter.updateProgress(progress, - ResourceStrings.getString("exp_exporting_options")); - } - try { - server.exportOptions(ref, allOptions, options); - } catch (BridgeException e) { - displayException(e, - ResourceStrings.getString("exp_err_exporting_options")); - throw new InterruptedException(); - } - progress += optionOps; - - if (macroOps != 0) { - // Only update progress if we're actually doing something here - exporter.updateProgress(progress, - ResourceStrings.getString("exp_exporting_macros")); - } - - // Now export the macros - try { - server.exportMacros(ref, allMacros, macros); - } catch (BridgeException e) { - displayException(e, - ResourceStrings.getString("exp_err_exporting_macros")); - throw new InterruptedException(); - } - progress += macroOps; - - // Set up for progress messages - MessageFormat form = new MessageFormat( - ResourceStrings.getString("exp_exporting_network")); - String [] nets = new String[1]; - - // Now export each network in turn - for (int i = 0; i < networks.length; ++i) { - // Export the network - try { - nets[0] = networks[i].toString(); - exporter.updateProgress(progress, form.format(nets)); - server.exportNetwork(ref, networks[i]); - progress += DEFAULT_CLIENTS_PER_NET; - } catch (BridgeException e) { - MessageFormat fmt = new MessageFormat( - ResourceStrings.getString("exp_err_exporting_network")); - String [] args = new String [] { nets[0], e.getMessage() }; - exporter.displayError(fmt.format(args)); - throw new InterruptedException(); - } - } - - // Success; don't delete the file - deleteFile = false; - - // If user wants data deleted, too, then do it now - if (deleteData) { - ActionError [] optionErrs, macroErrs; - - // Delete options - if (optionDelOps != 0) { - // Only update progress if something to delete - exporter.updateProgress(progress, - ResourceStrings.getString("exp_deleting_options")); - } - if (allOptions) { - try { - optionErrs = server.getDhcptabMgr().deleteAllOptions(); - } catch (BridgeException e) { - optionErrs = new ActionError[1]; - optionErrs[0] = new ActionError( - ResourceStrings.getString("all_options"), e); - } - } else { - optionErrs = server.getDhcptabMgr().deleteOptions(options); - } - progress += optionDelOps; - - // Delete macros - if (macroDelOps != 0) { - // Only update progress if something to delete - exporter.updateProgress(progress, - ResourceStrings.getString("exp_deleting_macros")); - } - if (allMacros) { - try { - macroErrs = server.getDhcptabMgr().deleteAllMacros(); - } catch (BridgeException e) { - macroErrs = new ActionError[1]; - macroErrs[0] = new ActionError( - ResourceStrings.getString("all_macros"), e); - } - } else { - macroErrs = server.getDhcptabMgr().deleteMacros(macros); - } - progress += macroDelOps; - - // Delete each network in turn - form = new MessageFormat( - ResourceStrings.getString("exp_deleting_network")); - ArrayList errList = new ArrayList(); - for (int i = 0; i < networks.length; ++i) { - nets[0] = networks[i].toString(); - exporter.updateProgress(progress, form.format(nets)); - try { - server.getNetMgr().deleteNetwork(nets[0], false); - } catch (BridgeException e) { - errList.add(new ActionError(nets[0], e)); - } - progress += DEFAULT_CLIENTS_PER_NET * NETWORK_DELETE_OPS; - } - - // This update informs caller we're done - exporter.updateProgress(progress, - ResourceStrings.getString("export_completed")); - // Now display whatever errors happened during delete - if (optionErrs != null && optionErrs.length > 0) { - exporter.displayErrors( - ResourceStrings.getString("exp_err_deleting_options"), - ResourceStrings.getString("exp_option"), - optionErrs); - } - - if (macroErrs != null && macroErrs.length > 0) { - exporter.displayErrors( - ResourceStrings.getString("exp_err_deleting_macros"), - ResourceStrings.getString("exp_macro"), - macroErrs); - } - - if (!errList.isEmpty()) { - exporter.displayErrors( - ResourceStrings.getString("exp_err_deleting_networks"), - ResourceStrings.getString("exp_network"), - (ActionError [])errList.toArray(new ActionError[0])); - } - } - retval = true; - } catch (InterruptedException e) { - /* - * User wanted to cancel, or some serious failure occurred; in the - * former case no need to display anything, in the latter it - * was already displayed before we got here, so just return. - */ - retval = false; - } catch (Exception e) { - // I/O error of some sort. Display it before returning. - displayException(e, ResourceStrings.getString("exp_err_io")); - retval = false; - } finally { - // Always close before leaving; display any resulting errors - try { - server.closeExportFile(ref, deleteFile); - } catch (IOException e) { - displayException(e, - ResourceStrings.getString("exp_err_closing_file")); - } - } - return retval; - } - - // Utility method to display an error message for an exception - private void displayException(Exception e, String format) { - MessageFormat form = new MessageFormat(format); - String [] args = new String [] { e.getMessage() }; - exporter.displayError(form.format(args)); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/Exporter.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/Exporter.java deleted file mode 100644 index 910c34682a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/Exporter.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.common; - -import com.sun.dhcpmgr.data.ActionError; - -/** - * This interface is implemented by users of the ExportController to - * allow it to communicate progress information during the export process. - * @see ExportController - */ -public interface Exporter { - /** - * Callback to initialize the exporter's progress display. - * @param length The number of steps expected for the export process. - */ - public void initializeProgress(int length); - - /** - * Callback to update progress display. - * @param done The number of steps completed. - * @param message The message corresponding to this step. - */ - public void updateProgress(int done, String message) - throws InterruptedException; - - /** - * Callback to display a single error message. - * @param message The message to display. - */ - public void displayError(String message); - - /** - * Callback to display a set of errors from the delete process. - * @param contextMsg Message identifying the context for the errors - * @param label The type of objects for which the errors occurred - * @param errs An array of errors to be displayed. - */ - public void displayErrors(String contextMsg, String label, - ActionError [] errs); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/ImportController.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/ImportController.java deleted file mode 100644 index 0fc6bf79ed..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/ImportController.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.common; - -import java.io.IOException; -import java.text.MessageFormat; - -import com.sun.dhcpmgr.data.ExportHeader; -import com.sun.dhcpmgr.data.ActionError; -import com.sun.dhcpmgr.data.Network; -import com.sun.dhcpmgr.server.DhcpMgr; -import com.sun.dhcpmgr.bridge.BridgeException; - -/** - * ImportController contains the logic to import data from a file to the - * server's data store. The file must have been written using the export - * procedure defined by ExportController. Users of this class must implement - * the Importer interface, which allows this class to communicate with the - * user. - * @see Importer - * @see ExportController - */ -public class ImportController { - Importer importer; - DhcpMgr server; - String file; - Object ref = null; - ExportHeader header = null; - /* - * The following constants are heuristics used to estimate the time - * required to complete each step of the import process; they're used to - * allow a GUI progress meter to pop up and behave relatively correctly. - * We can't afford from a performance point of view to be precise as it - * would defeat the purpose of our import architecture, so we try to - * make sure the user gets at least some idea of where we are in the - * process. The *OPS constants indicate an estimate of how expensive - * the various operations are relative to each other in a "typical" - * import, the assumption being that there are 5 macros exported to every - * option exported, and that there are around 150 clients per network. - * Obviously these can vary widely, but it gets the idea across pretty well. - */ - private static final int OPTION_OPS = 1; - private static final int MACRO_OPS = 5; - private static final int NET_OPS = 150; - - /** - * Construct an ImportController with the given Importer and server - * implementation to use for the import process. Don't pass in "null" - * for either argument; the implementation does not validate these inputs. - * @param importer The importing object - * @param server The server which will perform the work - */ - public ImportController(Importer importer, DhcpMgr server) { - this.importer = importer; - this.server = server; - } - - /** - * Set the name of the file to be used for the import - * @param file The name of the file. - */ - public void setFile(String file) { - // We can only have one file open at a time; close any currently open. - closeFile(); - this.file = file; - } - - /** - * Close the file and clean up references - */ - public void closeFile() { - if (ref != null) { - try { - // We *never* delete the file here - server.closeImportFile(ref, false); - } catch (IOException e) { - displayError(ResourceStrings.getString("imp_err_io"), - e.getMessage()); - } - } - ref = null; - header = null; - } - /** - * Retrieve the header from the file. - * @return the header record from the file - */ - public ExportHeader getHeader() - throws ClassNotFoundException, IOException { - // If header not already read, then read it - if (header == null) { - // If file not yet open, then open it now - if (ref == null) { - ref = server.openImportFile(file); - if (ref == null) { - // Import/export lock not available, display error and abort - String [] args = new String[2]; - args[0] = server.getDhcpServiceMgr().getServerName(); - args[1] = server.getLockPath(); - MessageFormat form = new MessageFormat( - ResourceStrings.getString("lock_error")); - importer.displayError(form.format(args)); - return null; - } - } - header = server.getExportHeader(ref); - } - return header; - } - - /** - * Import the data, optionally overwriting any conflicting data - * @param overwrite true if conflicting objects should be overwritten. - * @return true if the import completed successfully, false if not - */ - public boolean importData(boolean overwrite) { - // Default return is that import did not complete - boolean retval = false; - int totalOps = 0; - try { - // Ensure file is open and header has been read - if (getHeader() == null) { - // Couldn't get header; abort - return false; - } - - /* - * Initialize progress display; recCount is number of networks + - * one for macros and one for options. - */ - int recCount = header.getRecCount(); - totalOps = OPTION_OPS + MACRO_OPS + NET_OPS * (recCount - 2); - importer.initializeProgress(totalOps); - int progress = 0; - - // Update progress, and import the options - importer.updateProgress(progress, - ResourceStrings.getString("importing_options")); - ActionError [] result = server.importOptions(ref, overwrite); - if (result.length > 0) { - importer.displayErrors( - ResourceStrings.getString("imp_err_importing_options"), - ResourceStrings.getString("imp_option"), result); - } - - // Update progress and import the macros - progress += OPTION_OPS; - importer.updateProgress(progress, - ResourceStrings.getString("importing_macros")); - result = server.importMacros(ref, overwrite); - if (result.length > 0) { - importer.displayErrors( - ResourceStrings.getString("imp_err_importing_macros"), - ResourceStrings.getString("imp_macro"), result); - } - - // Set up for network progress messages - progress += MACRO_OPS; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("importing_network")); - String [] args = new String[1]; - - /* - * Get list of networks from the header; ExportController never - * writes a null reference, always a zero-length array at worst. - */ - Network [] nets = header.getNetworks(); - for (int i = 0; i < nets.length; ++i) { - // For each network, update progress and import it - args[0] = nets[i].toString(); - importer.updateProgress(progress, form.format(args)); - result = server.importNetwork(nets[i], ref, overwrite); - if (result.length > 0) { - MessageFormat errFmt = new MessageFormat( - ResourceStrings.getString("imp_err_importing_net")); - importer.displayErrors(errFmt.format(args), - ResourceStrings.getString("imp_address"), result); - } - progress += NET_OPS; - } - retval = true; - } catch (InterruptedException e) { - // User asked us to stop; nothing to do but let it fall through - } catch (ClassNotFoundException e) { - // Bad version of file - displayError(ResourceStrings.getString("imp_err_file_fmt"), - e.getMessage()); - } catch (Exception e) { - // Error reading the file - displayError(ResourceStrings.getString("imp_err_io"), - e.getMessage()); - } finally { - // Finish progress - try { - importer.updateProgress(totalOps, - ResourceStrings.getString("import_completed")); - } catch (InterruptedException e) { - // Ignore - } - // Always close import file - closeFile(); - } - return retval; - } - - private void displayError(String format, String data) { - MessageFormat form = new MessageFormat(format); - String [] args = new String [] { data }; - importer.displayError(form.format(args)); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/Importer.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/Importer.java deleted file mode 100644 index cc0f37dba1..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/Importer.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.common; - -import com.sun.dhcpmgr.data.ActionError; - -/** - * This interface is implemented by users of the ImportController to - * allow it to communicate progress information during the import process. - * @see ImportController - */ -public interface Importer { - /** - * Callback to initialize the importer's progress display - * @param length The number of steps expected for the import process. - */ - public void initializeProgress(int length); - - /** - * Callback to update progress display - * @param done The number of steps completed. - * @param message The message corresponding to this step. - */ - public void updateProgress(int done, String message) - throws InterruptedException; - - /** - * Callback to display an error message. - * @param message The message to display - */ - public void displayError(String message); - - /** - * Callback to display a list of error messages. - * @param msg Message identifying contect for the errors - * @param label The type of objects for which the errors occurred - * @param errors An array of ActionError - */ - public void displayErrors(String msg, String label, ActionError [] errors); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/Makefile deleted file mode 100644 index 76ecf25086..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/Makefile +++ /dev/null @@ -1,76 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/Makefile -# - -# Place high-level classes first to minimize build time -CLASSFILES = ExportController.class \ - ImportController.class \ - ResourceStrings.class - -include $(SRC)/Makefile.master - -CLASSPATH= $(SRC)/cmd/cmd-inet/usr.sadm/dhcpmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -MSGDIR= $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/common -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr \ - $(MSGDIR) - -MSGFILES= ResourceBundle.properties -MSGS= $(MSGFILES:%=$(MSGDIR)/%) - -CLEANFILES= *.class -CLOBBERFILES= - -.KEEP_STATE: - -all: $(CLASSFILES) - -install: all - -_msg: $(MSGDIRS) $(MSGS) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - -lint: - -clean: FRC - $(RM) $(CLEANFILES) - -clobber: clean - -FRC: diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/ResourceBundle.properties b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/ResourceBundle.properties deleted file mode 100644 index 0f39bb26af..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/ResourceBundle.properties +++ /dev/null @@ -1,73 +0,0 @@ -# -#pragma ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# Common lock error -lock_error=The lock file, {1},\nhas been detected on server, {0}.\nThis indicates that another export or import is already running.\nPlease try again later. - -# Export resources -exp_exporting_options=Exporting options... -exp_exporting_macros=Exporting macros... -exp_exporting_network=Exporting network {0}... - -exp_deleting_options=Deleting options... -exp_deleting_macros=Deleting macros... -exp_deleting_network=Deleting network {0}... - -export_completed=Export completed - -exp_err_loading_networks=Unable to load the list of networks; error was:\n{0} -exp_err_no_data=No data was specified for export. -exp_err_io=I/O Error while exporting, message was:\n{0} -exp_err_closing_file=Error while closing the export file, mesasge was:\n{0} -exp_err_exporting_options=Error while exporting options, message was:\n{0} -exp_err_exporting_macros=Error while exporting macros, message was:\n{0} -exp_err_exporting_network=Error while exporting network {0}, message was:\n{1} -exp_err_deleting_options=The following errors occurred while deleting options: -exp_err_deleting_macros=The following errors occurred while deleting macros: -exp_err_deleting_networks=The following errors occurred while deleting networks: - -all_options=All Options -all_macros=All Macros -exp_option=Option -exp_macro=Macro -exp_network=Network - -# Import resources -importing_options=Importing Options... -importing_macros=Importing Macros... -importing_network=Importing Network {0}... -import_completed=Import completed - -imp_err_importing_options=The following errors occurred while importing options: -imp_err_importing_macros=The following errors occurred while importing macros: -imp_err_importing_net=The following errors occurred while importing network {0}: -imp_err_file_fmt=The import file contained an unknown class; the detailed message was:\n{0} -imp_err_io=The file could not be imported due to the following input error:\n{0} - -imp_option=Option -imp_macro=Macro -imp_address=Address diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/ResourceStrings.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/ResourceStrings.java deleted file mode 100644 index 3f89b74ec1..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/common/ResourceStrings.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.common; - -import java.util.*; - -/** - * This class provides a convenient method to retrieve resources for - * the common package. - */ -public class ResourceStrings { - - /** - * The handle to the resource bundle for the module. - */ - private static ResourceBundle bundle = null; - - /** - * Return a string from the resource bundle. - * @param key the key to the resource bundle string. - * @return the resource bundle string. - */ - public static String getString(String key) { - String msg = null; - try { - if (bundle == null) { - bundle = ResourceBundle.getBundle( - "com.sun.dhcpmgr.common.ResourceBundle", - Locale.getDefault()); - } - msg = bundle.getString(key); - } catch (Throwable e) { - msg = new String(key); - } - return msg; - - } // getString - -} // ResourceStrings diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ActionError.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ActionError.java deleted file mode 100644 index c0ddb78777..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ActionError.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -package com.sun.dhcpmgr.data; - -import java.io.Serializable; - -/** - * This class represents an error which occurred during some action - */ -public class ActionError implements Serializable { - - /** - * The name of the element that was acted upon - */ - private String name; - - /** - * The exception that occurred while acting on the named element - */ - private Exception e; - - /** - * Basic constructor. - * @param name the element name. - */ - public ActionError(String name) { - this.name = name; - e = null; - } // constructor - - /** - * Create a fully formed versoin of this object - * @param name The name of the element - * @param exception The exception which occurred - */ - public ActionError(String name, Exception exception) { - this.name = name; - e = exception; - } - - /** - * Returns the element name. - * @return the element name. - */ - public String getName() { - return name; - } // getName - - /** - * Sets the exception. - * @param exception the exception to associate with the element. - */ - public void setException(Exception e) { - this.e = e; - } // setException - - /** - * Returns the exception. - * @return the exception. - */ - public Exception getException() { - return e; - } // getException -} // ActionError diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/AsciiOptionValue.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/AsciiOptionValue.java deleted file mode 100644 index bf6df4dada..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/AsciiOptionValue.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.data; - -import java.util.Vector; -import java.util.Enumeration; - -public class AsciiOptionValue extends OptionValue { - private String name; - private String value; - private boolean valid; - - // Serialization id for this class - static final long serialVersionUID = -4937655446360683504L; - - protected AsciiOptionValue(String name) { - this.name = name; - value = null; - valid = false; - } - - public String getName() { - return name; - } - - public String getValue() { - // Before we return the value, we go through and escape special chars. - StringBuffer retValue = new StringBuffer(); - char [] c = value.toCharArray(); - for (int i = 0; i < c.length; ++i) { - if (c[i] == '\\' || c[i] == '"') { - retValue.append('\\'); - } - retValue.append(c[i]); - } - return retValue.toString(); - } - - public void setValue(Object value) throws ValidationException { - // Find option in option definition table in order to validate the data - Option option = OptionsTable.getTable().get(name); - if (option == null) { - Object [] args = { name }; - throwException("invalid_option", args); - } - if (value instanceof String) { - String newValue = (String)value; - // Either quoted, or not, but must balance - if (newValue.startsWith("\"") ^ newValue.endsWith("\"")) { - Object [] args = { name, - Option.getTypeDhcptabString(option.getType()) }; - throwException("invalid_option_value", args); - } - if (newValue.startsWith("\"")) { - newValue = newValue.substring(1, newValue.length() - 1); - } - if (newValue.length() == 0) { - // Empty strings are not acceptable - Object [] args = { name, - Option.getTypeDhcptabString(option.getType()) }; - throwException("invalid_option_value", args); - } - // Check that the resulting length is OK - if ((option.getMaximum() != 0) - && (newValue.length() > option.getMaximum())) { - Object [] args = { name, - Integer.toString(option.getMaximum()) }; - throwException("invalid_option_maximum", args); - } - this.value = newValue; - valid = true; - } else if (value instanceof Vector) { - /* - * We generate the value by creating a blank-separated list of - * tokens; each token is the product of a toString() on the - * vector's elements. - */ - StringBuffer b = new StringBuffer(); - Enumeration en = ((Vector)value).elements(); - while (en.hasMoreElements()) { - if (b.length() != 0) { - b.append(' '); - } - b.append(en.nextElement().toString()); - } - setValue(b.toString()); - } else { - // Anything else should just tell us what it looks like as a string. - setValue(value.toString()); - } - } - - public String toString() { - return (getName() + "=\"" + getValue() + "\""); - } - - public boolean isValid() { - return valid; - } - - public Object clone() { - AsciiOptionValue v = new AsciiOptionValue(name); - v.value = value; - v.valid = valid; - return v; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/BogusOptionValue.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/BogusOptionValue.java deleted file mode 100644 index 56f4c5b189..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/BogusOptionValue.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data; - -import java.util.Vector; -import java.util.Enumeration; - -/** - * This class provides a way for us to handle errors in the dhcptab which - * may have been introduced through the command line or direct editing of - * the table. The idea is for the OptionValueFactory to trap bad option - * names or values and store them in an instance of this class so that the - * user can then be told about the error and allowed to fix it. - */ -public class BogusOptionValue extends OptionValue { - private String name; - private String value; - - // Serialization id for this class - static final long serialVersionUID = 8573418100554161901L; - - protected BogusOptionValue(String name) { - this.name = name; - value = null; - } - - protected BogusOptionValue(String name, Object value) { - this.name = name; - setValue(value); - } - - public String getName() { - return name; - } - - public String getValue() { - return value; - } - - public void setValue(Object value) { - if (value instanceof Vector) { - /* - * We generate the value by creating a blank-separated list of - * tokens; each token is the product of a toString() on the - * vector's elements. - */ - StringBuffer b = new StringBuffer(); - Enumeration en = ((Vector)value).elements(); - while (en.hasMoreElements()) { - if (b.length() != 0) { - b.append(' '); - } - b.append(en.nextElement().toString()); - } - setValue(b.toString()); - } else if (value instanceof String) { - this.value = (String)value; - } else { - // Anything else should just tell us what it looks like as a string. - setValue(value.toString()); - } - } - - public String toString() { - return (getName() + "=\"" + getValue() + "\""); - } - - public boolean isValid() { - // This kind of option is never valid - return false; - } - - public Object clone() { - return new BogusOptionValue(name, value); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/BooleanOptionValue.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/BooleanOptionValue.java deleted file mode 100644 index 8aca6da304..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/BooleanOptionValue.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.data; - -import java.util.Vector; - -public class BooleanOptionValue extends OptionValue { - private String name; - - // Serialization id for this class - static final long serialVersionUID = 5379063769810230706L; - - protected BooleanOptionValue(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public String getValue() { - return ""; - } - - public void setValue(Object value) throws ValidationException { - // Booleans must have an empty value - Option option = OptionsTable.getTable().get(name); - if (value != null && value.toString().length() != 0) { - Object [] args = { name, - Option.getTypeDhcptabString(option.getType()) }; - throwException("invalid_option_value", args); - } - } - - public String toString() { - return getName(); - } - - public boolean isValid() { - return true; - } - - public Object clone() { - return new BooleanOptionValue(name); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpClientFlagType.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpClientFlagType.java deleted file mode 100644 index 4564775994..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpClientFlagType.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -package com.sun.dhcpmgr.data; - -/** - * This class represents a flag type for a record in a DHCP network table. - */ -public class DhcpClientFlagType { - private byte numericVal; - private char charVal; - private String keyword; - - public DhcpClientFlagType() { - numericVal = 0; - charVal = '0'; - keyword = ""; - } - - public DhcpClientFlagType(byte numericVal, char charVal, String keyword) { - - this.numericVal = numericVal; - this.charVal = charVal; - this.keyword = keyword; - } - - public byte getNumericVal() { - return numericVal; - } - - public char getCharVal() { - return charVal; - } - - public String getKeyword() { - return keyword; - } - - public boolean isSet(byte flags) { - return ((flags & numericVal) != 0); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpClientFlagTypes.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpClientFlagTypes.java deleted file mode 100644 index e70c23f652..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpClientFlagTypes.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -package com.sun.dhcpmgr.data; - -/** - * This class contains definitiion for all the valid DHCP client flags. - */ -public class DhcpClientFlagTypes { - - public static final DhcpClientFlagType BOOTP = - new DhcpClientFlagType((byte)8, 'B', new String("BOOTP")); - - public static final DhcpClientFlagType UNUSABLE = - new DhcpClientFlagType((byte)4, 'U', new String("UNUSABLE")); - - public static final DhcpClientFlagType MANUAL = - new DhcpClientFlagType((byte)2, 'M', new String("MANUAL")); - - public static final DhcpClientFlagType PERMANENT = - new DhcpClientFlagType((byte)1, 'P', new String("PERMANENT")); - - public static final DhcpClientFlagType DYNAMIC = - new DhcpClientFlagType((byte)0, 'D', new String("DYNAMIC")); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpClientRecord.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpClientRecord.java deleted file mode 100644 index 483225a38b..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpClientRecord.java +++ /dev/null @@ -1,674 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data; - -import java.util.Date; -import java.text.SimpleDateFormat; -import java.text.DateFormat; -import java.util.StringTokenizer; -import java.io.Serializable; - -/** - * This class represents a record in a DHCP network table. It can also be used - * to manage an associated hosts record by setting the client name; that effect - * is not part of this class, but rather is provided by the DhcpNetMgr. - */ -public class DhcpClientRecord implements Serializable, Comparable, Cloneable { - - /** - * Default values for class attributes. - */ - public static final String DEFAULT_CLIENT_ID = new String("00"); - public static final String DEFAULT_FLAGS = new String("00"); - public static final String DEFAULT_CLIENT_NAME = new String(); - public static final String DEFAULT_EXPIRATION = new String("0"); - public static final String DEFAULT_SIGNATURE = new String("0"); - public static final String DEFAULT_MACRO = new String("UNKNOWN"); - public static final String DEFAULT_COMMENT = new String(); - - /** - * Expiration special values. - */ - private static final String EXPIRATION_ZERO = new String("0"); - private static final String EXPIRATION_FOREVER = new String("-1"); - - private String clientId; - private byte flags; - private IPAddress clientIP; - private IPAddress serverIP; - private Date expiration; - private String signature = DEFAULT_SIGNATURE; - private String macro; - private String comment; - private String clientName = null; - private String serverName = null; - - // Serialization id of this class - static final long serialVersionUID = 5007310554198923085L; - - /** - * Constructs a basic, empty client record. - */ - public DhcpClientRecord() { - clientId = DEFAULT_CLIENT_ID; - macro = comment = null; - flags = 0; - clientIP = serverIP = null; - expiration = null; - signature = DEFAULT_SIGNATURE; - } - - /** - * Constructs a client record with a client IP. - * @param clientIP the client IP address for the record. - */ - public DhcpClientRecord(String clientIP) throws ValidationException { - setDefaults(); - setClientIP(new IPAddress(clientIP)); - } - - /** - * Constructs a fully specified client record - * @param clientId Client's unique identifier - * @param flags Status flags for the record - * @param clientIP Client's IP address - * @param serverIP IP address of owning server - * @param expiration Lease expiration time in seconds since Unix epoch - * @param macro Configuration macro associated with this record - * @param comment User notes on this record - */ - public DhcpClientRecord(String clientId, String flags, String clientIP, - String serverIP, String expiration, String macro, - String comment) throws ValidationException { - - this(clientId, flags, clientIP, serverIP, expiration, macro, - comment, DEFAULT_SIGNATURE); - } - - /** - * Constructs a fully specified client record - * @param clientId Client's unique identifier - * @param flags Status flags for the record - * @param clientIP Client's IP address - * @param serverIP IP address of owning server - * @param expiration Lease expiration time in seconds since Unix epoch - * @param macro Configuration macro associated with this record - * @param comment User notes on this record - * @param signature Opaque signature - */ - public DhcpClientRecord(String clientId, String flags, String clientIP, - String serverIP, String expiration, String macro, - String comment, String signature) - throws ValidationException { - setClientId(clientId); - this.flags = Byte.parseByte(flags); - setClientIP(new IPAddress(clientIP)); - setServerIP(new IPAddress(serverIP)); - setExpiration(expiration); - this.macro = macro; - this.comment = comment; - this.signature = signature; - } - - /** - * Make a copy of this record - */ - public Object clone() { - DhcpClientRecord newrec = new DhcpClientRecord(); - newrec.clientId = clientId; - newrec.flags = flags; - if (clientIP != null) { - newrec.clientIP = (IPAddress)clientIP.clone(); - } - if (serverIP != null) { - newrec.serverIP = (IPAddress)serverIP.clone(); - } - if (expiration != null) { - newrec.expiration = (Date)expiration.clone(); - } - newrec.macro = macro; - newrec.comment = comment; - newrec.clientName = clientName; - newrec.serverName = serverName; - newrec.signature = signature; - return newrec; - } - - /** - * Fully specifies the defaults for a client record - */ - public void setDefaults() - throws ValidationException { - setClientId(DEFAULT_CLIENT_ID); - setFlags(DEFAULT_FLAGS); - setClientName(DEFAULT_CLIENT_NAME); - setExpiration(DEFAULT_EXPIRATION); - setMacro(DEFAULT_MACRO); - setComment(DEFAULT_COMMENT); - } - - /** - * Retrieve the client ID - * @return Client ID as a String - */ - public String getClientId() { - return clientId; - } - - /** - * Set the client ID. See dhcp_network(4) for the rules about client - * ID syntax which are implemented here. - * @param clientId Client's unique identifier - */ - public void setClientId(String clientId) throws ValidationException { - if (clientId.length() > 128 || clientId.length() % 2 != 0) { - // Must be even number of characters, no more than 128 characters - String msg = ResourceStrings.getString("dcr_invalid_clientid"); - throw new ValidationException(msg); - } - char [] c = clientId.toCharArray(); - for (int i = 0; i < c.length; ++i) { - if ((c[i] < '0' || c[i] > '9') && (c[i] < 'A' || c[i] > 'F')) { - String msg = ResourceStrings.getString("dcr_invalid_clientid"); - throw new ValidationException(msg); - } - } - this.clientId = clientId; - if (this.clientId.length() == 0) { - this.clientId = DEFAULT_CLIENT_ID; - } - } - - /** - * Get the flags byte - * @return A <code>byte</code> containing the record's status flags - */ - public byte getFlags() { - return flags; - } - - /** - * Get the flags as a string - * @return The flag byte converted to a String - */ - public String getFlagString() { - return getFlagString(false); - } - - public String getFlagString(boolean verbose) { - - StringBuffer b = new StringBuffer(); - if (!verbose) { - b.append(flags); - // Make sure we always have a 2-character representation. - if (flags < 10) { - b.insert(0, 0); - } - } - else { - if (flags == 0) { - b.append(DhcpClientFlagTypes.DYNAMIC.getCharVal()); - } else { - if (isPermanent()) { - b.append(DhcpClientFlagTypes.PERMANENT.getCharVal()); - } - if (isManual()) { - b.append(DhcpClientFlagTypes.MANUAL.getCharVal()); - } - if (isUnusable()) { - b.append(DhcpClientFlagTypes.UNUSABLE.getCharVal()); - } - if (isBootp()) { - b.append(DhcpClientFlagTypes.BOOTP.getCharVal()); - } - } - } - return b.toString(); - } - - /** - * Test for setting of unusable flag - * @return <code>true</code> if the unusable flag is set, - * <code>false</code> if not. - */ - public boolean isUnusable() { - return DhcpClientFlagTypes.UNUSABLE.isSet(flags); - } - - /** - * Set/reset the unusable flag. - * @param state <code>true</code> if address is to be unusable - */ - public void setUnusable(boolean state) { - if (state) { - flags |= DhcpClientFlagTypes.UNUSABLE.getNumericVal(); - } else { - flags &= ~DhcpClientFlagTypes.UNUSABLE.getNumericVal(); - } - } - - /** - * Test for setting of bootp flag - * @return <code>true</code> if the bootp flag is set, - * <code>false</code> if not. - */ - public boolean isBootp() { - return DhcpClientFlagTypes.BOOTP.isSet(flags); - } - - /** - * Set/reset the bootp flag - * @param state <code>true</code> if address is reserved for BOOTP clients - */ - public void setBootp(boolean state) { - if (state) { - flags |= DhcpClientFlagTypes.BOOTP.getNumericVal(); - } else { - flags &= ~DhcpClientFlagTypes.BOOTP.getNumericVal(); - } - } - - /** - * Test for setting of manual assignment flag - * @return <code>true</code> if address is manually assigned, - * <code>false</code> if not. - */ - public boolean isManual() { - return DhcpClientFlagTypes.MANUAL.isSet(flags); - } - - /** - * Set/reset the manual assignment flag - * @param state <code>true</code> if the address is manually assigned - */ - public void setManual(boolean state) { - if (state) { - flags |= DhcpClientFlagTypes.MANUAL.getNumericVal(); - } else { - flags &= ~DhcpClientFlagTypes.MANUAL.getNumericVal(); - } - } - - /** - * Test for setting of permanent assignment flag - * @return <code>true</code> if lease is permanent, - * <code>false</code> if dynamic - */ - public boolean isPermanent() { - return DhcpClientFlagTypes.PERMANENT.isSet(flags); - } - - /** - * Set/reset the permanent assignment flag - * @param state <code>true</code> if the address is permanently leased - */ - public void setPermanent(boolean state) { - if (state) { - flags |= DhcpClientFlagTypes.PERMANENT.getNumericVal(); - } else { - flags &= ~DhcpClientFlagTypes.PERMANENT.getNumericVal(); - } - } - - /** - * Set the flags as a unit - * @param flags a <code>byte</code> setting for the flags - */ - public void setFlags(String flags) throws ValidationException { - if (flags.charAt(0) >= '0' && flags.charAt(0) <= '9') { - this.flags = Byte.parseByte(flags); - } else { - this.flags = 0; - StringTokenizer flagTokenizer = new StringTokenizer(flags, "+"); - while (flagTokenizer.hasMoreTokens()) { - String keyword = flagTokenizer.nextToken(); - if (keyword.equalsIgnoreCase( - DhcpClientFlagTypes.DYNAMIC.getKeyword())) { - // nothing to do, default is Dynamic. - } else if (keyword.equalsIgnoreCase( - DhcpClientFlagTypes.PERMANENT.getKeyword())) { - this.flags |= DhcpClientFlagTypes.PERMANENT.getNumericVal(); - } else if (keyword.equalsIgnoreCase( - DhcpClientFlagTypes.MANUAL.getKeyword())) { - this.flags |= DhcpClientFlagTypes.MANUAL.getNumericVal(); - } else if (keyword.equalsIgnoreCase( - DhcpClientFlagTypes.UNUSABLE.getKeyword())) { - this.flags |= DhcpClientFlagTypes.UNUSABLE.getNumericVal(); - } else if (keyword.equalsIgnoreCase( - DhcpClientFlagTypes.BOOTP.getKeyword())) { - this.flags |= DhcpClientFlagTypes.BOOTP.getNumericVal(); - } else { - String msg = ResourceStrings.getString("dcr_invalid_flags"); - throw new ValidationException(msg); - } - } - } - } - - /** - * Set the flags as a unit - * @param flags a <code>byte</code> setting for the flags - */ - public void setFlags(byte flags) { - this.flags = flags; - } - - /** - * Retrieve the client's IP address - * @return the client's IP address - */ - public IPAddress getClientIP() { - return clientIP; - } - - /** - * Retrieve a string version of the client's IP address - * @return A <code>String</code> containing the dotted decimal IP address. - */ - public String getClientIPAddress() { - if (clientIP == null) { - return ""; - } else { - return clientIP.getHostAddress(); - } - } - - /** - * Set the client's IP address - * @param clientIP A String representation of the <code>IPAddress</code> - * to assign from this record. - */ - public void setClientIP(String clientIP) throws ValidationException { - if (clientIP == null) { - String msg = ResourceStrings.getString("dcr_invalid_null_clientip"); - throw new ValidationException(msg); - } - - try { - setClientIP(new IPAddress(clientIP)); - } catch (Throwable e) { - String msg = ResourceStrings.getString("dcr_invalid_clientip"); - throw new ValidationException(msg); - } - } - - /** - * Set the client's IP address - * @param clientIP An <code>IPAddress</code> to assign from this record. - */ - public void setClientIP(IPAddress clientIP) throws ValidationException { - if (clientIP == null) { - String msg = ResourceStrings.getString("dcr_invalid_null_clientip"); - throw new ValidationException(msg); - } - this.clientIP = clientIP; - } - - /** - * Retrieve the IP address of the owning server. - * @return An <code>IPAddress</code> for the server controlling this record. - */ - public IPAddress getServerIP() { - return serverIP; - } - - /** - * Retrieve a string version of the owning server's IP address - * @return The server's dotted decimal IP address as a <code>String</code> - */ - public String getServerIPAddress() { - if (serverIP == null) { - return ""; - } else { - return serverIP.getHostAddress(); - } - } - - /** - * Set the server's IP address - * @param serverIP A String representation of the <code>IPAddress</code> - * to assign from this record. - */ - public void setServerIP(String serverIP) throws ValidationException { - if (serverIP == null) { - String msg = ResourceStrings.getString("dcr_invalid_null_serverip"); - throw new ValidationException(msg); - } - - try { - setServerIP(new IPAddress(serverIP)); - } catch (Throwable e) { - String msg = ResourceStrings.getString("dcr_invalid_serverip"); - throw new ValidationException(msg); - } - } - - /** - * Assign this address to a server denoted by its IP address - * @param serverIP The <code>IPAddress</code> of the owning server. - */ - public void setServerIP(IPAddress serverIP) throws ValidationException { - if (serverIP == null) { - String msg = ResourceStrings.getString("dcr_invalid_null_serverip"); - throw new ValidationException(msg); - } - this.serverIP = serverIP; - } - - /** - * @return The expiration time of this record's lease as a <code>Date</code> - */ - public Date getExpiration() { - return expiration; - } - - /** - * @return The expiration time of this record's lease in seconds - * since the epoch, as a <code>String</code> - */ - public String getExpirationTime() { - if (expiration == null) { - return null; - } - if (expiration.getTime() == Long.parseLong(EXPIRATION_FOREVER)) { - return EXPIRATION_FOREVER; - } else { - return String.valueOf((expiration.getTime()/(long)1000)); - } - } - - /** - * Set the lease expiration date. - * @param expiration Lease expiration time in seconds since Unix epoch - */ - public void setExpiration(String expiration) { - this.expiration = new Date((long)(Long.parseLong(expiration)*1000)); - } - - /** - * Set the lease expiration date. - * @param expiration The <code>Date</code> when the lease expires. - */ - public void setExpiration(Date expiration) { - this.expiration = expiration; - } - - /** - * Set the lease expiration date by parsing a formatted string. Also - * provides special handling of the "0" and "-1" values. - * @param dateFormat A DateFormat used to parse the expiration date - * @param date Lease expiration in desired format. - */ - public void setExpiration(DateFormat dateFormat, String date) - throws ValidationException { - - if (date == null) { - setExpiration(date); - } else if (date.equals(EXPIRATION_ZERO)) { - setExpiration(date); - } else if (date.equals(EXPIRATION_FOREVER)) { - setExpiration(date); - } else { - try { - expiration = dateFormat.parse(date); - } catch (Exception ex) { - String msg = - ResourceStrings.getString("dcr_invalid_expiration"); - throw new ValidationException(msg); - } - } - } - - /** - * @return The name of the macro used to explicitly configure this address - */ - public String getMacro() { - return macro; - } - - /** - * Set the name of the macro used to explicitly configure this address - */ - public void setMacro(String macro) { - this.macro = macro; - } - - /** - * @return The descriptive comment for this record - */ - public String getComment() { - return comment; - } - - /** - * Set a descriptive comment for this record - * @param comment The comment - */ - public void setComment(String comment) { - this.comment = comment; - } - - /** - * @return The signature for this record - */ - public String getSignature() { - return signature; - } - - /** - * Set the signature for this record - * @param signature The new signature value - */ - public void setSignature(String signature) { - this.signature = signature; - } - - /** - * Perform comparisons to another DhcpClientRecord instance. This is used - * for sorting a network table by client address. - * @param o A <code>DhcpClientRecord</code> to compare against. - * @return 0 if the objects have the same address, - * a negative number if this record has a lower IP address than the - * supplied record, a positive number if this record has a higher IP - * address than the supplied record. - */ - public int compareTo(Object o) { - DhcpClientRecord r = (DhcpClientRecord)o; - return (int)(getBinaryAddress() - r.getBinaryAddress()); - } - - /** - * Retrieve the IP address as a number suitable for arithmetic operations. - * We use a <code>long</code> rather than an <code>int</code> in order to - * be able to treat it as an unsigned value, since all Java types are - * signed. - * @return The IP address as a <code>long</code>. - */ - public long getBinaryAddress() { - return (clientIP.getBinaryAddress()); - } - - /** - * @return The client's hostname - */ - public String getClientName() { - if (clientName == null && clientIP != null) { - clientName = clientIP.getHostName(); - } - return clientName; - } - - /** - * @param name The hostname for the client. - */ - public void setClientName(String name) { - clientName = name; - } - - /** - * @return The server's hostname - */ - public String getServerName() { - if (serverName == null && serverIP != null) { - serverName = serverIP.getHostName(); - } - return serverName; - } - - /** - * @param name The server's hostname - */ - public void setServerName(String name) { - serverName = name; - } - - public String toString() { - - String server = null; - if (serverIP != null) { - server = serverIP.getHostAddress(); - } - - String client = null; - if (clientIP != null) { - client = clientIP.getHostAddress(); - } - - String expiration = null; - if (this.expiration != null) { - expiration = this.expiration.toString(); - } - - String s = clientId + " " + String.valueOf(flags) + " " - + client + " " + server - + " " + expiration + " " + signature - + " " + macro + " " + comment; - return s; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpDatastore.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpDatastore.java deleted file mode 100644 index a5064107c9..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpDatastore.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -package com.sun.dhcpmgr.data; - -import java.io.Serializable; - -public class DhcpDatastore implements Serializable { - - private String resource; - private String location; - private String config; - private int version; - private boolean enabled; - - /** - * Simplest constructor. - */ - public DhcpDatastore() { - this(null, null, null, -1, true); - } // constructor - - /** - * Constructor. - * @param r the data store 'resource' value - * @param v the data store 'version' value - * @param e the data store 'enabled' value - */ - public DhcpDatastore(String r, int v, boolean e) { - this(r, null, null, v, e); - } // constructor - - /** - * Constructor. - * @param r the data store 'resource' value - * @param l the data store 'location' value - * @param a the data store 'config' value - */ - public DhcpDatastore(String r, String l, String a) { - this(r, l, a, -1, true); - } // constructor - - /** - * Constructor. - * @param r the data store 'resource' value - * @param l the data store 'location' value - * @param a the data store 'config' value - * @param v the data store 'version' value - */ - public DhcpDatastore(String r, String l, String a, int v) { - this(r, l, a, v, true); - } // constructor - - /** - * Constructor. - * @param r the data store 'resource' value - * @param l the data store 'location' value - * @param a the data store 'config' value - * @param v the data store 'version' value - * @param e the data store 'enabled' value - */ - public DhcpDatastore(String r, String l, String a, int v, boolean e) { - setResource(r); - setLocation(l); - setConfig(a); - setVersion(v); - setEnabled(e); - } // constructor - - /** - * Returns the data store 'resource' value. - * @returns the data store 'resource' value. - */ - public String getResource() { - return resource; - } // getResource - - /** - * Sets the data store 'resource' value. - * @param s the data store 'resource' value. - */ - public void setResource(String s) { - resource = s; - } // setResource - - /** - * Returns the data store 'location' value. - * @returns the data store 'location' value. - */ - public String getLocation() { - return location; - } // getLocation - - /** - * Sets the data store 'location' value. - * @param s the data store 'location' value. - */ - public void setLocation(String s) { - location = s; - } // setLocation - - /** - * Returns the data store 'config' value. - * @returns the data store 'config' value. - */ - public String getConfig() { - return config; - } // getConfig - - /** - * Sets the data store 'config' value. - * @param s the data store 'config' value. - */ - public void setConfig(String s) { - config = s; - } // setConfig - - /** - * Returns the data store 'version' value. - * @returns the data store 'version' value. - */ - public int getVersion() { - return version; - } // getVersion - - /** - * Sets the data store 'version' value. - * @param v the data store 'version' value. - */ - public void setVersion(int v) { - version = v; - } // setVersion - - /** - * Returns the data store 'enabled' value. - * @returns the data store 'enabled' value. - */ - public boolean isEnabled() { - return enabled; - } // isEnables - - /** - * Sets the data store 'enabled' value. - * @param e the data store 'enabled' value. - */ - public void setEnabled(boolean e) { - enabled = e; - } // setEnabled - - /** - * Indicates whether some other object "is equal" to this one. - * @param o the object with which to compare. - * @returns true if the objects are equal, false otherwise. - */ - public boolean equals(Object o) { - if (o instanceof DhcpDatastore) { - DhcpDatastore d = (DhcpDatastore)o; - - return (version == d.getVersion() && - stringsEqual(resource, d.getResource()) && - stringsEqual(location, d.getLocation()) && - stringsEqual(config, d.getConfig())); - - } else { - return false; - } - - } // equals - - /** - * Compares two strings for equality. - * @param s1 one of the strings to compare. - * @param s2 the other string to compare against. - * @returns true if the strings are equal, false otherwise. - */ - private boolean stringsEqual(String s1, String s2) { - if (s1 == s2) { - return true; - } else if (s1 == null || s2 == null) { - return false; - } else { - return s1.equals(s2); - } - } // stringsEqual - -} // DhcpDatastore diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpResource.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpResource.java deleted file mode 100644 index a4032c4c8f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpResource.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 Sun Microsystems, Inc. - * All rights reserved. - */ - -package com.sun.dhcpmgr.data; - -import java.io.Serializable; - -/** - * DhcpResource represents a record in the /etc/defaults/dhcp file. Each - * record is either an option setting for the DHCP daemon or a comment. - */ -public class DhcpResource implements Serializable { - private String key; - private String value; - private boolean comment; - - public DhcpResource() { - this("", "", false); - } - - public DhcpResource(String key, String value) { - this(key, value, false); - } - - public DhcpResource(String key, String value, boolean comment) { - this.key = key; - this.value = value; - this.comment = comment; - } - - public boolean isComment() { - return comment; - } - - public void setComment(boolean comment) { - this.comment = comment; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - /** - * Compare for equality against another object. - * @return true if the object is another DhcpResource instance and - * they are both comments or normal resources and the key value is - * identical. The value of 'value' is irrelevant. This is primarily - * used by the indexOf method of the ArrayList used to store the options - * in DhcpdOptions. - */ - public boolean equals(Object o) { - if (o instanceof DhcpResource) { - DhcpResource r = (DhcpResource)o; - return (comment == r.isComment()) && key.equals(r.getKey()); - } else { - return false; - } - } - - public String toString() { - if (comment) { - return "#" + key; - } else { - return key + "=" + value; - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpdOptions.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpdOptions.java deleted file mode 100644 index 6e3e1fbda4..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcpdOptions.java +++ /dev/null @@ -1,939 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.data; - -import java.util.ArrayList; -import java.util.Arrays; -import java.io.Serializable; -import com.sun.dhcpmgr.data.qualifier.*; - -/** - * DhcpdOptions models the option settings for the in.dhcpd daemon. We read - * and write the option settings in the daemon's defaults file. - * Getter and setter methods are provided for each individual option. - */ - -public class DhcpdOptions implements DhcpConfigOpts, Serializable { - /* The list of facility choices the user may select from for logging */ - private static final Integer [] loggingFacilities = { - new Integer(0), new Integer(1), new Integer(2), new Integer(3), - new Integer(4), new Integer(5), new Integer(6), new Integer(7) - }; - - // Store the option settings here - private ArrayList options; - - /** - * Dirty flag. Set after a clear or a set on an option. - */ - private boolean dirty = false; - - public DhcpdOptions() { - options = new ArrayList(); - } - - public DhcpdOptions(DhcpResource [] opts) { - options = new ArrayList(Arrays.asList(opts)); - } - - public Object clone() { - DhcpdOptions o = new DhcpdOptions(); - o.options = (ArrayList)options.clone(); - return o; - } - - /** - * Test whether a particular option is set. - * @param key - * The name of the option to set. - * @return - * True if the option is set, otherwise false. - */ - public boolean isSet(String key) { - return internalIsSet(key); - } - - /** - * Set an option to a supplied value. - * @param key - * The name of the option to set. - * @param value - * The value of the option. - */ - public void set(String key, String value) { - set(key, value, false); - } - - /** - * Set an option to a supplied value, or add a comment line to the - * table. - * @param key - * The name of the option to set. - * @param value - * The value of the option. - * @param comment - * true if this is a comment, in which case value is ignored - * and the comment text is contained entirely in key. - */ - public void set(String key, String value, boolean comment) { - internalSet(key, value, comment); - - /* - * Ensure that the run mode is kept consistent with the - * configuration parameters. Mgt. tools rely on this! - */ - if (key.equals(DSVC_CK_PATH)) { - internalSet(DSVC_CK_RUN_MODE, DSVC_CV_SERVER); - } else if (key.equals(DSVC_CK_RELAY_DESTINATIONS)) { - internalSet(DSVC_CK_RUN_MODE, DSVC_CV_RELAY); - } else if (key.equals(DSVC_CK_RESOURCE)) { - internalSet(DSVC_CK_RUN_MODE, DSVC_CV_SERVER); - } - } - - /** - * Clear an option. - * @param key - * The name of the option to clear. - */ - public void clear(String key) { - internalClear(key); - - if (key.equals(DSVC_CK_RELAY_DESTINATIONS)) { - internalSet(DSVC_CK_RUN_MODE, DSVC_CV_SERVER); - } - } - - /** - * Return the value of an option setting; null if it's not set. - * @param key - * The option whose value is to be retrieved. - * @return - * The value of an option setting; null if it's not set. - */ - public String valueOf(String key) { - return internalValueOf(key); - } - - // Test whether a particular option is set - private boolean internalIsSet(String key) { - DhcpResource res = new DhcpResource(); - res.setKey(key); - return options.contains(res); - } - - // Set an option to a supplied value - private void internalSet(String key, String value) { - internalSet(key, value, false); - } - - /** - * Set an option to a supplied value, or add a comment line to the - * table. - * @param key The name of the option to set - * @param value The value of the option - * @param comment true if this is a comment, in which case value is ignored - * and the comment text is contained entirely in key. - */ - private void internalSet(String key, String value, boolean comment) { - DhcpResource res = new DhcpResource(key, value, comment); - int i = options.indexOf(res); - if (i != -1) { - DhcpResource existing = (DhcpResource)options.get(i); - - if (!existing.getValue().equals(res.getValue())) { - options.set(i, res); - dirty = true; - } - } else { - options.add(res); - dirty = true; - } - } - - // Clear an option - private void internalClear(String key) { - DhcpResource res = new DhcpResource(); - res.setKey(key); - int i = options.indexOf(res); - if (i != -1) { - options.remove(i); - dirty = true; - } - } - - /** - * Return the value of an option setting; null if it's not set - * @param key The option whose value is to be retrieved - * @return The value of an option setting; null if it's not set - */ - private String internalValueOf(String key) { - DhcpResource res = new DhcpResource(); - res.setKey(key); - int i = options.indexOf(res); - if (i != -1) { - return ((DhcpResource)options.get(i)).getValue(); - } else { - return null; - } - } - - /** - * Return all of the option settings as an array - * @return An array of Objects which will all be DhcpResources - */ - public Object [] getAll() { - return options.toArray(); - } - - /** - * Test to see whether or not the daemon is enabled. - * @return true if daemon is enabled, false if not. - */ - public boolean isDaemonEnabled() { - return DSVC_CV_TRUE.equals(valueOf(DSVC_CK_DAEMON_ENABLED)); - } - - /** - * Set daemon enabled or disabled - * @param state true for enabled, false for disabled - */ - public void setDaemonEnabled(boolean state) { - set(DSVC_CK_DAEMON_ENABLED, state ? DSVC_CV_TRUE : DSVC_CV_FALSE); - } - - /** - * Set the DhcpDatastore attributes. - * @param resource the data store resource attribute - * @param location the data store location attribute - * @param config the data store config attribute - * @param version the data store version attribute - */ - public void setDhcpDatastore(String resource, String location, - String config, int version) { - setResource(resource); - setPath(location); - setConfig(config); - setResourceVersion(version); - } // setDhcpDatastore - - /** - * Set the DhcpDatastore attributes. - * @param datastore a datastore object whose attributes - * are the desired attributes. - */ - public void setDhcpDatastore(DhcpDatastore datastore) { - setResource(datastore.getResource()); - setPath(datastore.getLocation()); - setConfig(datastore.getConfig()); - setResourceVersion(datastore.getVersion()); - } // setDhcpDatastore - - /** - * Set the DhcpDatastore attributes. - * @param resource the data store resource attribute - * @param location the data store location attribute - * @param config the data store config attribute - * @param version the data store version attribute - */ - public DhcpDatastore getDhcpDatastore() { - return (new DhcpDatastore(getResource(), getPath(), - getConfig(), getResourceVersion())); - } // getDhcpDatastore - - /** - * Set the resource (aka data store) in which DHCP data is stored. - * This automatically also sets the run mode to server. - * @param s Unique name of resource - */ - public void setResource(String s) { - set(DSVC_CK_RESOURCE, s); - } - - /** - * Retrieve the name of the resource/data store used for DHCP. - * @return The unique name of the resource; null if not set - */ - public String getResource() { - return valueOf(DSVC_CK_RESOURCE); - } - - /** - * Set the version of the resource in which DHCP data is stored. - * @param i version number - */ - public void setResourceVersion(int i) { - set(DSVC_CK_CONVER, Integer.toString(i)); - } - - /** - * Retrieve the version of the resource/data store used for DHCP. - * @return The version number or -1 if not valid. - */ - public int getResourceVersion() { - try { - return Integer.parseInt(valueOf(DSVC_CK_CONVER)); - } catch (NumberFormatException e) { - return -1; - } - } - - /** - * Set the path within the resource in which to place the tables. - * For files, this is a Unix pathname; for NIS+, the directory name. - * @param s The path - */ - public void setPath(String s) { - set(DSVC_CK_PATH, s); - } - - /** - * Get the path used for data storage. - * @return The path within the resource; null if not set - */ - public String getPath() { - return valueOf(DSVC_CK_PATH); - } - - /** - * Set the config for the resource. - * @param s The config - */ - public void setConfig(String s) { - if (s != null) { - set(DSVC_CK_RESOURCE_CONFIG, s); - } else { - clear(DSVC_CK_RESOURCE_CONFIG); - } - } - - /** - * Get the config for data store. - * @return The config; null if not set - */ - public String getConfig() { - return valueOf(DSVC_CK_RESOURCE_CONFIG); - } - - /** - * Set the hosts resource (aka data store) in which host data is stored. - * @param s Unique name of resource - */ - public void setHostsResource(String s) { - set(DSVC_CK_HOSTS_RESOURCE, s); - } - - /** - * Retrieve the name of the resource/data store used for hosts. - * @return The unique name of the resource; null if not set - */ - public String getHostsResource() { - return valueOf(DSVC_CK_HOSTS_RESOURCE); - } - - /** - * Set the domain within the hosts resource in which to place the tables. - * For files resource, this value is meaningless. - * @param s The domain - */ - public void setHostsDomain(String s) { - set(DSVC_CK_HOSTS_DOMAIN, s); - } - - /** - * Get the domain used for hosts data storage. - * @return The domain within the resource; null if not set - */ - public String getHostsDomain() { - return valueOf(DSVC_CK_HOSTS_DOMAIN); - } - - /** - * Test whether BOOTP compatibility is enabled. - * @return true if BOOTP compatibility is enabled. - */ - public boolean isBootpCompatible() { - return isSet(DSVC_CK_BOOTP_COMPAT); - } - - /** - * Enable or disable BOOTP compatibility. - * @param state true if BOOTP compatibility is enabled, false if not. - * @param isAutomatic true if automatic allocation is allowed. - */ - public void setBootpCompatible(boolean state, boolean isAutomatic) { - if (state) { - if (isAutomatic) { - set(DSVC_CK_BOOTP_COMPAT, DSVC_CV_AUTOMATIC); - } else { - set(DSVC_CK_BOOTP_COMPAT, DSVC_CV_MANUAL); - } - } else { - clear(DSVC_CK_BOOTP_COMPAT); - } - } - - /** - * Test whether BOOTP compatibility is automatic or manual - * @return true if BOOTP compatibility is automatic. - */ - public boolean isBootpAutomatic() { - return DSVC_CV_AUTOMATIC.equals(valueOf(DSVC_CK_BOOTP_COMPAT)); - } - - /** - * Test whether relay hop limit is set. - * @return true if the limit is set, false if default value is used. - */ - public boolean isRelayHops() { - return isSet(DSVC_CK_RELAY_HOPS); - } - - /** - * Set the relay hop limit. - * @param state true if hop limit should be set, false if not - * @param hops Number of hops to limit forwarding to - */ - public void setRelayHops(boolean state, Integer hops) { - if (state) { - set(DSVC_CK_RELAY_HOPS, hops.toString()); - } else { - clear(DSVC_CK_RELAY_HOPS); - } - } - - /** - * Get the relay hop limit. - * @return The number of hops currently set, or null if this isn't set. - */ - public Integer getRelayHops() { - String hops = valueOf(DSVC_CK_RELAY_HOPS); - if (hops != null) { - return new Integer(hops); - } else { - return null; - } - } - - /** - * Test whether a network interface list is set; failure to set an interface - * list implies that all interfaces will be monitored. - * @return true if an interface list is set - */ - public boolean isInterfaces() { - return isSet(DSVC_CK_INTERFACES); - } - - /** - * Set the network interface list. - * @param state true if interface list is to be set, false if it should be - * cleared - * @param list A comma-separated list of interface names - */ - public void setInterfaces(boolean state, String list) { - if (state) { - set(DSVC_CK_INTERFACES, list); - } else { - clear(DSVC_CK_INTERFACES); - } - } - - /** - * Get the list of network interfaces. - * @return The comma-separated list of interfaces; null if not set - */ - public String getInterfaces() { - return valueOf(DSVC_CK_INTERFACES); - } - - /** - * Test whether ICMP address verification is enabled - * @return true if ICMP verification is performed - */ - public boolean isICMPVerify() { - /* - * Use this double-inverse comparison so that the default behavior of - * ICMP enabled is handled correctly. - */ - return !DSVC_CV_FALSE.equals(valueOf(DSVC_CK_ICMP_VERIFY)); - } - - /** - * Set ICMP verification - * @param state true if verification should be done, false otherwise - */ - public void setICMPVerify(boolean state) { - set(DSVC_CK_ICMP_VERIFY, state ? DSVC_CV_TRUE : DSVC_CV_FALSE); - } - - /** - * Test whether offer cache timeout is set - * @return true if it is set - */ - public boolean isOfferTtl() { - return isSet(DSVC_CK_OFFER_CACHE_TIMEOUT); - } - - /** - * Set offer cache timeout value - * @param state true if offer cache timeout value is set, false if server's - * default will be used instead - * @param time Number of seconds to hold offers in the cache - */ - public void setOfferTtl(boolean state, Integer time) { - if (state) { - set(DSVC_CK_OFFER_CACHE_TIMEOUT, time.toString()); - } else { - clear(DSVC_CK_OFFER_CACHE_TIMEOUT); - } - } - - /** - * Get the offer cache timeout value - * @return timeout value set, or null if server default is used - */ - public Integer getOfferTtl() { - String s = valueOf(DSVC_CK_OFFER_CACHE_TIMEOUT); - if (s != null) { - return new Integer(s); - } else { - return null; - } - } - - /** - * Test whether server is running in relay mode - * @return true if running as relay - */ - public boolean isRelay() { - return DSVC_CV_RELAY.equals(valueOf(DSVC_CK_RUN_MODE)); - } - - /** - * Set relay mode and server list - * @param state true if relay mode is desired, false for normal server - * @param servers list of servers to which requests should be forwarded - */ - public void setRelay(boolean state, String servers) { - if (state) { - set(DSVC_CK_RELAY_DESTINATIONS, servers); - } else { - clear(DSVC_CK_RELAY_DESTINATIONS); - } - } - - /** - * Get list of server targets for relay - * @return list of relay targets; null if not set - */ - public String getRelay() { - return valueOf(DSVC_CK_RELAY_DESTINATIONS); - } - - /** - * Test for server automatic reload of dhcptab - * @return true if server is rescanning dhcptab - */ - public boolean isRescan() { - return isSet(DSVC_CK_RESCAN_INTERVAL); - } - - /** - * Set the rescan interval - * @param state true if rescanning is enabled, false if not - * @param interval number of minutes between rescans - */ - public void setRescan(boolean state, Integer interval) { - if (state) { - set(DSVC_CK_RESCAN_INTERVAL, interval.toString()); - } else { - clear(DSVC_CK_RESCAN_INTERVAL); - } - } - - /** - * Get the rescan interval - * @return the rescan interval in minutes, or null if rescan is not enabled - */ - public Integer getRescan() { - String s = valueOf(DSVC_CK_RESCAN_INTERVAL); - if (s != null) { - return new Integer(s); - } else { - return null; - } - } - - /** - * Test whether ownerip - * @return true if ownerip - */ - public boolean isOwnerip() { - return isSet(DSVC_CK_OWNER_IP); - } - - /** - * Set ownerip server list - * @param state true if ownerip is desired, false for normal server - * @param ownerips list of servers ownerips - */ - public void setOwnerip(boolean state, String ownerips) { - if (state) { - set(DSVC_CK_OWNER_IP, ownerips); - } else { - clear(DSVC_CK_OWNER_IP); - } - } - - /** - * Get list of server targets for ownerip - * @return list of ownerip targets; null if not set - */ - public String getOwnerip() { - return valueOf(DSVC_CK_OWNER_IP); - } - - - /** - * Test for server dynamic DNS updates - * @return true if server is updating DNS - */ - public boolean isDnsUpdated() { - return isSet(DSVC_CK_NSU_TIMEOUT); - } - - /** - * Set the DNS update timeout value - * @param state true if DNS updates are enabled, false if not - * @param timeout number of seconds before timeout - */ - public void setDnsTimeout(boolean state, Integer timeout) { - if (state) { - set(DSVC_CK_NSU_TIMEOUT, timeout.toString()); - } else { - clear(DSVC_CK_NSU_TIMEOUT); - } - } - - /** - * Get the DNS update timeout value - * @return the timeout in seconds, or null if DNS updates are not enabled - */ - public Integer getDnsTimeout() { - String s = valueOf(DSVC_CK_NSU_TIMEOUT); - if (s != null) { - return new Integer(s); - } else { - return null; - } - } - - /** - * Test for verbose logging mode - * @return true if verbose logging, false for normal - */ - public boolean isVerbose() { - return DSVC_CV_TRUE.equals(valueOf(DSVC_CK_VERBOSE)); - } - - /** - * Set verbose logging mode - * @param state true for verbose, false for normal - */ - public void setVerbose(boolean state) { - set(DSVC_CK_VERBOSE, state ? DSVC_CV_TRUE : DSVC_CV_FALSE); - } - - - /** - * Test for transaction logging mode. - * @return true if transaction logging is enabled - */ - public boolean isLogging() { - return isSet(DSVC_CK_LOGGING_FACILITY); - } - - /** - * Get the syslog facility number used for transaction logging - * @return facility number, which will be between 0 and 7 - */ - public Integer getLogging() { - String s = valueOf(DSVC_CK_LOGGING_FACILITY); - if (s != null) { - return new Integer(s); - } else { - return null; - } - } - - /** - * Set transaction logging - * @param state true to enable transaction logging, false to disable - * @param value syslog facility number 0-7 used for logging - */ - public void setLogging(boolean state, Integer value) { - if (state) { - set(DSVC_CK_LOGGING_FACILITY, value.toString()); - } else { - clear(DSVC_CK_LOGGING_FACILITY); - } - } - - /** - * Get the list of logging facility choices - * @return an array of facility numbers - */ - public static Integer [] getLoggingFacilities() { - return loggingFacilities; - } - - /** - * Return an indicator of whether the parameters may have been changed - * by a set() or a clear() since the last call to clearDirty(). - * - * @return - * True if a set() or a clear() has occurred since the last call to - * clearDirty(), otherwise false. - */ - public boolean isDirty() { - return dirty; - } - - /** - * Set the dirty indicator to false. Any subsequent calls to set() or - * clear() may set the dirty flag. - */ - public void clearDirty() { - dirty = false; - } - - /** - * Get the parameters qualifier. - * - * @param key - * Parameters keyword. - * @return - * The qualifier for the parameter if one exists, otherwise null. - */ - public Qualifier getQualifier(String key) { - Qualifier qualifier = null; - - if (key.equals(DSVC_CK_BOOTP_COMPAT)) { - qualifier = - new QualifierImpl(DSVC_CK_BOOTP_COMPAT, false, false, - new QualifierStringEnum( - new String[] { - DSVC_CV_AUTOMATIC, - DSVC_CV_MANUAL - })); - } else if (key.equals(DSVC_CK_CACHE_TIMEOUT)) { - qualifier = - new QualifierImpl(DSVC_CK_CACHE_TIMEOUT, false, false, - new QualifierIntegerRange( - 0, - Integer.MAX_VALUE)); - - } else if (key.equals(DSVC_CK_CONVER)) { - qualifier = - new QualifierImpl(DSVC_CK_CONVER, true, false, - new QualifierInteger()); - - } else if (key.equals(DSVC_CK_DAEMON_ENABLED)) { - qualifier = - new QualifierImpl(DSVC_CK_DAEMON_ENABLED, true, false, - new QualifierBoolean( - DSVC_CV_TRUE, - DSVC_CV_FALSE)); - - } else if (key.equals(DSVC_CK_DBG_MEMORY_NET)) { - qualifier = - new QualifierImpl(DSVC_CK_DBG_MEMORY_NET, false, true, - new QualifierIntegerRange( - 0, - Integer.MAX_VALUE)); - - } else if (key.equals(DSVC_CK_DBG_PORT_OFFSET)) { - qualifier = - new QualifierImpl(DSVC_CK_DBG_PORT_OFFSET, false, true, - new QualifierIntegerRange( - 0, - Integer.MAX_VALUE)); - - } else if (key.equals(DSVC_CK_HOSTS_DOMAIN)) { - qualifier = - new QualifierImpl(DSVC_CK_HOSTS_DOMAIN, true, false, - new QualifierStringEnum( - new String[] { - DSVC_CV_DNS - })); - } else if (key.equals(DSVC_CK_HOSTS_RESOURCE)) { - qualifier = - new QualifierImpl(DSVC_CK_HOSTS_RESOURCE, true, false, - new QualifierStringEnum( - new String[] { - DSVC_CV_DNS, - DSVC_CV_FILES - })); - } else if (key.equals(DSVC_CK_ICMP_VERIFY)) { - qualifier = - new QualifierImpl(DSVC_CK_ICMP_VERIFY, false, false, - new QualifierBoolean( - DSVC_CV_TRUE, - DSVC_CV_FALSE)); - - } else if (key.equals(DSVC_CK_INTERFACES)) { - qualifier = - new QualifierImpl(DSVC_CK_INTERFACES, false, false, - new QualifierArray( - new QualifierString())); - - } else if (key.equals(DSVC_CK_LEASE_MIN_LRU)) { - qualifier = - new QualifierImpl(DSVC_CK_LEASE_MIN_LRU, false, true, - new QualifierIntegerRange( - 0, - Integer.MAX_VALUE)); - - } else if (key.equals(DSVC_CK_LOGGING_FACILITY)) { - qualifier = - new QualifierImpl(DSVC_CK_LOGGING_FACILITY, false, false, - new QualifierIntegerRange( - DSVC_CV_LOGGING_FACILITY_MIN, - DSVC_CV_LOGGING_FACILITY_MAX)); - - } else if (key.equals(DSVC_CK_MAX_CLIENTS)) { - qualifier = - new QualifierImpl(DSVC_CK_MAX_CLIENTS, false, true, - new QualifierIntegerRange( - -1, - Integer.MAX_VALUE)); - - } else if (key.equals(DSVC_CK_MAX_THREADS)) { - qualifier = - new QualifierImpl(DSVC_CK_MAX_THREADS, false, true, - new QualifierIntegerRange( - -1, - Integer.MAX_VALUE)); - - } else if (key.equals(DSVC_CK_OFFER_CACHE_TIMEOUT)) { - qualifier = - new QualifierImpl(DSVC_CK_OFFER_CACHE_TIMEOUT, false, false, - new QualifierIntegerRange( - 0, - Integer.MAX_VALUE)); - - } else if (key.equals(DSVC_CK_PATH)) { - qualifier = - new QualifierImpl(DSVC_CK_PATH, true, false, - new QualifierString()); - - } else if (key.equals(DSVC_CK_RELAY_DESTINATIONS)) { - qualifier = - new QualifierImpl(DSVC_CK_RELAY_DESTINATIONS, false, false, - new QualifierArray( - new QualifierOr( - new QualifierFQDN(), - new QualifierIPv4()))); - - } else if (key.equals(DSVC_CK_RELAY_HOPS)) { - qualifier = - new QualifierImpl(DSVC_CK_RELAY_HOPS, false, false, - new QualifierIntegerRange( - 0, - Integer.MAX_VALUE)); - - } else if (key.equals(DSVC_CK_RESCAN_INTERVAL)) { - qualifier = - new QualifierImpl(DSVC_CK_RESCAN_INTERVAL, false, false, - new QualifierIntegerRange( - 0, Integer.MAX_VALUE)); - - } else if (key.equals(DSVC_CK_OWNER_IP)) { - qualifier = - new QualifierImpl(DSVC_CK_OWNER_IP, false, false, - new QualifierArray( - new QualifierIPv4())); - - } else if (key.equals(DSVC_CK_RESOURCE)) { - qualifier = - new QualifierImpl(DSVC_CK_RESOURCE, true, false, - new QualifierString()); - - } else if (key.equals(DSVC_CK_RESOURCE_CONFIG)) { - qualifier = - new QualifierImpl(DSVC_CK_RESOURCE_CONFIG, true, false, - new QualifierString()); - - } else if (key.equals(DSVC_CK_RUN_MODE)) { - qualifier = - new QualifierImpl(DSVC_CK_RUN_MODE, true, false, - new QualifierStringEnum( - new String[] { - DSVC_CV_SERVER, - DSVC_CV_RELAY - })); - } else if (key.equals(DSVC_CK_RENOG_INTERVAL)) { - qualifier = - new QualifierImpl(DSVC_CK_RENOG_INTERVAL, false, false, - new QualifierIntegerRange( - 0, - Integer.MAX_VALUE)); - - } else if (key.equals(DSVC_CK_NSU_TIMEOUT)) { - qualifier = - new QualifierImpl(DSVC_CK_NSU_TIMEOUT, false, false, - new QualifierIntegerRange( - -1, - Integer.MAX_VALUE)); - - } else if (key.equals(DSVC_CK_VERBOSE)) { - qualifier = - new QualifierImpl(DSVC_CK_VERBOSE, false, false, - new QualifierBoolean( - DSVC_CV_TRUE, - DSVC_CV_FALSE)); - } - - return qualifier; - } - - /** - * Convert this object to a String representation - */ - public String toString() { - StringBuffer b = new StringBuffer(); - for (int i = 0; i < options.size(); ++i) { - DhcpResource res = (DhcpResource)options.get(i); - b.append(res.getKey()); - String s = res.getValue(); - if (s != null) { - b.append('='); - b.append(s); - } - b.append('\n'); - } - return b.toString(); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcptabRecord.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcptabRecord.java deleted file mode 100644 index e0c6508acd..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/DhcptabRecord.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data; - -import java.io.Serializable; - -public abstract class DhcptabRecord implements Serializable, Cloneable { - public static final String MACRO = "m"; - public static final String OPTION = "s"; - - public static final String DEFAULT_SIGNATURE = "0"; - - protected String key; - protected String flag; - protected String value; - protected String signature = DEFAULT_SIGNATURE; - - // Serialization id for this class - static final long serialVersionUID = -1734667901914072052L; - - public DhcptabRecord() { - key = flag = value = ""; - signature = DEFAULT_SIGNATURE; - } - - public DhcptabRecord(String k, String f, String v) { - this(k, f, v, DEFAULT_SIGNATURE); - } - - public DhcptabRecord(String k, String f, String v, String sig) { - key = k; - flag = f; - value = v; - signature = sig; - } - - public void setKey(String k) throws ValidationException { - key = k; - } - - public String getKey() { - return key; - } - - public void setFlag(String f) throws ValidationException { - flag = f; - } - - public String getFlag() { - return flag; - } - - public void setValue(String v) throws ValidationException { - value = v; - } - - public String getValue() { - return value; - } - - public void setSignature(String sig) { - signature = sig; - } - - public String getSignature() { - return signature; - } - - public String toString() { - return new String(key + " " + flag + " " + signature + " " + value); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ExportHeader.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ExportHeader.java deleted file mode 100644 index 7089a71162..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ExportHeader.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data; - -import java.io.Serializable; -import java.util.Date; - -/** - * This class defines the header for the export file. - */ -public class ExportHeader implements Serializable { - - /** - * The name of the server from which the data originated. - */ - private String server; - /** - * Date of export - */ - private Date date; - /** - * User who requested export - */ - private String user; - /** - * Number of records in this file. - */ - private int recCount; - /** - * Networks exported in this file - */ - private Network [] networks; - - // Serialization id for this class - static final long serialVersionUID = -3581829760827739278L; - - /** - * Simple constructor. - * @param server name of the server from which the server was exported - * @param user name of the user who performed the export - * @param recCount number of records which will be exported - * @param networks list of networks exported - */ - public ExportHeader(String server, String user, int recCount, - Network [] networks) { - - this.server = server; - this.user = user; - this.recCount = recCount; - this.networks = networks; - date = new Date(); - - } // constructor - - /** - * Get the server value. - * @return returns the server name - */ - public String getServer() { - - return server; - - } // getServer - - /** - * Retrieve exporting user name - * @return name of user - */ - public String getUser() { - return user; - } - - /** - * Retrieve date of export - * @return date & time of export - */ - public Date getDate() { - return date; - } - - /** - * Retrieve the number of records in the file. - * @return the number of records contained. - */ - public int getRecCount() { - return recCount; - } - - /** - * Retrieve the list of networks which are exported in this file. - * @return An array of networks - */ - public Network [] getNetworks() { - return networks; - } -} // ExportHeader diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/IPAddress.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/IPAddress.java deleted file mode 100644 index 595ef69e8a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/IPAddress.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.data; - -import java.net.InetAddress; -import java.util.StringTokenizer; -import java.io.Serializable; -import java.text.MessageFormat; - -/** - * This class provides a container for holding IP Addresses. It is different - * from java.net.InetAddress in that it allows for constructing an arbitrary IP - * address, rather than forcing you to use InetAddress.getByName, which can - * generate all sorts of nasty exception conditions in applets, especially when - * doing a configuration-type app which handles addresses which are not - * necessarily resolvable in any nameservice. - */ -public class IPAddress implements Cloneable, Serializable { - private byte [] bytes = new byte[] { 0, 0, 0, 0 }; - - // Serialization id for this class - static final long serialVersionUID = -7439646692550395242L; - - /** - * Construct an empty address - */ - public IPAddress() { - } - - /** - * Construct an address for the dotted-decimal <code>String</code> supplied. - * - */ - public IPAddress(String s) throws ValidationException { - try { - // If the input looks like a valid format, try parsing it - char [] chars = s.toCharArray(); - int dots = 0; // Count number of periods - for (int i = 0; i < chars.length; ++i) { - if (Character.isDigit(chars[i])) { - continue; - } - if ((chars[i] == '.')) { - if (++dots > 3) { - // Too many; we're done - throwException(s); - } - continue; - } - /* - * Can't be an address, so let InetAdddress try to resolve it - * as a name - */ - InetAddress a = InetAddress.getByName(s); - bytes = a.getAddress(); - return; - } - // Looks like an IP address; parse it - StringTokenizer st = new StringTokenizer(s, "."); - int b = 0; - while (st.hasMoreTokens()) { - /* - * Byte won't parse anything larger than 127 since it thinks - * everything's signed, so use Short instead - */ - short shortVal = Short.parseShort(st.nextToken()); - if (shortVal > 255 || shortVal < 0) { - throwException(s); - } - bytes[b++] = (byte)shortVal; - } - if (b < 4) { - // Not a fully specified address; don't read caller's mind - throwException(s); - } - } catch (ValidationException e) { - // Just re-throw it - throw e; - } catch (Throwable e) { - // Convert other exceptions to ValidationException - throw new ValidationException(e.getMessage()); - } - } - - /** - * Construct an IPAddress from an InetAddress - * @param a The InetAddress to convert - */ - public IPAddress(InetAddress a) { - bytes = a.getAddress(); - } - - /** - * Construct an IP address from an arbitrary 32-bit value - * @param addr The value to use - */ - public IPAddress(int addr) { - bytes = new byte[4]; - for (int i = 0; i < 4; ++i) { - // Careful; must mask to fight sign-extension - bytes[i] = (byte)((addr >> (8 * (3 - i))) & 0xff); - } - } - - public String toString() { - StringBuffer b = new StringBuffer(); - for (int i = 0; i < 4; ++i) { - if (i != 0) { - b.append('.'); - } - // Careful; must mask to fight sign-extension - b.append((int)bytes[i] & 0xff); - } - return b.toString(); - } - - /** - * Convert this address to an <code>int</code> - * @return The address as an <code>int</code> - */ - public int intValue() { - int i = 0; - for (int j = 0; j < 4; ++j) { - // Careful; must mask to fight sign-extension - i |= ((int)bytes[j] & 0xff) << (8 * (3 - j)); - } - return i; - } - - /** - * Try to convert to a name - * @return The hostname for this address, if one can be found. Otherwise, - * dotted-decimal form of this address is returned. - */ - public String getHostName() { - try { - return InetAddress.getByName(toString()).getHostName(); - } catch (Throwable e) { - return toString(); - } - } - - /** - * Provide the individual bytes of the address a la InetAddress - * @return A byte array of the address - */ - public byte [] getAddress() { - return bytes; - } - - /** - * @return the dotted-decimal string representing this address - */ - public String getHostAddress() { - return toString(); - } - - /** - * Compare this IP address to either another IP address or a - * <code>java.net.InetAddress</code>. - * @return <code>true</code> if the addresses are the same. - */ - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - - byte [] ba; - - if (obj instanceof InetAddress) { - ba = ((InetAddress)obj).getAddress(); - } else if (obj instanceof IPAddress) { - ba = ((IPAddress)obj).getAddress(); - } else { - return false; - } - - if (ba.length != bytes.length) { - return false; - } - - for (int i = 0; i < bytes.length; ++i) { - if (ba[i] != bytes[i]) { - return false; - } - } - - return true; - } - - /** - * Make a copy of this address - * @return a new IPAddress - */ - public Object clone() { - IPAddress a = new IPAddress(); - a.bytes = (byte [])bytes.clone(); - return a; - } - - /** - * Retrieve the IP address as a number suitable for arithmetic operations. - * We use a <code>long</code> rather than an <code>int</code> in order to - * be able to treat it as an unsigned value, since all Java types are - * signed. - * @return The IP address as a <code>long</code>. - */ - public long getBinaryAddress() { - byte [] bytes = getAddress(); - long result = 0; - for (int i = 0; i < bytes.length; ++i) { - // Defeat sign extension with cast & mask - result |= ((long)bytes[i] & 0xff) << (24-(i*8)); - } - return result; - } - - private void throwException(String s) - throws ValidationException { - Object [] args = { s }; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_ip_address")); - String msg = form.format(args); - throw new ValidationException(msg); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/IPInterface.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/IPInterface.java deleted file mode 100644 index dee117887e..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/IPInterface.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 Sun Microsystems, Inc. - * All rights reserved. - */ - -package com.sun.dhcpmgr.data; - -import java.io.Serializable; - -/** - * This class represents an IP network interface on the server. It consists - * of the interface's device name (short form) and the network it's attached to. - */ -public class IPInterface implements Serializable { - private String name; - private Network net; - - /** - * Construct a new interface with the given name, address, and subnet mask. - * @param name Interface name - * @param addr The address - * @param mask The subnet mask - */ - public IPInterface(String name, IPAddress addr, IPAddress mask) { - this.name = name; - net = new Network(addr, mask); - } - - /** - * Construct a new interface with the given name, address, and subnet mask. - * @param name The interface name - * @param addr The IP address as a dotted-decimal <code>String</code> - * @param mask The subnet mask as a dotted-decimal <code>String</code> - */ - public IPInterface(String name, String addr, String mask) - throws ValidationException { - this.name = name; - net = new Network(addr, mask); - } - - /** - * @return Interface's device name - */ - public String getName() { - return name; - } - - /** - * Set the interface's device name - * @param name Name of interface - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return Network the device is attached to. - */ - public Network getNetwork() { - return net; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/IPOptionValue.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/IPOptionValue.java deleted file mode 100644 index c276707924..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/IPOptionValue.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.data; - -import java.net.*; -import java.util.*; - -public class IPOptionValue extends OptionValue { - private String name; - private Vector addrs; - private boolean valid; - - // Serialization id for this class - static final long serialVersionUID = -7894568061270794048L; - - protected IPOptionValue(String name) { - this.name = name; - addrs = null; - valid = false; - } - - public void setValue(Object value) throws ValidationException { - // Find option in option definition table in order to validate the data - Option option = OptionsTable.getTable().get(name); - if (option == null) { - Object [] args = { name }; - throwException("invalid_option", args); - } - Vector newAddrs = new Vector(); - if (value instanceof String) { - if (((String)value).length() == 0) { - // Empty strings aren't acceptable - Object [] args = { name, - Option.getTypeDhcptabString(option.getType()) }; - throwException("invalid_option_value", args); - } - /* - * Break string apart at whitespace and use it to construct - * a vector of IPAddresses - */ - StringTokenizer st = new StringTokenizer((String)value, " "); - while (st.hasMoreTokens()) { - newAddrs.addElement(new IPAddress(st.nextToken())); - } - } else if (value instanceof InetAddress) { - newAddrs.addElement(value); - } else if (value instanceof IPAddress) { - newAddrs.addElement(value); - } else if (!(value instanceof Vector)) { - // Can't handle anything else but a vector of addresses - Object [] args = { name, - Option.getTypeDhcptabString(option.getType()) }; - throwException("invalid_option_value", args); - } else { - // Make sure vector only contains InetAddresses or IPAddresses - newAddrs = (Vector)value; - for (Enumeration en = newAddrs.elements(); en.hasMoreElements(); ) { - Object o = en.nextElement(); - if (!(o instanceof InetAddress) && !(o instanceof IPAddress)) { - Object [] args = { name, - Option.getTypeDhcptabString(option.getType()) }; - throwException("invalid_option_value", args); - } - } - } - if ((newAddrs.size() % option.getGranularity()) != 0) { - Object [] args = { name, - Integer.toString(option.getGranularity()) }; - throwException("invalid_option_granularity", args); - } - if ((option.getMaximum() != 0) && - (newAddrs.size() / option.getGranularity()) > - option.getMaximum()) { - Object [] args = { name, Integer.toString(option.getMaximum()) }; - throwException("invalid_option_maximum", args); - } - - addrs = newAddrs; - valid = true; - } - - public String getName() { - return name; - } - - public String getValue() { - if (addrs == null || addrs.size() == 0) { - return ""; - } - StringBuffer buf = new StringBuffer(); - for (Enumeration en = addrs.elements(); en.hasMoreElements(); ) { - Object o = en.nextElement(); - if (buf.length() != 0) { - buf.append(' '); - } - if (o instanceof IPAddress) { - buf.append(((IPAddress)o).getHostAddress()); - } else { - buf.append(((InetAddress)o).getHostAddress()); - } - } - return buf.toString(); - } - - public String toString() { - return (getName() + "=" + getValue()); - } - - public boolean isValid() { - return valid; - } - - public Object clone() { - IPOptionValue v = new IPOptionValue(name); - if (addrs != null) { - v.addrs = (Vector)addrs.clone(); - } - v.valid = valid; - return v; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/IncludeOptionValue.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/IncludeOptionValue.java deleted file mode 100644 index f24b85c8e3..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/IncludeOptionValue.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.data; - -import java.util.Vector; - -public class IncludeOptionValue extends OptionValue { - private String value; - private boolean valid; - - // Serialization id for this class - static final long serialVersionUID = -1764994428959712447L; - - protected IncludeOptionValue() { - value = ""; - valid = false; - } - - public void setValue(Object value) throws ValidationException { - if (value instanceof String) { - if (((String)value).length() == 0) { - // Empty values are not acceptable - throwException("invalid_include_option", null); - } - this.value = (String)value; - valid = true; - } else { - setValue(value.toString()); - } - } - - public String getName() { - return "Include"; - } - - public String getValue() { - return value; - } - - public String toString() { - return (getName() + "=" + getValue()); - } - - public boolean isValid() { - return valid; - } - - public Object clone() { - IncludeOptionValue v = new IncludeOptionValue(); - v.value = value; - v.valid = valid; - return v; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/Macro.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/Macro.java deleted file mode 100644 index 534a35b5af..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/Macro.java +++ /dev/null @@ -1,421 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data; - -import java.util.*; -import java.text.MessageFormat; - -/** - * Macro is a simple data class which encapsulates a macro record in - * the dhcptab. See dhcptab(4) for the gory details on macros. - * @see DhcptabRecord - * @see Option - */ -public class Macro extends DhcptabRecord implements Cloneable { - - private boolean valueClean = false; - private Vector options; - - // Definition for attribute limits - public final static short MAX_NAME_SIZE = 128; - - // Value used to edit a boolean symbol of a macro - public final static String BOOLEAN_EDIT_VALUE = "_NULL_VALUE_"; - - // Serialization id for this class - static final long serialVersionUID = -5255083189703724489L; - - public Macro() { - super("", DhcptabRecord.MACRO, ""); - options = new Vector(); - } - - public Macro(String name) throws ValidationException { - this(); - setKey(name); - } - - public Macro(String name, String expansion) throws ValidationException { - this(name, expansion, DhcptabRecord.DEFAULT_SIGNATURE); - } - - public Macro(String name, String expansion, String signature) - throws ValidationException { - this(); - setKey(name); - setValue(expansion, false, false); - setSignature(signature); - } - - public void setKey(String name) throws ValidationException { - if (name.length() > MAX_NAME_SIZE) { - Object [] args = new Object[1]; - args[0] = new Short(MAX_NAME_SIZE); - MessageFormat form = new MessageFormat( - ResourceStrings.getString("macro_key_length")); - String msg = form.format(args); - throw new ValidationException(msg); - } - super.setKey(name); - } - - public void setValue(String expansion, boolean edit, boolean validate) - throws ValidationException { - - StringBuffer symbol = new StringBuffer(); - StringBuffer value = new StringBuffer(); - boolean inQuote = false; - boolean inEscape = false; - char c; - - // State list for parsing machine - int START = 0; - int NAME = 1; - int VALUE = 2; - int state = !edit ? START : NAME; - - for (int i = 0; i < expansion.length(); ++i) { - c = expansion.charAt(i); - if (!edit && (state == START)) { - // Start of expansion - if (c != ':' || expansion.length() == 1) { - Object [] args = new Object[1]; - args[0] = getKey(); - MessageFormat form = new MessageFormat( - ResourceStrings.getString("mac_syntax_error")); - String msg = form.format(args); - throw new ValidationException(msg); - } - state = NAME; - } else if (state == NAME) { - // Name of symbol - if (c == '=') { - state = VALUE; - } else if (!edit && (c == ':')) { - if (!validate) { - storeOption(symbol.toString(), value.toString()); - } else { - setOption(symbol.toString(), value.toString(), false); - } - symbol.setLength(0); - value.setLength(0); - state = NAME; - } else { - symbol.append(c); - } - } else if (state == VALUE) { - // Value of symbol - if (inEscape) { - value.append(c); - inEscape = false; - } else if (c == '\\') { - inEscape = true; - } else if (c == '"') { - inQuote = !inQuote; - value.append(c); - } else if (inQuote) { - value.append(c); - } else if (!edit && (c == ':')) { - if (!validate) { - storeOption(symbol.toString(), value.toString()); - } else { - setOption(symbol.toString(), value.toString(), false); - } - symbol.setLength(0); - value.setLength(0); - state = NAME; - } else { - value.append(c); - } - } - } - - if (edit) { - setOption(symbol.toString(), value.toString(), true); - - valueClean = false; - } else { - if (state != NAME) { - Object [] args = new Object[1]; - args[0] = getKey(); - MessageFormat form = new MessageFormat( - ResourceStrings.getString("mac_syntax_error")); - String msg = form.format(args); - throw new ValidationException(msg); - } - super.setValue(expansion); - valueClean = true; - } - } - - public void editOption(String expansion) - throws ValidationException { - setValue(expansion, true, false); - } - - /** - * Common method used to set an option value for the macro. - * @param symbol name of the option - * @param value the option value(if any) - * @param edit flag indicating that this is an edit of and existing option - */ - private void setOption(String symbol, String value, boolean edit) - throws ValidationException { - - int index = getOptionIndex(symbol); - - if (value.length() == 0) { - - if (edit) { - if (index == -1) { - Object [] args = new Object[1]; - args[0] = symbol; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_option")); - String msg = form.format(args); - throw new ValidationException(msg); - } - deleteOptionAt(index); - } else { - OptionValue option = - OptionValueFactory.newOptionValue(symbol, new String()); - - if (option instanceof BogusOptionValue) { - Object [] args = new Object[1]; - args[0] = symbol; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_option")); - String msg = form.format(args); - throw new ValidationException(msg); - } else if (!(option instanceof BooleanOptionValue)) { - Object [] args = new Object[1]; - args[0] = symbol; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("not_boolean_option")); - String msg = form.format(args); - throw new ValidationException(msg); - } - } - - } else if (edit && value.equals(BOOLEAN_EDIT_VALUE)) { - - OptionValue option = - OptionValueFactory.newOptionValue(symbol, new String()); - - if (option instanceof BogusOptionValue) { - Object [] args = new Object[1]; - args[0] = symbol; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_option")); - String msg = form.format(args); - throw new ValidationException(msg); - } else if (!(option instanceof BooleanOptionValue)) { - Object [] args = new Object[1]; - args[0] = symbol; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("not_boolean_option")); - String msg = form.format(args); - throw new ValidationException(msg); - } - - if (index == -1) { - storeOption(option); - } else { - // nothing to do - option already turned on - } - - } else { - - OptionValue option = - OptionValueFactory.newOptionValue(symbol); - if (option instanceof BogusOptionValue) { - Object [] args = new Object[1]; - args[0] = symbol; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_option")); - String msg = form.format(args); - throw new ValidationException(msg); - } else if (edit && option instanceof BooleanOptionValue) { - Object [] args = new Object[1]; - args[0] = symbol; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("boolean_option")); - String msg = form.format(args); - throw new ValidationException(msg); - } - - if (index == -1) { - storeOption(option); - } else { - option = getOptionAt(index); - } - option.setValue(value); - - } - } - - public void storeOption(OptionValue option) - throws ValidationException { - options.addElement(option); - } - - public void storeOption(String option, Object value) - throws ValidationException { - options.addElement(OptionValueFactory.newOptionValue(option, value)); - } - - // Useful for creating options when standard code values are known. - // - // XXX - // NOTE!!! Do not use this method for now. We need to resolve whether or - // not all standard options are going to have unique codes. Today, they do - // not. We include internal options as standard and set their codes to 0. - // - public void storeOption(int code, Object value) throws ValidationException { - options.addElement( - OptionValueFactory.newOptionValue(StandardOptions.nameForCode(code), - value)); - } - - public String getValue() { - boolean first; - if (!valueClean) { - // Construct a new value - StringBuffer buf = new StringBuffer(); - for (Enumeration e = options.elements(); e.hasMoreElements(); ) { - OptionValue v = (OptionValue)e.nextElement(); - if (v == null) { - continue; // Ignore an empty position - } - buf.append(':'); - buf.append(v.toString()); - } - buf.append(':'); - try { - super.setValue(buf.toString()); - } catch (ValidationException ex) { - // Shouldn't happen; ignore it - } - valueClean = true; - } - return super.getValue(); - } - - public Enumeration elements() { - return options.elements(); - } - - public OptionValue [] getOptions() { - OptionValue [] optArray = new OptionValue[options.size()]; - options.copyInto(optArray); - return optArray; - } - - public OptionValue getOption(String name) { - for (Enumeration en = options.elements(); en.hasMoreElements(); ) { - OptionValue v = (OptionValue)en.nextElement(); - if (name.equals(v.getName())) { - return v; - } - } - return null; - } - - public int getOptionIndex(String name) { - int index = -1; - boolean found = false; - - Enumeration en = options.elements(); - while (en.hasMoreElements() && !found) { - index++; - OptionValue v = (OptionValue)en.nextElement(); - if (name.equals(v.getName())) { - found = true; - } - } - if (!found) { - index = -1; - } - - return index; - } - - public OptionValue getOptionAt(int index) { - return (OptionValue)options.elementAt(index); - } - - public void setOptionAt(OptionValue v, int index) { - if (index >= options.size()) { - options.setSize(index + 1); // Grow vector if necessary - } - options.setElementAt(v, index); - } - - public int optionCount() { - return options.size(); - } - - public void deleteOptionAt(int index) { - if (index >= options.size()) { - return; - } - options.removeElementAt(index); - } - - public void insertOptionAt(OptionValue v, int index) { - options.insertElementAt(v, index); - } - - // Make a copy of this macro - public Object clone() { - Macro m = new Macro(); - m.key = key; - m.options = new Vector(); - for (Enumeration en = options.elements(); en.hasMoreElements(); ) { - OptionValue v = (OptionValue)en.nextElement(); - m.options.addElement((OptionValue)v.clone()); - } - m.signature = signature; - return m; - } - - public String toString() { - return (getKey() + " m " + getValue()); - } - - // Verify that the options contained in this macro are all valid - public void validate() throws ValidationException { - for (Enumeration en = options.elements(); en.hasMoreElements(); ) { - OptionValue v = (OptionValue)en.nextElement(); - if (!v.isValid()) { - throw new ValidationException(v.getName()); - } - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/Makefile deleted file mode 100644 index d8e5af00e4..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/Makefile +++ /dev/null @@ -1,118 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/Makefile -# - -CONFIG_INTERFACE = DhcpConfigOpts.java - -CLASSFILES = Macro.class \ - OptionValueFactory.class \ - AsciiOptionValue.class \ - BogusOptionValue.class \ - BooleanOptionValue.class \ - IncludeOptionValue.class \ - IPOptionValue.class \ - NumberOptionValue.class \ - OctetOptionValue.class \ - OptionsTable.class \ - StandardOptions.class \ - Option.class \ - DhcptabRecord.class \ - DhcpClientRecord.class \ - DhcpClientFlagTypes.class \ - IPInterface.class \ - ExportHeader.class \ - Network.class \ - IPAddress.class \ - DhcpdOptions.class \ - DhcpDatastore.class \ - DhcpResource.class \ - OptionContext.class \ - OptionType.class \ - ActionError.class \ - DhcpClientFlagType.class \ - DhcpConfigOpts.class \ - ResourceStrings.class \ - ValidationException.class - -SUBDIRS = qualifier - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -include $(SRC)/Makefile.master - -CLASSPATH= $(SRC)/cmd/cmd-inet/usr.sadm/dhcpmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -MSGDIR= $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/data -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr \ - $(MSGDIR) - -MSGFILES= ResourceBundle.properties -MSGS= $(MSGFILES:%=$(MSGDIR)/%) - -CLEANFILES= *.class $(CONFIG_INTERFACE) -CLOBBERFILES= - -.KEEP_STATE: - -all: $(SUBDIRS) $(CONFIG_INTERFACE) $(CLASSFILES) - -install: $(SUBDIRS) all - -$(CONFIG_INTERFACE): $(SRC)/lib/libdhcpsvc/head/dhcp_svc_confkey.m4 - $(M4) -Djava $? > $@ - -_msg: $(SUBDIRS) $(MSGDIRS) $(MSGS) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - -lint: - -clean: $(SUBDIRS) FRC - $(RM) $(CLEANFILES) - -clobber: clean - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/Network.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/Network.java deleted file mode 100644 index d85a53f4a7..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/Network.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.data; - -import java.io.Serializable; -import java.util.StringTokenizer; -import java.text.MessageFormat; - -/** - * A representation of an IP network from DHCP's point of view; we're - * primarily interested in the address and subnet mask. - */ -public class Network implements Serializable, Comparable { - private IPAddress address; - private IPAddress netmask; - - // Serialization id for this class - static final long serialVersionUID = 7221738570228102243L; - - /** - * Construct an empty network object - */ - public Network() { - address = new IPAddress(); - netmask = new IPAddress(); - } - - /** - * Construct a network with the supplied address and a default mask - * @param addr The IP address of the network - */ - public Network(IPAddress addr) { - initialize(addr); - } - - // Common initialization routine - private void initialize(IPAddress addr) { - address = addr; - // Initialize a default netmask based on address class - byte [] b = address.getAddress(); - int msb = (int)b[0] & 0xff; - try { - if (msb < 128) { - netmask = new IPAddress("255.0.0.0"); - } else if (msb < 192) { - netmask = new IPAddress("255.255.0.0"); - } else { - netmask = new IPAddress("255.255.255.0"); - } - } catch (ValidationException e) { - // This shouldn't happen, above masks are all valid IP addrs - } - } - - /** - * Construct a network with the supplied address. - * @param addr The IP address of the network. - */ - public Network(String addr) throws ValidationException { - try { - initialize(new IPAddress(addr)); - } catch (ValidationException e) { - Object [] args = new Object[1]; - args[0] = addr; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_network")); - String msg = form.format(args); - throw new ValidationException(msg); - } - } - - /** - * Construct a network with the supplied address and subnet mask - * @param addr The IP address of the network as a <code>String</code> - * @param mask The subnet mask as an <code>int</code> - */ - public Network(String addr, int mask) throws ValidationException { - try { - address = new IPAddress(addr); - } catch (ValidationException e) { - Object [] args = new Object[1]; - args[0] = addr; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_network")); - String msg = form.format(args); - throw new ValidationException(msg); - } - - netmask = new IPAddress(mask); - } - - /** - * Construct a network with the supplied address and subnet mask. - * @param addr The IP address as an <code>IPAddress</code> - * @param mask The subnet mask as an <code>IPAddress</code> - */ - public Network(IPAddress addr, IPAddress mask) { - address = addr; - netmask = mask; - } - - /** - * Construct a network with the supplied address and subnet mask. - * @param addr The IP address as a dotted decimal <code>String</code> - * @param mask The subnet mask as a dotted decimal <code>String</code> - */ - public Network(String addr, String mask) throws ValidationException { - try { - address = new IPAddress(addr); - } catch (ValidationException e) { - Object [] args = new Object[1]; - args[0] = addr; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_network")); - String msg = form.format(args); - throw new ValidationException(msg); - } - - try { - netmask = new IPAddress(mask); - } catch (ValidationException e) { - Object [] args = new Object[1]; - args[0] = mask; - MessageFormat form = new MessageFormat( - ResourceStrings.getString("invalid_netmask")); - String msg = form.format(args); - throw new ValidationException(msg); - } - } - - /** - * @return The IP address of the network - */ - public IPAddress getAddress() { - return address; - } - - /** - * Return the actual network number, which is the product of applying - * the subnet mask to the address supplied. - * @return The network number as an <code>IPAddress</code> - */ - public IPAddress getNetworkNumber() { - // If netmask is not set then ignore it and return address raw - if (netmask.intValue() == 0) { - return address; - } else { - return new IPAddress(address.intValue() & netmask.intValue()); - } - } - - /** - * @return The subnet mask of the network - */ - public IPAddress getMask() { - return netmask; - } - - /** - * Set the subnet mask. - * @param mask The subnet mask. - */ - public void setMask(IPAddress mask) { - netmask = mask; - } - - /** - * Do the math to evaluate whether an address is part of this network. - * @param addr The IP address to evaluate - * @return <code>true</code> if the address is on this network, - * <code>false</code> if not. - */ - public boolean containsAddress(IPAddress addr) { - return ((addr.intValue() & netmask.intValue()) - == (address.intValue() & netmask.intValue())); - } - - /** - * Compute the broadcast address for this network and return it. - * @return a string representation of the broadcast address. - */ - public String getBroadcastAddress() { - - byte [] netBytes = getAddress().getAddress(); - byte [] maskBytes = getMask().getAddress(); - StringBuffer buf = new StringBuffer(); - for (int i = 0; i < netBytes.length; ++i) { - int b = (netBytes[i] | ~maskBytes[i]) & 0xff; - if (buf.length() != 0) { - buf.append('.'); - } - buf.append(b); - } - - return (buf.toString()); - - } // getBroadcastAddress - - /** - * Compare against another network object for equality. - * @param obj The network to compare against. - * @return <code>true</code> if the networks have the same network number - */ - public boolean equals(Object obj) { - // If object passed isn't of same type, always false. - if (!(obj instanceof Network)) { - return false; - } - return getNetworkNumber().equals(((Network)obj).getNetworkNumber()); - } - - public String toString() { - return getNetworkNumber().toString(); - } - - /** - * Perform comparisons to another Network instance. This is used - * for sorting a list of network tables. - * @param o A <code>Network</code> to compare against. - * @return 0 if the objects have the same address, - * a negative number if this record has a lower IP address than the - * supplied record, a positive number if this record has a higher IP - * address than the supplied record. - */ - public int compareTo(Object o) { - - Network n = (Network)o; - long result = getNetworkNumber().getBinaryAddress() - - n.getNetworkNumber().getBinaryAddress(); - - if (result < 0) { - return (-1); - } else if (result > 0) { - return (1); - } else { - return (0); - } - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/NumberOptionValue.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/NumberOptionValue.java deleted file mode 100644 index a914c3b099..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/NumberOptionValue.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.data; - -import java.io.Serializable; -import java.util.*; -import java.math.BigInteger; - -/** - * This class provides a way to retain the radix specified by the user - * when entering the data. Currently only support 10 and 16 for radix. - */ -class NumberValue implements Serializable { - private Number value; - private int radix; - - // Serialization id for this class - static final long serialVersionUID = -3480903816949402385L; - - public NumberValue(Number value, int radix) { - this.value = value; - this.radix = radix; - } - - public String toString() { - if (value instanceof BigInteger) { - return ((BigInteger)value).toString(radix); - } - // Handle hex specially - if (radix == 16) { - return "0x" + Long.toHexString(value.longValue()); - } else { - return Long.toString(value.longValue()); - } - } -} - -public class NumberOptionValue extends OptionValue { - private String name; - private Vector nums; - private boolean valid; - private int radix; - - // Serialization id for this class - static final long serialVersionUID = -5824132577553748971L; - - protected NumberOptionValue(String name) { - this.name = name; - nums = null; - valid = false; - } - - public void setValue(Object value) throws ValidationException { - // Find option in option definition table in order to validate the data - Option option = OptionsTable.getTable().get(name); - if (option == null) { - Object [] args = { name }; - throwException("invalid_option", args); - } - - // The granularity attribute must be interpreted in context - // of what kind of number option we're dealing with. If this - // is a NUMBER option, then granularity defines the number of - // octets the number will contain (in other words the size). - // For all other number types it defines how many numbers of - // that type make make a valid option of that type. Note that - // in the case of NUMBER options that granularity always defaults - // to one. XXX Swill code here. Should probably define a new class and - // create an array of them and simply loop. - byte type = option.getType(); - boolean isUnsigned = false; - int bits = option.getGranularity() * 8; - int realGranularity = option.getGranularity(); - - if (type == Option.types[Option.NUMBER].getCode()) { - realGranularity = 1; - } else if (type == Option.types[Option.SNUMBER8].getCode()) { - bits = 7; - } else if (type == Option.types[Option.UNUMBER8].getCode()) { - bits = 8; - isUnsigned = true; - } else if (type == Option.types[Option.SNUMBER16].getCode()) { - bits = 15; - } else if (type == Option.types[Option.UNUMBER16].getCode()) { - bits = 16; - isUnsigned = true; - } else if (type == Option.types[Option.SNUMBER32].getCode()) { - bits = 31; - } else if (type == Option.types[Option.UNUMBER32].getCode()) { - bits = 32; - isUnsigned = true; - } else if (type == Option.types[Option.SNUMBER64].getCode()) { - bits = 63; - } else if (type == Option.types[Option.UNUMBER64].getCode()) { - bits = 64; - isUnsigned = true; - } - - Vector newNums = new Vector(); - if (value instanceof String) { - if (((String)value).length() == 0) { - // Empty strings are not acceptable - Object [] args = { name, - Option.getTypeDhcptabString(type) }; - throwException("invalid_option_value", args); - } - // Parse each token into an object of the correct numeric type - StringTokenizer st = new StringTokenizer((String)value, " "); - while (st.hasMoreTokens()) { - int radix = 10; - String s = st.nextToken(); - if (s.startsWith("0x") || s.startsWith("0X")) { - radix = 16; - s = s.substring(2); - } else if (s.startsWith("0") && (s.length() > 1)) { - radix = 8; - s = s.substring(1); - } - - BigInteger b; - try { - b = new BigInteger(s, radix); - if (b.bitLength() > bits) { - Object [] args = { name, - Option.getTypeDhcptabString(type) }; - throwException("invalid_option_value", args); - } - if (isUnsigned && b.compareTo(BigInteger.ZERO) < 0) { - Object [] args = { name, - Option.getTypeDhcptabString(type) }; - throwException("invalid_option_value", args); - } - newNums.addElement(new NumberValue(b, radix)); - } catch (NumberFormatException e) { - Object [] args = { name, - Option.getTypeDhcptabString(type) }; - throwException("invalid_option_value", args); - } - } - } else if (value instanceof Number) { - newNums.addElement(new NumberValue((Number)value, 10)); - } else if (!(value instanceof Vector)) { - Object [] args = { name, - Option.getTypeDhcptabString(type) }; - throwException("invalid_option_value", args); - } else { - // Caller supplied a vector; make sure each value is a number - Enumeration en = ((Vector)value).elements(); - while (en.hasMoreElements()) { - Object o = en.nextElement(); - if (!(o instanceof Number)) { - Object [] args = { name, - Option.getTypeDhcptabString(type) }; - throwException("invalid_option_value", args); - } else { - newNums.addElement(new NumberValue((Number)o, 10)); - } - } - } - - // We now have a vector of numbers; check count against expected - if (newNums.size() % realGranularity != 0) { - Object [] args = { name, Integer.toString(realGranularity) }; - throwException("invalid_option_granularity", args); - } - if ((option.getMaximum() != 0) - && (newNums.size() / realGranularity > option.getMaximum())) { - Object [] args = { name, Integer.toString(option.getMaximum()) }; - throwException("invalid_option_maximum", args); - } - - nums = newNums; - valid = true; - } - - public String getName() { - return name; - } - - public String getValue() { - if (nums == null || nums.size() == 0) { - return ""; - } - StringBuffer buf = new StringBuffer(); - for (Enumeration en = nums.elements(); en.hasMoreElements(); ) { - if (buf.length() != 0) { - buf.append(' '); - } - buf.append(en.nextElement().toString()); - } - return buf.toString(); - } - - public String toString() { - return (getName() + "=" + getValue()); - } - - public boolean isValid() { - return valid; - } - - public Object clone() { - NumberOptionValue v = new NumberOptionValue(name); - if (nums != null) { - v.nums = (Vector)nums.clone(); - } - v.valid = valid; - return v; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OctetOptionValue.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OctetOptionValue.java deleted file mode 100644 index 1519ca575b..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OctetOptionValue.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.data; - -import java.util.Vector; -import java.util.Enumeration; - -public class OctetOptionValue extends OptionValue { - private String name; - private String value; - private boolean valid; - - // Serialization id for this class - static final long serialVersionUID = -3267221437949696358L; - - protected OctetOptionValue(String name) { - this.name = name; - value = ""; - valid = false; - } - - public void setValue(Object value) throws ValidationException { - // Find option in option definition table in order to validate the data - Option option = OptionsTable.getTable().get(name); - if (option == null) { - Object [] args = { name }; - throwException("invalid_option", args); - } - if (value instanceof String) { - if (((String)value).length() == 0) { - // Empty values are not acceptable - Object [] args = { name, - Option.getTypeDhcptabString(option.getType()) }; - throwException("invalid_option_value", args); - } - // Just make a copy of the reference - this.value = (String)value; - valid = true; - } else if (value instanceof Vector) { - /* - * Generate the value by concatenating toString()'s on the - * vector's elements - */ - StringBuffer b = new StringBuffer(); - Enumeration en = ((Vector)value).elements(); - while (en.hasMoreElements()) { - b.append(en.nextElement().toString()); - } - setValue(b.toString()); - } else { - // Convert anything else to a string - setValue(value.toString()); - } - } - - public String getName() { - return name; - } - - public String getValue() { - return value; - } - - public String toString() { - return (getName() + "=" + getValue()); - } - - public boolean isValid() { - return valid; - } - - public Object clone() { - OctetOptionValue v = new OctetOptionValue(name); - v.value = value; - v.valid = valid; - return v; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/Option.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/Option.java deleted file mode 100644 index 65830980dd..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/Option.java +++ /dev/null @@ -1,535 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data; - -import java.util.*; - -/** - * Option is a simple data class which encapsulates an option record in - * the dhcptab. See dhcptab(4) for the gory details on options (aka symbols). - * - * @see DhcptabRecord - * @see Macro - */ -public class Option extends DhcptabRecord implements Cloneable { - private byte context; - private short code; - private byte type; - private int granularity; - private int maximum; - private Vector vendors; - private boolean valueClean = false; - private boolean validValue = true; - - // The Option attributes that must match their native values. - - // Definition for attribute limits - public static short MAX_NAME_SIZE = 128; - - // Option contexts. - public static byte STANDARD = 0; - public static byte EXTEND = 1; - public static byte VENDOR = 2; - public static byte SITE = 3; - public static byte CONTEXTS = 4; - public static OptionContext [] ctxts = { - new OptionContext(STANDARD, "Standard", "standard_option"), - new OptionContext(EXTEND, "Extend", "extended_option"), - new OptionContext(VENDOR, "Vendor=", "vendor_option"), - new OptionContext(SITE, "Site", "site_option") }; - - // Option types. - public static byte ASCII = 0; - public static byte OCTET = 1; - public static byte IP = 2; - public static byte NUMBER = 3; - public static byte BOOLEAN = 4; - public static byte UNUMBER8 = 5; - public static byte UNUMBER16 = 6; - public static byte UNUMBER32 = 7; - public static byte UNUMBER64 = 8; - public static byte SNUMBER8 = 9; - public static byte SNUMBER16 = 10; - public static byte SNUMBER32 = 11; - public static byte SNUMBER64 = 12; - public static byte TYPES = 13; - - public static OptionType [] types = { - new OptionType((byte)0, "ASCII", "ascii_type"), - new OptionType((byte)1, "OCTET", "octet_type"), - new OptionType((byte)2, "IP", "ip_type"), - new OptionType((byte)3, "NUMBER", "number_type"), - new OptionType((byte)4, "BOOL", "boolean_type"), - new OptionType((byte)6, "UNUMBER8", "unumber8_type"), - new OptionType((byte)7, "UNUMBER16", "unumber16_type"), - new OptionType((byte)8, "UNUMBER32", "unumber32_type"), - new OptionType((byte)9, "UNUMBER64", "unumber64_type"), - new OptionType((byte)10, "SNUMBER8", "snumber8_type"), - new OptionType((byte)11, "SNUMBER16", "snumber16_type"), - new OptionType((byte)12, "SNUMBER32", "snumber32_type"), - new OptionType((byte)13, "SNUMBER64", "snumber64_type") }; - - /* - * These need to be the same as the definitions in libdhcputil's - * parser in dhcp_symbol.c - */ - public static String DSYM_CLASS_DEL_SPACE = " "; - public static String DSYM_CLASS_DEL = DSYM_CLASS_DEL_SPACE + "\t\n"; - public static String DSYM_CLASS_DEL_REGEXP = ".*[" + DSYM_CLASS_DEL + "].*"; - public static char DSYM_FIELD_DEL = ','; - public static char DSYM_QUOTE = '"'; - - - // Serialization id for this class - static final long serialVersionUID = 7468266817375654444L; - - /** - * Construct an empty instance. Default to Site option, IP type. - */ - public Option() { - super("", DhcptabRecord.OPTION, ""); - valueClean = false; - vendors = new Vector(); - context = ctxts[SITE].getCode(); - type = types[IP].getCode(); - granularity = 1; - } - - /** - * Construct a fully defined instance. Used by the server to create - * Options. - * @param name the option name/key - * @param context the option context/category code - * @param vendors the list of vendors (if any) - * @param code the option code - * @param type the option type code - * @param gran the option granularity - * @param max the option maximum - * @param sig the signature from the dhcptab - * @param isValid the flag indicating option definition validity - */ - public Option(String name, byte context, String [] vendors, short code, - byte type, int gran, int max, String sig, boolean isValid) { - - super("", DhcptabRecord.OPTION, ""); - - valueClean = false; - validValue = isValid; - - setKey(name); - setContext(context); - setVendors(vendors); - setCode(code); - setType(type); - setGranularity(gran); - setMaximum(max); - - if (sig != null) { - setSignature(sig); - } - } - - /** - * Set the option name as specified. - * @param name a string representing the option name. - */ - public void setKey(String name) { - try { - super.setKey(name); - } catch (ValidationException e) { - // Can't happen. - } - } - - /** - * Get the context for this option - * @return a byte for the option context (context codes are - * defined by the OptionContext objects in the ctxts array). - */ - public byte getContext() { - return context; - } - - /** - * Set the context for this option (context codes are defined - * by the OptionContext objects in the ctxts array). - */ - public void setContext(byte c) { - context = c; - valueClean = false; - } - - /** - * Enumerate the vendor list. - * @return an Enumeration of the vendors, which will be empty for - * non-vendor options. - */ - public Enumeration getVendors() { - return vendors.elements(); - } - - /** - * Get the number of vendors for this option. - * @return an int count of the vendors, zero for non-vendor options. - */ - public int getVendorCount() { - return vendors.size(); - } - - /** - * Add a vendor to the list for this option. - * @param v the vendor name as a String. - */ - public void addVendor(String v) throws ValidationException { - if (v.indexOf(DSYM_FIELD_DEL) != -1) { - throw new ValidationException(v); - } - vendors.addElement(v); - valueClean = false; - } - - /** - * Empty the vendor list. - */ - public void clearVendors() { - vendors = new Vector(); - valueClean = false; - } - - /** - * Remove a vendor from the list. - * @param index the position of the vendor to remove in the list of vendors - */ - public void removeVendorAt(int index) { - vendors.removeElementAt(index); - valueClean = false; - } - - /** - * Get the vendor at a specified index in the vendor list. - * @param index the index of the vendor to retrieve - * @return the vendor name - */ - public String getVendorAt(int index) { - return (String)vendors.elementAt(index); - } - - private void setVendors(String [] vendors) { - - this.vendors = new Vector(); - - if (vendors == null) { - return; - } - - for (int i = 0; i < vendors.length; i++) { - this.vendors.addElement(vendors[i]); - } - - } - - /** - * Set the vendor name at a specified index in the list. - * @param vendor the vendor name - * @param index the position in the list to set. - */ - public void setVendorAt(String vendor, int index) { - if (index >= vendors.size()) { - vendors.setSize(index+1); - } - vendors.setElementAt(vendor, index); - valueClean = false; - } - - /** - * Get the option code. - * @return the code as a short. - */ - public short getCode() { - return code; - } - - /** - * Set the option code. - * @param c the code to use - */ - public void setCode(short c) { - code = c; - valueClean = false; - } - - /** - * Get the type. - * @return a byte value for the type (type codes are - * defined by the OptionTypes objects in the type array). - * OCTET - */ - public byte getType() { - return type; - } - - /** - * Set the type. - * @param t the type code (type codes are defined by the - * OptionTypes objects in the type array). - * or OCTET. - */ - public void setType(byte t) { - type = t; - valueClean = false; - } - - /** - * Get the granularity. See dhcptab(4) for an explanation of granularity - * interpretations. - * @return the granularity as an int - */ - public int getGranularity() { - return granularity; - } - - /** - * Set the granularity. See dhcptab(4) for an explanation of granularity - * interpretations. - * @param g the granularity as an int. - */ - public void setGranularity(int g) { - granularity = g; - valueClean = false; - } - - /** - * Get the maximum. See dhcptab(4) for an explanation of maximum. - * @return the maximum as an int. - */ - public int getMaximum() { - return maximum; - } - - /** - * Set the maximum. See dhcptab(4) for an explanation of maximum. - * @param m the maximum as an int. - */ - public void setMaximum(int m) { - maximum = m; - valueClean = false; - } - - /** - * Return validity of this option. - * @return true if the option is correctly defined, false if not - */ - public boolean isValid() { - return (validValue); - } - - /** - * Get the definition as a string in the format specified by dhcptab(4) - * @return a String containing the definition - */ - public String getValue() { - /* The value string stored is not clean, regenerate */ - if (!valueClean) { - StringBuffer b = new StringBuffer(); - // Start with context - b.append(getContextDhcptabString(context)); - // Vendor context next adds the vendors, separate by blanks - if (context == ctxts[VENDOR].getCode()) { - boolean first = true; - for (Enumeration e = getVendors(); e.hasMoreElements(); ) { - String s = (String)e.nextElement(); - if (!first) { - b.append(DSYM_CLASS_DEL_SPACE); - } else { - first = false; - } - // If vendor class contains whitespace, need to quote it - boolean needQuoting = s.matches(DSYM_CLASS_DEL_REGEXP); - if (needQuoting) { - b.append(DSYM_QUOTE); - } - b.append(s); - if (needQuoting) { - b.append(DSYM_QUOTE); - } - } - } - b.append(DSYM_FIELD_DEL); - // Add the code - b.append(code); - b.append(DSYM_FIELD_DEL); - // Add the type - b.append(getTypeDhcptabString(type)); - b.append(DSYM_FIELD_DEL); - // Add the granularity - b.append(granularity); - b.append(DSYM_FIELD_DEL); - // Add the maximum - b.append(maximum); - // Save it and note as such so we can avoid doing this again - try { - super.setValue(b.toString()); - } catch (ValidationException e) { - // This should never happen! - } - valueClean = true; - } - return super.getValue(); - } - - // Make a copy of this option - public Object clone() { - Option o = new Option(); - - o.setKey(getKey()); - o.setContext(getContext()); - o.setCode(getCode()); - o.vendors = new Vector(); - for (Enumeration en = vendors.elements(); en.hasMoreElements(); ) { - String s = (String)en.nextElement(); - o.vendors.addElement(new String(s)); - } - o.setType(getType()); - o.setGranularity(getGranularity()); - o.setMaximum(getMaximum()); - o.setSignature(getSignature()); - - return o; - } - - /** - * Returns a string representation of this object. - * @return a string representation of this object. - */ - public String toString() { - return (getKey() + " s " + getValue()); - } - - /** - * Returns the context definition for the specified context. - * @param code the context code. - * @return the OptionContext for the context. - */ - public static OptionContext findContext(byte code) { - - OptionContext ctxt = null; - - for (int i = 0; i < CONTEXTS; i++) { - if (ctxts[i].getCode() == code) { - ctxt = ctxts[i]; - break; - } - } - - return (ctxt); - } - - /** - * Returns the dhcptab string representation of the specified context. - * @param code the context code. - * @return the dhcptab string representation of the context. - */ - public static String getContextDhcptabString(byte code) { - - OptionContext ctxt = findContext(code); - - if (ctxt == null) { - return ("undefined"); - } else { - return (ctxt.getDhcptabString()); - } - } - - /** - * Returns the string representation of the specified context. - * @param code the context code. - * @return a string representation of the context. - */ - public static String getContextString(byte code) { - - OptionContext ctxt = findContext(code); - - if (ctxt == null) { - return ("undefined"); - } else { - return (ctxt.toString()); - } - } - - /** - * Returns the type definition for the specified type. - * @param code the type code. - * @return the OptionType for the type. - */ - public static OptionType findType(byte code) { - - OptionType type = null; - - for (int i = 0; i < TYPES; i++) { - if (types[i].getCode() == code) { - type = types[i]; - break; - } - } - - return (type); - } - - /** - * Returns the dhcptab string representation of the specified type. - * @param code the type code. - * @return the dhcptab string representation of the type. - */ - public static String getTypeDhcptabString(byte code) { - - OptionType type = findType(code); - - if (type == null) { - return ("undefined"); // should never happen - } else { - return (type.getDhcptabString()); - } - } - - /** - * Returns the string representation of the specified type. - * @param code the type code. - * @return a string representation of the type. - */ - public static String getTypeString(byte code) { - - OptionType type = findType(code); - - if (type == null) { - return ("undefined"); // should never happen - } else { - return (type.toString()); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionContext.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionContext.java deleted file mode 100644 index 945c1ec1b1..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionContext.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data; - -import java.io.Serializable; - -/** - * OptionContext simply defines the attributes that should be associated - * with an Option context. Simply a container. - */ -public class OptionContext implements Serializable { - - private byte code; - private String dhcptabString; - private String string; - - // Serialization id for this class - static final long serialVersionUID = -8656392905082090762L; - - /** - * Constructs a fully defined instance of an OptionContext. - * @param code the context code - * @param dhcptabString the dhcptab string definition for the context - * @param msgid the msgid for the description of the context - */ - public OptionContext(byte code, String dhcptabString, String msgid) { - this.code = code; - this.dhcptabString = dhcptabString; - this.string = ResourceStrings.getString(msgid); - } // constructor - - /** - * Returns the code for the context - * @returns the code for the context - */ - public byte getCode() { - return code; - } // getCode - - /** - * Returns the dhcptab string definition for the context - * @returns the dhcptab string definition for the context - */ - public String getDhcptabString() { - return dhcptabString; - } // getDhcptabString - - /** - * Returns a string representation of this object. - * @return a string representation of this object. - */ - public String toString() { - return (string); - } // toString - -} // OptionContext diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionType.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionType.java deleted file mode 100644 index 4b9f0a39c7..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionType.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data; - -import java.io.Serializable; - -/** - * OptionType simply defines the attributes that should be associated - * with an Option type. Simply a container. - */ -public class OptionType implements Serializable { - - private byte code; - private String dhcptabString; - private String string; - - // Serialization id for this class - static final long serialVersionUID = -1933732689675276794L; - - /** - * Constructs a fully defined instance of an OptionType. - * @param code the type code - * @param dhcptabString the dhcptab string definition for the type - * @param msgid the msgid for the description of the type - */ - public OptionType(byte code, String dhcptabString, String msgid) { - this.code = code; - this.dhcptabString = dhcptabString; - this.string = ResourceStrings.getString(msgid); - } // constructor - - /** - * Returns the code for the type - * @returns the code for the type - */ - public byte getCode() { - return code; - } // getCode - - /** - * Returns the dhcptab string definition for the type - * @returns the dhcptab string definition for the type - */ - public String getDhcptabString() { - return dhcptabString; - } // getDhcptabString - - /** - * Returns a string representation of this object. - * @return a string representation of this object. - */ - public String toString() { - return (string); - } // toString - -} // OptionType diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionValue.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionValue.java deleted file mode 100644 index 3f555b8baf..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionValue.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.data; - -import java.io.Serializable; -import java.util.Vector; -import java.text.MessageFormat; - -/** - * OptionValue is an abstract superclass for all the actual types of options - * which may be stored in a macro. - */ -public abstract class OptionValue implements Serializable, Cloneable { - - // Serialization id for this class - static final long serialVersionUID = -1346853613202192887L; - - public abstract String getName(); - public abstract String getValue(); - public abstract void setValue(Object value) throws ValidationException; - public abstract boolean isValid(); - public abstract Object clone(); - - protected void throwException(String msgid, Object [] args) - throws ValidationException { - MessageFormat form = new MessageFormat( - ResourceStrings.getString(msgid)); - String msg = form.format(args); - throw new ValidationException(msg); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionValueFactory.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionValueFactory.java deleted file mode 100644 index aa3a0c00e1..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionValueFactory.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.data; - -import java.util.Vector; - -/** - * This class provides the functionality to construct an option value of the - * correct type when only the tag we associate with the option value is known. - */ -public class OptionValueFactory { - private static OptionsTable optionsTable = OptionsTable.getTable(); - - /** - * Construct an option value given the name, and initialize it to the - * provided value. - * @param name the name of the option - * @param value the initial value for the option - * @return an OptionValue of the correct type for this option. If the name - * or value supplied is invalid in some way, an instance of - * BogusOptionValue is returned and the caller should take appropriate - * action. - */ - public static OptionValue newOptionValue(String name, Object value) { - OptionValue v; - try { - v = newOptionValue(name); - v.setValue(value); - } catch (ValidationException e) { - // Not a valid value; put it in the bogus value placeholder - v = new BogusOptionValue(name, value); - } - return v; - } - - /** - * Construct an empty option value given the name - * @param name the name of the option - * @return an OptionValue of the correct type for this option. - */ - public static OptionValue newOptionValue(String name) { - if (name.length() == 0) { - // Empty name is not acceptable - return new BogusOptionValue(name); - } - Option opt = optionsTable.get(name); - if (opt == null) { - // Include is not in the options table - if (name.equals("Include")) { - return new IncludeOptionValue(); - } else { - /* - * Bogus option name; create a bogus value that callers - * can pick up later. - */ - return new BogusOptionValue(name); - } - } - - byte type = opt.getType(); - if (type == Option.types[Option.ASCII].getCode()) { - return new AsciiOptionValue(name); - } else if (type == Option.types[Option.BOOLEAN].getCode()) { - return new BooleanOptionValue(name); - } else if (type == Option.types[Option.IP].getCode()) { - return new IPOptionValue(name); - } else if (type == Option.types[Option.OCTET].getCode()) { - return new OctetOptionValue(name); - } else if (type == Option.types[Option.NUMBER].getCode() || - type == Option.types[Option.UNUMBER8].getCode() || - type == Option.types[Option.UNUMBER16].getCode() || - type == Option.types[Option.UNUMBER32].getCode() || - type == Option.types[Option.UNUMBER64].getCode() || - type == Option.types[Option.SNUMBER8].getCode() || - type == Option.types[Option.SNUMBER16].getCode() || - type == Option.types[Option.SNUMBER32].getCode() || - type == Option.types[Option.SNUMBER64].getCode()) { - return new NumberOptionValue(name); - } else { - // This should never happen - return new BogusOptionValue(name); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionsTable.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionsTable.java deleted file mode 100644 index aadf1d91d1..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/OptionsTable.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.data; - -import java.util.*; -import java.io.Serializable; - -/** - * This class provides a global table of all the options currently known. - * It is implemented as a singleton as there should be no need for more - * than a single instance of this table. It includes both the standard - * options and any vendor or site options defined in the current environment. - */ -public class OptionsTable implements Serializable { - private Hashtable options; - private static OptionsTable table = null; - - protected OptionsTable() { - // Get the standard options we know about - StandardOptions stdopts = new StandardOptions(); - - // Initialize hash table with extra size we will probably need. - options = new Hashtable(stdopts.size() + 20); - - // Add the standard options to the table - add(stdopts.getAllOptions()); - } - - /** - * Add an array of options to the table. - * @param opts An array of Options - */ - public void add(Option [] opts) { - for (int i = 0; opts != null && i < opts.length; ++i) { - add(opts[i]); - } - } - - /** - * Add a single option to the table. - * @param o The option to add. - */ - public void add(Option o) { - // Don't add unless it is a valid option. - if (o.isValid()) { - options.put(o.getKey(), o); - } - } - - /** - * Retrieve an option from the table by name - * @param opt the name of the option to retrieve - * @return the option found, or null if the option is not in the table - */ - public Option get(String opt) { - return (Option)options.get(opt); - } - - /** - * Retrieve an option from the table by its code - * @param code the code of the option to retrieve - * @return the option found, or null if the option is not in the table - */ - public Option getByCode(short code) { - - Option option = null; - for (Enumeration e = elements(); e.hasMoreElements(); ) { - if (((Option)e.nextElement()).getCode() == code) { - option = (Option)e.nextElement(); - } - } - return (option); - } - - /** - * Enumerate the options in this table for those that might need to walk it. - * @return an Enumeration of the options - */ - public Enumeration elements() { - return options.elements(); - } - - /** - * Return the global table, create it if not already in existence. - * @return the current options table - */ - public static OptionsTable getTable() { - if (table == null) { - table = new OptionsTable(); - } - return table; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ResourceBundle.properties b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ResourceBundle.properties deleted file mode 100644 index 10d340f199..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ResourceBundle.properties +++ /dev/null @@ -1,69 +0,0 @@ -# -# ident "%W% %E% SMI" -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -invalid_ip_address={0} is not a valid IP address -invalid_option_value=The {0} option requires an {1} value -invalid_include_option=The Include option requires a value -invalid_option_maximum=The {0} option value exceeds the maximum limit of {1} -invalid_option_granularity=The {0} option value must have a granularity of {1} - -invalid_option=The {0} option is an invalid option or is not of the correct type -boolean_option=The {0} option is a boolean option -not_boolean_option=The {0} option is not a boolean option -mac_syntax_error=The macro, {0}, contains a definition syntax error -macro_key_length=Macro names must be no more than {0} characters -invalid_network={0} is not valid a valid network -invalid_netmask={0} is not valid netmask - -dcr_invalid_null_clientip=The client address must be defined. -dcr_invalid_clientip=The client address is not a valid address. -dcr_invalid_clientid=The client id is not a valid client id. -dcr_invalid_flags=The flags value is not valid. -dcr_invalid_null_serverip=The server address must be defined. -dcr_invalid_serverip=The server address is not a valid address. -dcr_invalid_expiration=The lease expiration date is not in a valid format. - -# Note: these msgids are used by the native library. -standard_option=Standard -extended_option=Extended -vendor_option=Vendor -site_option=Site - -# Note: these msgids are used by the native library. -ascii_type=ASCII text -octet_type=Octet -ip_type=IP Address -number_type=Number -boolean_type=Boolean -unumber8_type=Unsigned 8-bit Number -unumber16_type=Unsigned 16-bit Number -unumber32_type=Unsigned 32-bit Number -unumber64_type=Unsigned 64-bit Number -snumber8_type=Signed 8-bit Number -snumber16_type=Signed 16-bit Number -snumber32_type=Signed 32-bit Number -snumber64_type=Signed 64-bit Number diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ResourceStrings.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ResourceStrings.java deleted file mode 100644 index 5e43a97bfb..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ResourceStrings.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.data; - -import java.util.*; - -/** - * This class provides a convenient method to retrieve resources for - * the data package. - */ -public class ResourceStrings { - - /** - * The handle to the resource bundle for the module. - */ - private static ResourceBundle bundle = null; - - /** - * Return a string from the resource bundle. - * @param key the key to the resource bundle string. - * @return the resource bundle string. - */ - public static String getString(String key) { - String msg = null; - try { - if (bundle == null) { - bundle = ResourceBundle.getBundle( - "com.sun.dhcpmgr.data.ResourceBundle", - Locale.getDefault()); - } - msg = bundle.getString(key); - } catch (Throwable e) { - msg = new String(key); - } - return msg; - - } // getString - -} // ResourceStrings diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/StandardOptions.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/StandardOptions.java deleted file mode 100644 index 02783d99fd..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/StandardOptions.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.data; - -import java.util.*; -import java.io.Serializable; - -/** - * This class defines the set of standard DHCP options we know about. - */ -public class StandardOptions implements Serializable { - - /* - * The following list of options are the ones that we use - * in order to configure DHCP for the user. - */ - public static final String CD_SUBNETMASK = "Subnet"; - public static final String CD_TIMEOFFSET = "UTCoffst"; - public static final String CD_ROUTER = "Router"; - public static final String CD_TIMESERV = "Timeserv"; - public static final String CD_DNSSERV = "DNSserv"; - public static final String CD_DNSDOMAIN = "DNSdmain"; - public static final String CD_BROADCASTADDR = "Broadcst"; - public static final String CD_ROUTER_DISCVRY_ON = "RDiscvyF"; - public static final String CD_NIS_DOMAIN = "NISdmain"; - public static final String CD_NIS_SERV = "NISservs"; - public static final String CD_LEASE_TIME = "LeaseTim"; - public static final String CD_BOOL_LEASENEG = "LeaseNeg"; - - /* - * Following list of options must be kept in sync with the list in - * usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/dhcptab.c in SunOS source tree. - */ - private static Option [] options = null; - - /** - * Return the size of this list - * @return the number of options known - */ - public static int size() { - return (options == null) ? 0 :options.length; - } - - /** - * Enumerate the options defined here. - * @return an Enumeration of the standard options. - */ - public Enumeration enumOptions() { - return new Enumeration() { - int cursor = 0; - - public boolean hasMoreElements() { - return (cursor < size()); - } - - public Object nextElement() throws NoSuchElementException { - if (cursor >= size()) { - throw new NoSuchElementException(); - } - return (options[cursor++]); - } - }; - } - - /** - * Return all options as an array - * @return the array of options defined here - */ - public static Option [] getAllOptions() { - return options; - } - - /** - * Set all options as an array - * @param options array of STANDARD options - */ - public static void setAllOptions(Option [] ops) { - options = ops; - } - - /** - * Find the option name for a given code. This could be - * much faster but not clear that it needs to be yet. - * @return the name of the option, or null if that code is unknown. - */ - public static String nameForCode(int code) { - for (int i = 0; i < options.length; ++i) { - if (options[i].getCode() == code) { - return options[i].getKey(); - } - } - return null; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ValidationException.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ValidationException.java deleted file mode 100644 index 521bd5b990..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/ValidationException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.data; - -public class ValidationException extends Exception { - public ValidationException() { - super(); - } - - public ValidationException(String s) { - super(s); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/Makefile deleted file mode 100644 index 745e54a335..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/Makefile +++ /dev/null @@ -1,80 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/Makefile -# - -CLASSFILES = QualifierType.class \ - QualifierTypeImpl.class \ - Qualifier.class \ - QualifierEnum.class \ - QualifierRange.class \ - QualifierImpl.class \ - QualifierBoolean.class \ - QualifierString.class \ - QualifierStringEnum.class \ - QualifierInteger.class \ - QualifierIntegerEnum.class \ - QualifierIntegerRange.class \ - QualifierArray.class \ - QualifierAnd.class \ - QualifierOr.class \ - QualifierFQDN.class \ - QualifierIPv4.class \ - QualifierIPv6.class - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -include $(SRC)/Makefile.master - -CLASSPATH= $(SRC)/cmd/cmd-inet/usr.sadm/dhcpmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -CLEANFILES= *.class -CLOBBERFILES= - -.KEEP_STATE: - -all: $(CLASSFILES) - -install: all - -_msg: - -lint: - -clean: - $(RM) $(CLEANFILES) - -clobber: clean - diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/Qualifier.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/Qualifier.java deleted file mode 100644 index 98b45d95a0..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/Qualifier.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -/** - * Common interface that all concrete qualifiers can implement. A qualifier - * contains information about a given parameter. This information includes the - * parameter type and whether the parameter is read only. - */ -public interface Qualifier { - - /** - * Attribute that indicates the name of the parameter the qualifier is - * associated with. - */ - public final static String KEYWORD = "keyword"; - - /** - * Attribute that indicates the Java type that can store a legal value for - * the parameter. - */ - public final static String TYPE = "type"; - - /** - * Attribute that indicates whether the parameter is designated as read - * only. - */ - public final static String READONLY = "readOnly"; - - /** - * Attribute that indicates whether the parameter is hidden. - */ - public final static String HIDDEN = "hidden"; - - /** - * Get the named qualifier attribute. - * - * @param attribute - * Attribute to get. - * @return - * The value of the attribute, or null if the attribute is not set. - */ - public Object getAttribute(String attribute); - - /** - * Set the named qualifier attributes value. - * - * @param attribute - * Attribute to set. - * @param value - * The value to set the attribute to, or null if the attribute is to - * be removed. - */ - public void setAttribute(String attribute, Object value); - - /** - * Get the name of the parameter this qualifier is connected to. - * Convenience method for obtaining the KEYWORD attribute. - * - * @return - * String containing the name of the parameter. - */ - public String getKeyword(); - - /** - * Indicates whether the parameter is designated as read only. - * Convenience method for obtaining the READONLY attribute. - * - * @return - * True if the parameter is read only, otherwise false. - */ - public boolean isReadOnly(); - - /** - * Indicates whether the parameter is hidden. - * Convenience method for obtaining the HIDDEN attribute. - * - * @return - * True if the parameter is hidden, otherwise false. - */ - public boolean isHidden(); - - /** - * Get the Java type that can store a legal value for the parameter. - * Primitive Java types have their counterpart wrapper classes returned. - * For example for an int the Integer class is returned. - * Convenience method for obtaining the TYPE attribute. - * - * @return - * A class that can store legal parameter values. - */ - public QualifierType getType(); - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierAnd.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierAnd.java deleted file mode 100644 index e1788569c5..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierAnd.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -/** - * This qualifier type allows the logical and of two qualifier types. Care - * must be taken that the two qualifier types are suitable. For instance - * if 'and'ing two integer ranges together that do not overlap will ensure - * that no legal values are ever parsed by parseValue(). - */ -public class QualifierAnd extends QualifierTypeImpl { - - protected QualifierType typeA; - - protected QualifierType typeB; - - public QualifierAnd(QualifierType typeA, QualifierType typeB) { - this.typeA = typeA; - this.typeB = typeB; - } - - public void setQualifierTypeA(QualifierType typeA) { - this.typeA = typeA; - } - - public void setQualifierTypeB(QualifierType typeB) { - this.typeB = typeB; - } - - public QualifierType getQualifierTypeA() { - return typeA; - } - - public QualifierType getQualifierTypeB() { - return typeB; - } - - public Object parseValue(String value) { - if (!typeA.getJavaType().equals(typeB.getJavaType())) { - return null; - } - - Object objectA = typeA.parseValue(value); - Object objectB = typeB.parseValue(value); - - if (objectA != null && objectB != null) { - return (objectA.equals(objectB)) ? objectA : null; - } else { - return null; - } - } - - public String formatValue(String value) { - if (!typeA.getJavaType().equals(typeB.getJavaType())) { - return null; - } - - String stringA = typeA.formatValue(value); - String stringB = typeB.formatValue(value); - - if (stringA != null && stringB != null) { - return (stringA.equals(stringB)) ? stringA : null; - } else { - return null; - } - } - - public Class getJavaType() { - return typeA.getJavaType(); - } - - public String toString() { - return "(" + typeA + " && " + typeB + ")"; - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierArray.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierArray.java deleted file mode 100644 index 5769c4202c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierArray.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.StringTokenizer; - -/** - * An an implementation of the qualifier type that provides an array of - * qualifier types. The element qualifer type is contained within the array - * qualifier type. - */ -public class QualifierArray extends QualifierTypeImpl { - - /** - * The default String of characters that delimit elements in a String - * representation of the array when it is parsed. - */ - public static final String DEFAULT_PARSE_DELIM = ", "; - - /** - * The default String of characters that delimit elements in a String - * representation of the array when it is formatted. - */ - public static final String DEFAULT_FORMAT_DELIM = ","; - - /** - * The type of the arrays elements. - */ - protected QualifierType type; - - /** - * The String of characters that delimit elements in a String - * representation of the array when it is parsed. - */ - protected String parseDelim = DEFAULT_PARSE_DELIM; - - /** - * The String of characters that delimit elements in a String - * representation of the array when it is formatted. - */ - protected String formatDelim = DEFAULT_FORMAT_DELIM; - - private QualifierArray() {} - - /** - * Construct an array qualifier type. - * - * @param type - * The qualifier type of the arrays elements. - */ - public QualifierArray(QualifierType type) { - this(type, DEFAULT_PARSE_DELIM, DEFAULT_FORMAT_DELIM); - } - - /** - * Construct an array qualifier type. - * - * @param type - * The qualifier type of the arrays elements. - * @param delim - * The String of characters that delimit elements in a String - * representation of the array. - */ - public QualifierArray(QualifierType type, - String parseDelim, - String formatDelim) { - this.type = type; - this.parseDelim = parseDelim; - this.formatDelim = formatDelim; - } - - /** - * Get the arrays element qualifier type. - * - * @areturn - * The qualifier type of the arrays elements. - */ - public QualifierType getElementType() { - return type; - } - - /** - * Determine if the given value is a legal value for this type. The - * element delimiters are the default or those supplied during - * construction of the QualifierArray. - * - * @param value - * The value to test. - * @return - * Returns a Java type containing the parse value if legal, otherwise - * null is returned if the value was illegal. - */ - public Object parseValue(String value) { - return parseValue(value, parseDelim); - } - - /** - * Determine if the given value is a legal value for this type. The - * element delimiters provided override the use of the defaults or - * those supplied during the construction of the QualifierArray. - * - * @param value - * The value to test. - * @param parseDelim - * The String of characters that delimit elements in a String - * representation of the array. - * @return - * Returns a Java type containing the parse value if legal, otherwise - * null is returned if the value was illegal. - */ - public Object parseValue(String value, String parseDelim) { - if (value == null) { - return null; - } - - StringTokenizer tokenizer = new StringTokenizer(value, parseDelim); - ArrayList elements = new ArrayList(); - - while (tokenizer.hasMoreTokens()) { - String token = tokenizer.nextToken(); - Object object = type.parseValue(token); - - if (object == null) { - return null; - } - - elements.add(object); - } - - return elements.toArray( - (Object[])Array.newInstance(type.getJavaType(), elements.size())); - } - - /** - * Format the given string if it is a legal value for this type. The - * element delimiters are the default or those supplied during - * construction of the QualifierArray. - * - * @param value - * The value to format. - * @return - * Returns a string containing the formatted value if legal, otherwise - * null is returned if the value was illegal. - */ - public String formatValue(String value) { - return formatValue(value, parseDelim, formatDelim); - } - - /** - * Format the given string if it is a legal value for this type. The - * element delimiters provided override the use of the defaults or - * those supplied during the construction of the QualifierArray. - * - * @param value - * The value to format. - * @param parseDelim - * The String of characters that delimit elements in a String - * representation of the array when it is parsed. - * @param formatDelim - * The String of characters that delimit elements in a String - * representation of the array when it is formatted. - * @return - * Returns a string containing the formatted value if legal, otherwise - * null is returned if the value was illegal. - */ - public String formatValue(String value, - String parseDelim, - String formatDelim) { - - if (value == null) { - return null; - } - - value = value.trim(); - - StringTokenizer tokenizer = new StringTokenizer(value, parseDelim); - StringBuffer string = new StringBuffer(); - - while (tokenizer.hasMoreTokens()) { - String token = tokenizer.nextToken(); - token = type.formatValue(token); - - if (token == null) { - return null; - } - - string.append(token); - - if (tokenizer.hasMoreTokens()) { - string.append(formatDelim); - } - } - - return string.toString(); - } - - /** - * Get the String containing the characters that delimit elements in - * a String representation of the array when it is parsed. - * - * @return - * Returns a String containing the characters that delimit elements in - * a String representation of the array when it is parsed. - */ - public String getParseDelimiters() { - return parseDelim; - } - - /** - * Get the String containing the characters that delimit elements in - * a String representation of the array when it is formatted. - * - * @return - * Returns a String containing the characters that delimit elements in - * a String representation of the array when it is formatted. - */ - public String getFormatDelimiters() { - return formatDelim; - } - - public Class getJavaType() { - return java.lang.reflect.Array.class; - } - - public String toString() { - return "[L" + type.getClass().getName() + ";"; - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierBoolean.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierBoolean.java deleted file mode 100644 index 7c5d5ab34d..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierBoolean.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -/** - * An implementation of the qualifier type that provide a boolean type. - * The symbolic values for true and false can be set in two ways during - * object construction. Either no arguments are given the constructor and the - * Java Boolean.TRUE and Boolean.FALSE are used. Alternatively a pair of - * Strings can be passed to the constructor, the first representing true - * and the second false. - */ -public class QualifierBoolean extends QualifierStringEnum { - - /** - * True value. - */ - protected String trueValue; - - /** - * False value. - */ - protected String falseValue; - - /** - * Contruct a boolean qualifier type using the Java string representations - * of true and false. - */ - public QualifierBoolean() { - this(Boolean.TRUE.toString(), Boolean.FALSE.toString()); - } - - /** - * Contruct a boolean qualifier using the supplied string representations - * of true and false. - * - * @param trueValue - * True value. - * @param falseValue - * False value. - */ - public QualifierBoolean(String trueValue, String falseValue) { - super(new String[] {trueValue, falseValue}); - - this.trueValue = trueValue; - this.falseValue = falseValue; - } - - /** - * Get the string representing true. - * - * @return - * True value. - */ - public String getTrue() { - return trueValue; - } - - /** - * Get the string representing false. - * - * @return - * False value. - */ - public String getFalse() { - return falseValue; - } - - public Object parseValue(String value) { - if (value == null) { - return null; - } - - value = value.trim(); - - if (value.equals(trueValue) || value.equals(falseValue)) { - return new Boolean(value); - } else { - return null; - } - } - - public String formatValue(String value) { - if (value == null || parseValue(value) == null) { - return null; - } - - return value.trim(); - } - - public Class getJavaType() { - return Boolean.class; - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierEnum.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierEnum.java deleted file mode 100644 index be457acf3c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierEnum.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -/** - * Marker interface for qualifer enumerated types. - */ -public interface QualifierEnum {} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierFQDN.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierFQDN.java deleted file mode 100644 index 6f1a7fd2cc..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierFQDN.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -import java.util.regex.*; - -/** - * An implementation of the qualifier type that provides a string type - * where values must be a valid fully qualified domain name. - */ -public class QualifierFQDN extends QualifierString { - - private static final String fqdnRegex = "([a-zA-Z][a-zA-Z0-9-]*[.]?)+"; - - public Object parseValue(String value) { - if (value == null) { - return null; - } - - value = value.trim(); - - Pattern pattern = Pattern.compile(fqdnRegex); - Matcher matcher = pattern.matcher(value); - - if (matcher.matches()) { - return value; - } else { - return null; - } - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierIPv4.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierIPv4.java deleted file mode 100644 index 5ae01ff3c1..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierIPv4.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -import java.util.regex.*; - -/** - * An implementation of the qualifier type that provides a string type - * where values must be a valid IPv4 address. - */ -public class QualifierIPv4 extends QualifierString { - - private static final String octetRegex = - "0*(1?[0-9]{1,2}|2([0-4][0-9]|5[0-5]))"; - - private static final String addressRegex = - "(" + octetRegex + "[.]){3}" + octetRegex; - - private static Pattern pattern; - - public Object parseValue(String value) { - if (value == null) { - return null; - } - - value = value.trim(); - - Matcher matcher = pattern.matcher(value); - - return (matcher.matches() ? value : null); - } - - static { - pattern = Pattern.compile(addressRegex); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierIPv6.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierIPv6.java deleted file mode 100644 index 23f83f29f6..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierIPv6.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -import java.util.*; -import java.util.regex.*; - -/** - * An implementation of the qualifier type that provides a string type - * where values must be a valid IPv6 address. - */ -public class QualifierIPv6 extends QualifierString { - - private static final String fieldRegex = "0*[0-9a-fA-F]{1,4}"; - - private static Pattern pattern; - - public Object parseValue(String value) { - if (value == null) { - return null; - } - - value = value.trim(); - - if (value.equals("::")) { - return value; - } - - QualifierIPv4 ipv4 = new QualifierIPv4(); - Matcher matcher; - int numFields = 0; - int numZeroFields = 0; - int numAdjacentZeroFields = 0; - StringTokenizer tokenizer = new StringTokenizer(value, ":", true); - - while (tokenizer.hasMoreTokens()) { - String field = tokenizer.nextToken(); - - if (field == null) { - return null; - } else if (field.equals(":")) { - numAdjacentZeroFields++; - - if (numAdjacentZeroFields > 2) { - return null; - } else if (numAdjacentZeroFields == 2) { - numZeroFields++; - - if (numZeroFields > 1) { - return null; - } - } - } else { - numAdjacentZeroFields = 0; - matcher = pattern.matcher(field); - - if (!matcher.matches()) { - Object ipv4Field = ipv4.parseValue(field); - - if ((ipv4Field != null && tokenizer.countTokens() > 0) || - ipv4Field == null) { - return null; - } - } - - numFields++; - } - } - - if ((numFields > 0 && numFields < 9) || value.equals("::")) { - return value; - } else { - return null; - } - } - - static { - pattern = Pattern.compile(fieldRegex); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierImpl.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierImpl.java deleted file mode 100644 index ba9f815869..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierImpl.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -import java.util.Map; -import java.util.HashMap; - -/** - * Super class for qualifier. Provides common methods and fields. - */ -public class QualifierImpl implements Qualifier { - - /** - * Map of qualifier attributes to values. - */ - protected Map attributes; - - /** - * Construct an empty qualifier. - */ - public QualifierImpl() { - } - - /** - * Construct a qualifier, assigning all the required fields. - * - * @param keyword - * The name of the parameter that the qualifier is associated with. - * @param readOnly - * Inidicate whether the parameter is to be treated as read only. - * @param hidden - * Inidicate whether the parameter is hidden. - * @param type - * The parameter value type. - */ - public QualifierImpl(String keyword, - boolean readOnly, - boolean hidden, - QualifierType type) { - - attributes = new HashMap(); - attributes.put(KEYWORD, keyword); - attributes.put(READONLY, new Boolean(readOnly)); - attributes.put(HIDDEN, new Boolean(hidden)); - attributes.put(TYPE, type); - } - - public synchronized Object getAttribute(String attribute) { - return attributes.get(attribute); - } - - public synchronized void setAttribute(String attribute, Object value) { - if (value == null) { - if (attributes.containsKey(attribute)) { - attributes.remove(attribute); - } - } else { - attributes.put(attribute, value); - } - } - - public String getKeyword() { - return (String)attributes.get(KEYWORD); - } - - public boolean isReadOnly() { - return ((Boolean)attributes.get(READONLY)).booleanValue(); - } - - public boolean isHidden() { - return ((Boolean)attributes.get(HIDDEN)).booleanValue(); - } - - public QualifierType getType() { - return (QualifierType)attributes.get(TYPE); - } - - public String toString() { - return attributes.toString(); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierInteger.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierInteger.java deleted file mode 100644 index f9b64c56fd..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierInteger.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -/** - * An implementation of the qualifier type that provides an integer type. - */ -public class QualifierInteger extends QualifierTypeImpl { - - public Object parseValue(String value) { - if (value != null) { - try { - int intValue = Integer.parseInt(value.trim()); - return new Integer(intValue); - } catch (NumberFormatException nfe) {} - } - - return null; - } - - public String formatValue(String value) { - Object object = parseValue(value); - - return (object == null) ? null : object.toString(); - } - - public Class getJavaType() { - return Integer.class; - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierIntegerEnum.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierIntegerEnum.java deleted file mode 100644 index 7b2e4ce162..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierIntegerEnum.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -import java.util.Arrays; -import java.util.ArrayList; - -/** - * An extension of the integer qualifier type that restricts the integer - * values to a given set. - */ -public class QualifierIntegerEnum extends QualifierInteger - implements QualifierEnum { - - /** - * The set of legal integer values. - */ - protected int[] values; - - private QualifierIntegerEnum() {} - - /** - * Construct an integer enumerated qualifier type. - * - * @param values - * The set of legal integer values. - */ - public QualifierIntegerEnum(int[] values) { - this.values = values; - } - - /** - * Get the set of legal integer values. - * - * @return - * The set of legal integer values. - */ - public int[] getValues() { - return values; - } - - public Object parseValue(String value) { - Integer intValue = (Integer) super.parseValue(value); - - if (intValue != null) { - int i = intValue.intValue(); - - for (int index = 0; index < values.length; index++) { - if (values[index] == i) { - return intValue; - } - } - } - - return null; - } - - public String toString() { - ArrayList vals = new ArrayList(); - - for (int index = 0; index < values.length; index++) { - vals.add(new Integer(values[index])); - } - - return super.toString() + vals; - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierIntegerRange.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierIntegerRange.java deleted file mode 100644 index f05a868279..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierIntegerRange.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -/** - * An extension of the integer qualifier type that restricts the integer - * values to a given range, bounded by an inclusive minimum and maximum value. - */ -public class QualifierIntegerRange extends QualifierInteger - implements QualifierRange { - - /** - * Minimum legal value. - */ - protected int min; - - /** - * Maximum legal value. - */ - protected int max; - - private QualifierIntegerRange() {} - - /** - * Construct an integer range qualifier type. - * - * @param min - * Minimum legal value. - * @param max - * Maximum legal value. - */ - public QualifierIntegerRange(int min, int max) { - this.min = min; - this.max = max; - } - - /** - * Get the minimum boundary. - * - * @return - * Minimum legal value. - */ - public int getMin() { - return min; - } - - /** - * Get the maximum boundary. - * - * @return - * Maximum legal value. - */ - public int getMax() { - return max; - } - - public Object parseValue(String value) { - Integer intValue = (Integer)super.parseValue(value); - - if (intValue != null) { - int i = intValue.intValue(); - - if (i >= min && i <= max) { - return intValue; - } - } - - return null; - } - - public String toString() { - return super.toString() + "<" + min + "," + max + ">"; - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierOr.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierOr.java deleted file mode 100644 index 0feb9b36f5..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierOr.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -/** - * This qualifier type allows the logical or of two qualifier types. Care - * must be taken that the two qualifier types are suitable. For instance - * if 'or'ing a string and an integer may result in parseValue() returning - * either a String or an Integer. - */ -public class QualifierOr extends QualifierTypeImpl { - - protected QualifierType typeA; - - protected QualifierType typeB; - - public QualifierOr(QualifierType typeA, QualifierType typeB) { - this.typeA = typeA; - this.typeB = typeB; - } - - public void setQualifierTypeA(QualifierType typeA) { - this.typeA = typeA; - } - - public void setQualifierTypeB(QualifierType typeB) { - this.typeB = typeB; - } - - public QualifierType getQualifierTypeA() { - return typeA; - } - - public QualifierType getQualifierTypeB() { - return typeB; - } - - public Object parseValue(String value) { - if (!typeA.getJavaType().equals(typeB.getJavaType())) { - return null; - } - - Object objectA = typeA.parseValue(value); - Object objectB = typeB.parseValue(value); - - if (objectA != null && objectB != null) { - return (objectA.equals(objectB)) ? objectA : null; - } else { - return (objectA == null) ? objectB : objectA; - } - } - - public String formatValue(String value) { - if (!typeA.getJavaType().equals(typeB.getJavaType())) { - return null; - } - - String stringA = typeA.formatValue(value); - String stringB = typeB.formatValue(value); - - if (stringA != null && stringB != null) { - return (stringA.equals(stringB)) ? stringA : null; - } else { - return (stringA == null) ? stringB : stringA; - } - } - - public Class getJavaType() { - return typeA.getJavaType(); - } - - public String toString() { - return "(" + typeA + " || " + typeB + ")"; - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierRange.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierRange.java deleted file mode 100644 index 4fb61824e4..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierRange.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -/** - * Marker interface for qualifer range types. - */ -public interface QualifierRange {} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierString.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierString.java deleted file mode 100644 index b72a359480..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierString.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -/** - * An implementation of the qualifier type that provides a string type. - */ -public class QualifierString extends QualifierTypeImpl { - - public Object parseValue(String value) { - return value.trim(); - } - - public String formatValue(String value) { - if (value == null) { - return null; - } - - return value.trim(); - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierStringEnum.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierStringEnum.java deleted file mode 100644 index fa5fc8efba..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierStringEnum.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -import java.util.Arrays; - -/** - * An extension of the string qualifier type that restricts the string - * values to a given set. - */ -public class QualifierStringEnum extends QualifierString - implements QualifierEnum { - - /** - * The set of legal string values. - */ - protected String[] values; - - private QualifierStringEnum() {} - - /** - * Construct an string enumerated qualifier type. - * - * @param values - * The set of legal string values. - */ - public QualifierStringEnum(String[] values) { - this.values = values; - } - - /** - * Get the set of legal string values. - * - * @return - * The set of legal string values. - */ - public String[] getValues() { - return values; - } - - public Object parseValue(String value) { - if (value != null && Arrays.asList(values).contains(value)) { - return value; - } else { - return null; - } - } - - public String toString() { - return super.toString() + Arrays.asList(values); - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierType.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierType.java deleted file mode 100644 index 33bf0cef14..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierType.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -/** - * Common interface for qualifier types. - */ -public interface QualifierType { - - /** - * Determine if the given string is a legal value for this type. - * - * @param value - * The value to test. - * @return - * Returns a Java type containing the parsed value if legal, otherwise - * null is returned if the value was illegal. - */ - public Object parseValue(String value); - - /** - * Format the value into a form that could be offered to parseValue(). - * The validity of the value is implementation dependent. The value - * passed to formatValue() may result in a non-null result but the same - * value passed to parseValue() may return null. Also the value returned - * by formatValue() passed to parseValue() does not guarantee an non-null - * result from parseValue(). - * - * @param value - * The value to format. - * @return - * Returns a String containing the formatted value or null if the - * value could not be formatted correctly. - */ - public String formatValue(String value); - - /** - * Get the Java class that is suitable for storing values of the qualifier - * type. - * - * @return - * Suitable Java type for storing values of the qualifier type. - */ - public Class getJavaType(); - - public String toString(); - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierTypeImpl.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierTypeImpl.java deleted file mode 100644 index 7b21477b55..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/data/qualifier/QualifierTypeImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -package com.sun.dhcpmgr.data.qualifier; - -/** - * Super class for qualifier types. Provides common methods and fields. - */ -public abstract class QualifierTypeImpl implements QualifierType { - - public Class getJavaType() { - return String.class; - } - - public String toString() { - return this.getClass().getName(); - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpMgr.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpMgr.java deleted file mode 100644 index fe4d3fdd1c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpMgr.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.server; - -import java.io.IOException; -import java.io.OptionalDataException; - -import com.sun.dhcpmgr.data.*; -import com.sun.dhcpmgr.bridge.*; - -public interface DhcpMgr { - public DhcpNetMgr getNetMgr(); - public DhcptabMgr getDhcptabMgr(); - public DhcpServiceMgr getDhcpServiceMgr(); - public String getLockPath(); - public Object openExportFile(String name, String user, int recCount, - Network [] nets, boolean overWrite) - throws ExistsException, IOException; - public Object openImportFile(String name) - throws IOException; - public ExportHeader getExportHeader(Object ref) - throws IOException, ClassNotFoundException; - public void exportMacros(Object ref, boolean allMacros, String [] names) - throws BridgeException, IOException; - public void exportOptions(Object ref, boolean allOptions, String [] names) - throws BridgeException, IOException; - public void exportNetwork(Object ref, Network net) - throws BridgeException, IOException; - public ActionError [] importOptions(Object ref, boolean overwrite) - throws IOException, OptionalDataException, ClassNotFoundException; - public ActionError [] importMacros(Object ref, boolean overwrite) - throws IOException, OptionalDataException, ClassNotFoundException; - public ActionError [] importNetwork(Network net, Object ref, - boolean overwrite) - throws IOException, OptionalDataException, ClassNotFoundException, - BridgeException; - public void closeExportFile(Object ref, boolean deleteFile) - throws IOException; - public void closeImportFile(Object ref, boolean deleteFile) - throws IOException; -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpMgrImpl.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpMgrImpl.java deleted file mode 100644 index cde7ba9a63..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpMgrImpl.java +++ /dev/null @@ -1,508 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.server; - -import java.io.*; -import java.util.zip.*; -import java.util.*; - -import com.sun.dhcpmgr.bridge.*; -import com.sun.dhcpmgr.data.*; - -public class DhcpMgrImpl implements DhcpMgr { - private Bridge bridge; - private DhcpNetMgrImpl netMgr; - private DhcptabMgrImpl dtMgr; - private DhcpServiceMgrImpl srvMgr; - // Global lock file used to ensure only one export or import is running - private static final String LOCK_FILE = "/var/run/dhcp_import_export_lock"; - private static final File lockFile = new File(LOCK_FILE); - private File currentlyOpenFile = null; - private Object currentStream = null; - - public DhcpMgrImpl() { - bridge = new Bridge(); - } - - public DhcpNetMgr getNetMgr() { - if (netMgr == null) { - netMgr = new DhcpNetMgrImpl(bridge); - } - return netMgr; - } - - public DhcptabMgr getDhcptabMgr() { - if (dtMgr == null) { - dtMgr = new DhcptabMgrImpl(bridge); - } - return dtMgr; - } - - public DhcpServiceMgr getDhcpServiceMgr() { - if (srvMgr == null) { - srvMgr = new DhcpServiceMgrImpl(bridge); - } - return srvMgr; - } - - /** - * Set the file which is currently open. - */ - private synchronized File setFile(String name) throws IOException { - // Some other file is currently listed as open; deny the request - if (currentlyOpenFile != null) { - return null; - } - - // Get system-wide lock by atomically creating lockfile - if (!lockFile.createNewFile()) { - return null; - } - currentlyOpenFile = new File(name); - currentStream = null; - return currentlyOpenFile; - } - - private synchronized void clearFile(File file) { - // If this is truly the currently open file, then clear our reference - if (isFileOpen(file)) { - currentlyOpenFile = null; - currentStream = null; - // Release system-wide lock by deleting lockfile - lockFile.delete(); - } - } - - /** - * Get the file which is currently open. - */ - private synchronized File getFile() { - return currentlyOpenFile; - } - - /** - * Test whether a file is currently open. - */ - private synchronized boolean isFileOpen(File file) { - return (file == currentlyOpenFile); - } - - /** - * Returns the fullpath to the lock file. - * @return the fullpath to the lock file. - */ - public String getLockPath() { - return (LOCK_FILE); - } - - /** - * Opens an export file and writes a header record to it. - * @param fileName the fullpath to the export file to create. - * @param user the name of the user creating this file - * @param nets an array of networks which will be exported - * @param overwrite true if file should be forcible overwritten - * @return a reference key for this file instance, or null if there is - * another file already open for import or export - */ - public Object openExportFile(String fileName, String user, - int recCount, Network [] nets, boolean overwrite) - throws ExistsException, IOException { - - // Grab the lock - File file = setFile(fileName); - - if (file != null) { - // File exists and not supposed to overwrite, throw exception - if (!overwrite && file.exists()) { - clearFile(file); - throw new ExistsException(fileName); - } - - try { - // Open a stream to write on - ObjectOutputStream export = new ObjectOutputStream( - new GZIPOutputStream(new FileOutputStream(file))); - - // Construct a header record, and write it - ExportHeader header = new ExportHeader( - getDhcpServiceMgr().getServerName(), user, recCount, nets); - export.writeObject(header); - - // Save stream reference - currentStream = export; - } catch (IOException e) { - // Something went wrong, release the lock and re-throw - clearFile(file); - throw e; - } - } - // Give caller a reference to use for writing additional data - return file; - } // openExportFile - - /** - * Close an export file, delete it if need be - * @param ref Reference to the open file, returned from openExportFile - * @param delete true if file is to be deleted on close, false otherwise. - */ - public void closeExportFile(Object ref, boolean delete) throws IOException { - if (!isFileOpen((File)ref)) { - throw new FileNotFoundException(((File)ref).getName()); - } - try { - ObjectOutputStream oos = (ObjectOutputStream)currentStream; - oos.flush(); - oos.close(); - if (delete) { - ((File)ref).delete(); - } - } catch (IOException e) { - // Just re-throw, let finally block clean up - throw e; - } finally { - /* - * Always release the lock, we consider the file no longer useful - * no matter the outcome above. - */ - clearFile((File)ref); - } - } - - /** - * Open an import file - * @param fileName Name of file to open - * @return A reference to the opened import file, or null if another - * export or import is already in progress. - */ - public Object openImportFile(String fileName) throws IOException { - File file = setFile(fileName); - if (file != null) { - if (!file.exists()) { - clearFile(file); - throw new FileNotFoundException(fileName); - } - - try { - currentStream = new ObjectInputStream(new GZIPInputStream( - new FileInputStream(file))); - } catch (IOException e) { - clearFile(file); - throw e; - } - } - // Return reference caller can use to actually do the import - return file; - } - - /** - * Close an import file, delete it if need be - * @param ref Reference to the open file, returned from openImportFile - * @param delete true if file is to be deleted on close, false otherwise. - */ - public void closeImportFile(Object ref, boolean delete) throws IOException { - if (!isFileOpen((File)ref)) { - throw new FileNotFoundException(((File)ref).getName()); - } - try { - ((ObjectInputStream)currentStream).close(); - if (delete) { - ((File)ref).delete(); - } - } catch (IOException e) { - // Just re-throw and let finally do the cleanup - throw e; - } finally { - clearFile((File)ref); - } - } - - /** - * Retrieve the export header for the import file - * @param ref Reference to the file we're reading from - * @return The ExportHeader written at export time. - */ - public ExportHeader getExportHeader(Object ref) - throws IOException, ClassNotFoundException { - if (!isFileOpen((File)ref)) { - // No such file open; throw an exception - throw new FileNotFoundException(((File)ref).getName()); - } else { - ObjectInputStream ois = (ObjectInputStream)currentStream; - ExportHeader rec = (ExportHeader)ois.readObject(); - return rec; - } - } - - // Get the desired records out of an array - private ArrayList getSelectedRecs(String [] names, DhcptabRecord [] recs) - throws NoEntryException { - // Grab only the ones we want - TreeSet nameSet = new TreeSet(Arrays.asList(names)); - ArrayList recArr = new ArrayList(); - for (int i = 0; i < recs.length; ++i) { - if (nameSet.contains(recs[i].getKey())) { - recArr.add(recs[i]); - nameSet.remove(recs[i].getKey()); - } - } - if (!nameSet.isEmpty()) { - // We didn't find one of the requested records - throw new NoEntryException((String)nameSet.first()); - } - return recArr; - } - - /** - * Export a list of macros specified by name to a file. - * @param ref A reference to the file, acquired from openExportFile() - * @param allMacros true if all macros are to be exported - * @param names names of macros to be exported if allMacros is false - */ - public void exportMacros(Object ref, boolean allMacros, String [] names) - throws BridgeException, IOException { - if (!isFileOpen((File)ref)) { - // throw an exception that this is a bad reference - throw new FileNotFoundException(((File)ref).getName()); - } - - Macro [] macros = getDhcptabMgr().getMacros(); - if (!allMacros) { - // Grab only the ones we want - ArrayList macArr = getSelectedRecs(names, macros); - macros = (Macro [])macArr.toArray(new Macro[0]); - } - - ObjectOutputStream oos = (ObjectOutputStream)currentStream; - oos.writeObject(macros); - } - - /** - * Export a list of options specified by name to a file. - * @param ref A reference to the file, acquired from openExportFile() - * @param allOptions true if all options are to be exported - * @param names names of options to be exported if allOptions is false - */ - public void exportOptions(Object ref, boolean allOptions, String [] names) - throws BridgeException, IOException { - if (!isFileOpen((File)ref)) { - // throw an exception that this is a bad reference - throw new FileNotFoundException(((File)ref).getName()); - } - - Option [] options = getDhcptabMgr().getOptions(); - if (!allOptions) { - // Grab only the ones we want - ArrayList optArr = getSelectedRecs(names, options); - options = (Option [])optArr.toArray(new Option[0]); - } - - ObjectOutputStream oos = (ObjectOutputStream)currentStream; - oos.writeObject(options); - } - - /** - * Export a network and its client records to a file - * @param ref A reference to the file, acquired from openExportFile() - * @param net Network to be exported - */ - public void exportNetwork(Object ref, Network net) - throws BridgeException, IOException { - if (!isFileOpen((File)ref)) { - // throw an exception that this is a bad reference - throw new FileNotFoundException(((File)ref).getName()); - } - - // Get clients from database - DhcpClientRecord [] clients = - getNetMgr().loadNetworkCompletely(net.toString()); - - // Now write client array for this net - ObjectOutputStream oos = (ObjectOutputStream)currentStream; - oos.writeObject(clients); - } - - /** - * Import dhcptab records from an export file into the configuration. - * @param recType The type of record to import; must be either - * DhcptabRecord.MACRO or DhcptabRecord.OPTION - * @param ref The file reference returned by openImportFile() - * @param overwrite true if this data should overwrite existing data - * @return An array of import results; empty if all records were imported. - */ - private ActionError [] importDhcptabRecs(String recType, Object ref, - boolean overwrite) - throws IOException, OptionalDataException, ClassNotFoundException { - - ArrayList resultList = new ArrayList(); - DhcptabRecord [] recs = new DhcptabRecord[0]; - - if (!isFileOpen((File)ref)) { - // No such file open; throw an exception - throw new FileNotFoundException(((File)ref).getName()); - } - ObjectInputStream ois = (ObjectInputStream)currentStream; - recs = (DhcptabRecord [])ois.readObject(); - // Try to cast to appropriate type to ensure data is OK. - if (recType.equals(DhcptabRecord.MACRO)) { - Macro [] macros = (Macro []) recs; - } else { - Option [] options = (Option []) recs; - } - - DhcptabMgr mgr = getDhcptabMgr(); - for (int i = 0; recs != null && i < recs.length; ++i) { - try { - if (overwrite) { - /* - * Hack alert! We reset the signature to a default value - * that the datastores will not interpret. This allows us - * to forcibly delete the record, even if it came from a - * previous attempt to import this record. Without this - * step, the datastore may (correctly) signal an update - * collision and refuse to perform the delete. An - * alternative that might be used is to mark the signature - * member of DhcptabRecord as transient; however, that would - * have the future undesirable effect of dropping that - * field when we put a remote communication method - * in the mix which uses serialization, such as RMI. - */ - recs[i].setSignature(DhcptabRecord.DEFAULT_SIGNATURE); - mgr.deleteRecord(recs[i], false); - } - } catch (Throwable t) { - // Do nothing; we'll probably have an error on the create - } - try { - mgr.createRecord(recs[i], false); - } catch (Exception e) { - // Record the error, we try all of them no matter what - resultList.add(new ActionError(recs[i].getKey(), e)); - } - } - - return (ActionError [])resultList.toArray(new ActionError[0]); - } - - /** - * Import options from an export file. - * @param ref Reference to import file returned by openImportFile - * @param overwrite true if existing data should be overwritten. - * @return An array of errors in the import process; empty if all OK - */ - public ActionError [] importOptions(Object ref, boolean overwrite) - throws IOException, OptionalDataException, ClassNotFoundException { - return importDhcptabRecs(DhcptabRecord.OPTION, ref, overwrite); - } - - /** - * Import macros from an export file. - * @param ref Reference to import file returned by openImportFile - * @param overwrite true if existing data should be overwritten. - * @return An array of errors in the import process; empty if all OK - */ - public ActionError [] importMacros(Object ref, boolean overwrite) - throws IOException, OptionalDataException, ClassNotFoundException { - return importDhcptabRecs(DhcptabRecord.MACRO, ref, overwrite); - } - - - - /** - * Import network records from an export file into the configuration. - * @param net The network which is expected to be imported - * @param ref The file reference returned by openImportFile() - * @param overwrite true if this data should overwrite existing data - * @return An array of import results; empty if all records were imported. - */ - public ActionError [] importNetwork(Network net, Object ref, - boolean overwrite) throws IOException, OptionalDataException, - ClassNotFoundException, BridgeException { - - if (!isFileOpen((File)ref)) { - // No such file open; throw an exception - throw new FileNotFoundException(((File)ref).getName()); - } - - ArrayList resultList = new ArrayList(); - DhcpClientRecord [] clients = null; - ObjectInputStream ois = (ObjectInputStream)currentStream; - clients = (DhcpClientRecord [])ois.readObject(); - - String networkName = net.toString(); - DhcpNetMgr mgr = getNetMgr(); - - // Create the network table. It may already exist. - boolean netExisted = false; - try { - mgr.createNetwork(networkName); - } catch (TableExistsException e) { - /* - * This is o.k. no matter whether overwrite is true or not; - * however, record the fact that it existed so that we don't - * optimize out the delete in the loop below. - */ - netExisted = true; - } - - // Add the addresses to the table and record any exceptions. - for (int i = 0; clients != null && i < clients.length; ++i) { - /* - * If we're supposed to overwrite and the network table - * existed before we started, then try to delete the client - */ - if (overwrite && netExisted) { - try { - /* - * Hack alert! We reset the signature to a default value - * that the datastores will not interpret. This allows us - * to forcibly delete the record, even if it came from a - * previous attempt to import this record. Without this - * step, the datastore may "correctly" signal an update - * collision and refuse to perform the delete. An - * alternative that might be used is to mark the signature - * member of DhcptabRecord as transient; however, that would - * have the future undesirable effect of dropping that - * field when we put a remote communication method - * in the mix which uses serialization, such as RMI. - */ - clients[i].setSignature(DhcpClientRecord.DEFAULT_SIGNATURE); - mgr.deleteClient(clients[i], networkName); - } catch (Throwable t) { - // Ignore delete error, we'll probably have an error on add - } - } - try { - // Now add the client - mgr.addClient(clients[i], networkName); - } catch (Exception e) { - String address = clients[i].getClientIPAddress(); - resultList.add(new ActionError(address, e)); - } - } - - return (ActionError [])resultList.toArray(new ActionError[0]); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpNetMgr.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpNetMgr.java deleted file mode 100644 index 58efbcf3bf..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpNetMgr.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.server; - -import com.sun.dhcpmgr.bridge.*; -import com.sun.dhcpmgr.data.*; - -/** - * This class defines the methods available to manage the DHCP network - * tables and hosts table. - */ -public interface DhcpNetMgr { - public Network getNetwork(String networkName) - throws BridgeException; - public Network [] getNetworks(DhcpDatastore datastore) - throws BridgeException; - public Network [] getNetworks() - throws BridgeException; - public DhcpClientRecord [] loadNetwork(String network, - DhcpDatastore datastore) throws BridgeException; - public DhcpClientRecord [] loadNetwork(String network) - throws BridgeException; - public DhcpClientRecord [] loadNetworkCompletely(String network) - throws BridgeException; - public void modifyClient(DhcpClientRecord oldClient, - DhcpClientRecord newClient, String table) - throws BridgeException; - public void modifyClient(DhcpClientRecord oldClient, - DhcpClientRecord newClient, String table, - DhcpDatastore datastore) throws BridgeException; - public void addClient(DhcpClientRecord client, String table, - DhcpDatastore datastore) throws BridgeException; - public void addClient(DhcpClientRecord client, String table) - throws BridgeException; - public void deleteClient(DhcpClientRecord client, String table, - DhcpDatastore datastore) - throws BridgeException; - public void deleteClient(DhcpClientRecord client, String table) - throws BridgeException; - public DhcpClientRecord getClient(DhcpClientRecord client, String table, - DhcpDatastore datastore) throws BridgeException; - public void cvtNetwork(String network, - DhcpDatastore datastore) throws BridgeException; - public void createNetwork(String network, - DhcpDatastore datastore) throws BridgeException; - public void createNetwork(String network) - throws BridgeException; - public void deleteNetwork(String network, boolean deleteMacro, - DhcpDatastore datastore) - throws BridgeException; - public void deleteNetwork(String network, boolean deleteMacro) - throws BridgeException; -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpNetMgrImpl.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpNetMgrImpl.java deleted file mode 100644 index 86653f56da..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpNetMgrImpl.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.server; - -import com.sun.dhcpmgr.bridge.*; -import com.sun.dhcpmgr.data.*; - -import java.net.InetAddress; -import java.net.UnknownHostException; - -/** - * This class provides the functionality to manage the DHCP network tables and - * the hosts table. - */ -public class DhcpNetMgrImpl implements DhcpNetMgr { - private Bridge bridge; - - public DhcpNetMgrImpl(Bridge bridge) { - this.bridge = bridge; - } - - /** - * Return the Network corresponding to the network string - * @return a Network - */ - public Network getNetwork(String network) - throws BridgeException { - - return bridge.getNetwork(network); - } - - /** - * Return the list of networks currently known to DHCP - * @return an array of Networks - */ - public Network [] getNetworks() throws BridgeException { - return getNetworks(null); - } - - public Network [] getNetworks(DhcpDatastore datastore) - throws BridgeException { - return bridge.getNetworks(datastore); - } - - /** - * Return the list of addresses managed by DHCP on a given network - * @param network the dotted-decimal representation of the network address - * @return an array of records for the addresses defined on that network - */ - public DhcpClientRecord [] loadNetwork(String network) - throws BridgeException { - return loadNetwork(network, null); - } - - /** - * Return the list of addresses managed by DHCP on a given network - * @param network the dotted-decimal representation of the network address - * @param datastore user-supplied datastore attributes - * @return an array of records for the addresses defined on that network - */ - public DhcpClientRecord [] loadNetwork(String network, - DhcpDatastore datastore) throws BridgeException { - return bridge.loadNetwork(network, datastore); - } - - /** - * Return the list of addresses managed by DHCP on a given network, with - * the hostnames for each client looked up, too. - * @param network the dotted-decimal representation of the network address - * @return an array of records for the addresses defined on that network - */ - public DhcpClientRecord [] loadNetworkCompletely(String network) - throws BridgeException { - DhcpClientRecord [] clients = loadNetwork(network); - // Force loading of client name for each client - for (int i = 0; i < clients.length; ++i) { - clients[i].getClientName(); - } - return clients; - } - - /** - * Modify an existing client record, and update the associated hosts - * record if needed. - * @param oldClient the existing record - * @param newClient the new record - * @param table the network on which the record is defined - */ - public void modifyClient(DhcpClientRecord oldClient, - DhcpClientRecord newClient, String table) throws BridgeException { - - modifyClient(oldClient, newClient, table, null); - } - - /** - * Modify an existing client record, and update the associated hosts - * record if needed. - * @param oldClient the existing record - * @param newClient the new record - * @param table the network on which the record is defined - * @param datastore user-supplied datastore attributes - */ - public void modifyClient(DhcpClientRecord oldClient, - DhcpClientRecord newClient, String table, DhcpDatastore datastore) - throws BridgeException { - - // Update the network table record - bridge.modifyDhcpClientRecord(oldClient, newClient, - table, datastore); - } - - /** - * Create a new record in the given table, and create a hosts record. - * @param client the client to create - * @param table the network on which to create the client - */ - public void addClient(DhcpClientRecord client, String table) - throws BridgeException { - - addClient(client, table, null); - } - - /** - * Create a new record in the given table, and create a hosts record. - * @param client the client to create - * @param table the network on which to create the client - * @param datastore user-supplied datastore attributes - */ - public void addClient(DhcpClientRecord client, String table, - DhcpDatastore datastore) throws BridgeException { - - // Create the record in the per-network table - bridge.createDhcpClientRecord(client, table, datastore); - - } - - /** - * Delete a record from the given table, and delete the associated hosts - * record if requested. - * @param client the client to delete - * @param table the network to delete the client from - */ - public void deleteClient(DhcpClientRecord client, String table) - throws BridgeException { - - deleteClient(client, table, null); - } - - /** - * Delete a record from the given table, and delete the associated hosts - * record if requested. - * @param client the client to delete - * @param table the network to delete the client from - * @param datastore user-supplied datastore attributes - */ - public void deleteClient(DhcpClientRecord client, String table, - DhcpDatastore datastore) - throws BridgeException { - - // Delete the client record from the per-network table - bridge.deleteDhcpClientRecord(client, table, datastore); - } - - - /** - * Retrieve a client record from the given table. - * @param client the client to delete - * @param table the network to delete the client from - * @param datastore user-supplied datastore attributes - */ - public DhcpClientRecord getClient(DhcpClientRecord client, - String table, DhcpDatastore datastore) throws BridgeException { - - // Retrieve the client record from the per-network table - DhcpClientRecord clientRecord = - bridge.getDhcpClientRecord(client, table, datastore); - - return clientRecord; - } - - /** - * Create a new per-network table for the given network by converting the - * one from the server's data store into a new data store. - * @param network the network number in dotted-decimal form. - * @param datastore user-supplied datastore attributes - */ - public void cvtNetwork(String network, - DhcpDatastore datastore) throws BridgeException { - bridge.cvtNetwork(network, datastore); - } - - /** - * Create a new per-network table for the given network. - * @param network the network number in dotted-decimal form. - */ - public void createNetwork(String network) - throws BridgeException { - - createNetwork(network, null); - } - - /** - * Create a new per-network table for the given network. - * @param network the network number in dotted-decimal form. - * @param datastore user-supplied datastore attributes - */ - public void createNetwork(String network, - DhcpDatastore datastore) throws BridgeException { - bridge.createDhcpNetwork(network, datastore); - } - - /** - * Delete a per-network table, the macro associated with the network number, - * and optionally deleting the associated hosts records. - * @param network the network number in dotted-decimal form. - * @param deleteMacro true if the network macro should be deleted - */ - public void deleteNetwork(String network, boolean deleteMacro) - throws BridgeException { - deleteNetwork(network, deleteMacro, null); - } - - /** - * Delete a per-network table, the macro associated with the network number, - * and optionally deleting the associated hosts records. - * @param network the network number in dotted-decimal form. - * @param deleteMacro true if the network macro should be deleted - * @param datastore user-supplied datastore attributes - */ - public void deleteNetwork(String network, boolean deleteMacro, - DhcpDatastore datastore) - throws BridgeException { - - // Delete network table, then the macro for the network - bridge.deleteDhcpNetwork(network, datastore); - try { - if (deleteMacro) { - bridge.deleteDhcptabRecord(new Macro(network), - datastore); - } - } catch (Throwable e) { - // All the errors here are ignorable - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpServiceMgr.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpServiceMgr.java deleted file mode 100644 index 38aad9f083..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpServiceMgr.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.server; - -import java.util.*; -import java.net.InetAddress; - -import com.sun.dhcpmgr.bridge.*; -import com.sun.dhcpmgr.data.*; - -/** - * This interface defines the methods available for managing the basic - * service parameters which are not stored in the dhcptab or network tables. - */ -public interface DhcpServiceMgr { - public String getServerName(); - public String getShortServerName(); - public InetAddress getServerAddress(); - public void makeLocation(DhcpDatastore datastore) - throws BridgeException; - public DhcpDatastore getDataStore(String resource) throws BridgeException; - public DhcpDatastore [] getDataStores() throws BridgeException; - public Option [] getInittabOptions(byte context) throws BridgeException; - public String getDataStoreClassname(String dataStoreName) - throws BridgeException; - public DhcpdOptions readDefaults() throws BridgeException; - public void writeDefaults(DhcpdOptions defs) throws BridgeException; - public void removeDefaults() throws BridgeException; - public void startup() throws BridgeException; - public void shutdown() throws BridgeException; - public void reload() throws BridgeException; - public IPInterface [] getInterfaces() throws BridgeException; - public String [] getArguments(String line) throws BridgeException; - public String getStringOption(String optionName, String arg) - throws BridgeException; - public IPAddress [] getIPOption(String optionName, String arg) - throws BridgeException; - public long [] getNumberOption(String optionName, String arg) - throws BridgeException; - public boolean isServerRunning() throws BridgeException; - public boolean isVersionCurrent() throws BridgeException; -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpServiceMgrImpl.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpServiceMgrImpl.java deleted file mode 100644 index 48ba400e6c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcpServiceMgrImpl.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.server; - -import java.util.*; -import java.util.jar.*; -import java.net.InetAddress; -import java.net.UnknownHostException; - -import com.sun.dhcpmgr.bridge.*; -import com.sun.dhcpmgr.data.*; - -/** - * This class provides the capabilities for managing the the basic service - * parameters which are not stored in the dhcptab or per-network tables. - */ -public class DhcpServiceMgrImpl implements DhcpServiceMgr { - private Bridge bridge; - - private String serverName; - private String shortServerName; - private InetAddress serverAddress; - - public DhcpServiceMgrImpl(Bridge bridge) { - this.bridge = bridge; - - try { - serverAddress = InetAddress.getLocalHost(); - serverName = serverAddress.getHostName(); - - int i = serverName.indexOf('.'); - if (i == -1) { - shortServerName = serverName; - } else { - shortServerName = serverName.substring(0, i); - } - } catch (UnknownHostException e) { - serverName = shortServerName = ""; - } - } - - public String getServerName() { - return serverName; - } - - public String getShortServerName() { - return shortServerName; - } - - public InetAddress getServerAddress() { - return serverAddress; - } - - public void makeLocation(DhcpDatastore datastore) - throws BridgeException { - bridge.makeLocation(datastore); - } - - public DhcpDatastore getDataStore(String resource) throws BridgeException { - return bridge.getDataStore(resource); - } - - /** - * Retrieve the list of possible data stores for this server - * @return an array of data store module names. - */ - public DhcpDatastore [] getDataStores() throws BridgeException { - return bridge.getDataStores(); - } - - /** - * Retrieve a list of options from the DHCP inittab. - * @return an array of options - */ - public Option [] getInittabOptions(byte context) throws BridgeException { - return bridge.getInittabOptions(context); - } - - public String getDataStoreClassname(String dataStoreName) - throws BridgeException { - - String beansDirectory = new String("/usr/sadm/admin/dhcpmgr/"); - String jarPath = beansDirectory.concat(dataStoreName).concat(".jar"); - String className = null; - try { - JarFile jarFile = new JarFile(jarPath); - Manifest manifest = jarFile.getManifest(); - if (manifest == null) { - throw new BridgeException(); - } - Attributes attrs = manifest.getMainAttributes(); - if (attrs == null) { - throw new BridgeException(); - } - className = attrs.getValue("Name"); - if (!className.endsWith(".class")) { - throw new BridgeException(); - } - className = className.substring(0, className.length() - 6); - className = className.replace('/', '.'); - } catch (Throwable e) { - throw new BridgeException(); - } - - return className; - } - - /** - * Retrieve the contents of the DHCP config file. - * @return the config settings - */ - public DhcpdOptions readDefaults() throws BridgeException { - return bridge.readDefaults(); - } - - /** - * Write new settings to the DHCP config file. - * @param cfgs the new config settings - */ - public void writeDefaults(DhcpdOptions cfgs) throws BridgeException { - bridge.writeDefaults(cfgs); - } - - /** - * Remove the DHCP config file. - */ - public void removeDefaults() throws BridgeException { - bridge.removeDefaults(); - } - - /** - * Start the server - */ - public void startup() throws BridgeException { - bridge.startup(); - } - - /** - * Stop the server - */ - public void shutdown() throws BridgeException { - bridge.shutdown(); - } - - /** - * Send the server a SIGHUP to re-read the dhcptab - */ - public void reload() throws BridgeException { - bridge.reload(); - } - - /** - * Get the list of possible interfaces for the server to monitor - * @return an array of interfaces - */ - public IPInterface [] getInterfaces() throws BridgeException { - return bridge.getInterfaces(); - } - - /** - * Break up a line into a list of arguments - * @param input line - * @return an array of arguments - */ - public String [] getArguments(String line) throws BridgeException { - return bridge.getArguments(line); - } - - /** - * Get the default value for an option which would take a string - * @param optionName name of the option - * @param arg additional information needed for this code - */ - public synchronized String getStringOption(String optionName, String arg) - throws BridgeException { - Option option = OptionsTable.getTable().get(optionName); - return bridge.getStringOption(option.getCode(), arg); - } - - /** - * Get the default value for an option which would take one or more IP addrs - * @param optionName name of the option - * @param arg additional information needed for this code - */ - public synchronized IPAddress [] getIPOption(String optionName, String arg) - throws BridgeException { - Option option = OptionsTable.getTable().get(optionName); - return bridge.getIPOption(option.getCode(), arg); - } - - /** - * Get the default value for an option which would take one or more numbers - * @param optionName name of the option - * @param arg additional information needed for this code - */ - public synchronized long [] getNumberOption(String optionName, String arg) - throws BridgeException { - Option option = OptionsTable.getTable().get(optionName); - return bridge.getNumberOption(option.getCode(), arg); - } - - /** - * Check if the datastore version is current. - * @return true if the datastore version if current. - */ - public boolean isVersionCurrent() throws BridgeException { - return bridge.isVersionCurrent(); - } - - /** - * Check if the server is currently running - * @return true if the server process is started - */ - public boolean isServerRunning() throws BridgeException { - return bridge.isServerRunning(); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcptabMgr.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcptabMgr.java deleted file mode 100644 index 38effbac70..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcptabMgr.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.server; - -import java.util.*; -import java.net.InetAddress; - -import com.sun.dhcpmgr.bridge.*; -import com.sun.dhcpmgr.data.*; - -/** - * This interface defines the methods available for managing the dhcptab. - */ -public interface DhcptabMgr { - public Option createOption(String name, String value) - throws BridgeException; - public Option [] getOptions(DhcpDatastore datastore) - throws BridgeException; - public Option [] getOptions() - throws BridgeException; - public Macro [] getMacros(DhcpDatastore datastore) - throws BridgeException; - public Macro [] getMacros() - throws BridgeException; - public Macro getMacro(String key, DhcpDatastore datastore) - throws BridgeException; - public Macro getMacro(String key) - throws BridgeException; - public Option getOption(String key, DhcpDatastore datastore) - throws BridgeException; - public Option getOption(String key) - throws BridgeException; - public void createRecord(DhcptabRecord rec, boolean signalServer, - DhcpDatastore datastore) throws BridgeException; - public void createRecord(DhcptabRecord rec, boolean signalServer) - throws BridgeException; - public void modifyRecord(DhcptabRecord oldRec, DhcptabRecord newRec, - boolean signalServer, DhcpDatastore datastore) - throws BridgeException; - public void modifyRecord(DhcptabRecord oldRec, DhcptabRecord newRec, - boolean signalServer) throws BridgeException; - public void deleteRecord(DhcptabRecord rec, boolean signalServer, - DhcpDatastore datastore) throws BridgeException; - public void deleteRecord(DhcptabRecord rec, boolean signalServer) - throws BridgeException; - public ActionError [] deleteAllMacros() throws BridgeException; - public ActionError [] deleteAllOptions() throws BridgeException; - public ActionError [] deleteMacros(String [] macroNames); - public ActionError [] deleteOptions(String [] optionNames); - public void cvtDhcptab(DhcpDatastore datastore) - throws BridgeException; - public void createDhcptab(DhcpDatastore datastore) - throws BridgeException; - public void createDhcptab() - throws BridgeException; - public void deleteDhcptab(DhcpDatastore datastore) - throws BridgeException; - public void deleteDhcptab() - throws BridgeException; - public void createLocaleMacro() - throws BridgeException, ValidationException; - public void createLocaleMacro(DhcpDatastore datastore) - throws BridgeException, ValidationException; - public void createServerMacro(String svrName, InetAddress svrAddress, - int leaseLength, boolean leaseNegotiable, String dnsDomain, - Vector dnsServs) throws BridgeException, ValidationException; - public void createServerMacro(String svrName, InetAddress svrAddress, - int leaseLength, boolean leaseNegotiable, String dnsDomain, - Vector dnsServs, DhcpDatastore datastore) - throws BridgeException, ValidationException; - public void createNetworkMacro(Network network, IPAddress [] routers, - boolean isLan, String nisDomain, Vector nisServs) - throws BridgeException, ValidationException; - public void createNetworkMacro(Network network, IPAddress [] routers, - boolean isLan, String nisDomain, Vector nisServs, - DhcpDatastore datastore) - throws BridgeException, ValidationException; -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcptabMgrImpl.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcptabMgrImpl.java deleted file mode 100644 index bb7d5115a3..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/DhcptabMgrImpl.java +++ /dev/null @@ -1,461 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.server; - -import java.util.*; -import java.net.InetAddress; - -import com.sun.dhcpmgr.bridge.*; -import com.sun.dhcpmgr.data.*; - -/** - * This class provides methods to manage the contents of the dhcptab. - */ - -public class DhcptabMgrImpl implements DhcptabMgr { - private Bridge bridge; - - /** - * Create a new DhcptabMgr using the provided native bridge. - * @param bridge the native bridge class which actually does the work. - */ - public DhcptabMgrImpl(Bridge bridge) { - this.bridge = bridge; - } - - /** - * Create an option. - * @param name the name of the option. - * @param value the value for the option in dhcptab(4) format. - * @return the Option. - */ - public Option createOption(String name, String value) - throws BridgeException { - return bridge.createOption(name, value); - } - - /** - * Retrieve all options currently defined in the dhcptab. - * @return an array of Options - */ - public Option [] getOptions() throws BridgeException { - return getOptions(null); - } - - /** - * Retrieve all options currently defined in the dhcptab. - * @param datastore user-supplied datastore attributes - * @return an array of Options - */ - public Option [] getOptions(DhcpDatastore datastore) - throws BridgeException { - return bridge.getOptions(datastore); - } - - /** - * Retrieve all the macros currently defined in the dhcptab. - * @return an array of Macros - */ - public Macro [] getMacros() throws BridgeException { - return getMacros(null); - } - - /** - * Retrieve all the macros currently defined in the dhcptab. - * @param datastore user-supplied datastore attributes - * @return an array of Macros - */ - public Macro [] getMacros(DhcpDatastore datastore) - throws BridgeException { - /* - * Load the vendor and site options before loading the macros - * so we can validate correctly, adding them to the standard options - * table. - */ - OptionsTable optionsTable = OptionsTable.getTable(); - optionsTable.add(bridge.getOptions(datastore)); - return bridge.getMacros(datastore); - } - - /** - * Create a given record in the dhcptab, and signal the server to - * reload the dhcptab if so requested. - * @param rec the record to add to the table - * @param signalServer true if the server is to be sent a SIGHUP - */ - public void createRecord(DhcptabRecord rec, boolean signalServer) - throws BridgeException { - createRecord(rec, signalServer, null); - } - - /** - * Create a given record in the dhcptab, and signal the server to - * reload the dhcptab if so requested. - * @param rec the record to add to the table - * @param signalServer true if the server is to be sent a SIGHUP - * @param datastore user-supplied datastore attributes - */ - public void createRecord(DhcptabRecord rec, boolean signalServer, - DhcpDatastore datastore) throws BridgeException { - bridge.createDhcptabRecord(rec, datastore); - if (signalServer) { - bridge.reload(); - } - } - - /** - * Modify a given record in the dhcptab, and signal the server to reload - * the dhcptab if so requested - * @param oldRec the current record to modify - * @param newRec the new record to be placed in the table - * @param signalServer true if the server is to be sent a SIGHUP - */ - public void modifyRecord(DhcptabRecord oldRec, DhcptabRecord newRec, - boolean signalServer) throws BridgeException { - modifyRecord(oldRec, newRec, signalServer, null); - } - - /** - * Modify a given record in the dhcptab, and signal the server to reload - * the dhcptab if so requested - * @param oldRec the current record to modify - * @param newRec the new record to be placed in the table - * @param signalServer true if the server is to be sent a SIGHUP - * @param datastore user-supplied datastore attributes - */ - public void modifyRecord(DhcptabRecord oldRec, DhcptabRecord newRec, - boolean signalServer, DhcpDatastore datastore) - throws BridgeException { - bridge.modifyDhcptabRecord(oldRec, newRec, datastore); - if (signalServer) { - bridge.reload(); - } - } - - /** - * Delete a given record from the dhcptab, and signal the server to reload - * the dhcptab if so requested - * @param rec the record to delete - * @param signalServer true if the server is to be sent a SIGHUP - */ - public void deleteRecord(DhcptabRecord rec, boolean signalServer) - throws BridgeException { - deleteRecord(rec, signalServer, null); - } - - /** - * Delete a given record from the dhcptab, and signal the server to reload - * the dhcptab if so requested - * @param rec the record to delete - * @param signalServer true if the server is to be sent a SIGHUP - * @param datastore user-supplied datastore attributes - */ - public void deleteRecord(DhcptabRecord rec, boolean signalServer, - DhcpDatastore datastore) throws BridgeException { - bridge.deleteDhcptabRecord(rec, datastore); - if (signalServer) { - bridge.reload(); - } - } - - /** - * Delete a record by name and type - * @param key The key for the record - * @param type The type of record; either MACRO or OPTION - */ - private void deleteRecord(String name, String type) throws BridgeException { - DhcptabRecord rec = null; - if (type.equals(DhcptabRecord.MACRO)) { - rec = getMacro(name); - } else { - rec = getOption(name); - } - deleteRecord(rec, false); - } - - /** - * Delete a set of records. - * @return An array of ActionError, one error for each record not deleted - */ - private ActionError [] deleteRecords(DhcptabRecord [] recs) { - ArrayList errorList = new ArrayList(); - - for (int i = 0; i < recs.length; ++i) { - try { - deleteRecord(recs[i], false); - } catch (BridgeException e) { - errorList.add(new ActionError(recs[i].getKey(), e)); - } - } - - return (ActionError[])errorList.toArray(new ActionError[0]); - } - - private ActionError [] deleteAllRecords(String type) - throws BridgeException { - DhcptabRecord [] recs; - if (type.equals(DhcptabRecord.MACRO)) { - recs = getMacros(); - } else { - recs = getOptions(); - } - return deleteRecords(recs); - } - - /** - * Delete all macros - * @return An array of ActionError, one error for each macro not deleted - */ - public ActionError [] deleteAllMacros() throws BridgeException { - return deleteAllRecords(DhcptabRecord.MACRO); - } - - /** - * Delete all options - * @return An array of ActionError, one error for each option not deleted - */ - public ActionError [] deleteAllOptions() throws BridgeException { - return deleteAllRecords(DhcptabRecord.OPTION); - } - - /** - * Delete a list of macros identified by name - * @param macroNames Names of the macros to delete - * @return An array of ActionError, one element per macro not deleted - */ - public ActionError [] deleteMacros(String [] macroNames) { - ArrayList errorList = new ArrayList(); - - for (int i = 0; i < macroNames.length; ++i) { - try { - deleteRecord(macroNames[i], DhcptabRecord.MACRO); - } catch (BridgeException e) { - errorList.add(new ActionError(macroNames[i], e)); - } - } - - return (ActionError [])errorList.toArray(new ActionError[0]); - } - - /** - * Delete a list of options identified by name - * @param optionNames Names of options to delete - * @return An array of ActionError, one element per option not deleted - */ - public ActionError [] deleteOptions(String [] optionNames) { - ArrayList errorList = new ArrayList(); - - for (int i = 0; i < optionNames.length; ++i) { - try { - deleteRecord(optionNames[i], DhcptabRecord.OPTION); - } catch (BridgeException e) { - errorList.add(new ActionError(optionNames[i], e)); - } - } - - return (ActionError [])errorList.toArray(new ActionError[0]); - } - - /** - * Retrieve a given macro from the dhcptab. - * @param key the key of the record to retrieve - * @return the Macro for the given key - */ - public Macro getMacro(String key) - throws BridgeException { - return getMacro(key, null); - } - - /** - * Retrieve a given macro from the dhcptab. - * @param key the key of the record to retrieve - * @param datastore user-supplied datastore attributes - * @return the Macro for the given key - */ - public Macro getMacro(String key, DhcpDatastore datastore) - throws BridgeException { - OptionsTable optionsTable = OptionsTable.getTable(); - optionsTable.add(bridge.getOptions(datastore)); - return bridge.getMacro(key, datastore); - } - - /** - * Retrieve a given option from the dhcptab. - * @param key the key of the record to retrieve - * @return the Option for the given key - */ - public Option getOption(String key) - throws BridgeException { - return getOption(key, null); - } - - /** - * Retrieve a given option from the dhcptab. - * @param key the key of the record to retrieve - * @param datastore user-supplied datastore attributes - * @return the Option for the given key - */ - public Option getOption(String key, DhcpDatastore datastore) - throws BridgeException { - return bridge.getOption(key, datastore); - } - - /** - * Create a new dhcptab converting the one in the server's data store, - * into a new data store. - * @param datastore user-supplied datastore attributes - */ - public void cvtDhcptab(DhcpDatastore datastore) - throws BridgeException { - bridge.cvtDhcptab(datastore); - } - - /** - * Create a new empty dhcptab in the server's data store, which must - * already be configured. - */ - public void createDhcptab() throws BridgeException { - createDhcptab(null); - } - - /** - * Create a new empty dhcptab in the server's data store, which must - * already be configured. - * @param datastore user-supplied datastore attributes - */ - public void createDhcptab(DhcpDatastore datastore) - throws BridgeException { - bridge.createDhcptab(datastore); - } - - /** - * Delete the server's dhcptab in the current data store. - */ - public void deleteDhcptab() throws BridgeException { - deleteDhcptab(null); - } - - /** - * Delete the server's dhcptab in the current data store. - * @param datastore user-supplied datastore attributes - */ - public void deleteDhcptab(DhcpDatastore datastore) - throws BridgeException { - bridge.deleteDhcptab(datastore); - } - - public void createLocaleMacro() - throws BridgeException, ValidationException { - createLocaleMacro(null); - } - - public void createLocaleMacro(DhcpDatastore datastore) - throws BridgeException, ValidationException { - - Macro macro = new Macro(); - macro.setKey("Locale"); - macro.storeOption(StandardOptions.CD_TIMEOFFSET, - String.valueOf(TimeZone.getDefault().getRawOffset()/1000)); - - createRecord(macro, false); - } - - public void createServerMacro(String svrName, - InetAddress svrAddress, int leaseLength, - boolean leaseNegotiable, String dnsDomain, Vector dnsServs) - throws BridgeException, ValidationException { - - createServerMacro(svrName, svrAddress, leaseLength, leaseNegotiable, - dnsDomain, dnsServs, null); - } - - public void createServerMacro(String svrName, - InetAddress svrAddress, int leaseLength, - boolean leaseNegotiable, String dnsDomain, Vector dnsServs, - DhcpDatastore datastore) - throws BridgeException, ValidationException { - - Macro macro = new Macro(); - macro.setKey(svrName); - macro.storeOption("Include", "Locale"); - macro.storeOption(StandardOptions.CD_TIMESERV, svrAddress); - macro.storeOption(StandardOptions.CD_LEASE_TIME, - String.valueOf(leaseLength)); - if (leaseNegotiable) { - macro.storeOption(StandardOptions.CD_BOOL_LEASENEG, null); - } - if (dnsDomain != null && dnsDomain.length() != 0 && - dnsServs != null && dnsServs.size() != 0) { - macro.storeOption(StandardOptions.CD_DNSDOMAIN, dnsDomain); - macro.storeOption(StandardOptions.CD_DNSSERV, dnsServs); - } - // First delete it in case it's already there - try { - deleteRecord(macro, false); - } catch (Throwable e) { - // Ignore any error - } - - createRecord(macro, false); - } - - public synchronized void createNetworkMacro(Network network, - IPAddress [] routers, boolean isLan, String nisDomain, Vector nisServs) - throws BridgeException, ValidationException { - - createNetworkMacro(network, routers, isLan, nisDomain, nisServs, - null); - } - - public void createNetworkMacro(Network network, - IPAddress [] routers, boolean isLan, String nisDomain, Vector nisServs, - DhcpDatastore datastore) throws BridgeException, ValidationException { - - Macro macro = new Macro(); - macro.setKey(network.toString()); - macro.storeOption(StandardOptions.CD_SUBNETMASK, network.getMask()); - if (routers == null) { - macro.storeOption(StandardOptions.CD_ROUTER_DISCVRY_ON, "1"); - } else { - for (int i = 0; i < routers.length; i++) { - macro.storeOption(StandardOptions.CD_ROUTER, routers[i]); - } - } - - if (isLan) { - macro.storeOption(StandardOptions.CD_BROADCASTADDR, - network.getBroadcastAddress()); - } - - // NIS config - if (nisDomain != null && nisDomain.length() != 0 && - nisServs != null && nisServs.size() != 0) { - macro.storeOption(StandardOptions.CD_NIS_DOMAIN, nisDomain); - macro.storeOption(StandardOptions.CD_NIS_SERV, nisServs); - } - - createRecord(macro, false); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/Makefile deleted file mode 100644 index 76ae00d480..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/Makefile -# - - -# Place high-level classes first in order to minimize build time. -CLASSFILES = DhcpMgrImpl.class \ - DhcpNetMgrImpl.class \ - DhcpServiceMgrImpl.class \ - DhcptabMgrImpl.class - - -include $(SRC)/lib/Makefile.lib - -CLASSPATH= $(SRC)/cmd/cmd-inet/usr.sadm/dhcpmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -MSGDIR = $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/server -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr \ - $(MSGDIR) - - -CLEANFILES= *.class -CLOBBERFILES= - -.KEEP_STATE: - -all: $(CLASSFILES) - -install: all - -_msg: - -include $(SRC)/lib/Makefile.targ diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/ResourceStrings.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/ResourceStrings.java deleted file mode 100644 index 643b251a64..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/server/ResourceStrings.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.server; - -import java.util.*; - -/** - * This class provides a convenient method to retrieve resources for - * the server package. - */ -public class ResourceStrings { - - /** - * The handle to the resource bundle for the module. - */ - private static ResourceBundle bundle = null; - - /** - * Return a string from the resource bundle. - * @param key the key to the resource bundle string. - * @return the resource bundle string. - */ - public static String getString(String key) { - String msg = null; - try { - if (bundle == null) { - bundle = ResourceBundle.getBundle( - "com.sun.dhcpmgr.server.ResourceBundle", - Locale.getDefault()); - } - msg = bundle.getString(key); - } catch (Throwable e) { - msg = new String(key); - } - return msg; - - } // getString - -} // ResourceStrings diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ALIGNMENT.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ALIGNMENT.java deleted file mode 100644 index b21e9132f6..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ALIGNMENT.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1996-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -/** - * Enumeration for <CODE>ALIGNMENT</CODE> values. - */ -public class ALIGNMENT { - - public static final ALIGNMENT CENTER = new ALIGNMENT(); - public static final ALIGNMENT LEFT = new ALIGNMENT(); - public static final ALIGNMENT RIGHT = new ALIGNMENT(); - public static final ALIGNMENT TOP = new ALIGNMENT(); - public static final ALIGNMENT BOTTOM = new ALIGNMENT(); - - private ALIGNMENT() { } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/AutosizingTable.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/AutosizingTable.java deleted file mode 100644 index 51c052c6a3..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/AutosizingTable.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import javax.swing.JTable; -import javax.swing.table.*; -import javax.swing.event.TableModelEvent; -import java.awt.Component; -import java.util.Date; - -import com.sun.dhcpmgr.data.IPAddress; -import com.sun.dhcpmgr.data.ValidationException; - -/** - * A subclass of Swing's JTable which automatically resizes its columns to - * fit the data being displayed in them. - */ -public class AutosizingTable extends JTable { - Date aDate = null; - IPAddress longIP = null; - - /** - * Construct the table - */ - public AutosizingTable() { - super(); - } - - /** - * Construct the table with the given model. - * @param model the TableModel to be used. - */ - public AutosizingTable(TableModel model) { - super(model); - } - - /** - * The table has changed; we'll resize the columns to contain the new data - * as best they can. - */ - public void tableChanged(TableModelEvent e) { - /* - * Let JTable do its thing, which probably includes wiping out - * the old columns and creating new ones - */ - super.tableChanged(e); - TableModel model = getModel(); - if (model.getRowCount() == 0) { - // No data, so just skip all the gymnastics - return; - } - /* - * Set column widths by first finding largest value in each column - * and then sizing accordingly - */ - for (int i = 0; i < getColumnCount(); ++i) { - TableColumn col = getColumnModel().getColumn(i); - - // Get the width of the header for this column - TableCellRenderer r = col.getHeaderRenderer(); - int headerWidth = 0; - Component c; - if (r == null) - r = getTableHeader().getDefaultRenderer(); - if (r != null) { - c = r.getTableCellRendererComponent(this, col.getHeaderValue(), - false, false, 0, 0); - headerWidth = c.getPreferredSize().width; - } - Object maxVal = null; - - if (model.getColumnClass(i) == String.class) { - // Column contains strings; find the longest one - String maxString = ""; - for (int j = 0; j < model.getRowCount(); ++j) { - String s = (String)model.getValueAt(j, i); - if (s != null) { - if (maxString.length() < s.length()) { - maxString = s; - } - } - } - maxVal = maxString; - } else if (model.getColumnClass(i) == IPAddress.class) { - // Column contains IP addresses; one long one is as good as any - if (longIP == null) { - try { - longIP = new IPAddress("222.222.222.222"); - } catch (ValidationException ex) { - // This should never happen! - } - } - maxVal = longIP; - } else if (model.getColumnClass(i) == Date.class) { - // Column contains dates; now is as good a time as any other. - if (aDate == null) { - aDate = new Date(); - } - maxVal = aDate; - } - // Now compute the width of the cell containing the longest value - c = getDefaultRenderer( - model.getColumnClass(i)).getTableCellRendererComponent( - this, maxVal, false, false, 0, i); - int cellWidth = c.getPreferredSize().width; - - // Set preferred width to the greater of the header & cell widths - col.setPreferredWidth(Math.max(headerWidth, cellWidth)); - } - // Now force the resizing we just did to be displayed - sizeColumnsToFit(-1); - - // Force header to repaint itself, otherwise it won't align correctly - getTableHeader().resizeAndRepaint(); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ButtonLayout.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ButtonLayout.java deleted file mode 100644 index 230e6b30d2..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ButtonLayout.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1996-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import java.awt.*; - -/** - * <CODE>ButtonLayout</CODE> is used to layout buttons in a - * <CODE>Panel</CODE>. It will arrange buttons left to right - * until no more buttons fit on the same line. Each line is - * centered. All buttons are set to an equal size.<P> - * - * While <CODE>ButtonLayout</CODE> was designed for <CODE>Buttons</CODE>, - * any component can be added to the layout. All components are - * set to an equal size.<P> - * - */ -public class ButtonLayout implements LayoutManager { - - ALIGNMENT align; - int hgap; - int vgap; - - /** - * Constructs a new <CODE>ButtonLayout</CODE> with a centered alignment. - */ - public ButtonLayout() { - this(ALIGNMENT.CENTER, 5, 5); - } - - /** - * Constructs a new <CODE>ButtonLayout</CODE> with the specified alignment. - * @param <VAR>align</VAR> The alignment value. - * @see ALIGNMENT - */ - public ButtonLayout(ALIGNMENT align) { - this(align, 5, 5); - } - - /** - * Constructs a new <CODE>ButtonLayout</CODE> with the specified - * alignment and gap values. - * @param <VAR>align</VAR> The alignment value. - * @param <VAR>hgap</VAR> The horizontal gap variable. - * @param <VAR>vgap</VAR> The vertical gap variable. - * @see ALIGNMENT - */ - public ButtonLayout(ALIGNMENT align, int hgap, int vgap) { - this.align = align; - this.hgap = hgap; - this.vgap = vgap; - } - - /** - * Adds the specified component to the layout. This is not - *used by this class. - * @param <VAR>name</VAR> The name of the component. - * @param <VAR>comp</VAR> The component to be added. - */ - public void addLayoutComponent(String name, Component comp) { - } - - /** - * Removes the specified component from the layout. This - * is not used by this class. - * @param <VAR>comp</VAR> The component to remove. - */ - public void removeLayoutComponent(Component comp) { - } - - /** - * Returns the preferred dimensions for this layout given - * the components in the specified target container. - * @param <VAR>target</VAR> The component that needs to be laid out. - * @see java.awt.Container - * @see #minimumLayoutSize - */ - public Dimension preferredLayoutSize(Container target) { - Dimension dim = new Dimension(0, 0); - int nmembers = target.getComponentCount(); - - for (int i = 0; i < nmembers; i++) { - Component m = target.getComponent(i); - if (m.isVisible()) { - Dimension d = m.getPreferredSize(); - dim.height = Math.max(dim.height, d.height); - dim.width = Math.max(dim.width, d.width); - } - } - dim.width = (dim.width*nmembers) + (hgap*nmembers-1); - Insets insets = target.getInsets(); - dim.width += insets.left + insets.right + hgap*2; - dim.height += insets.top + insets.bottom + vgap*2; - return dim; - } - - /** - * Returns the minimum dimensions needed to layout the components - * contained in the specified target container. - * @param <VAR>target</VAR> The component that needs to be laid out - * @see #preferredLayoutSize - */ - public Dimension minimumLayoutSize(Container target) { - Dimension dim = new Dimension(0, 0); - int nmembers = target.getComponentCount(); - - for (int i = 0; i < nmembers; i++) { - Component m = target.getComponent(i); - if (m.isVisible()) { - Dimension d = m.getMinimumSize(); - dim.height = Math.max(dim.height, d.height); - dim.width = Math.max(dim.width, d.width); - } - } - dim.width = (dim.width*nmembers) + (hgap*nmembers-1); - Insets insets = target.getInsets(); - dim.width += insets.left + insets.right + hgap*2; - dim.height += insets.top + insets.bottom + vgap*2; - return dim; - } - - /** - * Centers the elements in the specified row, if there is any slack. - * @param <VAR>target</VAR> The component which needs to be moved. - * @param <VAR>x</VAR> The x coordinate. - * @param <VAR>y</VAR> The y coordinate. - * @param <VAR>width</VAR> The width dimensions. - * @param <VAR>height</VAR> The height dimensions. - * @param <VAR>rowStart</VAR> Index of the first component in the row. - * @param <VAR>rowEnd</VAR> Index of the last component in the row. - */ - private void moveComponents(Container target, int x, int y, int width, - int height, int rowStart, int rowEnd) { - Dimension dim; - - if (align == ALIGNMENT.LEFT) { - // do nothing - } else if (align == ALIGNMENT.CENTER) { - x += width / 2; - } else if (align == ALIGNMENT.RIGHT) { - x += width; - } - for (int i = rowStart; i < rowEnd; i++) { - Component m = target.getComponent(i); - if (m.isVisible()) { - dim = m.getSize(); - m.setLocation(x, y + (height - dim.height) / 2); - x += hgap + dim.width; - } - } - } - - /** - * Lays out the container. This method will actually reshape the - * components in the target in order to satisfy the constraints of - * the <CODE>BorderLayout</CODE> object. - * @param <VAR>target</VAR> The specified component being laid out. - * @see java.awt.Container - */ - public void layoutContainer(Container target) { - Insets insets = target.getInsets(); - Dimension tdim = target.getSize(); - int maxwidth = tdim.width - (insets.left + insets.right + hgap*2); - int nmembers = target.getComponentCount(); - int x = 0, y = insets.top + vgap; - int rowh = 0, start = 0; - Dimension dim = new Dimension(0, 0); - - for (int i = 0; i < nmembers; i++) { - Component m = target.getComponent(i); - if (m.isVisible()) { - Dimension d = m.getMinimumSize(); - dim.width = Math.max(dim.width, d.width); - } - } - for (int i = 0; i < nmembers; i++) { - Component m = target.getComponent(i); - if (m.isVisible()) { - Dimension d = m.getPreferredSize(); - m.setSize(dim.width, d.height); - - if ((x == 0) || ((x + dim.width) <= maxwidth)) { - if (x > 0) { - x += hgap; - } - x += dim.width; - rowh = Math.max(rowh, d.height); - } else { - moveComponents(target, insets.left + hgap, y, maxwidth - x, - rowh, start, i); - x = dim.width; - y += vgap + rowh; - rowh = d.height; - start = i; - } - } - } - moveComponents(target, insets.left + hgap, y, maxwidth - x, rowh, - start, nmembers); - } - - /** - * Returns the <CODE>String</CODE> representation of this - * <CODE>ButtonLayout</CODE>'s values. - */ - public String toString() { - String str = ""; - if (align == ALIGNMENT.LEFT) { - str = ",align=left"; - } else if (align == ALIGNMENT.RIGHT) { - str = ",align=right"; - } else if (align == ALIGNMENT.CENTER) { - str = ",align=center"; - } - return getClass().getName() - + "[hgap=" + hgap + ",vgap=" + vgap + str + "]"; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ButtonPanel.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ButtonPanel.java deleted file mode 100644 index 7a2d734da8..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ButtonPanel.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.ui; - -import javax.swing.*; -import java.awt.event.*; -import java.util.*; - -/** - * A simple panel with the buttons commonly used in a dialog. Register as - * a ButtonPanelListener in order to receive the events from this class. - * @see ButtonPanelListener - */ -public class ButtonPanel extends JPanel { - - // Convert action events on each button to button panel notifications - class ButtonAdaptor implements ActionListener { - public void actionPerformed(ActionEvent e) { - int buttonId = -1; - Object source = e.getSource(); - if (source == okButton) { - buttonId = ButtonPanelListener.OK; - } else if (source == resetButton) { - buttonId = ButtonPanelListener.RESET; - } else if (source == cancelButton) { - buttonId = ButtonPanelListener.CANCEL; - } else if (source == helpButton) { - buttonId = ButtonPanelListener.HELP; - } - Enumeration en = listeners.elements(); - while (en.hasMoreElements()) { - ButtonPanelListener l = (ButtonPanelListener)en.nextElement(); - l.buttonPressed(buttonId); - } - } - } - - JButton okButton, resetButton, cancelButton, helpButton; - ButtonAdaptor adaptor; - Vector listeners; - - /** - * Construct a ButtonPanel with OK, Cancel, and Help buttons, and - * the reset button display controlled by the parameter. - * @param showReset true if Reset button is to be included - */ - public ButtonPanel(boolean showReset) { - this(showReset, true); - } - - /** - * Construct a ButtonPanel with reset and help buttons controlled - * by the parameters passed, and always showing OK and Cancel. - * @param showReset true if Reset button is to be included - * @param showHelp true if Help button is to be included - */ - public ButtonPanel(boolean showReset, boolean showHelp) { - super(); - setLayout(new ButtonLayout(ALIGNMENT.RIGHT)); - // Create event handler - adaptor = new ButtonAdaptor(); - listeners = new Vector(); - - Mnemonic mn = new Mnemonic(ResourceStrings.getString("ok_button")); - okButton = new JButton(mn.getString()); - okButton.setToolTipText(mn.getString()); - okButton.setMnemonic(mn.getMnemonic()); - - okButton.setEnabled(false); - okButton.addActionListener(adaptor); - add(okButton); - - // Only show reset if requested - if (showReset) { - Mnemonic mnReset = - new Mnemonic(ResourceStrings.getString("reset_button")); - resetButton = new JButton(mnReset.getString()); - resetButton.setToolTipText(mnReset.getString()); - resetButton.setMnemonic(mnReset.getMnemonic()); - - resetButton.addActionListener(adaptor); - add(resetButton); - } else { - resetButton = null; - } - - Mnemonic mnCancel = - new Mnemonic(ResourceStrings.getString("cancel_button")); - cancelButton = new JButton(mnCancel.getString()); - cancelButton.setToolTipText(mnCancel.getString()); - cancelButton.setMnemonic(mnCancel.getMnemonic()); - - cancelButton.addActionListener(adaptor); - add(cancelButton); - - if (showHelp) { - Mnemonic mnHelp = - new Mnemonic(ResourceStrings.getString("help_button")); - helpButton = new JButton(mnHelp.getString()); - helpButton.setToolTipText(mnHelp.getString()); - helpButton.setMnemonic(mnHelp.getMnemonic()); - - helpButton.addActionListener(adaptor); - add(helpButton); - } else { - helpButton = null; - } - } - - public void addButtonPanelListener(ButtonPanelListener l) { - listeners.addElement(l); - } - - public void removeButtonPanelListener(ButtonPanelListener l) { - listeners.removeElement(l); - } - - public void setOkEnabled(boolean state) { - okButton.setEnabled(state); - } - - public boolean isOkEnabled() { - return okButton.isEnabled(); - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ButtonPanelListener.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ButtonPanelListener.java deleted file mode 100644 index c0e434708a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ButtonPanelListener.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -public interface ButtonPanelListener { - public final static int OK = 0; - public final static int CANCEL = 1; - public final static int HELP = 2; - public final static int RESET = 3; - - public void buttonPressed(int buttonId); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/DownButton.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/DownButton.java deleted file mode 100644 index 3301ac9ea2..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/DownButton.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.ui; - -/** - * Class to produce a button with an icon pointing down. - */ -public class DownButton extends ImageButton { - public DownButton() { - Mnemonic mnText = - new Mnemonic(ResourceStrings.getString("down_button")); - setImage(getClass(), "down.gif", mnText); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ExtendedCellRenderer.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ExtendedCellRenderer.java deleted file mode 100644 index ec743cc795..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ExtendedCellRenderer.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import javax.swing.table.DefaultTableCellRenderer; -import java.util.Date; -import java.text.DateFormat; -import java.net.InetAddress; -import com.sun.dhcpmgr.data.IPAddress; - -// Renderer for cells containing Dates, InetAddresses or IPAddresses -public class ExtendedCellRenderer extends DefaultTableCellRenderer { - private DateFormat dateFormat = DateFormat.getInstance(); - - protected void setValue(Object value) { - if (value != null) { - if (value instanceof Date) { - long t = ((Date)value).getTime(); - if (t == 0) { - super.setValue(null); - } else if (t < 0) { - super.setValue(ResourceStrings.getString("never")); - } else { - super.setValue(dateFormat.format(value)); - } - } else if (value instanceof InetAddress) { - super.setValue(((InetAddress)value).getHostAddress()); - } else if (value instanceof IPAddress) { - super.setValue(((IPAddress)value).getHostAddress()); - } else { - super.setValue(value); - } - } else { - super.setValue(value); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/FieldLayout.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/FieldLayout.java deleted file mode 100644 index 4dbf2e09d7..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/FieldLayout.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1996-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import java.awt.*; -import java.util.*; - -/** - * <CODE>FieldLayout</CODE> treats components as a list of - * labeled fields, where each label is placed on the left - * edge of the container with its associated field to its - * right.<P> - * - * Two kinds of components may be added: "Label" and "Field." - * Labels and Fields must be added in pairs, because there is - * a one-to-one correspondence between them.<P> - * - * When a <CODE>Field</CODE> is added, it is associated with the - * last <CODE>Label</CODE> added.<P> - */ -public class FieldLayout implements LayoutManager { - public static final String LABEL = "Label"; - public static final String LABELTOP = "LabelTop"; - public static final String FIELD = "Field"; - - class Row { - Component label; - Component field; - double yRatio; - boolean center; - - public Row() { - label = null; - field = null; - yRatio = 1; - center = true; - } - } - - Vector rows; - int hgap; - int vgap; - - /** - * Constructs a new <CODE>FieldLayout</CODE> with a centered alignment. - */ - public FieldLayout() { - this(5, 5); - } - - /** - * Constructs a new <CODE>FieldLayout</CODE> with the specified gap values. - * @param <VAR>hgap</VAR> The horizontal gap variable. - * @param <VAR>vgap</VAR> The vertical gap variable. - */ - public FieldLayout(int hgap, int vgap) { - this.hgap = hgap; - this.vgap = vgap; - rows = new Vector(); - } - - /** - * Adds the specified component to the layout. - * @param <VAR>name</VAR> The name of the component. - * @param <VAR>comp</VAR> The component to be added. - */ - public void addLayoutComponent(String name, Component comp) { - if (LABEL.equals(name)) { - Row r = new Row(); - r.label = comp; - r.center = true; - rows.addElement(r); - } else if (LABELTOP.equals(name)) { - Row r = new Row(); - r.label = comp; - r.center = false; - rows.addElement(r); - } else if (FIELD.equals(name)) { - ((Row)rows.lastElement()).field = comp; - } - } - - /** - * Removes the specified component from the layout. - * @param <VAR>comp</VAR> The component to remove. - */ - public void removeLayoutComponent(Component comp) { - Enumeration en = rows.elements(); - while (en.hasMoreElements()) { - Row r = (Row)en.nextElement(); - if (comp == r.label || comp == r.field) { - rows.removeElement(r); - return; - } - } - } - - /** - * Returns the preferred dimensions for this layout given the components - * in the specified target container. - * @param <VAR>target</VAR> The component that needs to be laid out. - * @see java.awt.Container - * @see #minimumLayoutSize - */ - public Dimension preferredLayoutSize(Container target) { - Dimension dim = new Dimension(0, 0); - int widestLabel = 0, widestField = 0; - - Enumeration en = rows.elements(); - while (en.hasMoreElements()) { - Row r = (Row)en.nextElement(); - if (!r.label.isVisible() || !r.field.isVisible()) { - continue; - } - Dimension ld = r.label.getPreferredSize(); - widestLabel = Math.max(widestLabel, ld.width); - Dimension fd = r.field.getPreferredSize(); - widestField = Math.max(widestField, fd.width); - dim.height += Math.max(ld.height, fd.height) + vgap; - } - dim.width = widestLabel + hgap + widestField; - Insets insets = target.getInsets(); - dim.width += insets.left + insets.right + hgap*2; - dim.height += insets.top + insets.bottom + vgap; - return dim; - } - - /** - * Returns the minimum dimensions needed to layout the components - * contained in the specified target container. - * @param <VAR>target</VAR> The component that needs to be laid out. - * @see #preferredLayoutSize - */ - public Dimension minimumLayoutSize(Container target) { - Dimension dim = new Dimension(0, 0); - int widestLabel = 0, widestField = 0; - - Enumeration en = rows.elements(); - while (en.hasMoreElements()) { - Row r = (Row)en.nextElement(); - if (!r.label.isVisible() || !r.field.isVisible()) { - continue; - } - Dimension ld = r.label.getMinimumSize(); - widestLabel = Math.max(widestLabel, ld.width); - Dimension fd = r.field.getMinimumSize(); - widestField = Math.max(widestField, fd.width); - dim.height += Math.max(ld.height, fd.height) + vgap; - } - dim.width = widestLabel + hgap + widestField; - Insets insets = target.getInsets(); - dim.width += insets.left + insets.right + hgap*2; - dim.height += insets.top + insets.bottom + vgap; - return dim; - } - - /** - * Performs the layout of the container. Components are treated - * either as labels or fields. Labels go on the left (right-aligned), - * with their associated fields placed immediately to their right. - * @param <VAR>target</VAR> The specified component being laid out. - * @see java.awt.Container - */ - public void layoutContainer(Container target) { - Insets insets = target.getInsets(); - Dimension dim = target.getSize(); - int x = 0, y = insets.top, offset = 0; - int widestLabel = 0; - int ySlop = 0; - - // Compute whether preferred sizes will fit - Dimension pDim = preferredLayoutSize(target); - boolean usingPreferred = true; - if ((pDim.height > (dim.height - insets.top - insets.bottom)) || - (pDim.width > (dim.width - insets.left - insets.right))) { - usingPreferred = false; - // Compute leftover vertical space - pDim = minimumLayoutSize(target); - ySlop = dim.height - insets.top - insets.bottom - pDim.height; - if (ySlop < 0) { - ySlop = 0; - } - } - - /* - * Find widest label. Our policy on horizontal space is that labels - * are fully satisfied and fields get whatever's left. - * For vertical space, if there's any leftovers then allocate it - * in proportion to demand, which we'll define as the ratio between - * preferred size and minimum size. - */ - double sumRatios = 0; - Enumeration en = rows.elements(); - while (en.hasMoreElements()) { - Row r = (Row)en.nextElement(); - if (r.label.isVisible() && r.field.isVisible()) { - Dimension d = usingPreferred ? r.label.getPreferredSize() : - r.label.getMinimumSize(); - widestLabel = Math.max(widestLabel, d.width); - if (!usingPreferred) { - double lRatio = r.label.getPreferredSize().getHeight() / - r.label.getMinimumSize().getHeight(); - double fRatio = r.field.getPreferredSize().getHeight() / - r.field.getMinimumSize().getHeight(); - r.yRatio = Math.max(lRatio, fRatio); - } - // If there is no demand, then adjust ratio to zero - if (r.yRatio == 1.0) { - r.yRatio = 0; - } - sumRatios += r.yRatio; - } - } - - // lay out rows, right-aligning labels - en = rows.elements(); - while (en.hasMoreElements()) { - Row r = (Row)en.nextElement(); - Component l = r.label; - Component f = r.field; - // Skip the row if both aren't visible - if (!l.isVisible() || !f.isVisible()) - continue; - Dimension ld = usingPreferred ? l.getPreferredSize() : - l.getMinimumSize(); - Dimension fd = usingPreferred ? f.getPreferredSize() : - f.getMinimumSize(); - - int rowHeight = Math.max(ld.height, fd.height) + - (int)(ySlop * r.yRatio / sumRatios); - - x = insets.left; - /* - * If the field is visible, move it right to line up with - * the widest line. - */ - x += Math.max(widestLabel - ld.width, 0); - offset = 0; - if (r.center) { - // center label on field - offset = Math.max(0, (rowHeight-ld.height)/2); - } - int labelHeight = rowHeight; - /* - * If label doesn't look like it wants extra space, don't give it; - * otherwise, JLabels will get drawn centered even if user - * specified it as a top alignment when doing the layout. - */ - if (l.getPreferredSize().height == l.getMinimumSize().height) { - labelHeight = ld.height; - } - l.setBounds(x, y+offset, ld.width, labelHeight); - x = insets.left + widestLabel + hgap; - int w = dim.width-x-hgap; - f.setBounds(x, y, w, rowHeight); - y += rowHeight + vgap; - } - - } - - /** - * Returns the <CODE>String</CODE> representation of this - * <CODE>FieldLayout</CODE>'s values. - */ - public String toString() { - return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + "]"; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/HelpIds.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/HelpIds.java deleted file mode 100644 index 3cbbe422ab..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/HelpIds.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import java.util.*; - -public class HelpIds { - private ResourceBundle bundle; - - public HelpIds(String bundleName) throws MissingResourceException { - bundle = ResourceBundle.getBundle(bundleName); - } - - public String getFilePath(String key) { - try { - /* - * The original version of this code was: - * if (bundle.getLocale().toString().length() == 0) { - * bug 4177489 causes that not to work correctly, so for the moment - * we *require* that each key in a locale contain a relative - * path, otherwise it is assumed we're in the default locale and - * proceed with the default location. - */ - String s = bundle.getString(key); - if (s.indexOf('/') == -1) { - // Not localized, use the default location - return "/usr/sadm/admin/dhcpmgr/help/" + s; - } else { - return "/usr/share/lib/locale/com/sun/dhcpmgr/client/help/" + s; - } - } catch (Throwable e) { - e.printStackTrace(); - return ""; - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/HostnameField.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/HostnameField.java deleted file mode 100644 index 912fa180d9..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/HostnameField.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.text.*; - -/** - * A text field which limits input to only those characters which can legally - * appear in a hostname as specified in RFC1123, i.e. the letters, digits - * and '-'. - */ -public class HostnameField extends JTextField { - - /** - * Constructs an empty field, 20 characters wide. - */ - public HostnameField() { - this(""); - } - - /** - * Constructs a field initialized to the provided text. Defaults to 20 - * characters wide. - * @param text the text to display initially - */ - public HostnameField(String text) { - this(text, 20); - } - - /** - * Constructs a field initialized to the provided text with the requested - * size. - * @param text the text to display initially - * @param length the length in characters the field should size itself to - */ - public HostnameField(String text, int length) { - super(text, length); - } - - protected Document createDefaultModel() { - return new HostnameDocument(); - } - - /* - * This is the recommended way to validate/filter input, as opposed to - * trapping KeyEvents because this will catch paste operations, too. - */ - static class HostnameDocument extends PlainDocument { - public void insertString(int offs, String str, AttributeSet a) - throws BadLocationException { - if (str != null) { - char [] chars = str.toCharArray(); - if ((chars.length != 0) && (getLength() == 0)) { - // First character in field must be a letter or digit - if (!Character.isLetterOrDigit(chars[0])) { - throw new BadLocationException("", offs); - } - } - // Now validate that everything we're inserting is legal - for (int i = 0; i < chars.length; ++i) { - if (!Character.isLetterOrDigit(chars[i]) - && chars[i] != '-') { - throw new BadLocationException("", offs); - } - } - } - super.insertString(offs, str, a); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/IPAddressField.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/IPAddressField.java deleted file mode 100644 index aa9bb9b01f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/IPAddressField.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.text.*; -import java.net.InetAddress; - -import com.sun.dhcpmgr.data.IPAddress; -import com.sun.dhcpmgr.data.ValidationException; - -/** - * A text field which limits input to only those characters which can legally - * appear in an IP address, i.e. the digits and '.'. - */ -public class IPAddressField extends JTextField { - - /** - * Constructs an empty field. - */ - public IPAddressField() { - this(""); - } - - /** - * Constructs a field initialized to the provided text. - * @param text the text to display initially - */ - public IPAddressField(String text) { - super(text, 15); - } - - /** - * Sets the value to a provided IP address. - * @param addr an <code>InetAddress</code> to display - */ - public void setValue(InetAddress addr) { - if (addr == null) { - setText(""); - } else { - setText(addr.getHostAddress()); - } - } - - /** - * Sets the value to the provided IP address. This is our special - * <code>IPAddress</code> class. - * @param addr a <code>IPAddress</code> to display - */ - public void setValue(IPAddress addr) { - if (addr == null) { - setText(""); - } else { - setText(addr.getHostAddress()); - } - } - - /** - * Return the current value as an <code>IPAddress</code>. - * @return the current value as an <code>IPAddress</code>, or null if the - * current text is not a valid IP address. - */ - public IPAddress getValue() { - IPAddress a = null; - try { - a = new IPAddress(getText()); - } catch (ValidationException e) { - // Do nothing - } - return a; - } - - protected Document createDefaultModel() { - return new IPAddressDocument(); - } - - /* - * This is the recommended way to validate/filter input, as opposed to - * trapping KeyEvents because this will catch paste operations, too. - */ - static class IPAddressDocument extends PlainDocument { - public void insertString(int offs, String str, AttributeSet a) - throws BadLocationException { - if (str != null) { - char [] chars = str.toCharArray(); - if ((getLength() + chars.length) > 15) { - // IP addresses are limited to 15 characters, period. - throw new BadLocationException("", offs); - } - for (int i = 0; i < chars.length; ++i) { - if (!Character.isDigit(chars[i]) && chars[i] != '.') { - throw new BadLocationException("", offs); - } - } - } - super.insertString(offs, str, a); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/IPAddressList.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/IPAddressList.java deleted file mode 100644 index b943e67bf7..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/IPAddressList.java +++ /dev/null @@ -1,364 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.ui; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; -import java.util.*; - -import com.sun.dhcpmgr.data.IPAddress; -import com.sun.dhcpmgr.data.ValidationException; - -/** - * A panel which allows the user to edit a list of IP addresses. Consists of - * a text field for entering new data, paired with a list which allows the - * addresses entered to be ordered or deleted. - */ -public class IPAddressList extends JPanel { - IPAddressField address; - JList serverList; - IPAddressListModel serverListModel; - JButton add, delete; - UpButton moveUp; - DownButton moveDown; - - /** - * Construct the address list. - */ - public IPAddressList() { - super(); - GridBagLayout bag = new GridBagLayout(); - setLayout(bag); - - GridBagConstraints c = new GridBagConstraints(); - c.gridx = c.gridy = 0; - c.weightx = c.weighty = 1.0; - c.gridheight = 1; - c.gridwidth = 1; - - // Field to type in addresses - address = new IPAddressField(); - address.getAccessibleContext().setAccessibleDescription( - ResourceStrings.getString("dhcp_server_address")); - - c.fill = GridBagConstraints.HORIZONTAL; - bag.setConstraints(address, c); - add(address); - - // Button for Add operation - Mnemonic mnAdd = new Mnemonic(ResourceStrings.getString("add")); - add = new JButton(mnAdd.getString()); - add.setToolTipText(mnAdd.getString()); - add.setMnemonic(mnAdd.getMnemonic()); - - c.fill = GridBagConstraints.NONE; - ++c.gridx; - c.weightx = 0.5; - bag.setConstraints(add, c); - add(add); - - // List for addresses - serverListModel = new IPAddressListModel(); - serverList = new JList(serverListModel); - // Make sure it's wide enough for our purposes - serverList.setPrototypeCellValue("222.222.222.222"); - serverList.setSelectionMode( - ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - JScrollPane scrollPane = new JScrollPane(serverList); - // Don't allow horizontal scrolling here - scrollPane.setHorizontalScrollBarPolicy( - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - c.fill = GridBagConstraints.BOTH; - c.gridx = 0; - ++c.gridy; - c.weightx = 1.0; - bag.setConstraints(scrollPane, c); - add(scrollPane); - - // Buttons to manipulate the list contents - JPanel buttonPanel = new JPanel(new VerticalButtonLayout()); - moveUp = new UpButton(); - moveUp.setToolTipText(ResourceStrings.getString("move_up")); - buttonPanel.add(moveUp); - moveDown = new DownButton(); - moveDown.setToolTipText(ResourceStrings.getString("move_down")); - buttonPanel.add(moveDown); - - Mnemonic mnDelete = new Mnemonic(ResourceStrings.getString("delete")); - delete = new JButton(mnDelete.getString()); - delete.setToolTipText(mnDelete.getString()); - delete.setMnemonic(mnDelete.getMnemonic()); - - buttonPanel.add(delete); - ++c.gridx; - c.weightx = 0.5; - bag.setConstraints(buttonPanel, c); - add(buttonPanel); - - // Disable all buttons to start; selection changes adjust button state - add.setEnabled(false); - delete.setEnabled(false); - moveUp.setEnabled(false); - moveDown.setEnabled(false); - - // Create listener for button presses, take action as needed - ActionListener l = new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (e.getSource() == add || e.getSource() == address) { - IPAddress a = address.getValue(); - if (a != null) { - serverListModel.addElement(a); - } - } else if (e.getSource() == delete) { - int [] indices = serverList.getSelectedIndices(); - if (indices.length > 1) { - /* - * Need to sort the indices so that the delete's - * don't interfere with each other - */ - for (int i = 0; i < indices.length; ++i) { - for (int j = i; j < indices.length; ++j) { - if (indices[i] > indices[j]) { - int k = indices[i]; - indices[i] = indices[j]; - indices[j] = k; - } - } - } - } - // Now delete from high index to low - for (int i = indices.length - 1; i >= 0; --i) { - serverListModel.removeElementAt(indices[i]); - } - if (indices.length > 1) { - // Clear selection if multiple deleted - serverList.clearSelection(); - /* - * We don't get a selection event for some reason - * so make it work for now - */ - delete.setEnabled(false); - } else { - // Make sure to select something in the list - if (serverListModel.getSize() == 0) { - /* - * List is empty, nothing to select so disable - * delete - */ - delete.setEnabled(false); - } else if (indices[0] >= serverListModel.getSize()) { - // Select last one if we're off the end - serverList.setSelectedIndex( - serverListModel.getSize()-1); - } else { - // Select next one in list - serverList.setSelectedIndex(indices[0]); - } - } - } else if (e.getSource() == moveUp) { - int i = serverList.getSelectedIndex(); - serverListModel.moveUp(i); - // Keep item selected so repeated moveUp's affect same item - serverList.setSelectedIndex(i-1); - } else if (e.getSource() == moveDown) { - int i = serverList.getSelectedIndex(); - serverListModel.moveDown(i); - // Keep item selected so repeated moveDowns affect same item - serverList.setSelectedIndex(i+1); - } - } - }; - address.addActionListener(l); - add.addActionListener(l); - delete.addActionListener(l); - moveUp.addActionListener(l); - moveDown.addActionListener(l); - - // Put a selection listener on the list to enable buttons appropriately - serverList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - int [] indices = serverList.getSelectedIndices(); - switch (indices.length) { - case 0: - // Nothing selected; disable them all - delete.setEnabled(false); - moveUp.setEnabled(false); - moveDown.setEnabled(false); - break; - case 1: - delete.setEnabled(true); - // Can't move first one up - if (indices[0] == 0) { - moveUp.setEnabled(false); - } else { - moveUp.setEnabled(true); - } - // Can't move last one down - if (indices[0] == (serverListModel.getSize() - 1)) { - moveDown.setEnabled(false); - } else { - moveDown.setEnabled(true); - } - break; - default: - // More than one; only delete is allowed - delete.setEnabled(true); - moveUp.setEnabled(false); - moveDown.setEnabled(false); - } - } - }); - // Enable Add when address is not empty. - address.getDocument().addDocumentListener(new DocumentListener() { - public void insertUpdate(DocumentEvent e) { - add.setEnabled(address.getText().length() != 0); - } - public void changedUpdate(DocumentEvent e) { - insertUpdate(e); - } - public void removeUpdate(DocumentEvent e) { - insertUpdate(e); - } - }); - } - - /** - * Initialize the data in the list - */ - public void setAddressList(IPAddress [] ipAddrs) { - serverListModel.setData(ipAddrs); - } - - /** - * Set the addresses from a comma-delimited string - */ - public void setAddressList(String s) { - serverListModel.setData(s); - } - - /** - * Retrieve the data in the list - */ - public Vector getAddressList() { - return serverListModel.getDataVector(); - } - - /** - * Retrieve the list converted to a comma-delimited string - */ - public String getAddressListString() { - return serverListModel.getDataString(); - } - - /** - * Return the size of the list - */ - public int getListSize() { - return serverListModel.getDataVector().size(); - } - - class IPAddressListModel extends AbstractListModel { - private Vector addrs; - - public IPAddressListModel() { - super(); - addrs = new Vector(); - } - - public int getSize() { - return addrs.size(); - } - - public Object getElementAt(int index) { - return addrs.elementAt(index); - } - - public void setData(IPAddress [] ipAddrs) { - addrs.removeAllElements(); - for (int i = 0; i < ipAddrs.length; ++i) { - addrs.addElement(ipAddrs[i]); - } - fireContentsChanged(this, 0, addrs.size()-1); - } - - public void setData(String s) { - addrs.removeAllElements(); - StringTokenizer st = new StringTokenizer(s, ","); - while (st.hasMoreTokens()) { - try { - addrs.addElement(new IPAddress(st.nextToken())); - } catch (ValidationException e) { - // Ignore it, didn't parse for some reason - } - } - fireContentsChanged(this, 0, addrs.size()-1); - } - - public void addElement(IPAddress addr) { - addrs.addElement(addr); - fireIntervalAdded(this, addrs.size()-1, addrs.size()-1); - } - - public void removeElementAt(int index) { - addrs.removeElementAt(index); - fireIntervalRemoved(this, index, index); - } - - public void moveUp(int index) { - Object t = addrs.elementAt(index-1); - addrs.setElementAt(addrs.elementAt(index), index-1); - addrs.setElementAt(t, index); - fireContentsChanged(this, index-1, index); - } - - public void moveDown(int index) { - Object t = addrs.elementAt(index+1); - addrs.setElementAt(addrs.elementAt(index), index+1); - addrs.setElementAt(t, index); - fireContentsChanged(this, index, index+1); - } - - public Vector getDataVector() { - return (Vector)addrs.clone(); - } - - public String getDataString() { - StringBuffer b = new StringBuffer(); - Enumeration en = addrs.elements(); - while (en.hasMoreElements()) { - if (b.length() != 0) { - b.append(','); - } - b.append(((IPAddress)en.nextElement()).getHostAddress()); - } - return b.toString(); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ImageButton.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ImageButton.java deleted file mode 100644 index 1152a1dc9f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ImageButton.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.ui; - -import javax.swing.JButton; -import javax.swing.ImageIcon; -import java.io.InputStream; -import java.io.BufferedInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -/** - * A button with an image loaded from a gif file. To use this class, extend it - * and in your constructor call setImage(). - */ -public abstract class ImageButton extends JButton { - - /** - * Sets the button's icon to the image loaded from the file; falls back the - * specified text if for some reason the icon can't be loaded. Base class - * is used to find the gif image in the same directory as the class that's - * using it, a convention we use. - * @param baseClass the name of the class we're doing this on behalf of - * @param file the name of the file the gif image is stored in - * @param mnText is the mnemonic/text to be used for the button - */ - public void setImage(Class baseClass, String file, Mnemonic mnText) { - try { - InputStream resource = baseClass.getResourceAsStream(file); - if (resource != null) { - BufferedInputStream in = new BufferedInputStream(resource); - ByteArrayOutputStream out = new ByteArrayOutputStream(1024); - byte [] buffer = new byte[1024]; - int n; - while ((n = in.read(buffer)) > 0) { - out.write(buffer, 0, n); - } - in.close(); - out.flush(); - buffer = out.toByteArray(); - setIcon(new ImageIcon(buffer)); - } - } catch (IOException ioe) { - } - // Added for accessibility - setText(mnText.getString()); - setToolTipText(mnText.getString()); - setMnemonic(mnText.getMnemonic()); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/IntegerField.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/IntegerField.java deleted file mode 100644 index 52d6e76d42..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/IntegerField.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.text.*; - -/** - * A text field which limits input to only digits. - */ -public class IntegerField extends JTextField { - - /** - * Construct an empty field - */ - public IntegerField() { - this(""); - } - - /** - * Construct a field initialized to the specified text. Defaults to a width - * of 5 characters. - * @param text The initial text to display - */ - public IntegerField(String text) { - this(text, 5); - } - - /** - * Construct a field initialized to the specified value. Defaults to a - * width of 5 characters. - * @param value The initial value to display - */ - public IntegerField(int value) { - this(); - setValue(value); - } - - /** - * Construct a field initialized to the specified Integer object. - * Defaults to a width of 5 characters. - * @param value The initial value to display - */ - public IntegerField(Integer value) { - this(); - setValue(value); - } - - /** - * Construct a field initialized to the specified text and width. - * @param text The initial text to display - * @param width The width of the field in characters - */ - public IntegerField(String text, int width) { - super(text, width); - setHorizontalAlignment(RIGHT); - } - - /** - * Set the value of the field - * @param value An <code>int</code> value to set - */ - public void setValue(int value) { - setText(String.valueOf(value)); - } - - /** - * Set the value of the field - * @param value The value to set as an <code>Integer</code> - */ - public void setValue(Integer value) { - if (value != null) { - setValue(value.intValue()); - } - } - - /** - * Retrieve the entered value - * @return The value stored in the field as an <code>int</code> - */ - public int getValue() { - String s = getText(); - if ((s == null) || (s.length() == 0)) { - return 0; - } else { - return Integer.parseInt(getText()); - } - } - - protected Document createDefaultModel() { - return new IntegerDocument(); - } - - /* - * This is the recommended way to validate input, as opposed to trapping - * KeyEvents because this will actually catch paste operations as well. - */ - static class IntegerDocument extends PlainDocument { - public void insertString(int offs, String str, AttributeSet a) - throws BadLocationException { - if (str != null) { - char [] chars = str.toCharArray(); - for (int i = 0; i < chars.length; ++i) { - if (!Character.isDigit(chars[i])) { - throw new BadLocationException("", offs); - } - } - } - super.insertString(offs, str, a); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/LeftButton.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/LeftButton.java deleted file mode 100644 index 4d64618d88..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/LeftButton.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.ui; - -/** - * A button with an icon pointing left - */ -public class LeftButton extends ImageButton { - - public LeftButton() { - Mnemonic mnText = - new Mnemonic(ResourceStrings.getString("left_button")); - setImage(getClass(), "back.gif", mnText); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ListPair.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ListPair.java deleted file mode 100644 index d831a67035..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ListPair.java +++ /dev/null @@ -1,344 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.ui; - -import java.awt.*; -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; -import javax.swing.*; -import javax.swing.event.*; -import java.util.ArrayList; -import java.util.Arrays; - -/* - * This class is a hack to get around the fact that clearSelection() - * in DefaultListSelectionModel does not always fire an event to its listeners. - * We rely on such an event to enable & disable the arrow buttons which - * move data items between lists. See bug 4177723. - */ -class FixedSelectionModel extends DefaultListSelectionModel { - public void clearSelection() { - super.clearSelection(); - fireValueChanged(getMinSelectionIndex(), getMaxSelectionIndex(), false); - } -} - -/* - * We implement our own list model rather than use the default so - * that we can take advantage of some of the more advanced collection - * features not supported by DefaultListModel - */ -class OurListModel implements ListModel { - ArrayList data = new ArrayList(); - EventListenerList listenerList = new EventListenerList(); - - public OurListModel(Object [] data) { - if (data != null) { - this.data.addAll(Arrays.asList(data)); - } - } - - public void addListDataListener(ListDataListener l) { - listenerList.add(ListDataListener.class, l); - } - - public void removeListDataListener(ListDataListener l) { - listenerList.remove(ListDataListener.class, l); - } - - protected void fireContentsChanged() { - ListDataEvent e = - new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, - 0, getSize()); - Object [] listeners = listenerList.getListenerList(); - /* - * Listener array is formatted as pairs of (class, listener); walk - * the array backwards and call each ListDataListener in turn with - * the event. See javax.swing.event.EventListenerList for more info. - */ - for (int i = listeners.length - 2; i >= 0; i -= 2) { - if (listeners[i] == ListDataListener.class) { - ((ListDataListener)listeners[i+1]).contentsChanged(e); - } - } - } - - public Object getElementAt(int index) { - return data.get(index); - } - - public int getSize() { - return data.size(); - } - - public void addElement(Object o) { - data.add(o); - fireContentsChanged(); - } - - public void removeElement(Object o) { - data.remove(data.indexOf(o)); - fireContentsChanged(); - } - - public Object [] toArray(Object [] arr) { - return data.toArray(arr); - } -} - -/* - * Our own layout manager which keeps the left & right lists the same size. - */ -class ListPairLayout implements LayoutManager { - Component leftComponent, centerComponent, rightComponent; - public static final String LEFT = "left"; - public static final String CENTER = "center"; - public static final String RIGHT = "right"; - - public ListPairLayout() { - leftComponent = centerComponent = rightComponent = null; - } - - public void addLayoutComponent(String name, Component comp) { - if (name.equals(LEFT)) { - leftComponent = comp; - } else if (name.equals(CENTER)) { - centerComponent = comp; - } else if (name.equals(RIGHT)) { - rightComponent = comp; - } - } - - public void layoutContainer(Container target) { - // Make left & right components same size, center no smaller than min - Insets insets = target.getInsets(); - Dimension dim = target.getSize(); - int x = insets.left; - int y = insets.top; - int totalHeight = dim.height - insets.bottom; - int totalWidth = dim.width - insets.right; - - // If preferred sizes don't fit, go to minimum. - Dimension cDim = centerComponent.getPreferredSize(); - Dimension d = preferredLayoutSize(target); - if (d.width > totalWidth || d.height > totalHeight) { - cDim = centerComponent.getMinimumSize(); - } - - // Left & right each get half of what's left after center allocated - int lrWidth = (totalWidth - cDim.width) / 2; - - // Now place each component - leftComponent.setBounds(x, y, lrWidth, totalHeight); - centerComponent.setBounds(x + lrWidth, y, cDim.width, totalHeight); - rightComponent.setBounds(x + lrWidth + cDim.width, y, lrWidth, - totalHeight); - } - - public Dimension minimumLayoutSize(Container parent) { - Dimension retDim = new Dimension(); - // Compute minimum width as max(leftwidth, rightwidth) * 2 + centerwidth - int lrwidth = Math.max(leftComponent.getMinimumSize().width, - rightComponent.getMinimumSize().width); - retDim.width = lrwidth * 2 + centerComponent.getMinimumSize().width; - // Compute minimum height as max(leftheight, rightheight, centerheight) - int lrheight = Math.max(leftComponent.getMinimumSize().height, - rightComponent.getMinimumSize().height); - retDim.height = Math.max(centerComponent.getMinimumSize().height, - lrheight); - return retDim; - } - - public Dimension preferredLayoutSize(Container parent) { - Dimension retDim = new Dimension(); - // Preferred width is max(leftwidth, rightwidth) * 2 + centerwidth - int lrwidth = Math.max(leftComponent.getPreferredSize().width, - rightComponent.getPreferredSize().width); - retDim.width = lrwidth * 2 + centerComponent.getPreferredSize().width; - // Preferred height is max(leftheight, rightheight, centerheight) - int lrheight = Math.max(leftComponent.getPreferredSize().height, - rightComponent.getPreferredSize().height); - retDim.height = Math.max(centerComponent.getPreferredSize().height, - lrheight); - return retDim; - } - - public void removeLayoutComponent(Component comp) { - // Do nothing - } -} - -/** - * A ListPair provides a way to display two lists of objects and to move - * objects from one list to another. It is initialized with the contents - * of each list, and can be queried at any time for the contents of each list - */ -public class ListPair extends JPanel { - private JList leftList, rightList; - private OurListModel leftModel, rightModel; - private ListSelectionModel leftSelectionModel, rightSelectionModel; - private LeftButton leftButton = new LeftButton(); - private RightButton rightButton = new RightButton(); - private JScrollPane leftPane, rightPane; - - /** - * Construct a ListPair with the specified data and captions for each list - * @param leftCaption Caption for left list - * @param leftData An array of objects to display in the left list - * @param rightCaption Caption for right list - * @param rightData An array of objects to display in the right list - */ - public ListPair(String leftCaption, Object [] leftData, String rightCaption, - Object [] rightData) { - - // Use our custom layout manager - setLayout(new ListPairLayout()); - - // Store data into the list models - leftModel = new OurListModel(leftData); - rightModel = new OurListModel(rightData); - - // Now create the lists - leftList = new JList(leftModel); - rightList = new JList(rightModel); - leftList.setSelectionModel(new FixedSelectionModel()); - rightList.setSelectionModel(new FixedSelectionModel()); - - // Now do the layout - JPanel leftPanel = new JPanel(new BorderLayout()); - - JLabel leftCapLbl = new JLabel(leftCaption); - leftCapLbl.setLabelFor(leftPanel); - leftCapLbl.setToolTipText(leftCaption); - leftPanel.add(leftCapLbl, BorderLayout.NORTH); - - leftPane = new JScrollPane(leftList); - leftPanel.add(leftPane, BorderLayout.CENTER); - add(leftPanel, ListPairLayout.LEFT); - - JPanel centerPanel = new JPanel(new VerticalButtonLayout()); - rightButton.setEnabled(false); - leftButton.setEnabled(false); - centerPanel.add(rightButton); - centerPanel.add(leftButton); - add(centerPanel, ListPairLayout.CENTER); - - JPanel rightPanel = new JPanel(new BorderLayout()); - - JLabel rightCapLbl = new JLabel(rightCaption); - rightCapLbl.setLabelFor(rightPanel); - rightCapLbl.setToolTipText(rightCaption); - rightPanel.add(rightCapLbl, BorderLayout.NORTH); - - rightPane = new JScrollPane(rightList); - rightPanel.add(rightPane, BorderLayout.CENTER); - add(rightPanel, ListPairLayout.RIGHT); - - // Now create and hook up the listeners for selection state - leftSelectionModel = leftList.getSelectionModel(); - leftSelectionModel.addListSelectionListener( - new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - // Ignore if user is dragging selection state - if (e.getValueIsAdjusting()) { - return; - } - // Right enabled only if something is selected in left list - rightButton.setEnabled(!leftSelectionModel.isSelectionEmpty()); - if (!leftSelectionModel.isSelectionEmpty()) { - rightSelectionModel.clearSelection(); - } - } - }); - - rightSelectionModel = rightList.getSelectionModel(); - rightSelectionModel.addListSelectionListener( - new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - // Ignore if user is dragging selection state - if (e.getValueIsAdjusting()) { - return; - } - // Left enabled only if something is selected in the right list - leftButton.setEnabled(!rightSelectionModel.isSelectionEmpty()); - if (!rightSelectionModel.isSelectionEmpty()) { - leftSelectionModel.clearSelection(); - } - } - }); - - // Now add listeners to buttons to move data between lists - rightButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Object [] values = leftList.getSelectedValues(); - for (int i = 0; i < values.length; ++i) { - rightModel.addElement(values[i]); - leftModel.removeElement(values[i]); - } - /* - * Clear the selection state; this shouldn't be necessary, - * but the selection and data models are unfortunately not - * hooked up to handle this automatically - */ - leftSelectionModel.clearSelection(); - } - }); - - leftButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - Object [] values = rightList.getSelectedValues(); - for (int i = 0; i < values.length; ++i) { - leftModel.addElement(values[i]); - rightModel.removeElement(values[i]); - } - /* - * Clear the selection state; this shouldn't be necessary, - * but the selection and data models are unfortunately not - * hooked up to handle this automatically - */ - rightSelectionModel.clearSelection(); - } - }); - } - - /** - * Retrieve the contents of the left list - * @return the contents as an array of Object - */ - public Object [] getLeftContents(Object [] arr) { - return leftModel.toArray(arr); - } - - /** - * Retrieve the contents of the right list - * @return the contents as an array of Object - */ - public Object [] getRightContents(Object [] arr) { - return rightModel.toArray(arr); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/MainFrame.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/MainFrame.java deleted file mode 100644 index 6dd8be3996..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/MainFrame.java +++ /dev/null @@ -1,429 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.ui; - -import javax.swing.*; -import javax.swing.event.*; -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.net.URL; - -/** - * A main window container for an application which glues together multiple sets - * of functionality (called Views) into a whole with a single menu bar, - * status bar, and search functionality. - * @see View - */ -public class MainFrame extends JFrame { - - class StatusBar extends JPanel { - private JLabel data; - private FindPanel finder; - - public StatusBar() { - super(new BorderLayout()); - setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); - data = new JLabel("", SwingConstants.LEFT); - Font f = data.getFont(); - Font f2 = new Font(f.getName(), Font.PLAIN, f.getSize()); - data.setFont(f2); - data.setForeground(Color.black); - data.setLabelFor(this); - add(data, BorderLayout.WEST); - finder = new FindPanel(); - add(finder, BorderLayout.EAST); - } - - public void setText(String s) { - data.setText(s); - data.setToolTipText(s); - // Force a relayout to avoid truncating text if longer - invalidate(); - validate(); - } - - public String getText() { - return data.getText(); - } - } - - /** - * The panel with the Find control - */ - class FindPanel extends JPanel implements ActionListener { - private JTextField text; - private JButton button; - - public void actionPerformed(ActionEvent e) { - activeView.find(text.getText()); - } - - public FindPanel() { - text = new JTextField("", 20); - - Mnemonic mnNext = - new Mnemonic(ResourceStrings.getString("next_button")); - button = new JButton(mnNext.getString()); - button.setToolTipText(mnNext.getString()); - button.setMnemonic(mnNext.getMnemonic()); - - button.addActionListener(this); - text.addActionListener(this); - - Mnemonic mnFind = - new Mnemonic(ResourceStrings.getString("find_label")); - JLabel findLbl = new JLabel(mnFind.getString()); - findLbl.setLabelFor(text); - findLbl.setToolTipText(mnFind.getString()); - findLbl.setDisplayedMnemonic(mnFind.getMnemonic()); - add(findLbl); - - add(text); - add(button); - } - } - - // Handler for the File->Exit menu item - class ExitAction extends MnemonicAction { - public ExitAction() { - super(ResourceStrings.getString("exit_item")); - } - - public void actionPerformed(ActionEvent e) { - setVisible(false); - dispose(); - } - } - - // Handler for Edit->Create menu item - class CreateAction extends MnemonicAction { - public CreateAction() { - super(ResourceStrings.getString("create_item")); - } - - public void actionPerformed(ActionEvent e) { - activeView.handleCreate(); - } - } - - // Handler for the Edit->Delete menu item - class DeleteAction extends MnemonicAction { - public DeleteAction() { - super(ResourceStrings.getString("delete_item")); - } - - public void actionPerformed(ActionEvent e) { - activeView.handleDelete(); - } - } - - // Handler for the Edit->Duplicate menu item - class DuplicateAction extends MnemonicAction { - public DuplicateAction() { - super(ResourceStrings.getString("duplicate_item")); - } - - public void actionPerformed(ActionEvent e) { - activeView.handleDuplicate(); - } - } - - // Handler for the Edit->Properties menu item - class PropertiesAction extends MnemonicAction { - public PropertiesAction() { - super(ResourceStrings.getString("properties_item")); - } - - public void actionPerformed(ActionEvent e) { - activeView.handleProperties(); - } - } - - // Handler for the View->Update menu item - class UpdateAction extends MnemonicAction { - public UpdateAction() { - super(ResourceStrings.getString("update_item")); - } - - public void actionPerformed(ActionEvent e) { - activeView.handleUpdate(); - } - } - - // Listener for selection events from the views - class ViewSelectionListener implements SelectionListener { - public void valueChanged() { - // Set menu item state on edit menu - for (int i = 1; i < menuActions[EDIT_MENU].length; ++i) { - if (i == 2) { - // Duplicate can only be active for a single selection - menuActions[EDIT_MENU][i].setEnabled( - !activeView.isSelectionEmpty() - && !activeView.isSelectionMultiple()); - } else { - menuActions[EDIT_MENU][i].setEnabled( - !activeView.isSelectionEmpty()); - } - } - } - } - - public static final int FILE_MENU = 0; - public static final int EDIT_MENU = 1; - public static final int VIEW_MENU = 2; - public static final int ACTIONS_MENU = 3; - public static final int HELP_MENU = 4; - public static final int MENU_COUNT = 5; - // The set of menus for the application - private static String menuKeys[] = { "file_menu", "edit_menu", "view_menu", - "actions_menu", "help_menu" }; - /* - * Table of all the menu actions owned by MainFrame; some end up - * delegating to the View. - */ - private Action [] [] menuActions = { - // File Menu - { new ExitAction() }, - - // Edit Menu - { new CreateAction(), new DeleteAction(), new DuplicateAction(), - new PropertiesAction() }, - // View Menu - { new UpdateAction() }, - - // Actions Menu - { }, - - // Help Menu - { } - }; - private JMenuBar menuBar; - private JMenu menuList[]; - private static StatusBar statusBar; - private Component display = null; - private JTabbedPane displayPanel; - private View activeView, initialView; - private Vector views; - private int [] separatorIndex = new int[MENU_COUNT]; - private ButtonGroup viewButtonGroup = new ButtonGroup(); - private ViewSelectionListener viewSelectionListener = - new ViewSelectionListener(); - private boolean initialized = false; - - public MainFrame() { - this(""); - } - - public MainFrame(String title) { - super(title); - views = new Vector(); - Container contentPane = getContentPane(); - // Create basic menu structure - menuBar = new JMenuBar(); - menuList = new JMenu[menuKeys.length]; - // First the menus - for (int i = 0; i < menuList.length; ++i) { - Mnemonic m = new Mnemonic(ResourceStrings.getString(menuKeys[i])); - menuList[i] = (JMenu)menuBar.add(new JMenu(m.getString())); - menuList[i].setMnemonic(m.getMnemonic()); - } - // Now the items on each menu - for (int i = 0; i < menuActions.length; ++i) { - for (int j = 0; j < menuActions[i].length; ++j) { - menuList[i].add(menuActions[i][j]); - } - } - - // separatorIndex will remember where we automatically put separators - for (int i = 0; i < MENU_COUNT; ++i) { - separatorIndex[i] = -1; - } - - setJMenuBar(menuBar); - contentPane.setLayout(new BorderLayout()); - - // Status bar for messages - statusBar = new StatusBar(); - contentPane.add(statusBar, BorderLayout.SOUTH); - - // Display panel is the area for the view's main display - displayPanel = new JTabbedPane(); - displayPanel.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - /* - * Prevent premature activation of a view which would otherwise - * happen as a byproduct of adding views to the tabbed pane. - */ - if (initialized) { - try { - setActiveView((View)views.elementAt( - displayPanel.getSelectedIndex())); - } catch (Throwable t) { - t.printStackTrace(); - } - } - } - }); - contentPane.add(displayPanel, BorderLayout.CENTER); - activeView = null; - } - - public static String getStatusText() { - return statusBar.getText(); - } - - public static void setStatusText(String text) { - statusBar.setText(text); - } - - // Add a global menu - public void addMenuAction(int menu, Action action) { - menuList[menu].add(action); - } - - // Add a view to the system - public void addView(View v, boolean isInitial) { - views.addElement(v); - displayPanel.addTab(v.getName(), v.getDisplay()); - if (isInitial) { - initialView = v; - } - - /* - * Listen to selection events from the view, update menu state - * accordingly - */ - v.addSelectionListener(viewSelectionListener); - } - - // Delete a view - public void deleteView(View v) { - views.removeElement(v); - /* - * If we're deleting the currently active view, need to activate - * another one; default to the initial view, unless that is also - * the one we're deleting, in which case just pick the first view. - */ - if (v == activeView) { - if (v != initialView) { - setActiveView(initialView); - } else { - setActiveView((View)views.firstElement()); - } - } - displayPanel.remove(v.getDisplay()); - v.removeSelectionListener(viewSelectionListener); - } - - // Select the view to be shown - public void setActiveView(View v) { - if (activeView != null) { - activeView.setActive(false); - } - // Remove custom menus from existing active view - for (int i = MENU_COUNT + 1; i < menuBar.getMenuCount(); ++i) { - menuBar.remove(i); - } - /* - * Remove menu items on standard menus from existing active view, - * add those from new view - */ - for (int i = 0; i < menuList.length; ++i) { - JMenu m = menuBar.getMenu(i); - if (activeView != null) { - Enumeration e = activeView.menuItems(i); - if (e != null) { - if (separatorIndex[i] != -1) { - m.remove(separatorIndex[i]); - separatorIndex[i] = -1; - } - while (e.hasMoreElements()) { - JMenuItem mi = (JMenuItem)e.nextElement(); - if (mi != null) { - m.remove((Component)mi); - } - } - } - } - Enumeration e = v.menuItems(i); - if (e != null) { - while (e.hasMoreElements()) { - /* - * This test here so separator is only added if we - * actually get a menu item from the view, protecting - * against an empty enumeration causing a stray separator. - */ - if (separatorIndex[i] == -1) { - separatorIndex[i] = m.getItemCount(); - m.addSeparator(); - } - JMenuItem mi = (JMenuItem)e.nextElement(); - if (mi != null) { - m.add(mi); - } - } - } - } - - // Add view's menus - Enumeration e = v.menus(); - while ((e != null) && e.hasMoreElements()) { - JMenu m = (JMenu)e.nextElement(); - if (m != null) { - menuBar.add(m); - } - } - activeView = v; - activeView.setActive(true); - viewSelectionListener.valueChanged(); - invalidate(); - validate(); - } - - // Call this to get things started - public void initialize() { - if (initialView != null) { - setActiveView(initialView); - initialized = true; - } - } - - // Set enabled/disabled state for menus - public void setMenuEnabled(int menu, boolean state) { - menuList[menu].setEnabled(state); - } - - // Refresh all views, including those not currently active - public void refreshAllViews() { - for (Enumeration en = views.elements(); en.hasMoreElements(); ) { - View v = (View)en.nextElement(); - v.handleUpdate(); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/Makefile deleted file mode 100644 index c66f436745..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/Makefile +++ /dev/null @@ -1,107 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/Makefile -# - -# Place high-level classes first in order to minimize build time. -CLASSFILES = ListPair.class \ - Wizard.class \ - TableSorter.class \ - MainFrame.class \ - View.class \ - MnemonicAction.class \ - IPAddressList.class \ - ExtendedCellRenderer.class \ - PreviousButton.class \ - NextButton.class \ - RightButton.class \ - LeftButton.class \ - UpButton.class \ - DownButton.class \ - ImageButton.class \ - ButtonPanel.class \ - ButtonPanelListener.class \ - VerticalButtonLayout.class \ - ButtonLayout.class \ - ALIGNMENT.class \ - AutosizingTable.class \ - FieldLayout.class \ - HelpIds.class \ - HostnameField.class \ - IntegerField.class \ - IPAddressField.class \ - Mnemonic.class \ - NoSpaceField.class \ - ProgressManager.class \ - ProportionalLayout.class \ - ResourceStrings.class \ - SelectionListener.class \ - SortedHeaderRenderer.class \ - SwingWorker.class \ - TableMap.class \ - WizardStep.class - -include $(SRC)/Makefile.master - -CLASSPATH= $(SRC)/cmd/cmd-inet/usr.sadm/dhcpmgr - -JAVAFILES = $(CLASSFILES:.class=.java) - -MSGDIR= $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/ui -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr \ - $(MSGDIR) - -MSGFILES= ResourceBundle.properties -MSGS= $(MSGFILES:%=$(MSGDIR)/%) - -CLEANFILES= *.class -CLOBBERFILES= - -.KEEP_STATE: - -all: $(CLASSFILES) - -install: all - -_msg: $(MSGDIRS) $(MSGS) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - -lint: - -clean: - $(RM) $(CLEANFILES) - -clobber: clean diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/Mnemonic.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/Mnemonic.java deleted file mode 100644 index 4f56eca41c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/Mnemonic.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.ui; - -import java.util.*; - - -public class Mnemonic { - - public String string = ""; - public int mnemonic = 0; - - public Mnemonic(String locStr) { - string = locStr; - - int i = string.indexOf('&'); - if (i > -1) { - String sUpper = string.toUpperCase(); - mnemonic = sUpper.charAt(i+1); - StringBuffer s = new StringBuffer(string); - s.delete(i, i+1); - string = s.toString(); - } - } - - public String getString() { - - return string; - - } // getString - - public int getMnemonic() { - - return mnemonic; - - } // getMnemonic -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/MnemonicAction.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/MnemonicAction.java deleted file mode 100644 index 9713ecc7c4..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/MnemonicAction.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.ui; - -import javax.swing.AbstractAction; - -/** - * MnemonicAction is an extended version of AbstractAction which - * allows the name and mnemonic for the action to be specified using - * the & syntax in a resource string. - */ -public abstract class MnemonicAction extends AbstractAction { - private Mnemonic m; - - public MnemonicAction(String s) { - m = new Mnemonic(s); - putValue(NAME, m.getString()); - putValue(MNEMONIC_KEY, new Integer(m.getMnemonic())); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/NextButton.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/NextButton.java deleted file mode 100644 index b41f95a18e..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/NextButton.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.ui; - -/** - * Class to produce a button with an icon pointing right (Next) - */ -public class NextButton extends ImageButton { - public NextButton() { - Mnemonic mnText = - new Mnemonic(ResourceStrings.getString("next_button")); - setImage(getClass(), "next.gif", mnText); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/NoSpaceField.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/NoSpaceField.java deleted file mode 100644 index a525bc1bb3..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/NoSpaceField.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.text.*; - -/** - * A text field which disallows whitespace in its input - */ -public class NoSpaceField extends JTextField { - - /** - * Constructs an empty field, 20 characters wide. - */ - public NoSpaceField() { - this(""); - } - - /** - * Constructs a field initialized to the provided text. Defaults to - * 20 characters wide. - * @param text the text to display initially - */ - public NoSpaceField(String text) { - this(text, 20); - } - - /** - * Constructs a field initialized to the provided text with the requested - * size. - * @param text the text to display initially - * @param length the length in characters the field should size itself to - */ - public NoSpaceField(String text, int length) { - super(text, length); - } - - protected Document createDefaultModel() { - return new NoSpaceDocument(); - } - - /* - * This is the recommended way to validate input, as opposed to trapping - * KeyEvents because this will actually catch paste operations as well. - */ - static class NoSpaceDocument extends PlainDocument { - public void insertString(int offs, String str, AttributeSet a) - throws BadLocationException { - if (str != null) { - char [] chars = str.toCharArray(); - for (int i = 0; i < chars.length; ++i) { - if (Character.isWhitespace(chars[i])) { - throw new BadLocationException("", offs); - } - } - } - super.insertString(offs, str, a); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/PreviousButton.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/PreviousButton.java deleted file mode 100644 index bbbaaa389c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/PreviousButton.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.ui; - -/** - * A button with an icon pointing left (Previous) - */ -public class PreviousButton extends ImageButton { - - public PreviousButton() { - Mnemonic mnText = - new Mnemonic(ResourceStrings.getString("previous_button")); - setImage(getClass(), "back.gif", mnText); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ProgressManager.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ProgressManager.java deleted file mode 100644 index bdf064845f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ProgressManager.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import javax.swing.ProgressMonitor; -import javax.swing.SwingUtilities; -import java.awt.Component; - -/** - * Provides a framework for doing long-running operations and keeping the - * user apprised of the results. Also provides an exception if Cancel is - * pressed in the progress dialog. - */ -public class ProgressManager { - private ProgressMonitor monitor; - private int count; - private String message; - private Runnable progressUpdater; - - /** - * Create a new ProgressManager; see ProgressMonitor for description - * of the parameters here. - * @see javax.swing.ProgressMonitor - */ - public ProgressManager(Component comp, Object msg, String note, int min, - int max) { - // Initialize count so we can auto-increment - count = min; - monitor = new ProgressMonitor(comp, msg, note, min, max); - // Create background object to update monitor - progressUpdater = new Runnable() { - public void run() { - monitor.setProgress(count); - monitor.setNote(message); - } - }; - } - - /** - * Update the progress display. Throws InterruptedException if user - * has pressed the Cancel button on the progress dialog - * @param progress the amount of the task that has been completed - * @param msg the message to be displayed at this time - * @throws java.lang.InterruptedException - */ - public void update(int progress, String msg) throws InterruptedException { - count = progress; - message = msg; - SwingUtilities.invokeLater(progressUpdater); - if (monitor.isCanceled()) { - throw new InterruptedException(); - } - } - - /** - * Update the progress display, automatically incrementing the count - * by one. Throws InterruptedException if the user has pressed the - * Cancel button in the progress dialog - * @param msg the message to be display at this time - * @throws java.lang.InterruptedException - */ - public void update(String msg) throws InterruptedException { - update(count+1, msg); - } - -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ProportionalLayout.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ProportionalLayout.java deleted file mode 100644 index d8391e56f5..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ProportionalLayout.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import java.awt.*; -import java.util.Hashtable; - -/** - * This layout manager provides a layout which allocates space either - * horizontally or vertically to components in proportion to a weight assigned - * to each component. All components receive the same dimension along the - * other axis. - */ -public class ProportionalLayout implements LayoutManager { - /** - * Constant for a horizontal proportional layout. - */ - public static final int HORIZONTAL = 0; - /** - * Constant for a vertical proportional layout. - */ - public static final int VERTICAL = 1; - private int direction; - private Hashtable components; - private int totalWeight = 0; - - /** - * Construct a horizontal version of this layout. - */ - public ProportionalLayout() { - this(HORIZONTAL); - } - - /** - * Construct a proportional layout in the direction specified. - * @param direction Must be either HORIZONTAL or VERTICAL - */ - public ProportionalLayout(int direction) { - this.direction = direction; - components = new Hashtable(); - } - - public void addLayoutComponent(String name, Component component) { - Integer weight; - try { - weight = Integer.decode(name); - } catch (NumberFormatException e) { - weight = new Integer(1); - } - totalWeight += weight.intValue(); - components.put(component, weight); - } - - public void removeLayoutComponent(Component component) { - Integer weight = (Integer)components.get(component); - totalWeight -= weight.intValue(); - components.remove(component); - } - - private Dimension computeLayoutSize(Container target, boolean minimum) { - Dimension dim = new Dimension(0, 0); - for (int i = 0; i < target.getComponentCount(); ++i) { - Component c = target.getComponent(i); - if (c.isVisible()) { - Dimension d; - if (minimum) { - d = c.getMinimumSize(); - } else { - d = c.getPreferredSize(); - } - if (direction == HORIZONTAL) { - dim.height = Math.max(dim.height, d.height); - dim.width += d.width; - } else { - dim.height += d.height; - dim.width = Math.max(dim.width, d.width); - } - } - } - Insets insets = target.getInsets(); - dim.width += insets.left + insets.right; - dim.height += insets.top + insets.bottom; - return dim; - } - - public Dimension preferredLayoutSize(Container target) { - return computeLayoutSize(target, false); - } - - public Dimension minimumLayoutSize(Container target) { - return computeLayoutSize(target, true); - } - - public void layoutContainer(Container target) { - Insets insets = target.getInsets(); - Dimension dim = target.getSize(); - int x = insets.left; - int y = insets.top; - int totalHeight = dim.height - insets.bottom; - int totalWidth = dim.width - insets.right; - - for (int i = 0; i < target.getComponentCount(); ++i) { - Component c = target.getComponent(i); - if (c.isVisible()) { - if (direction == HORIZONTAL) { - float fw = (float)totalWidth - * (float)((Integer)components.get(c)).intValue() - / (float)totalWeight; - c.setBounds(x, y, (int)fw, totalHeight); - x += (int)fw; - } else { - float fh = (float)totalHeight - * (float)((Integer)components.get(c)).intValue() - / (float)totalWeight; - c.setBounds(x, y, totalWidth, (int)fh); - y += (int)fh; - } - } - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ResourceBundle.properties b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ResourceBundle.properties deleted file mode 100644 index 2893c37952..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ResourceBundle.properties +++ /dev/null @@ -1,71 +0,0 @@ -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Resource bundle for ui package - -file_menu=&File -edit_menu=&Edit -view_menu=&View -actions_menu=&Service -help_menu=&Help - -exit_item=E&xit -create_item=&Create -delete_item=&Delete -duplicate_item=D&uplicate -properties_item=&Properties -update_item=&Refresh - -ok_button=&OK -cancel_button=&Cancel -reset_button=&Reset -help_button=&Help -finish_button=&Finish - -find_label=F&ind: -steps_label=&Steps: - -never=Never - -add=&Add -delete=De&lete -move_up=Move Up -move_down=Move Down - -# Added for accessibility compliance -dhcp_server_address=DHCP Server Address - -# Arrow buttons used in wizards, chooser dialogs -# and up, down buttons. NB: Next is used also in -# the dhcpmgr main dialog. -left_button=Remo&ve -right_button=&Add -up_button=&Up -down_button=Do&wn -next_button=&Next -previous_button=&Back - - diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ResourceStrings.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ResourceStrings.java deleted file mode 100644 index 1934ea2397..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/ResourceStrings.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import java.util.*; - -/** - * This class provides a convenient method to retrieve resources for - * the ui package. - */ -public class ResourceStrings { - - /** - * The handle to the resource bundle for the module. - */ - private static ResourceBundle bundle = null; - - /** - * Return a string from the resource bundle. - * @param key the key to the resource bundle string. - * @return the resource bundle string. - */ - public static String getString(String key) { - String msg = null; - try { - if (bundle == null) { - bundle = ResourceBundle.getBundle( - "com.sun.dhcpmgr.ui.ResourceBundle", - Locale.getDefault()); - } - msg = bundle.getString(key); - } catch (Throwable e) { - msg = new String(key); - } - return msg; - - } // getString - -} // ResourceStrings diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/RightButton.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/RightButton.java deleted file mode 100644 index a9cda099ec..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/RightButton.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.ui; - -/** - * Class to produce a button with an icon pointing right - */ -public class RightButton extends ImageButton { - public RightButton() { - Mnemonic mnText = - new Mnemonic(ResourceStrings.getString("right_button")); - setImage(getClass(), "next.gif", mnText); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/SelectionListener.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/SelectionListener.java deleted file mode 100644 index f6c0e722fc..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/SelectionListener.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import java.util.EventListener; - -public interface SelectionListener extends EventListener { - public void valueChanged(); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/SortedHeaderRenderer.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/SortedHeaderRenderer.java deleted file mode 100644 index 39ef5e627d..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/SortedHeaderRenderer.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import javax.swing.JTable; -import javax.swing.table.TableCellRenderer; -import java.awt.Font; -import java.awt.Component; - -/** - * This class provides the functionality to indicate to the user which column - * a table is currently being sorted on. At present it merely uses a bold - * font to display the column name, and does not indicate the collation order. - */ -public class SortedHeaderRenderer implements TableCellRenderer { - TableCellRenderer renderer; - - public SortedHeaderRenderer(JTable table) { - renderer = table.getTableHeader().getDefaultRenderer(); - } - - public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int column) { - Component c = renderer.getTableCellRendererComponent(table, value, - isSelected, hasFocus, row, column); - Font f = c.getFont(); - c.setFont(new Font(f.getName(), Font.BOLD, f.getSize())); - return c; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/SwingWorker.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/SwingWorker.java deleted file mode 100644 index b8166787ec..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/SwingWorker.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import javax.swing.SwingUtilities; - -/** - * An abstract class that you subclass to perform - * GUI-related work in a dedicated thread. - * For instructions on using this class, see - * http://java.sun.com/products/jfc/swingdoc-current/threads2.html - */ -public abstract class SwingWorker { - private Object value; - private Thread thread; - - /** - * Compute the value to be returned by the <code>get</code> method. - */ - public abstract Object construct(); - - /** - * Called on the event dispatching thread (not on the worker thread) - * after the <code>construct</code> method has returned. - */ - public void finished() { - } - - /** - * A new method that interrupts the worker thread. Call this method - * to force the worker to abort what it's doing. - */ - public void interrupt() { - Thread t = thread; - if (t != null) { - t.interrupt(); - } - thread = null; - } - - /** - * Return the value created by the <code>construct</code> method. - */ - public Object get() { - while (true) { // keep trying if we're interrupted - Thread t; - synchronized (SwingWorker.this) { - t = thread; - if (t == null) { - return value; - } - } - try { - t.join(); - } - catch (InterruptedException e) { - } - } - } - - /** - * Start a thread that will call the <code>construct</code> method - * and then exit. - */ - public SwingWorker() { - final Runnable doFinished = new Runnable() { - public void run() { finished(); } - }; - - Runnable doConstruct = new Runnable() { - public void run() { - synchronized (SwingWorker.this) { - value = construct(); - thread = null; - } - SwingUtilities.invokeLater(doFinished); - } - }; - - thread = new Thread(doConstruct); - thread.start(); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/TableMap.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/TableMap.java deleted file mode 100644 index 8a6846ee91..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/TableMap.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2000 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * ident "%Z%%M% %I% %E% SMI" - */ -package com.sun.dhcpmgr.ui; - -/* - * @(#)TableMap.java 1.4 97/12/17 - */ - -/** - * In a chain of data manipulators some behaviour is common. TableMap - * provides most of this behavour and can be subclassed by filters - * that only need to override a handful of specific methods. TableMap - * implements TableModel by routing all requests to its model, and - * TableModelListener by routing all events to its listeners. Inserting - * a TableMap which has not been subclassed into a chain of table filters - * should have no effect. - * - * @version 1.4 12/17/97 - * @author Philip Milne */ - -import javax.swing.table.*; -import javax.swing.event.TableModelListener; -import javax.swing.event.TableModelEvent; - -public class TableMap extends AbstractTableModel implements TableModelListener -{ - protected TableModel model; - - public TableModel getModel() { - return model; - } - - public void setModel(TableModel model) { - this.model = model; - model.addTableModelListener(this); - } - - // By default, Implement TableModel by forwarding all messages - // to the model. - - public Object getValueAt(int aRow, int aColumn) { - return model.getValueAt(aRow, aColumn); - } - - public void setValueAt(Object aValue, int aRow, int aColumn) { - model.setValueAt(aValue, aRow, aColumn); - } - - public int getRowCount() { - return (model == null) ? 0 : model.getRowCount(); - } - - public int getColumnCount() { - return (model == null) ? 0 : model.getColumnCount(); - } - - public String getColumnName(int aColumn) { - return model.getColumnName(aColumn); - } - - public Class getColumnClass(int aColumn) { - return model.getColumnClass(aColumn); - } - - public boolean isCellEditable(int row, int column) { - return model.isCellEditable(row, column); - } -// -// Implementation of the TableModelListener interface, -// - - // By default forward all events to all the listeners. - public void tableChanged(TableModelEvent e) { - fireTableChanged(e); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/TableSorter.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/TableSorter.java deleted file mode 100644 index 3e9645655e..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/TableSorter.java +++ /dev/null @@ -1,409 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2000 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * ident "%Z%%M% %I% %E% SMI" - */ -package com.sun.dhcpmgr.ui; - -/* - * @(#)TableSorter.java 1.5 97/12/17 - */ - -/** - * A sorter for TableModels. The sorter has a model (conforming to TableModel) - * and itself implements TableModel. TableSorter does not store or copy - * the data in the TableModel, instead it maintains an array of - * integers which it keeps the same size as the number of rows in its - * model. When the model changes it notifies the sorter that something - * has changed eg. "rowsAdded" so that its internal array of integers - * can be reallocated. As requests are made of the sorter (like - * getValueAt(row, col) it redirects them to its model via the mapping - * array. That way the TableSorter appears to hold another copy of the table - * with the rows in a different order. The sorting algorthm used is stable - * which means that it does not move around rows when its comparison - * function returns 0 to denote that they are equivalent. - * - * @version 1.5 12/17/97 - * @author Philip Milne - */ - -import java.util.*; - -import javax.swing.table.TableModel; -import javax.swing.event.TableModelEvent; - -import com.sun.dhcpmgr.data.IPAddress; - -// Imports for picking up mouse events from the JTable. - -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.InputEvent; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.JTable; -import javax.swing.table.JTableHeader; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; - -public class TableSorter extends TableMap -{ - int indexes[] = new int[0]; - Vector sortingColumns = new Vector(); - boolean ascending = true; - int compares; - Vector listeners = new Vector(); - - public TableSorter() { - indexes = new int[0]; // For consistency. - } - - public TableSorter(TableModel model) { - setModel(model); - } - - public void setModel(TableModel model) { - super.setModel(model); - reallocateIndexes(); - } - - public int compareRowsByColumn(int row1, int row2, int column) { - Class type = model.getColumnClass(column); - TableModel data = model; - - // Check for nulls - - Object o1 = data.getValueAt(row1, column); - Object o2 = data.getValueAt(row2, column); - - // If both values are null return 0 - if (o1 == null && o2 == null) { - return 0; - } else if (o1 == null) { // Define null less than everything. - return -1; - } else if (o2 == null) { - return 1; - } - - /* - * We copy all returned values from the getValue call in case - * an optimised model is reusing one object to return many values. - * The Number subclasses in the JDK are immutable and so will not be - * used in this way but other subclasses of Number might want to do - * this to save space and avoid unnecessary heap allocation. - */ - if (type.getSuperclass() == java.lang.Number.class) { - Number n1 = (Number)data.getValueAt(row1, column); - double d1 = n1.doubleValue(); - Number n2 = (Number)data.getValueAt(row2, column); - double d2 = n2.doubleValue(); - - if (d1 < d2) - return -1; - else if (d1 > d2) - return 1; - else - return 0; - } else if (type == java.util.Date.class) { - Date d1 = (Date)data.getValueAt(row1, column); - long n1 = d1.getTime(); - Date d2 = (Date)data.getValueAt(row2, column); - long n2 = d2.getTime(); - - // Handle negatives specially - if (n1 < 0) { - return 1; - } else if (n2 < 0) { - return -1; - } - if (n1 < n2) - return -1; - else if (n1 > n2) - return 1; - else - return 0; - } else if (type == String.class) { - String s1 = (String)data.getValueAt(row1, column); - String s2 = (String)data.getValueAt(row2, column); - int result = s1.compareTo(s2); - - if (result < 0) - return -1; - else if (result > 0) - return 1; - else return 0; - } else if (type == Boolean.class) { - Boolean bool1 = (Boolean)data.getValueAt(row1, column); - boolean b1 = bool1.booleanValue(); - Boolean bool2 = (Boolean)data.getValueAt(row2, column); - boolean b2 = bool2.booleanValue(); - - if (b1 == b2) - return 0; - else if (b1) // Define false < true - return 1; - else - return -1; - } else if (type == IPAddress.class) { - IPAddress addr1 = (IPAddress)data.getValueAt(row1, column); - IPAddress addr2 = (IPAddress)data.getValueAt(row2, column); - byte [] a1 = addr1.getAddress(); - byte [] a2 = addr2.getAddress(); - int c1, c2; - for (int i = 0; i < a1.length; ++i) { - /* - * Promote and mask because bytes are signed and 128-255 - * will be done wrong - */ - c1 = a1[i] & 0xff; - c2 = a2[i] & 0xff; - if (c1 < c2) { - return -1; - } else if (c1 > c2) { - return 1; - } - } - return 0; - } else { - Object v1 = data.getValueAt(row1, column); - String s1 = v1.toString(); - Object v2 = data.getValueAt(row2, column); - String s2 = v2.toString(); - int result = s1.compareTo(s2); - - if (result < 0) - return -1; - else if (result > 0) - return 1; - else return 0; - } - } - - public int compare(int row1, int row2) { - compares++; - for (int level = 0; level < sortingColumns.size(); level++) { - Integer column = (Integer)sortingColumns.elementAt(level); - int result = compareRowsByColumn(row1, row2, column.intValue()); - if (result != 0) - return ascending ? result : -result; - } - return 0; - } - - public void reallocateIndexes() { - int rowCount = model.getRowCount(); - - // Set up a new array of indexes with the right number of elements - // for the new data model. - indexes = new int[rowCount]; - - // Initialise with the identity mapping. - for (int row = 0; row < rowCount; row++) - indexes[row] = row; - } - - public void tableChanged(TableModelEvent e) { - // System.out.println("Sorter: tableChanged"); - reallocateIndexes(); - sort(this); - super.tableChanged(e); - } - - public void checkModel() { - if (indexes.length != model.getRowCount()) { - System.err.println("Sorter not informed of a change in model."); - } - } - - public void sort(Object sender) { - checkModel(); - - compares = 0; - // n2sort(); - // qsort(0, indexes.length-1); - shuttlesort((int[])indexes.clone(), indexes, 0, indexes.length); - // System.out.println("Compares: "+compares); - } - - public void n2sort() { - for (int i = 0; i < getRowCount(); i++) { - for (int j = i+1; j < getRowCount(); j++) { - if (compare(indexes[i], indexes[j]) == -1) { - swap(i, j); - } - } - } - } - - /* - * This is a home-grown implementation which we have not had time - * to research - it may perform poorly in some circumstances. It - * requires twice the space of an in-place algorithm and makes - * NlogN assigments shuttling the values between the two - * arrays. The number of compares appears to vary between N-1 and - * NlogN depending on the initial order but the main reason for - * using it here is that, unlike qsort, it is stable. - */ - public void shuttlesort(int from[], int to[], int low, int high) { - if (high - low < 2) { - return; - } - int middle = (low + high)/2; - shuttlesort(to, from, low, middle); - shuttlesort(to, from, middle, high); - - int p = low; - int q = middle; - - /* - * This is an optional short-cut; at each recursive call, - * check to see if the elements in this subset are already - * ordered. If so, no further comparisons are needed; the - * sub-array can just be copied. The array must be copied rather - * than assigned otherwise sister calls in the recursion might - * get out of sinc. When the number of elements is three they - * are partitioned so that the first set, [low, mid), has one - * element and and the second, [mid, high), has two. We skip the - * optimisation when the number of elements is three or less as - * the first compare in the normal merge will produce the same - * sequence of steps. This optimisation seems to be worthwhile - * for partially ordered lists but some analysis is needed to - * find out how the performance drops to Nlog(N) as the initial - * order diminishes - it may drop very quickly. - */ - - if (high - low >= 4 && compare(from[middle-1], from[middle]) <= 0) { - for (int i = low; i < high; i++) { - to[i] = from[i]; - } - return; - } - - // A normal merge. - - for (int i = low; i < high; i++) { - if (q >= high || (p < middle && compare(from[p], from[q]) <= 0)) { - to[i] = from[p++]; - } else { - to[i] = from[q++]; - } - } - } - - public void swap(int i, int j) { - int tmp = indexes[i]; - indexes[i] = indexes[j]; - indexes[j] = tmp; - } - - /* - * The mapping only affects the contents of the data rows. - * Pass all requests to these rows through the mapping array: "indexes". - */ - - public Object getValueAt(int aRow, int aColumn) - { - checkModel(); - return model.getValueAt(indexes[aRow], aColumn); - } - - public int mapRowAt(int aRow) { - checkModel(); - if (aRow < indexes.length) { - return indexes[aRow]; - } else { - return -1; - } - } - - public void setValueAt(Object aValue, int aRow, int aColumn) { - checkModel(); - model.setValueAt(aValue, indexes[aRow], aColumn); - } - - public void sortByColumn(int column) { - // Re-sort on this column, but don't change sort order - sortByColumn(column, this.ascending); - } - - public void sortByColumn(int column, boolean ascending) { - this.ascending = ascending; - sortingColumns.removeAllElements(); - sortingColumns.addElement(new Integer(column)); - sort(this); - super.tableChanged(new TableModelEvent(this)); - fireActionPerformed(); - } - - /* - * There is no-where else to put this. - * Add a mouse listener to the Table to trigger a table sort - * when a column heading is clicked in the JTable. - */ - public void addMouseListenerToHeaderInTable(JTable table) { - final TableSorter sorter = this; - final JTable tableView = table; - tableView.setColumnSelectionAllowed(false); - MouseAdapter listMouseListener = new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - TableColumnModel columnModel = tableView.getColumnModel(); - int viewColumn = columnModel.getColumnIndexAtX(e.getX()); - int column = tableView.convertColumnIndexToModel(viewColumn); - if (e.getClickCount() == 1 && column != -1) { - // System.out.println("Sorting ..."); - int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK; - boolean ascending = (shiftPressed == 0); - sorter.sortByColumn(column, ascending); - } - } - }; - JTableHeader th = tableView.getTableHeader(); - th.addMouseListener(listMouseListener); - } - - // Allow others to be notified when re-sorting is done - public void addActionListener(ActionListener l) { - listeners.addElement(l); - } - - // Take me off the notify list - public void removeActionListener(ActionListener l) { - listeners.removeElement(l); - } - - /* - * Notify listeners of sort events; we just use ActionEvent as it's a - * good all-purpose event - */ - protected void fireActionPerformed() { - ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, - sortingColumns.firstElement().toString()); - Enumeration en = listeners.elements(); - while (en.hasMoreElements()) { - ActionListener l = (ActionListener)en.nextElement(); - l.actionPerformed(e); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/UpButton.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/UpButton.java deleted file mode 100644 index ebf342974a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/UpButton.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.ui; - -/** - * Class to produce a button with an icon pointing up. - */ -public class UpButton extends ImageButton { - public UpButton() { - Mnemonic mnText = - new Mnemonic(ResourceStrings.getString("up_button")); - setImage(getClass(), "up.gif", mnText); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/VerticalButtonLayout.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/VerticalButtonLayout.java deleted file mode 100644 index bb5ea247e3..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/VerticalButtonLayout.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1996-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import java.awt.*; - -/** - * <CODE>VerticalButtonLayout</CODE> is used to layout buttons in a - * <CODE>Panel</CODE>. It will arrange buttons top to bottom - * until no more buttons fit in the same column. Each column is - * centered vertically. All buttons are set to an equal size.<P> - * - * While <CODE>VerticalButtonLayout</CODE> was designed for - * <CODE>Buttons</CODE>, any component can be added to the layout. All - * components are set to an equal size.<P> - */ -public class VerticalButtonLayout implements LayoutManager { - - ALIGNMENT align; - int hgap; - int vgap; - - /** - * Constructs a new <CODE>VerticalButtonLayout</CODE> with a centered - * alignment. - */ - public VerticalButtonLayout() { - this(ALIGNMENT.CENTER, 5, 5); - } - - /** - * Constructs a new <CODE>VerticalButtonLayout</CODE> with the specified - * alignment. - * @param <VAR>align</VAR> The alignment value. - * @see ALIGNMENT - */ - public VerticalButtonLayout(ALIGNMENT align) { - this(align, 5, 5); - } - - /** - * Constructs a new <CODE>VerticalButtonLayout</CODE> with the specified - * alignment and gap values. - * @param <VAR>align</VAR> The alignment value. - * @param <VAR>hgap</VAR> The horizontal gap variable. - * @param <VAR>vgap</VAR> The vertical gap variable. - * @see ALIGNMENT - */ - public VerticalButtonLayout(ALIGNMENT align, int hgap, int vgap) { - this.align = align; - this.hgap = hgap; - this.vgap = vgap; - } - - /** - * Adds the specified component to the layout. This is not - * used by this class. - * @param <VAR>name</VAR> The name of the component. - * @param <VAR>comp</VAR> The component to be added. - */ - public void addLayoutComponent(String name, Component comp) { - } - - /** - * Removes the specified component from the layout. This - * is not used by this class. - * @param <VAR>comp</VAR> The component to remove. - */ - public void removeLayoutComponent(Component comp) { - } - - /** - * Returns the preferred dimensions for this layout given - * the components in the specified target container. - * @param <VAR>target</VAR> The component that needs to be laid out. - * @see java.awt.Container - * @see #minimumLayoutSize - */ - public Dimension preferredLayoutSize(Container target) { - Dimension dim = new Dimension(0, 0); - int nmembers = target.getComponentCount(); - - for (int i = 0; i < nmembers; i++) { - Component m = target.getComponent(i); - if (m.isVisible()) { - Dimension d = m.getPreferredSize(); - dim.height = Math.max(dim.height, d.height); - dim.width = Math.max(dim.width, d.width); - } - } - dim.height = (dim.height*nmembers) + (vgap*nmembers-1); - Insets insets = target.getInsets(); - dim.width += insets.left + insets.right + hgap*2; - dim.height += insets.top + insets.bottom + vgap*2; - return dim; - } - - /** - * Returns the minimum dimensions needed to layout the components - * contained in the specified target container. - * @param <VAR>target</VAR> The component that needs to be laid out - * @see #preferredLayoutSize - */ - public Dimension minimumLayoutSize(Container target) { - Dimension dim = new Dimension(0, 0); - int nmembers = target.getComponentCount(); - - for (int i = 0; i < nmembers; i++) { - Component m = target.getComponent(i); - if (m.isVisible()) { - Dimension d = m.getMinimumSize(); - dim.height = Math.max(dim.height, d.height); - dim.width = Math.max(dim.width, d.width); - } - } - dim.height = (dim.height*nmembers) + (vgap*nmembers-1); - Insets insets = target.getInsets(); - dim.width += insets.left + insets.right + hgap*2; - dim.height += insets.top + insets.bottom + vgap*2; - return dim; - } - - /** - * Centers the elements in the specified column, if there is any slack. - * @param <VAR>target</VAR> The component which needs to be moved. - * @param <VAR>x</VAR> The x coordinate. - * @param <VAR>y</VAR> The y coordinate. - * @param <VAR>width</VAR> The width dimensions. - * @param <VAR>height</VAR> The height dimensions. - */ - private void moveComponents(Container target, int x, int y, int width, - int height) { - Dimension dim; - - if (align == ALIGNMENT.LEFT) { - // do nothing - } else if (align == ALIGNMENT.CENTER) { - y += height / 2; - } else if (align == ALIGNMENT.RIGHT) { - y += height; - } - for (int i = 0; i < target.getComponentCount(); i++) { - Component m = target.getComponent(i); - if (m.isVisible()) { - dim = m.getSize(); - m.setLocation(x + (width - dim.width) / 2, y); - y += vgap + dim.height; - } - } - } - - /** - * Lays out the container. This method will actually reshape the - * components in the target in order to satisfy the constraints of - * the <CODE>BorderLayout</CODE> object. - * @param <VAR>target</VAR> The specified component being laid out. - * @see java.awt.Container - */ - public void layoutContainer(Container target) { - Insets insets = target.getInsets(); - Dimension tdim = target.getSize(); - int maxheight = tdim.height - (insets.top + insets.bottom + vgap*2); - int maxwidth = tdim.width - insets.left - insets.right; - int nmembers = target.getComponentCount(); - Dimension dim = new Dimension(0, 0); - int y = 0; - - for (int i = 0; i < nmembers; i++) { - Component m = target.getComponent(i); - if (m.isVisible()) { - Dimension d = m.getMinimumSize(); - dim.height = Math.max(dim.height, d.height); - dim.width = Math.max(dim.width, d.width); - } - } - for (int i = 0; i < nmembers; i++) { - Component m = target.getComponent(i); - if (m.isVisible()) { - m.setSize(dim.width, dim.height); - y += dim.height; - } - } - moveComponents(target, insets.left, 0, maxwidth, maxheight - y); - } - - /** - * Returns the <CODE>String</CODE> representation of this - * <CODE>VerticalButtonLayout</CODE>'s values. - */ - public String toString() { - String str = ""; - if (align == ALIGNMENT.LEFT) { - str = ",align=left"; - } else if (align == ALIGNMENT.RIGHT) { - str = ",align=right"; - } else if (align == ALIGNMENT.CENTER) { - str = ",align=center"; - } - return getClass().getName() - + "[hgap=" + hgap + ",vgap=" + vgap + str + "]"; - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/View.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/View.java deleted file mode 100644 index 33292b81d5..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/View.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import java.util.Enumeration; -import java.awt.Component; - -/** - * View is the interface implemented by objects which wish to appear as tabs in - * the main window. Each View is given a tab in the tabbed display managed by - * MainFrame. - * @see MainFrame - */ -public interface View { - /** - * Supply the view's display name, which will be the tab's title. - * @return a short name to describe the view - */ - public String getName(); - /** - * the menus the view wishes to add to the interface. - * @return an enumeration of JMenus - */ - public Enumeration menus(); - /** - * the menu items to be added to a specific menu - * @return an enumeration of JMenuItems - */ - public Enumeration menuItems(int menu); - /** - * the display to be shown for this view. It will occupy the entire tab. - * @return a component to display - */ - public Component getDisplay(); - /** - * view is to search for the next occurrence of the supplied string and - * update its display accordingly. - * @param s the string to search for - */ - public void find(String s); - /** - * notification to view that it has been activated or deactivated. - * Views may wish to update their display state at this time. - * @param state true if view is now active, false if now inactive - */ - public void setActive(boolean state); - /** - * user has selected Edit->Create menu item. View should provide an - * interface to create an instance of its primary object type. - */ - public void handleCreate(); - /** - * user has selected Edit->Delete menu item. View should attempt to delete - * any selected objects, probably with a confirmation notice. - */ - public void handleDelete(); - /** - * user has selected Edit->Duplicate menu item. View should provide an - * interface which creates a new object with attributes similar to the - * currently selected object. - */ - public void handleDuplicate(); - /** - * user has selected Edit->Properties menu item. View should provide an - * interface to modify the properties of the selected item. - */ - public void handleProperties(); - /** - * user has selected View->Refresh menu item. View should make its display - * current. - */ - public void handleUpdate(); - /** - * add a listener for selection events. - * @param listener a SelectionListener - */ - public void addSelectionListener(SelectionListener listener); - /** - * remove a listener for selection events. - * @param listener a SelectionListener - */ - public void removeSelectionListener(SelectionListener listener); - /** - * listeners query to ascertain whether selection state is empty. - * @return true if no objects are selected - */ - public boolean isSelectionEmpty(); - /** - * listeners query to ascertain whether selection state is multiple. - * @return true if multiple objects selected - */ - public boolean isSelectionMultiple(); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/Wizard.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/Wizard.java deleted file mode 100644 index cbabd4ea6c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/Wizard.java +++ /dev/null @@ -1,678 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright 1998-2002 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -package com.sun.dhcpmgr.ui; - -import javax.swing.*; -import javax.swing.border.*; - -import java.awt.event.*; -import java.awt.*; -import java.util.*; -import java.text.NumberFormat; - -// Interface for notification of button events -interface WizButtonListener { - public void buttonPressed(int buttonId); - public static final int BACK = 0; - public static final int FORWARD = 1; - public static final int CANCEL = 2; - public static final int HELP = 3; - public static final int FINISH = 4; -} - -/** - * This is a widget for presenting a multi-step task, such as an installation - * sequence or other task with many questions or multiple possible paths. This - * component displays as a dialog, with a contents outline on the left and a - * panel for display of each step on the right, with a set of control buttons - * at the bottom. Typical usage is to subclass this class and implement a set - * of WizardStep classes which provide the steps to be executed. - * - * @see WizardStep - */ -public class Wizard extends JDialog { - - // Panel to manage display and processing of buttons at base of window - class WizButtonPanel extends JPanel { - - // Adaptor class to catch all button presses and pass along to listeners - class ButtonAdaptor implements ActionListener { - public void actionPerformed(ActionEvent e) { - int buttonId = -1; - Object source = e.getSource(); - if (source == backButton || source == backButton2) { - buttonId = WizButtonListener.BACK; - } else if (source == forwardButton) { - buttonId = WizButtonListener.FORWARD; - } else if (source == cancelButton || source == cancelButton2) { - buttonId = WizButtonListener.CANCEL; - } else if (source == helpButton || source == helpButton2) { - buttonId = WizButtonListener.HELP; - } else if (source == finishButton) { - buttonId = WizButtonListener.FINISH; - } - Enumeration en = listeners.elements(); - while (en.hasMoreElements()) { - WizButtonListener l = (WizButtonListener)en.nextElement(); - l.buttonPressed(buttonId); - } - } - } - - PreviousButton backButton, backButton2; - NextButton forwardButton; - JButton cancelButton, helpButton, finishButton; - JButton cancelButton2, helpButton2; - Vector listeners; - ButtonAdaptor adaptor; - JPanel innerPanel; - - public WizButtonPanel() { - super(); - - setBorder(new EtchedBorder()); - // Right justify the buttons - setLayout(new FlowLayout(FlowLayout.RIGHT)); - innerPanel = new JPanel(new CardLayout()); - - // Create event handler - adaptor = new ButtonAdaptor(); - listeners = new Vector(); - - /* - * Construct back buttons; need 2 for the separate cards used - * in the button panel - */ - backButton = new PreviousButton(); - backButton2 = new PreviousButton(); - backButton.addActionListener(adaptor); - backButton2.addActionListener(adaptor); - backButton.setAlignmentY(Component.CENTER_ALIGNMENT); - backButton2.setAlignmentY(Component.CENTER_ALIGNMENT); - - // Construct forward button - forwardButton = new NextButton(); - forwardButton.addActionListener(adaptor); - forwardButton.setAlignmentY(Component.CENTER_ALIGNMENT); - - Mnemonic mnFinish = - new Mnemonic(ResourceStrings.getString("finish_button")); - finishButton = new JButton(mnFinish.getString()); - finishButton.setToolTipText(mnFinish.getString()); - finishButton.setMnemonic(mnFinish.getMnemonic()); - finishButton.addActionListener(adaptor); - finishButton.setAlignmentY(Component.CENTER_ALIGNMENT); - - Mnemonic mnCancel = - new Mnemonic(ResourceStrings.getString("cancel_button")); - cancelButton = new JButton(mnCancel.getString()); - cancelButton.setToolTipText(mnCancel.getString()); - cancelButton.setMnemonic(mnCancel.getMnemonic()); - - cancelButton.addActionListener(adaptor); - cancelButton.setAlignmentY(Component.CENTER_ALIGNMENT); - - cancelButton2 = new JButton(mnCancel.getString()); - cancelButton2.setToolTipText(mnCancel.getString()); - cancelButton2.setMnemonic(mnCancel.getMnemonic()); - - cancelButton2.addActionListener(adaptor); - cancelButton2.setAlignmentY(Component.CENTER_ALIGNMENT); - - Mnemonic mnHelp = - new Mnemonic(ResourceStrings.getString("help_button")); - helpButton = new JButton(mnHelp.getString()); - helpButton.setToolTipText(mnHelp.getString()); - helpButton.setMnemonic(mnHelp.getMnemonic()); - - helpButton.addActionListener(adaptor); - helpButton.setAlignmentY(Component.CENTER_ALIGNMENT); - - helpButton2 = new JButton(mnHelp.getString()); - helpButton2.setToolTipText(mnHelp.getString()); - helpButton2.setMnemonic(mnHelp.getMnemonic()); - - helpButton2.addActionListener(adaptor); - helpButton2.setAlignmentY(Component.CENTER_ALIGNMENT); - - /* - * Now create cards; we created two copies of buttons that - * needed to be on both cards - */ - Box box = Box.createHorizontalBox(); - box.add(Box.createHorizontalGlue()); - box.add(backButton); - box.add(Box.createHorizontalStrut(5)); - box.add(forwardButton); - box.add(Box.createHorizontalStrut(5)); - box.add(cancelButton); - box.add(Box.createHorizontalStrut(5)); - box.add(helpButton); - innerPanel.add(box, "normal"); - - // Finish panel replaces the forward button with the finish button - box = Box.createHorizontalBox(); - box.add(Box.createHorizontalGlue()); - box.add(backButton2); - box.add(Box.createHorizontalStrut(5)); - box.add(finishButton); - box.add(Box.createHorizontalStrut(5)); - box.add(cancelButton2); - box.add(Box.createHorizontalStrut(5)); - box.add(helpButton2); - innerPanel.add(box, "finish"); - - add(innerPanel); - } - - // Show the first step - public void showFirst() { - backButton.setEnabled(false); // Can't go backwards - setForwardEnabled(false); - getRootPane().setDefaultButton(forwardButton); - forwardButton.requestFocus(true); - ((CardLayout)innerPanel.getLayout()).show(innerPanel, "normal"); - } - - // Show the last step - public void showLast() { - backButton.setEnabled(true); - setFinishEnabled(false); - getRootPane().setDefaultButton(finishButton); - finishButton.requestFocus(true); - ((CardLayout)innerPanel.getLayout()).show(innerPanel, "finish"); - } - - // Show any other step - public void showMiddle() { - backButton.setEnabled(true); - setForwardEnabled(false); - getRootPane().setDefaultButton(forwardButton); - cancelButton.requestFocus(true); - ((CardLayout)innerPanel.getLayout()).show(innerPanel, "normal"); - } - - // Allow steps to control when user may advance to next step - public void setForwardEnabled(boolean state) { - forwardButton.setEnabled(state); - } - - // Allow the final step to control when a user may complete the task - public void setFinishEnabled(boolean state) { - finishButton.setEnabled(state); - } - - public void addWizButtonListener(WizButtonListener l) { - listeners.addElement(l); - } - - public void removeWizButtonListener(WizButtonListener l) { - listeners.removeElement(l); - } - } - - /* - * Panel to display the list of steps; we use a very custom JList - * for this as it does reasonable rendering with minimal effort on our part. - */ - class WizContentsPanel extends JPanel { - - // Data model for holding the description text displayed - class ContentsModel extends AbstractListModel { - Vector data; - - public ContentsModel() { - data = new Vector(); - } - - public Object getElementAt(int index) { - return data.elementAt(index); - } - - public int getSize() { - return data.size(); - } - - public void addItem(String description) { - data.addElement(description); - fireIntervalAdded(this, data.size()-1, data.size()-1); - } - } - - // Class to render the cells in the list - class ContentsRenderer implements ListCellRenderer { - NumberFormat nf; - - public ContentsRenderer() { - nf = NumberFormat.getInstance(); - } - - public Component getListCellRendererComponent(JList list, - Object value, int index, boolean isSelected, - boolean cellHasFocus) { - - // Format label properly for i18n - JTextArea text = new JTextArea((String)value, 2, 15); - text.setWrapStyleWord(true); - text.setLineWrap(true); - text.setOpaque(false); - text.setAlignmentY(Component.TOP_ALIGNMENT); - JLabel l = new JLabel(nf.format(index + 1)); - l.setForeground(Color.black); - l.setAlignmentY(Component.TOP_ALIGNMENT); - - JPanel stepBox = new JPanel(); - stepBox.setLayout(new BoxLayout(stepBox, BoxLayout.X_AXIS)); - stepBox.add(l); - stepBox.add(Box.createHorizontalStrut(5)); - stepBox.add(text); - stepBox.setBackground(list.getSelectionBackground()); - // Selected component is opaque, others transparent - stepBox.setOpaque(isSelected); - return stepBox; - } - } - - /* - * This class is defined strictly so that we can prevent - * focus from ever reaching the steps list as it is a display-only - * use of JList, not intended for any sort of input by the user. - */ - class MyList extends JList { - public MyList(ListModel m) { - super(m); - // Don't allow this list to be focused - setFocusable(false); - } - // Ignore mouse clicks so highlighted step can't be changed - protected void processMouseEvent(MouseEvent e) { - return; - } - // Ignore mouse drags, which can also change highlighting - protected void processMouseMotionEvent(MouseEvent e) { - return; - } - } - - MyList contentsList; - ContentsModel model; - - public WizContentsPanel() { - setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 10)); - setBackground(Color.white); - setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - - Mnemonic mnSteps = - new Mnemonic(ResourceStrings.getString("steps_label")); - JLabel l = new JLabel(mnSteps.getString()); - l.setLabelFor(this); - l.setToolTipText(mnSteps.getString()); - l.setDisplayedMnemonic(mnSteps.getMnemonic()); - - l.setForeground(Color.black); - l.setAlignmentX(Component.LEFT_ALIGNMENT); - add(l); - - model = new ContentsModel(); - contentsList = new MyList(model); - contentsList.setCellRenderer(new ContentsRenderer()); - /* - * Wrap the list with scroll bars, vertical as necessary but - * never a horizontal one. - */ - JScrollPane scrollPane = new JScrollPane(contentsList, - ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, - ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.setBorder(BorderFactory.createEmptyBorder(15, 10, 0, 0)); - scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT); - scrollPane.setBackground(Color.white); - add(scrollPane); - add(Box.createVerticalGlue()); - } - - public void addStep(WizardStep step) { - // Index the steps using the description string - model.addItem(step.getDescription()); - } - - public void showStep(WizardStep step) { - contentsList.setSelectedValue(step.getDescription(), true); - } - } - - /* - * This class provides a simple card layout to display each step as needed. - */ - class WizStepPanel extends JPanel { - CardLayout layout; - - public WizStepPanel() { - setLayout(layout = new CardLayout()); - // Make sure we have some space around the edges. - setBorder(BorderFactory.createEmptyBorder(15, 10, 10, 10)); - } - - public void addStep(WizardStep step) { - add(step.getComponent(), step.getDescription()); - } - - public void showStep(WizardStep step) { - layout.show(this, step.getDescription()); - } - } - - WizButtonPanel buttonPanel; - WizContentsPanel contentsPanel; - WizStepPanel stepPanel; - Vector steps; - WizardStep activeStep = null; - int stepNumber = 0; - Vector listeners; - - /** - * Constructs a wizard with the specified owning frame and title. - * - * @param owner the owning frame - * @param title the wizard's title string - */ - public Wizard(Frame owner, String title) { - super(owner, title); - - setLocationRelativeTo(owner); - - getContentPane().setLayout(new BorderLayout()); - steps = new Vector(); - listeners = new Vector(); - - // Put the buttons at the bottom. - buttonPanel = new WizButtonPanel(); - getContentPane().add(buttonPanel, BorderLayout.SOUTH); - - /* - * The main display is designed to use a 7:11 ratio for the horizontal - * area consumed by the contents panel and the display panel, - * respectively. There's nothing particularly magical about the - * ratio, that's just the way the designer drew it. - */ - JPanel mainPanel = new JPanel(new ProportionalLayout()); - - contentsPanel = new WizContentsPanel(); - mainPanel.add(contentsPanel, "7"); - - stepPanel = new WizStepPanel(); - mainPanel.add(stepPanel, "11"); - - // Consume all space not needed for buttons - getContentPane().add(mainPanel, BorderLayout.CENTER); - - /* - * We manage the button interactions, but the steps get limited veto - * power - */ - buttonPanel.addWizButtonListener(new WizButtonListener() { - public void buttonPressed(int buttonId) { - switch (buttonId) { - case BACK: - showPreviousStep(); - break; - case FORWARD: - showNextStep(); - break; - case FINISH: - doFinish(); - break; - case CANCEL: - doCancel(); - break; - case HELP: - doHelp(); - break; - default: - } - } - }); - } - - /** - * Override of setVisible to control size when displayed. Perhaps this - * should be relaxed, but subclasses can always do whatever they want. - * @param state make visible or not? - */ - public void setVisible(boolean state) { - if (state) { - setSize(525, 425); - } - super.setVisible(state); - } - - /** - * Adds a step to the wizard. Steps <bold>must</bold> be added in the - * sequence they will be displayed when traversing forward. - * @param step a <code>WizardStep</code> - */ - public void addStep(WizardStep step) { - steps.addElement(step); - contentsPanel.addStep(step); - stepPanel.addStep(step); - } - - private boolean showStep(WizardStep step, int direction) { - // Deactivate currently active step - if (activeStep != null) { - if (!activeStep.setInactive(direction)) { - // Step vetoed its deactivation. We honor its wishes. - return false; - } - } - /* - * Activate new step by updating contents, display area, and possibly - * buttons - */ - activeStep = step; - contentsPanel.showStep(step); - stepPanel.showStep(step); - if (step == steps.firstElement()) { - buttonPanel.showFirst(); - } else if (step == steps.lastElement()) { - buttonPanel.showLast(); - } else { - buttonPanel.showMiddle(); - } - activeStep.setActive(direction); - return true; - } - - // Show some arbitrary step indexed by number. - private boolean showStep(int index, int direction) - throws ArrayIndexOutOfBoundsException { - WizardStep ws = (WizardStep)steps.elementAt(index); - return showStep(ws, direction); - } - - /** - * Show the very first step. - */ - public void showFirstStep() { - stepNumber = 0; - showStep(stepNumber, WizardStep.FORWARD); - } - - /** - * Show the next step. - */ - public void showNextStep() { - ++stepNumber; - try { - // Handle step vetoing deactivation - if (!showStep(stepNumber, WizardStep.FORWARD)) { - --stepNumber; - } - } catch (ArrayIndexOutOfBoundsException e) { - --stepNumber; - } - } - - /** - * Show the previous step. - */ - public void showPreviousStep() { - --stepNumber; - try { - if (!showStep(stepNumber, WizardStep.BACKWARD)) { - ++stepNumber; - } - } catch (ArrayIndexOutOfBoundsException e) { - ++stepNumber; - } - } - - /** - * Show the last step. - */ - public void showLastStep() { - int saveStep = stepNumber; - stepNumber = steps.size()-1; - try { - if (!showStep(stepNumber, WizardStep.FORWARD)) { - stepNumber = saveStep; - } - } catch (ArrayIndexOutOfBoundsException e) { - stepNumber = saveStep; - } - } - - /** - * Control state of the forward button. - * @param state <code>true</code> to enable the button - */ - public void setForwardEnabled(boolean state) { - buttonPanel.setForwardEnabled(state); - } - - /** - * Control state of the finish button. - * @param state <code>true</code> to enable the button - */ - public void setFinishEnabled(boolean state) { - buttonPanel.setFinishEnabled(state); - } - - /** - * Handle user's press of the Cancel button. Subclasses can override for - * special cleanup needs. - */ - public void doCancel() { - fireActionPerformed("cancelled"); - dispose(); - } - - /** - * Handle user's press of the Finish button. Subclasses should override - * to perform whatever processing needed to complete the wizard's task. - */ - public void doFinish() { - fireActionPerformed("finished"); - dispose(); - } - - /** - * Handle user's press of the Help button. Does nothing by default, - * subclasses can override to provide help as desired. - */ - public void doHelp() { - } - - /** - * Utility function to create a multi-line text display such as for the - * explanatory text that most wizard steps use. - * @param text the text to display - * @param rows the number of rows to use for displaying the text - * @param columns the number of columns to wrap text at. 45 is generally a - * good number for standard wizards with standard fonts - * @return a <code>JComponent</code> displaying the supplied text - */ - public static JComponent createTextArea( - String text, int rows, int columns) { - - // We extend JTextArea in order to make this behave more like a label - class MyTextArea extends JTextArea { - public MyTextArea(String text, int rows, int columns) { - /* - * Create a text area with word-wrapping, no editing, - * and no background. - */ - super(text, rows, columns); - setLineWrap(true); - setWrapStyleWord(true); - setEditable(false); - setOpaque(false); - setFocusable(false); - } - } - - MyTextArea area = new MyTextArea(text, rows, columns); - - // Put it in a scrollpane to get sizing to happen - JScrollPane scrollPane = new JScrollPane(area, - ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, - ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - - // Put empty borders on the subcomponents so that all we get is text - Border b = BorderFactory.createEmptyBorder(); - area.setBorder(b); - scrollPane.setBorder(b); - return scrollPane; - } - - /** - * Add a listener for action events. Wizard fires an - * <code>ActionEvent</code> when user either cancels or finishes the wizard. - */ - public void addActionListener(ActionListener l) { - listeners.addElement(l); - } - - /** - * Remove an action listener. - */ - public void removeActionListener(ActionListener l) { - listeners.removeElement(l); - } - - /** - * Fire an action event. - */ - protected void fireActionPerformed(String command) { - ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, - command); - for (Enumeration en = listeners.elements(); en.hasMoreElements(); ) { - ActionListener l = (ActionListener)en.nextElement(); - l.actionPerformed(e); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/WizardStep.java b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/WizardStep.java deleted file mode 100644 index 45a3af697f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/com/sun/dhcpmgr/ui/WizardStep.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * ident "%Z%%M% %I% %E% SMI" - * - * Copyright (c) 1998-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ -package com.sun.dhcpmgr.ui; - -import java.awt.Component; - -/** - * The interface implemented by a step in a wizard. - * - * @see Wizard - */ -public interface WizardStep { - /** - * Constant for traversing forward. - */ - public static final int FORWARD = 1; - /** - * Constant for traversing backward. - */ - public static final int BACKWARD = -1; - /** - * Returns the descriptive text which will be displayed for this step in the - * contents pane (i.e. the left side of the wizard). The description must - * be unique for each step used in a wizard. - * @return a <code>String</code> describing the step - */ - public String getDescription(); - /** - * Returns the component to be displayed when the step is active. Usually - * this will be some form of a panel. This is displayed in the right half - * of the wizard's display area. - * @return a <code>Component</code> to display - */ - public Component getComponent(); - /** - * Called when the step transitions from the inactive to active state. - * Use the direction to determine which direction user is traversing to - * possibly differentiate the initialization actions needed. - * @param direction either <code>FORWARD</code> or <code>BACKWARD</code> to - * indicate direction of traversal. - */ - public void setActive(int direction); - /** - * Called when the step transitions from the active to inactive state. - * Use the direction to determine which direction user is traversing to - * differentiate the input processing needed. Return false if there is a - * problem the user needs to correct before being allowed to proceed to the - * next step. - * @param direction either <code>FORWARD</code> or <code>BACKWARD</code> to - * indicate direction of traversal. - * @return <code>true</code> if traversal should proceed, - * <code>false</code> if not. - */ - public boolean setInactive(int direction); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/Makefile deleted file mode 100644 index 1b0dff5898..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/Makefile +++ /dev/null @@ -1,136 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%W% %E% SMI" -# -# Copyright (c) 1999-2001 by Sun Microsystems, Inc. -# All rights reserved. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/help/Makefile - - -include $(SRC)/cmd/Makefile.cmd - -SUBDIRS = art - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -_msg := TARGET= _msg - -HELPFILES= dhcp_addr_create.html \ - dhcp_addr_del.html \ - dhcp_addr_dup.html \ - dhcp_addr_how.html \ - dhcp_addr_mod.html \ - dhcp_addr_multi.html \ - dhcp_addr_ref.html \ - dhcp_addr_rel.html \ - dhcp_addr_view.html \ - dhcp_addr_wiz.html \ - dhcp_config_wiz.html \ - dhcp_convert_wiz.html \ - dhcp_export_wiz.html \ - dhcp_import_wiz.html \ - dhcp_macro_create.html \ - dhcp_macro_del.html \ - dhcp_macro_dup.html \ - dhcp_macro_how.html \ - dhcp_macro_mod.html \ - dhcp_macro_ref.html \ - dhcp_macro_view.html \ - dhcp_macros_about.html \ - dhcp_main_hlp.html \ - dhcp_main_how.html \ - dhcp_main_idx.html \ - dhcp_main_menus.html \ - dhcp_main_top.html \ - dhcp_net_del.html \ - dhcp_net_ref.html \ - dhcp_net_wiz.html \ - dhcp_option_create.html \ - dhcp_option_del.html \ - dhcp_option_dup.html \ - dhcp_option_how.html \ - dhcp_option_mod.html \ - dhcp_option_ref.html \ - dhcp_option_tags.html \ - dhcp_option_view.html \ - dhcp_relay_choose.html \ - dhcp_relay_config.html \ - dhcp_relay_dis.html \ - dhcp_relay_enable.html \ - dhcp_relay_how.html \ - dhcp_relay_ref.html \ - dhcp_relay_serv.html \ - dhcp_relay_unconfig.html \ - dhcp_server_serv.html \ - dhcp_server_unconfig.html \ - dhcp_solaris_about.html - -ROOTHELPDIR= $(ROOT)/usr/sadm/admin/dhcpmgr/help - -ROOTDIRS= $(ROOTHELPDIR) - -IHELPFILES= $(HELPFILES:%=$(ROOTHELPDIR)/%) - -MSGDIR= $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/client/help -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/client \ - $(MSGDIR) - -MSGFILES= $(HELPFILES) -MSGS= $(MSGFILES:%=$(MSGDIR)/%) - -FILEMODE= 0444 - -$(ROOTHELPDIR)/%: % - $(INS.file) - -.KEEP_STATE: - -all: $(HELPFILES) $(SUBDIRS) - -install: all $(ROOTDIRS) $(IHELPFILES) $(SUBDIRS) - -clean clobber lint: - -_msg: $(MSGDIRS) $(MSGS) $(SUBDIRS) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - -$(ROOTDIRS): - $(INS.dir) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/art/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/art/Makefile deleted file mode 100644 index 9131e7dd4f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/art/Makefile +++ /dev/null @@ -1,81 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%W% %E% SMI" -# -# Copyright (c) 1999 by Sun Microsystems, Inc. -# All rights reserved. -# -# cmd/cmd-inet/usr.sadm/dhcpmgr/help/art/Makefile - -include $(SRC)/cmd/Makefile.cmd - -HELPFILES= bannersmc.gif \ - dot1.gif \ - dot2.gif \ - folder.gif \ - macro2.gif \ - macroflow.gif \ - tip2.gif - -ROOTHELPDIR= $(ROOT)/usr/sadm/admin/dhcpmgr/help/art - -ROOTDIRS= $(ROOTHELPDIR) - -IHELPFILES= $(HELPFILES:%=$(ROOTHELPDIR)/%) - -MSGDIR= $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/client/help/art -MSGDIRS = $(ROOT)/usr/share/lib/locale \ - $(ROOT)/usr/share/lib/locale/com \ - $(ROOT)/usr/share/lib/locale/com/sun \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/client \ - $(ROOT)/usr/share/lib/locale/com/sun/dhcpmgr/client/help \ - $(MSGDIR) - -MSGFILES= $(HELPFILES) -MSGS= $(MSGFILES:%=$(MSGDIR)/%) - -FILEMODE= 0444 - -$(ROOTHELPDIR)/%: % - $(INS.file) - -.KEEP_STATE: - -all: $(HELPFILES) - -install: all $(ROOTDIRS) $(IHELPFILES) - -$(ROOTDIRS): - $(INS.dir) - -clean clobber lint: - -_msg: $(MSGDIRS) $(MSGS) - -$(MSGDIR)/%: % - $(INS.file) - -$(MSGDIRS): - $(INS.dir) - diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_create.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_create.html deleted file mode 100644 index 9a42649124..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_create.html +++ /dev/null @@ -1,235 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Create Address</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relay Agents</STRONG></A><P>
-<A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><BR>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Create<BR>
- <a href="#ip"><EM>Address</EM></a><BR>
- <a href="#name"><EM>Name</EM></a><BR>
- <a href="#server"><EM>Server</EM></a><BR>
- <a href="#macro"><EM>Macro</EM></a><BR>
- <a href="#comment"><EM>Comment</EM></a><BR>
- <a href="#cid"><EM>Client ID</EM></a><BR>
- <a href="#res"><EM>Reserved</EM></a><BR>
- <a href="#lease"><EM>Lease</EM></a><BR>
- <a href="#bootp"><EM>BOOTP</EM></a><BR>
- <a href="#unusable"><EM>Unusable</EM></a><BR>
- <A HREF="dhcp_addr_wiz.html">Address Wizard</A><BR>
- <A HREF="dhcp_addr_dup.html">Duplicate</A><BR>
- <A HREF="dhcp_addr_mod.html">Modify</A><BR>
- <A HREF="dhcp_addr_multi.html">Modify Multiple</A><BR>
-
- <A HREF="dhcp_addr_rel.html">Release</A><BR>
- <A HREF="dhcp_addr_del.html">Delete</A><P>
-
-<A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
-<A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff">
-
-
-
-<P> </P>
-
-
-<h1>Create Address</h1>
-
-The Create Address dialog box lets you create a new DHCP client entry in the selected
-DHCP network. <p>
-Use the <A HREF="dhcp_addr_wiz.html">Address Wizard</A> to add a block of addresses to the DHCP network. The Address Wizard is available from the Edit menu.<P>
-The settings available in the Create Address dialog box are described below.<p>
-<P><HR NOSHADE><P>
-
- <table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><a name="ip"><STRONG>IP Address</STRONG></a></td>
- <td valign="top">Specify the IP address to make available to new
- DHCP clients. The new address must be unique in the current DHCP network table.</td>
- </tr>
-
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><A NAME="name"><STRONG>Client Name</STRONG></A> (optional)</td>
- <td valign="top">Specify the host name of the client. If you use this option, the DHCP Manager will
-attempt to create an entry in the <tt>hosts</tt>
-table.</td>
- </tr>
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="server"><STRONG>Owned By Server</STRONG></a></td>
- <td valign="top">Specify the IP address of the DHCP server
- that owns the new IP address. This server is
- responsible for initially responding to the DHCP client's request for
- IP address allocation.</td>
- </tr>
-
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="macro"><STRONG>Configuration Macro</STRONG></a></td>
- <td valign="top">Specify an optional macro for the server to
- use to obtain client configuration parameters from the <tt>dhcptab</tt>. Click the arrow to see a list of macros available on the
- server. If the macro you want to specify does not already exist on the server, you
- can create it, using the <a href="dhcp_macro_create.html">Create Macro</A>
- dialog box.</td>
- </tr>
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="comment"><STRONG>Comment</STRONG> (optional)</a></td>
- <td valign="top">Enter an optional text comment.</td>
- </tr>
-
-
-</table>
-
-
-<P><HR NOSHADE><P>
-
-
-Click Lease to configure the setting for lease status and expiration.
-The following settings are available.
-
-
- <table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
-
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="cid"><STRONG>Client ID</STRONG></a></td>
-<td valign="top">A unique indentifier of the DHCP or BOOTP client using this address. The client ID is determined by the vendor of the DHCP client. For non-Solaris DHCP clients, consult your DHCP client documentation for more information.<P> For Solaris DHCP clients, the client ID is a string created by the concatenation of the network hardware type and the client's hardware address. For example, a client with a hardware type of <tt>01</tt> (10-Mb Ethernet) and a hardware address of <tt>8:0:20:11:12:b7</tt> would have a client ID of <tt>010800201112B7</tt>.
-<p>
- An entry with a Client ID value of 00 indicates that the address is
- freely available for dynamic allocation to a requesting client.
- <p></td>
- </tr>
-
- <TR>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="res"><STRONG>Reserved</STRONG></a></td>
- <TD>The address is reserved for this client and cannot be reassigned
- by the server.</TD>
- </tr>
- <TR>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="lease"><STRONG>Lease Policy</STRONG></a></td>
- <td valign="top">
- <U>Dynamic:</U> The DHCP server is responsible for the allocation
- and re-allocation of this range of IP addresses. <P>
- Enter the expiration time of the lease. You can specify an
- expiration date for the lease in mm/dd/yyyy format.<P>
- <U>Permanent:</U> The lease does not expire.
- </td>
- </tr>
-
-
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><A NAME="bootp"><STRONG>Assign Only to BOOTP Clients</STRONG></A></td>
- <td valign="top">The selected IP address is reserved for
- BOOTP clients.</td>
- </tr>
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><A NAME="unusable"><STRONG>Address is Unusable</STRONG></A></td>
- <td valign="top">This IP address cannot be used. You can use this setting together
- with Reserved to prevent a client from booting.</td>
- </tr>
-
- </table>
-
-<p> </p>
-
- <A HREF="#top"><small>return to top</small></A>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_del.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_del.html deleted file mode 100644 index 4d20213f11..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_del.html +++ /dev/null @@ -1,134 +0,0 @@ -<!--
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Delete Address</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-<td colspan=1 valign="top" width=105>
- <P> </P>
-
-
-<A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
-
-<A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relay Agents</STRONG></A><P>
-<A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><BR>
- <A HREF="dhcp_addr_create.html">Create</A><BR>
- <A HREF="dhcp_addr_wiz.html">Address Wizard</A><BR>
- <A HREF="dhcp_addr_dup.html">Duplicate</A><BR>
- <A HREF="dhcp_addr_mod.html">Modify</A><BR>
- <A HREF="dhcp_addr_multi.html">Modify Multi</A><BR>
-
- <A HREF="dhcp_addr_rel.html">Release</A><BR>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Delete<P>
-
-<A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
-
-<A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-
-
-<h1>Delete Address</h1>
-
-The Delete Address dialog box lets you delete one or more addresses
-from the selected DHCP network. <P>
-
-Click OK to remove the selected addresses
-from the network table. <P>
-
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_dup.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_dup.html deleted file mode 100644 index ccdcdc4fda..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_dup.html +++ /dev/null @@ -1,234 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- Use is subject to license terms.
-
- CDDL HEADER START
-
- The contents of this file are subject to the terms of the
- Common Development and Distribution License, Version 1.0 only
- (the "License"). You may not use this file except in compliance
- with the License.
-
- You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- or http://www.opensolaris.org/os/licensing.
- See the License for the specific language governing permissions
- and limitations under the License.
-
- When distributing Covered Code, include this CDDL HEADER in each
- file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- If applicable, add the following below this CDDL HEADER, with the
- fields enclosed by brackets "[]" replaced with your own identifying
- information: Portions Copyright [yyyy] [name of copyright owner]
-
- CDDL HEADER END
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Duplicate Address</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
-<A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
-
-<A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relay Agents</STRONG></A><P>
-<A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><BR>
- <A HREF="dhcp_addr_create.html">Create</A><BR>
- <A HREF="dhcp_addr_wiz.html">Address Wizard</A><BR>
-
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Duplicate<BR>
- <a href="#ip"><EM>Address</EM></a><BR>
- <a href="#name"><EM>Name</EM></a><BR>
- <a href="#server"><EM>Server</EM></a><BR>
- <a href="#macro"><EM>Macro</EM></a><BR>
- <a href="#comment"><EM>Comment</EM></a><BR>
- <a href="#cid"><EM>Client ID</EM></a><BR>
- <a href="#res"><EM>Reserved</EM></a><BR>
- <a href="#lease"><EM>Lease</EM></a><BR>
- <a href="#bootp"><EM>BOOTP</EM></a><BR>
- <a href="#unusable"><EM>Unusable</EM></A><BR>
- <A HREF="dhcp_addr_mod.html">Modify</A><BR>
-
- <A HREF="dhcp_addr_multi.html">Modify Multiple</A><BR>
-
-
- <A HREF="dhcp_addr_rel.html">Release</A><BR>
- <A HREF="dhcp_addr_del.html">Delete</A><P>
-
-<A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
-
-<A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-<h1>Duplicate Address</h1>
-
-The Duplicate Address dialog box provides a quick way to add a new
-address to the current DHCP network table. Select an address with
-settings that you want to copy to a new address, and then choose
-Duplicate from the Edit menu. <p>
-
-<p>The settings in the Duplicate Address dialog box are described below.
-<P><HR NOSHADE><P>
-
-<a name="one"></a>
- <table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
- <td width=125 valign="top"><a name="ip"><STRONG>IP Address</STRONG></a></td>
- <td valign="top">The IP address for this record.</td>
- </tr>
-
- <tr>
- <td width=125 valign="top"><a name="name"><STRONG>Client Name</STRONG> (optional)</a></td>
- <td valign="top">The host name of the client.</td>
- </tr>
-
-<tr>
- <td width=125 valign="top"><a name="server"><STRONG>Owned By Server</STRONG></a></td>
- <td valign="top">The IP address of the DHCP server
- that owns this record's IP address.</td>
- </tr>
-
- <tr>
- <td width=125 valign="top"><A NAME="macro"><STRONG>Configuration Macro</STRONG></A></td>
- <td valign="top">An optional macro for the server to
- use to obtain client configuration parameters from the <tt>dhcptab</tt>. Click the arrow to see a list of macros available on the
- server. If the macro you want to specify does not already exist on the server,
- you can create one using the <A HREF="dhcp_macro_create.html">Create Macro</A> dialog box.</td>
- </tr>
- <tr>
- <td width=125 valign="top"><A NAME="comment"><STRONG>Comment</STRONG></A> (optional)</td>
- <td valign="top">An optional text comment.</td>
- </tr>
- </table>
-
-
- <P><HR NOSHADE><P>
-
-Click Lease to modify settings that affect the type of lease and expiration date.<P>
-
-
-
- <table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
-
-<td width=125 valign="top"><a name="cid"><STRONG>Client ID</STRONG></a></td>
- <td valign="top">A unique indentifier of the DHCP or BOOTP client using this address. The client ID is determined by the vendor of the DHCP client. For non-Solaris DHCP clients, consult your DHCP client documentation for more information.<P> For Solaris DHCP clients, the client ID is a string created by the concatenation of the network hardware type and the client's hardware address. For example, a client with a hardware type of <tt>01</tt> (10-Mb Ethernet) and a hardware address of <tt>8:0:20:11:12:b7</tt> would have a client ID of <tt>010800201112B7</tt>.
-<p>
- An entry with a Client ID value of 00 indicates that the address is
- freely available for dynamic allocation to a requesting client.
- <p></td>
- </tr>
-
- <TR>
- <td width=125 valign="top"><a name="res"><STRONG>Reserved</STRONG></a></td>
- <TD>The address is reserved for this client and cannot be reclaimed
- by the server.</TD>
- </TR>
-
- <TR>
- <td width=125 valign="top"><a name="lease"><STRONG>Lease Policy</STRONG></a></td>
- <td valign="top">
- <U>Dynamic:</U> The DHCP server is responsible for the allocation
- and re-allocation of this range of IP addresses. <P>
- Enter the expiration time of the lease. You can specify an
- expiration time for the lease in mm/dd/yyyy HH:MM format.<P>
-
- <U>Permanent:</U> The lease does not expire.
- </td>
- </tr>
-
-
-
- <tr>
- <td width=100 valign="top"><A NAME="bootp"><STRONG>Assign Only to BOOTP Clients</STRONG></A></td>
- <td valign="top">The selected IP address is reserved for
- BOOTP clients.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><A NAME="unusable"><STRONG>Address is Unusable</STRONG></A></td>
- <td valign="top">This IP address cannot be used. You can use this setting together
- with Reserved to prevent a client from booting.</td>
- </tr>
-
- </table>
-
-
- <A HREF="#top"><small>return to top</small></A>
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_how.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_how.html deleted file mode 100644 index d38d1834da..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_how.html +++ /dev/null @@ -1,327 +0,0 @@ -<!-- - -- ident "%W% %E% SMI" - -- - Copyright 2005 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - --> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: How To... IP Addresses</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><BR>
- <A HREF="dhcp_relay_how.html">Servers/Relays</A><BR>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Addresses<BR>
- <A HREF="#viewtable"><EM>View</EM></A><BR>
- <A href="#newtable"><EM>Create</EM></A><BR>
- <A HREF="#copy"><EM>Duplicate</EM></A><BR>
- <A HREF="#modaddr"><EM>Modify</EM></A><BR>
- <A HREF="#modmulti"><EM>Modify Multiple</EM></A><BR>
- <A HREF="#addwiz"><EM>Add Multiple</EM></A><BR>
- <A HREF="#reladdr"><EM>Release</EM></A><BR>
- <A HREF="#deltable"><EM>Delete</EM></A><BR>
- <A HREF="dhcp_macro_how.html">Macros</A><BR>
- <A HREF="dhcp_option_how.html">Options</A><P>
-
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
- <H1>How To: Addresses</H1>
-
-
-
-
-<strong><big><A NAME="viewtable">View IP Addresses</A></big></strong><p>
-
- <ol type=1>
-
- <li><B>Choose the <a href="dhcp_addr_ref.html">Addresses</a>
- tab in the main window.</B></LI><P>
-
- <li><strong>Choose a network from the Network list.</strong><BR>
- DHCP Manager displays a list of client records in the
- current network, listed by IP address.</li><P>
-</OL>
-To change the way the addresses data is displayed, click in the column header. For example, click the Server column heading to view the records alphabetically in ascending order by server name. Hold down the shift key and click the Server column heading to view the records listed by server in descending order. <P>
-
-<HR NOSHADE>
-
-<strong><big><A NAME="newtable">Create a New IP Address</A></big></strong><p>
-
- <ol type=1>
-
-<li><B>Choose the <a href="dhcp_addr_ref.html">Addresses</a>
- tab in the main window.</B></LI><P>
-
- <li><strong>Choose a network from the Network list.</strong><BR>
- DHCP Manager displays a list of client records in the
- current network, listed by IP address.</li><P>
-
- <LI>Click <a href="dhcp_addr_create.html"><strong>Create</strong></a> in the Edit menu.<br>
-
- The Create Address dialog box opens.</LI><P>
-
- <li><strong>Enter the desired <a href="dhcp_addr_ref.html">settings</a> for the new address.</strong><BR>
- You can enter the following settings in the Address screen:
- <UL TYPE="DISC">
- <LI>IP address - the new address</LI>
- <LI>Client name </LI>
- <LI>Owning server</LI>
- <LI>Configuration macro - scroll for available macro</LI>
- </UL>
- Click Lease to enter further settings:
- <UL TYPE="DISC">
- <LI>Client ID</LI>
- <LI>Lease status</LI>
- <LI>Lease expiration</LI>
- </UL>
- </LI><P>
- <LI><strong>Click OK to exit the dialog.</strong><p></li>
-
- </ol><P>
-
- <HR NOSHADE>
-
-<strong><big><A NAME="addwiz">Add Multiple IP Addresses</A></big></strong><p>
-
- <ol type=1>
-
- <li><B>Choose the <a href="dhcp_addr_ref.html">Addresses</a>
- tab in the main window.</B></LI><P>
-
- <li><strong>Choose a network from the Network list.</strong><BR>
- DHCP Manager displays a list of client records in the
- current network, listed by IP address.</li><P>
-
- <LI><strong>Click <A HREF="dhcp_addr_wiz.html">Address Wizard</A> in the Edit menu.</strong><br>
-
- The Address Wizard starts.</LI><P>
-
- <li><strong>Follow the directions to add one of more addresses to the selected network.</strong><BR>
- You can enter values for the following <a href="dhcp_addr_ref.html">settings</a>:
- <UL TYPE="DISC">
- <LI>Owning server</LI>
- <LI>Number of addresses to add</li>
- <LI>Starting IP address</LI>
- <LI>Whether to generate host names for clients</LI>
- <LI>Configuration macro</LI>
- <LI>Lease status</LI>
- <LI>Lease type</LI>
- </UL><P>
- <LI><strong>Click OK to exit the dialog box.</strong></LI>
- </ol><P>
- <A HREF="#top"><small>return to top</small></A>
-
- <HR NOSHADE>
-
-<strong><big><A NAME="copy">Duplicate an IP Address</A></big></strong><p>
-
- <ol type=1>
-
- <li><B>Choose the <a href="dhcp_addr_ref.html">Addresses</a>
- tab in the main window.</B></LI><P>
-
- <li><strong>Choose a network from the Network list.</strong><BR>
- DHCP Manager displays a list of client records in the
- current network, listed by IP address.</li><P>
-
- <LI><strong>From the list of addresses, select a client record that
- you want to copy.</strong></LI><P>
-
- <LI><strong>Click <a href="dhcp_addr_dup.html">Duplicate</a> from the Edit menu.</strong><br>
-
- The Duplicate Address dialog box opens. Some of the fields have settings that duplicate those of the selected client record.</LI><P>
-
- <li><strong>Enter the new IP address in the IP Address field.</strong><br>
-You can change any of the settings listed for this address.</LI><P>
- <li><strong>Click OK to exit the dialog box.</strong><p></li>
-
- </ol><P>
-
-
-<HR NOSHADE>
-
-<strong><big><A NAME="modaddr">Modify an IP Address</A></big></strong><p>
-
- <ol type=1>
-
- <li><B>Choose the <a href="dhcp_addr_ref.html">Addresses</a>
- tab in the main window.</B></LI><P>
-
- <li><strong>Choose a network from the Network list.</strong><BR>
- DHCP Manager displays a list of client records in the
- current network, listed by IP address.</li><P>
-
- <li><strong>Select the client record you want to modify, and then
- choose <a href="dhcp_addr_mod.html">Properties</a> from the Edit menu (or
-double-click in the table).</strong><br>
-
- The Address Properties dialog box is displayed.<p></li>
-
- <li><strong>Enter the desired settings for the addresses, and then
- click OK to exit the dialog.</strong><p></li>
-
- </ol><P>
- <A HREF="#top"><small>return to top</small></A>
-<HR NOSHADE>
-
-<strong><big><A NAME="modmulti">Modify Multiple IP Addresses</A></big></strong><p>
-
- <ol type=1>
-
- <li><strong>Choose the <a
-href="dhcp_addr_ref.html">Addresses</a> tab in the main window.</strong><P></LI>
-
- <li><strong>Choose a network from the Network list.</strong><BR>
- DHCP Manager displays a list of client records in the
- current network, listed by IP address.</li><P>
-
- <li><strong>Select the client records you want to modify, and then
- choose <a href="dhcp_addr_multi.html">Properties</a> from the Edit menu.</strong><BR>
- You can select a range of addresses by holding down the Shift key
- as you highlight your choices. <P>
- To select individual addresses, hold down the Control key and select
- the addresses you want to modify.<P>
-
- The Modify Multiple Addresses
- dialog box is displayed.<p></li>
-
- <li><strong>Edit this screen to change one or more settings.</strong></LI><P>
-
- <LI><strong>Click OK to exit the dialog.</strong><p></li>
-
- </ol>
-
-<HR NOSHADE>
-
-<strong><big><A NAME="reladdr">Release IP Addresses</A></big></strong><p>
-
- <ol type=1>
-
- <li><B>Choose the <a href="dhcp_addr_ref.html">Addresses</a>
- tab in the main window.</B></LI><P>
-
- <li><strong>Choose a network from the Network list.</strong><BR>
- DHCP Manager displays a list of client records in the
- current network, listed by IP address.</li><P>
-
- <LI><strong>Select one or more addresses to release, and then choose <a href="dhcp_addr_rel.html">Release</a> from the Edit menu.</strong><BR>
- The Release Address dialog box opens. </LI><P>
- <li><strong>Click OK to release the selected addresses.</strong><p></li>
-
- </ol>
-
-<HR NOSHADE>
-
-<strong><big><A NAME="deltable">Delete IP Addresses</A></big></strong><p>
-
- <ol type=1>
-
- <li><B>Choose the <a href="dhcp_addr_ref.html">Addresses</a>
- tab in the main window.</B></LI><P>
-
- <li><strong>Choose a network from the Network list.</strong><BR>
- DHCP Manager displays a list of client records in the
- current network, listed by IP address.</li><P>
-
- <LI><strong>Select one or more addresses to delete, and then choose <A HREF="dhcp_addr_del.html">Delete</A> from the Edit menu.</strong></LI><P>
-
- <li><strong>Click OK to delete the selected addresses.</strong><p></li>
-
- </ol>
-
-
-<p>
- <A HREF="#top"><small>return to top</small></A>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_mod.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_mod.html deleted file mode 100644 index 3a18484c7c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_mod.html +++ /dev/null @@ -1,244 +0,0 @@ -<!--
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Modify Address</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
-
-
-<td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relay Agents</STRONG></A><P>
-
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><BR>
- <A HREF="dhcp_addr_create.html">Create</A><BR>
- <A HREF="dhcp_addr_wiz.html">Address Wizard</A><BR>
- <A HREF="dhcp_addr_dup.html">Duplicate</A><BR>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Modify<BR>
- <a href="#ip"><EM>Address</EM></a><BR>
- <a href="#server"><EM>Server</EM></a><BR>
- <a href="#macro"><EM>Macro</EM></a><BR>
- <a href="#comment"><EM>Comment</EM></a><BR>
- <a href="#cid"><EM>Client ID</EM></a><BR>
- <a href="#res"><EM>Reserved</EM></a><BR>
- <a href="#lease"><EM>Lease</EM></a><BR>
- <a href="#bootp"><EM>BOOTP</EM></a><BR>
- <a href="#unusable"><EM>Unusable</EM></A><BR>
-
- <A HREF="dhcp_addr_multi.html">Modify Multiple</A><BR>
-
- <A HREF="dhcp_addr_rel.html">Release</A><BR>
- <A HREF="dhcp_addr_del.html">Delete</A><P>
-
-<A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
-<A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-<h1>Modify Address</h1>
-
-The Address Properties dialog box lets you view and modify the settings for
-an address in the current DHCP network table on the selected DHCP server. <p>
-
-<center>
-
- <table border=1 cellspacing=3 cellpadding=3>
-
- <tr>
- <td valign="top" align="left" BGCOLOR="#EBEBEB">To modify
- several addresses at once, select the addresses in the View Addresses main window,
- and then choose Properties from the Edit menu to display the <a
- href="dhcp_addr_multi.html">Modify Multiple Addresses</a> dialog box.</td>
- </tr>
-
- </table>
-
-</center>
-
-<p>The settings in the Address Properties dialog box are described below.<p>
-
-<P><HR NOSHADE><P>
-
- <table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><a name="ip"><STRONG>IP Address</STRONG></a></td>
- <td valign="top">Specify the IP address to make available to new
- DHCP clients. The new address must be unique in the current DHCP network table.</td>
- </tr>
-
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="server"><STRONG>Owned By Server</STRONG></a></td>
- <td valign="top">Specify the IP address of the DHCP server
- that owns the new IP address. This server is
- responsible for initially responding to the DHCP client's request for
- IP address allocation.</td>
- </tr>
-
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="macro"><STRONG>Configuration Macro</STRONG></a></td>
- <td valign="top">Specify an optional macro for the server to
- use to obtain client configuration parameters from the <tt>dhcptab</tt>. Click the arrow to see a list of macros available on the
- server. If the macro you want to specify does not already exist on the server, you
- can create it, using the <a href="dhcp_macro_create.html">Create Macro</A>
- dialog box.</td>
- </tr>
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="comment"><STRONG>Comment</STRONG> (optional)</a></td>
- <td valign="top">Enter an optional text comment.</td>
- </tr>
-
-
-</table>
-
-
-<P><HR NOSHADE><P>
-
-
-Click Lease to configure the setting for lease status and expiration.
-The following settings are available.
-
-
- <table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
-
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="cid"><STRONG>Client ID</STRONG></a></td><td valign="top">A unique indentifier of the DHCP or BOOTP client using this address. The client ID is determined by the vendor of the DHCP client. For non-Solaris DHCP clients, consult your DHCP client documentation for more information.<P> For Solaris DHCP clients, the client ID is a string created by the concatenation of the network hardware type and the client's hardware address. For example, a client with a hardware type of <tt>01</tt> (10-Mb Ethernet) and a hardware address of <tt>8:0:20:11:12:b7</tt> would have a client ID of <tt>010800201112B7</tt>.
-<p>
- An entry with a Client ID value of 00 indicates that the address is
- freely available for dynamic allocation to a requesting client.
- <p></td>
- </tr>
-
- <TR>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="res"><STRONG>Reserved</STRONG></a></td>
- <TD>The address is reserved for this client and cannot be reclaimed
- by the server.</TD>
- </tr>
- <TR>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="lease"><STRONG>Lease Policy</STRONG></a></td>
- <td valign="top">
- <U>Dynamic:</U> The DHCP server is responsible for the allocation
- and re-allocation of this range of IP addresses. <P>
- Enter the expiration time of the lease. You can specify an
- expiration date for the lease in mm/dd/yyyy format.<P>
-
- <U>Permanent:</U> The lease does not expire.
- </td>
- </tr>
-
-
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><A NAME="bootp"><STRONG>Assign Only to BOOTP Clients</STRONG></A></td>
- <td valign="top">The selected IP address is reserved for
- BOOTP clients.</td>
- </tr>
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><A NAME="unusable"><STRONG>Address is Unusable</STRONG></A></td>
- <td valign="top">This IP address cannot be used. You can use this setting together with Reserved to prevent a client from booting.</td>
- </tr>
-
- </table>
-
-<p> </p>
-
- <A HREF="#top"><small>return to top</small></A>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_multi.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_multi.html deleted file mode 100644 index f1fdf1ae31..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_multi.html +++ /dev/null @@ -1,205 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Modify Multiple Addresses</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relay Agents</STRONG></A><P>
-
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><BR>
- <A HREF="dhcp_addr_create.html">Create</A><BR>
- <A HREF="dhcp_addr_wiz.html">Address Wizard</A><BR>
- <A HREF="dhcp_addr_dup.html">Duplicate</A><BR>
- <A HREF="dhcp_addr_mod.html">Modify</A><BR>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Modify Multi<BR>
- <a href="#server"><EM>Server</EM></a><BR>
- <a href="#comment"><EM>Comment</EM></a><BR>
- <a href="#macro"><EM>Macro</EM></a><BR>
- <a href="#bootp"><EM>BOOTP</EM></a><BR>
- <a href="#unusable"><EM>Unusable</EM></A><BR>
- <a href="#lease"><EM>Lease</EM></a><BR>
- <A HREF="dhcp_addr_rel.html">Release</A><BR>
- <A HREF="dhcp_addr_del.html">Delete</A><P>
-
-<A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
-<A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-<h1>Modify Multiple Addresses</h1>
-
-The Modify Multiple Addresses dialog box lets you modify multiple client
-records in the current DHCP network table. <p>
-
-<center>
-
- <table border=1 cellspacing=3 cellpadding=3 width=400>
-
- <tr>
- <td width=400 valign="top" align="left" BGCOLOR="#EBEBEB">To modify one
- address at a time, select the address in the list of addresses
- for the selected network, and then choose Properties from the Edit menu
- to display the <a href="dhcp_addr_mod.html">Address Properties</a>
- dialog box.</td>
- </tr>
-
- </table>
-
-</center>
-
-<p>The settings in the Modify Multiple Addresses dialog box are described below.<p>
-Note that fields labelled Keep Current Settings are not modified in the selected records.
-
-<P><HR NOSHADE><P>
-
- <table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="server"><STRONG>Managing Server</STRONG></a></td>
- <td valign="top">Specify the host name or IP address of the DHCP server
- that owns the IP address. This server is responsible for initially responding to the DHCP client's request for IP address allocation.<P>
-
-Click the arrow to view a list of servers to which you are connected.
-You can enter a the name or address of a server that is not on this list.</td>
- </tr>
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="comment"><STRONG>Comment</STRONG> (optional)</a></td>
- <td valign="top">Enter an optional text comment.</td>
- </tr>
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="macro"><STRONG>Configuration Macro</STRONG></a></td>
- <td valign="top">The configuration macro is used by the server to
- obtain client configuration parameters from the <tt>dhcptab</tt>. Click the arrow to see a list of macros available on the
- server. If the macro you want to specify does not already exist on the server, you can create it, using the <a href="dhcp_macro_create.html">Create Macro</A> dialog box.</td>
- </tr>
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="bootp"><STRONG>BootP</STRONG></a></td>
- <td valign="top">You can choose whether or not to assign all the addresses to BOOTP clients.</td>
- </tr>
-
- <tr>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="unusable"><STRONG>Unusable</STRONG></a></td>
- <td valign="top">You can choose whether or not to mark these addresses as Unusable.</td>
- </tr>
-
- <TR>
- <TD WIDTH="100" ALIGN="LEFT" VALIGN="TOP"><a name="lease"><STRONG>Lease Type</STRONG></a></td>
- <td valign="top">
- <U>Dynamic:</U> The DHCP server is responsible for the allocation
- and re-allocation of this range of IP addresses. <P>
- Enter the expiration time of the lease. You can specify an
- expiration date for the lease in mm/dd/yyyy format.<P>
- <U>Permanent:</U> The lease does not expire.
-
- </td>
- </tr>
-
-
- </table>
-
-<p> </p>
-
- <A HREF="#top"><small>return to top</small></A>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_ref.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_ref.html deleted file mode 100644 index 1e96011ae8..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_ref.html +++ /dev/null @@ -1,255 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: IP Addresses </title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
- </table>
-
-<!-- End navigation banner -->
-
-
-<!-- Start contents block -->
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-<tr>
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT=""><STRONG>Addresses</STRONG><BR>
- <a href="#ip"><EM>Address</EM></a><BR>
- <a href="#status"><EM>Status</EM></a><BR>
- <a href="#expires"><EM>Expires</EM></a><BR>
- <a href="#server"><EM>Server</EM></a><BR>
- <a href="#macro"><EM>Macro</EM></a><BR>
- <a href="#cid"><EM>Client ID</EM></a><BR>
- <a href="#comment"><EM>Comment</EM></a><BR>
- <A HREF="dhcp_addr_create.html">Create</A><BR>
- <A HREF="dhcp_addr_wiz.html">Address Wizard</A><BR>
- <A HREF="dhcp_addr_dup.html">Duplicate</A><BR>
- <A HREF="dhcp_addr_mod.html">Modify</A><BR>
- <A HREF="dhcp_addr_multi.html">Modify Multiple</A><BR>
- <A HREF="dhcp_addr_rel.html">Release</A><BR>
- <A HREF="dhcp_addr_del.html">Delete</A><P>
-
-
-<A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
-<A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-<h1>Addresses</h1>
-
-When you select the Addresses tab in the main window, DHCP Manager displays the
-client records in the selected network, sorted by host name. These records are stored in the DHCP network tables maintained by the data store.<P>
-<STRONG>List Addresses</STRONG><BR>
-To view the records sorted by IP address, click Show Address in
-the View menu. Servers and clients are listed by IP address instead of by host name.<P>
-<STRONG>Change Sort</STRONG><BR>
-The client records are sorted by client
-IP address or host name. To change the sort, click
-in the column header. For example, click the Server
-column heading to view the records alphabetically in ascending
-order by server name. Hold down the Shift key and click the
-Server column heading to view the records listed by server
-in descending order.
-<P>
-<STRONG>Add Address</STRONG><BR>
-To add new addresses to the selected network, choose <a
-href="dhcp_addr_wiz.html">the Address Wizard</a> from the Edit menu.
-You can add a single address by selecting
-<A Href="dhcp_addr_create.html">Create</A> from the Edit menu.<P>
-<STRONG>Modify Address</STRONG><BR>
-You can select an address and view the settings assigned to that address,
-<a href="dhcp_addr_how.html#modaddr">modify</a> one or more settings, and <a
-href="dhcp_addr_how.html#reladdr">release</A> or <A HREF="dhcp_addr_how.html#deltable">delete</a> addresses in the list.
-<P><HR NOSHADE><P>
-<STRONG>Address Settings</STRONG><BR>
-The address settings are described in the following table.<p>
-
-
-
-<table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><a name="ip"><STRONG>IP Address</STRONG></a></td>
- <td valign="top">An IP address in
-the selected network that can be made available to DHCP clients.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a name="status"><STRONG>Status</STRONG></a></td>
-
- <td valign="top">The lease and address attributes assigned to the client:
-
-<table cellspacing=3 cellpadding=3>
-
-
- <tr>
- <td width=90 valign="top"><U>Dynamic</U></td>
- <td valign="top">DHCP server is responsible for the allocation
- and re-allocation of IP addresses.</td>
- </tr>
-
- <tr>
- <td width=90 valign="top"><U>Permanent</U></td>
- <td valign="top">Disable evaluation of the lease setting (lease
- is permanent).</td>
- </tr>
-
- <tr>
- <td width=90 valign="top"><U>Reserved</U><BR>(Manual)</td>
- <td valign="top">The address is reserved for this client (manually
- assigned). The DHCP server cannot assign this address to another
- client. The address cannot be reclaimed by the DHCP server.</td>
- </tr>
-
- <tr>
- <td width=90 valign="top"><A NAME="bootp"><U>BOOTP</U></A></td>
- <td valign="top">The selected IP addresses are reserved for
- BOOTP clients only.</td>
- </tr>
-
- <tr>
- <td width=90 valign="top"><A NAME="unuse"><U>Unusable</U></A></td>
- <td valign="top">This address is not usable. This setting
- can also be used in combination with the Reserved setting to
- prevent the client from booting.</td>
- </tr>
- </table>
-</td>
-</tr>
-
- <tr>
- <td width=100 valign="top"><a name="expires"><STRONG>Expires</STRONG></a></td>
-
- <td width=325 valign="top">The date
-the lease expires for this IP address.
-
- You can specify an expiration date for the lease in
- mm/dd/yyyy format.
-</td>
-</tr>
-
- <tr>
- <td width=100 valign="top"><a name="server"><STRONG>Server</STRONG></a></td>
- <td valign="top">The IP address of the DHCP server
- that owns this IP address. This server is
- responsible for initially responding to the DHCP client's request for
- an IP address.</td>
- </tr>
-
-<TR>
- <td width=100 valign="top"><a name="macro"></a><STRONG>Macro</STRONG></td>
- <td valign="top">An optional macro for the server to
- use to obtain client configuration parameters from the <tt>dhcptab</tt>.</td>
- </tr>
-
-
- <tr>
- <td width=100 valign="top"><a name="cid"><STRONG>Client ID</STRONG></a></td>
- <td valign="top">A unique indentifier of the DHCP or BOOTP client using this address. The client ID is determined by the vendor of the DHCP client. For non-Solaris DHCP clients, consult your DHCP client documentation for more information.<P> For Solaris DHCP clients, the client ID is a string created by the concatenation of the network hardware type and the client's hardware address. For example, a client with a hardware type of <tt>01</tt> (10-Mb Ethernet) and a hardware address of <tt>8:0:20:11:12:b7</tt> would have a client ID of <tt>010800201112B7</tt>.
-<p>
- An entry with a Client ID value of 00 indicates that the address is
- freely available for dynamic allocation to a requesting client.
- <p></td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a name="comment"></a><STRONG>Comment</STRONG></td>
- <td valign="top">An optional text comment.</td>
- </tr>
- </table>
-
-
-<p>
- <A HREF="#top"><small>return to top</small></A>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_rel.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_rel.html deleted file mode 100644 index ed5157be9e..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_rel.html +++ /dev/null @@ -1,138 +0,0 @@ -<!-- - -- ident "%W% %E% SMI" - -- - Copyright 2005 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - --> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Release Address</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
-
-<A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
-
-<A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relay Agents</STRONG></A><P>
-<A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><BR>
- <A HREF="dhcp_addr_create.html">Create</A><BR>
- <A HREF="dhcp_addr_wiz.html">Address Wizard</A><BR>
- <A HREF="dhcp_addr_dup.html">Duplicate</A><BR>
- <A HREF="dhcp_addr_mod.html">Modify</A><BR>
- <A HREF="dhcp_addr_multi.html">Modify Multiple</A><BR>
-
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Release<BR>
- <A HREF="dhcp_addr_del.html">Delete</A><P>
-
-<A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
-
-<A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-<h1>Release Addresses</h1>
-
-The Release Addresses dialog box lets you reclaim one or more addresses in the
-selected DHCP network. Reclaiming the address clears the Client ID and
-Lease fields.<P>
-
-Click OK to release the selected addresses.<P>
-<TABLE WIDTH="500" BORDER="1" CELLSPACING="2" CELLPADDING="2" VALIGN="TOP" BORDERCOLOR="#CCCCCC" BGCOLOR="#DEDEDE">
-<TR>
-<TD><STRONG>Note:</STRONG> Reclaiming the address will not clear the Reserved field. To make a reserved address available to another client, modify the address properties using the Properties dialog box from the Edit menu. Uncheck the box marked Reserved, then select Dynamic and enter a lease expiration date.
-</TD></TR>
-
-</TABLE>
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_view.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_view.html deleted file mode 100644 index a7e358a24c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_view.html +++ /dev/null @@ -1,332 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Address Menus</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=625>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><BR>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Address View<BR>
- <A HREF="dhcp_macro_view.html">Macro View</A><BR>
- <A HREF="dhcp_option_view.html">Option View</A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff" WIDTH="495">
-
- <P> </P>
-
-<H1>Address View Menus</H1>
-<table ALIGN="LEFT" BORDER="0" CELLPADDING="3" WIDTH="495">
-
-<TR>
-<td colspan=1 width=20 VALIGN="TOP"> </td>
-<TH colspan=1 align=left valign="top" width=150>
- <FONT SIZE="+1">Titles</FONT><P></TH>
- <TH align=left valign="top"><FONT SIZE="+1">Description</FONT><P></TH>
-
-</TR>
-
-
-<tr>
-<td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF"><U>File Menu</U></td>
- <Td></Td>
- </TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150> <STRONG>Exit</STRONG></TD>
- <TD ALIGN="LEFT" VALIGN="TOP">Exit from the application.</TD>
- </TR>
-<TR><TD COLSPAN="2"><P> </P></TD></TR>
-<tr>
-<td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF"><U>Edit Menu</U></td>
- <Td></Td>
- </TR>
-
- <tr>
-<td colspan=1 width=20> </td>
-
-<TD COLSPAN="1" ALIGN="left" VALIGN="TOP" width="150"> <STRONG>Create</STRONG></TD>
-
- <TD ALIGN="LEFT" VALIGN="TOP">
-Add new address to DHCP server.</TD></TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Delete</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Delete the selected address(es).</TD>
-</TR>
-
-<tr>
-<td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top" width=150> <STRONG>Duplicate</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Copy the selected address entry.</TD>
-</TR>
-
-<tr>
-<td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top" width=150> <STRONG>Properties</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Modify the properties of the selected address(es).</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top" width=150> <STRONG>Address Wizard</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Use Address Wizard to add multiple addresses.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Release Addresses</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Release the selected address(es).</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top" width=150> <STRONG>Network Wizard</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Configure and add network to the DHCP server's list of networks to monitor.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top" width=150> <STRONG>Delete Networks</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Remove selected network from DHCP servers list of networks to monitor.</TD>
-</TR>
-
-<TR><TD COLSPAN="2"><P> </P></TD></TR>
-
-
-<tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>View Menu</U><P></td>
-<TD></TD></TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Refresh</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Refresh the data from the server.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Show Addresses</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">List clients by IP address instead of by hostname.</TD>
-</TR>
-
-
-
- <tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Show Grid</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Turn on grid lines in display.</TD>
-</TR>
-<TR><TD COLSPAN="2"><P> </P></TD></TR>
-
-<tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>Service Menu</U><P></td>
- <Td></Td></TR>
-
- <tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Restart</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Stop and restart the DHCP daemon.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Stop</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Stop the DHCP daemon.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Start</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Start the DHCP daemon.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Disable</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Disable the DHCP server or BOOTP relay agent.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Enable</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Enable the DHCP server or BOOTP relay agent.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Modify</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Customize services of DHCP server or BOOTP relay agent.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Export Data</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Copy from the DHCP data store selected IP addresses, macros, and options to a file for the purpose of importing to a DHCP server.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Import Data</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Bring into the DHCP data store IP addresses, macros, and options that were exported from a DHCP server. </TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Convert Data Store</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Configure the DHCP server to use a new data store and convert existing data to new data store format. </TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Unconfigure</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Unconfigure the DHCP server or BOOTP relay agent.<P> </P></TD>
-</TR>
-
-
-<tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>Help Menu</U></td>
- <Td>Display the online help.<P> </P></Td></TR>
-
-
-<tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>Network</U></td>
- <Td>Scroll the list of configured networks. Select which network to display.<P> </P></Td></TR>
-
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>Find</U></td>
- <Td>Search for an address entry.<P> </P></Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>Column Entries</U></td>
- <Td></Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150> <STRONG>IP Address</STRONG>
-</td>
- <Td>Client IP address</Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150> <STRONG>Status</STRONG></td>
- <Td>Lease and address attributes</Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150> <STRONG>Expires</STRONG></td>
- <Td>Expiration date for the lease</Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150> <STRONG>Server</STRONG></td>
- <Td>IP address of owning server</Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150> <STRONG>Macro</STRONG></td>
- <Td>Configuration macro</Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150> <STRONG>CI</STRONG></td>
- <Td>Client ID</Td></TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top" width=150> <STRONG>Comment</STRONG></td>
- <Td>Optional comment</Td></TR>
-
- <TR><TD COLSPAN="3"><P> <A HREF="#top"><small>return to top</small></A></P></TD></TR>
- </TABLE>
-
-
-
-
-
-
-
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_wiz.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_wiz.html deleted file mode 100644 index c2f37d42d7..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_addr_wiz.html +++ /dev/null @@ -1,208 +0,0 @@ -<!--
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Address Wizard</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
-<A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
-
-<A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
-<A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><BR>
-
- <A HREF="dhcp_addr_create.html">Create</A><BR>
-
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Address Wizard<BR>
- <a href="#addrno"><EM>Number</EM></a><BR>
- <a href="#ownserv"><EM>Server</EM></a><BR>
- <a href="#startaddr"><EM>Start Addr</EM></a><BR>
- <a href="#name"><EM>Names</EM></a><BR>
- <a href="#confirm"><EM>Confirm</EM></a><BR>
- <a href="#config"><EM>Config</EM></a><BR>
- <a href="#unusable"><EM>Unusable</EM></a><BR>
- <a href="#lease"><EM>Lease</EM></a><BR>
- <A HREF="dhcp_addr_dup.html">Duplicate</A><BR>
- <A HREF="dhcp_addr_mod.html">Modify</A><BR>
- <A HREF="dhcp_addr_multi.html">Modify Multiple</A><BR>
- <A HREF="dhcp_addr_rel.html">Release</A><BR>
- <A HREF="dhcp_addr_del.html">Delete</A><P>
-
-
-
-
-<A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
-<A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-<h1>Address Wizard</h1>
-
-Use the Address Wizard to add a block of addresses to the server's DHCP network. To start the Address Wizard, select Addresses from the View menu, and then select Address Wizard from the Edit menu.
-<p>
-
-Proceed through the steps by clicking the arrow key at the bottom of
-the screen.
-
-<p>
-To enter information, double-click in the field, enter the desired value, and then press Enter.
-<P>
-If you choose the Address Wizard, you will be asked
-to supply the following information. <P><HR NOSHADE><P>
-
- <table border=0 cellspacing=4 cellpadding=3>
-
-
-
- <tr>
- <td valign="top" width=125><A NAME="addrno"><STRONG>Number of Addresses</STRONG></A></td>
- <td valign="top">Enter the total number of addresses to add
- to the DHCP server's network. </td>
- </tr>
-
- <tr>
- <td valign="top" width=125><A NAME="ownserv"><STRONG>Managed by Server</STRONG></A></td>
- <td valign="top">Enter the IP address of the DHCP server
- that manages these IP addresses. This server is responsible for initially responding
- to the DHCP client's request for an IP address.
- </td>
- </tr>
-
- <tr>
- <td valign="top" width=125><A NAME="startaddr"><STRONG>Starting IP Address</STRONG></A></td>
- <td valign="top">Enter the first IP address in the series.<P></td>
- </tr>
-
- <tr>
- <td valign="top" width=125><A NAME="confirm"><STRONG>Confirm Address List</STRONG></A></td>
- <td valign="top">You can view the information that you have entered.<P>
- If you want to add or modify addresses, use the <A HREF="dhcp_addr_create.html">Create Address</A> or <A HREF="dhcp_addr_mod.html">Modify Address</A> options in the Edit menu.<P>
- <P>
- </td>
- </tr>
-
- <tr>
- <td valign="top" width=125><A NAME="config"><STRONG>Client Configuration Macro</STRONG></A></td>
- <td valign="top">Enter the name of a client configuration macro. You can
- scroll for existing macros. Select a macro from the list and click View to display the contents of the macro.<P>
-If you want to name a macro that does not exist,
- you can create it with the <A HREF="dhcp_macro_create.html">Create Macro</A>
- dialog box.<P>
- </td>
- </tr>
-
- <tr>
- <td valign="top" width=125><A NAME="unusable"><STRONG>Unusable</STRONG></A></td>
- <td valign="top">You can choose to mark these addresses as <A HREF="dhcp_addr_ref.html#unuse">Unusable</A>. <P>
- </td>
- </tr>
-
- <tr>
- <td valign="top" width=125><A NAME="lease"><STRONG>Lease Type</STRONG></A></td>
- <td valign="top">Select Dynamic or Permanent.<p>
- <U>Dynamic:</U> The DHCP server is responsible for the allocation
- and re-allocation of this range of IP addresses. Choose Dynamic if you want to
- make IP addresses available when they are not being used.<P>
- Enter the expiration time of the lease. You can specify an
- expiration date in mm/dd/yyyy format. <P>
- <U>Permanent:</U> The address is permanently assigned to the client.<P>
- </td>
- </tr>
-
- </table>
- <A HREF="#top"><small>return to top</small></A>
-
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_config_wiz.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_config_wiz.html deleted file mode 100644 index 6b3d4290a3..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_config_wiz.html +++ /dev/null @@ -1,259 +0,0 @@ -<!--
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License (the "License"). - You may not use this file except in compliance with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- -- Use is subject to license terms.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Configuring DHCP Server</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#ffffff">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=625>
-
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="left" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
- <STRONG><A HREF="dhcp_relay_ref.html">Servers and Relays</A></STRONG><BR>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">DHCP Config<BR>
- <A HREF="#store"><EM>Data Store</EM></A><BR>
- <A HREF="#hostnmserv"><EM>Hosts Name Service</EM></A><BR>
- <A HREF="#lease"><EM>Lease Policy</EM></A><BR>
- <A HREF="#dns"><EM>DNS Domain/Server</EM></A><BR>
- <A HREF="#net"><EM>Network</EM></A><BR>
- <A HREF="#router"><EM>Router</EM></A><BR>
- <A HREF="#nis"><EM>NIS</EM></A><BR>
- <A HREF="dhcp_relay_config.html">Relay Config</A><BR>
- <A HREF="dhcp_net_wiz.html">Network Config</A><BR>
- <A HREF="dhcp_server_serv.html">DHCP Services</A><BR>
- <A HREF="dhcp_relay_serv.html">Relay Services</A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" width="495">
-<P> </P>
-
-
-<H1>DHCP Configuration Wizard</H1>
-
-The DHCP Configuration Wizard helps you configure a Solaris<small><sup>TM</sup></small>
-system to be a DHCP server and configures the first network. <P>
-<TABLE WIDTH="500" BORDER="1" CELLSPACING="2" CELLPADDING="2" VALIGN="TOP" BORDERCOLOR="#CCCCCC" BGCOLOR="#DEDEDE">
-<TR>
-<TD><STRONG>Note: </STRONG>Please read the "Planning for DHCP Service" chapter in the Solaris <em>DHCP Administration Guide, </em> before configuring a DHCP server.
-</TD></TR>
-</TABLE>
-<P>
-After initial configuration, use the Modify option in the <A HREF="dhcp_server_serv.html">Services</A>
-menu to configure services such as BOOTP compatibility, duplicate address detection,
-and which interfaces to monitor.<P>
-To enter information in the wizard, double-click in the field, enter the desired value, and then press Enter.<P>
-The DHCP Configuration Wizard, asks you to supply the following information.
-<P><HR NOSHADE><P>
-
-<table border=0 cellspacing=4 cellpadding=3 width=490>
- <tr>
- <td width=125 valign="top"><A NAME="store"><STRONG>Data Store </STRONG></A><br>
- </td>
- <td valign="top">Select the type of data store the DHCP server will use to
- store configuration data. The choices are:
-
-<table cellspacing=3 cellpadding=3>
- <tr>
- <td width=90 valign="top"><em>Text files</em></td>
- <td valign="top">Data is stored in clear text ASCII files. Suitable for small number of clients, up to 10,000. Data can be shared through NFS among several DHCP servers.</td>
- </tr>
-<tr>
- <td width=90 valign="top"><em>Binary files</em></td>
- <td valign="top">Data is stored in binary text files. Suitable for large numbers of clients up to 100,000. Data can <em>not</em> be shared among several DHCP servers. </td>
- </tr>
-</table>
-</td>
-</tr>
-<!-- end data store row -->
- <tr>
- <td width=125 valign="top"><A NAME="lease"><STRONG>Lease Policy</STRONG></A><br>
- </td>
- <td valign="top">Enter the length of time before a lease expires.
- The lease is the amount of time a DHCP server grants
- permission to a DHCP client to use a particular address.
- You can enter from 1 hour to 3550 weeks. <P>
- The lease time value should be relatively small, so that expired addresses
-are reclaimed quickly, but large enough so that if your DHCP service becomes
-unavailable, the clients continue to function until the machine(s) running
-the DHCP service can be repaired. A rule of thumb is to specify a time that
-is two times the predicted down time of a server. For example, if it generally
-takes four hours to obtain and replace a defective part and reboot the server,
-you should specify a lease time of eight hours. <P>
- The default is to allow a client to renegotiate the lease before it expires.
- A Solaris DHCP client will try to renew the lease when it is halfway
- through the lease period. <P>
- If not allowed to renegotiate, clients must issue a new DHCP request
- in order to obtain a
- new address when the lease expires. You may choose this option
- in an environment where there are more clients than there are
- addresses, and you need to enforce a time limit on the use of an IP
- address.
- </td>
- </tr>
-
- <tr>
- <td width=125 valign="top"><A NAME="dns"><STRONG>DNS Domain</STRONG></A></td>
- <td valign="top">The domain server resolves host names to host
- addresses. If the server is configured to use DNS, the domain name and address
- of the DNS server will be displayed.
- If the fields are empty, you can enter the domain name and address of a
- DNS domain server. <p>
- You can enter the address of more than one server. The order in the list
- determines the order in which the servers are queried.
- </td>
-
- </tr>
- <TR><TD COLSPAN="2"> <A HREF="#top"><small>return to top</small></A></TD></TR>
-
- </table>
-
-<HR noshade size=2>
-
-
-<strong><A NAME="net"><big>Network Configuration</big></A></STRONG><P>
-This section begins the network configuration.
-You can configure the first network using the DHCP Configuration Wizard. Once
-the DHCP server is configured, you can add additional networks using the Network Wizard, which is available from the Edit menu, when the Address view is displayed.<P>
-
- <table border=0 cellspacing=4 cellpadding=3 width=490>
- <tr>
- <td width=125 valign="top"><A NAME="addr"><STRONG>Network Address</STRONG></A></td>
- <td valign="top">
- Enter the IP address of the network you are configuring.<p>
- </td>
- </tr>
-
- <tr>
- <td width=125 valign="top"><A NAME="info"><STRONG>Subnet Mask</STRONG></A><br></td>
- <td valign="top">
- Enter the subnet mask for this network. A subnet mask is a way of dividing
- up the host portion of an Internet address to form local subnetworks.
- </TD></TR>
-
- <tr>
- <td width=125 valign="top"><A NAME="info"><STRONG>Network Type</STRONG></A><br></td>
- <td valign="top">
- Specify whether the network is a local area network (LAN) or point-to-point (PPP).<p>
-
-
- </TD>
- </tr>
-
- <tr>
- <td width=125 valign="top"><A NAME="router"><STRONG>Routing</STRONG></A></td>
- <td valign="top">A router is a machine with multiple network
- interfaces that can forward IP packets from one network to
- another. In most cases, your clients should use router discovery to
- connect to a router. If you have clients in your network that cannot
- use router discovery, enter the IP address of a router which
- they can use to communicate with systems on another network.
- </td>
- </tr>
-
-
- <tr>
- <td width=125 valign="top"><A NAME="nis"><STRONG>NIS Domain Name</STRONG></A><br>
- <STRONG>NIS Server Address</STRONG></td>
- <td valign="top">If the server is configured to use NIS naming service,
- the NIS server information will be filled in. If not, you can enter the domain
- name and IP address of one or more NIS name servers.<P>
-
- The order in which the address appears in the list determines the order in
- which the servers are queried.
- </td>
- </tr>
-
-</table>
- <A HREF="#top"><small>return to top</small></A>
-
-
-
-<p> </p>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_convert_wiz.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_convert_wiz.html deleted file mode 100644 index 45e4d46e42..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_convert_wiz.html +++ /dev/null @@ -1,172 +0,0 @@ -<!--
- -- ident "%Z%%M% %I% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Data Store Conversion</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#ffffff">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=625>
-
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="left" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
- <STRONG><A HREF="dhcp_relay_ref.html">Servers and Relays</A></STRONG><BR>
- <A HREF="dhcp_config_wiz.html">DHCP
-Config</a><BR>
- <A HREF="dhcp_relay_config.html">BOOTP Relay Config</A><BR>
- <A HREF="dhcp_net_wiz.html">Network Config</A><BR>
- <A HREF="dhcp_server_serv.html">Modify DHCP Service</A><BR>
- <A HREF="dhcp_relay_serv.html">Modify BOOTP Service</A><br>
-
- <A HREF="dhcp_export_wiz.html">Export Config Data</A><br>
- <A HREF="dhcp_import_wiz.html">Import Config Data</A> <BR>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT=""><A HREF="dhcp_convert_wiz.html">Convert Data Store</A><br><P><A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To...</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" width="495">
-<P> </P>
-
-
-<H1>Data Store Conversion</H1>
-
-The Data Store Conversion wizard enables you to convert the Solaris DHCP data store from one format to another. Choose Convert Data Store from the Services menu to start the wizard.
-<P>
-The Data Store Conversion wizard asks you to supply the following information.
-<P><HR NOSHADE><P>
-
-<table border=0 cellspacing=4 cellpadding=3 width=490>
- <tr>
- <td width=125 valign="top"><A NAME="store"><STRONG>Data storage type</STRONG></A><br>
- </td>
- <td valign="top">Select the new data store type you want to use.
- <P>
- Text files are recommended if you are serving a small number of
- DHCP clients, less than 10,000.
-
- <P>Binary files are recommended in sites having a very large number
- of clients and no sharing is required among DHCP servers.
-
- <P>NIS+ is recommended if you are already using NIS+ for name service,
- and if you have an environment with multiple DHCP servers, so that the
- information can be shared by all the DHCP servers in the NIS+ domain.
- <P>
-<STRONG>Note:</STRONG> If the server is not already configured as a NIS+ client, you cannot select the NIS+ option. To use NIS+ for the data store, cancel the wizard, configure the server as a NIS+ client, and run DHCP Manager again.
-
- </td>
- </tr>
- <tr>
- <td width=125 valign="top"><A NAME="path"><STRONG>Configure data store</STRONG></A><br>
- </td>
- <td valign="top">The information requested here varies according to the data store chosen.
- If you selected text files or binary files, enter the path to the
- data (<tt>/var/dhcp</tt> is the default). If you use NIS+, enter the domain
- of the NIS+ server (this server's domain is the default). <p>
-
- </td>
- </tr>
-
- <tr>
- <td width=125 valign="top"><A NAME="save"><STRONG>Save old tables</STRONG></A></td>
- <td valign="top">By default, the DHCP tables that the server had been using before the
-conversion are deleted after it is determined that the conversion was successful. If you
-do not want the tables to be deleted, select Save old tables. Note that if a problem occurs during the conversion,
-the tables will not be deleted even if you did not elect to save the tables.<p>
-
- </td>
-
- </tr>
- <TR><TD COLSPAN="2"> <A HREF="#top"><small>return to top</small></A></TD></TR>
-
- </table>
-
-
-</table>
-
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_export_wiz.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_export_wiz.html deleted file mode 100644 index 81085bc3d0..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_export_wiz.html +++ /dev/null @@ -1,181 +0,0 @@ -<!--
- -- ident "%Z%%M% %I% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Export Data</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#ffffff">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=625>
-
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="left" valign="top"><IMG
-SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALIGN="LEFT" ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
- <STRONG><A HREF="dhcp_relay_ref.html">Servers and
-Relays</A></STRONG><BR>
- <A HREF="dhcp_config_wiz.html">DHCP
-Config</A><BR>
- <A HREF="dhcp_relay_config.html">BOOTP Relay Config</A><BR>
- <A HREF="dhcp_net_wiz.html">Network Config</A><BR>
- <A HREF="dhcp_server_serv.html">Modify DHCP Service</A><BR>
- <A HREF="dhcp_relay_serv.html">Modify BOOTP Service</A><BR>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT=""><A HREF="dhcp_export_wiz.html">Export Data</A><br>
- <A HREF="dhcp_import_wiz.html">Import Data</A><br>
- <A HREF="dhcp_convert_wiz.html">Convert Data Store</A><P> <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" width="495">
-<P> </P>
-
-
-<H1>Export Data</H1>
-
-The Export Data wizard helps you
-transfer DHCP networks, IP addresses, macros, and
-options from one Solaris DHCP server to another. The
-wizard exports configuration data from this Solaris DHCP
-server so that it can then be imported onto
-another Solaris DHCP server. This effectively moves
-support of a set of DHCP clients from one server to
-another.
-<P>
-After you fill in the requested information in each
-dialog, click the right-arrow button at the bottom of the window to advance to the
-next dialog.
-<P>
-The Export Data wizard asks you for the
-following information.
-<P><HR NOSHADE><P>
-
-<table border=0 cellspacing=4 cellpadding=3 width=490>
- <tr>
- <td width=125 valign="top"><A
- NAME="export_networks"><STRONG>Select networks</STRONG></A><br>
- </td>
- <td valign="top">This dialog lists in the Do Not Export column all the networks configured for DHCP service . Any network that you
-transfer to the Export column will be exported from this server. The IP addresses and their associated bindings will be placed in the export file
-so that they can be imported to another server. <P> To transfer a network to the Export column, select it and click the right-arrow button between the columns. <p>
-You can also choose to leave all the networks in the Do Not Export column. This allows you to proceed to selecting macros and options to export without exporting any networks.
-
- </td>
- </tr>
-
- <tr>
- <td width=125 valign="top"><A
- NAME="export_macros"><STRONG>Select macros</STRONG></A><br>
- </td>
- <td valign="top">The Do Not Export column displays all macros defined for this DHCP server. To export a macro, select it and click the right-arrow button between the columns to transfer the macro to the Export column.
- </td>
- </tr>
-<tr><td width=125 valign="top"><A
- NAME="export_options"><STRONG>Select options</STRONG></A><br>
- </td>
- <td valign="top">The Do Not Export column displays all options defined for this DHCP server. To export an option, select it and click the right-arrow button between the columns to transfer the option to the Export column. </td></tr>
- <tr><td width=125 valign="top"><A
- NAME="export_file"><STRONG>Export file</STRONG></A><br>
- </td>
- <td valign="top">The export file is the file to which the data you selected to export will be copied and compressed. You must provide a full path name to the file. The file should be placed in a shared directory that is accessible to the DHCP server that will be importing the data. </td></tr>
- <tr><td width=125 valign="top"><A
- NAME="export_delete"><STRONG>Delete exported data</STRONG></A><br>
- </td>
- <td valign="top">If you want the exported data to be deleted from the DHCP server after the export is complete, select this option. This is recommended, especially if you are exporting networks to avoid conflicting ownership of the IP addresses. ???
-</td></tr>
-
-<TR><TD COLSPAN="2"> <A HREF="#top"><FONT
-size=2>return to top</FONT></A></TD></TR>
-
- </table>
-
-<HR noshade size=2>
-
-
-
-<p> </p>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_import_wiz.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_import_wiz.html deleted file mode 100644 index fde591a04a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_import_wiz.html +++ /dev/null @@ -1,173 +0,0 @@ -<!--
- -- ident "%Z%%M% %I% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Import Data</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#ffffff">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=575>
-
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="left" valign="top"><IMG
-SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALIGN="LEFT" ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
- <STRONG><A HREF="dhcp_relay_ref.html">Servers and
-Relays</A></STRONG><BR>
- <A HREF="dhcp_config_wiz.html">DHCP
-Config</a><BR>
- <A HREF="dhcp_relay_config.html">BOOTP Relay Config</A><BR>
- <A HREF="dhcp_net_wiz.html">Network Config</A><BR>
- <A HREF="dhcp_server_serv.html">Modify DHCP Service</A><BR>
- <A HREF="dhcp_relay_serv.html">Modify BOOTP Service</A><br>
- <A HREF="dhcp_export_wiz.html">Export Data</A><br>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT=""><A HREF="dhcp_import_wiz.html">Import Data</A>
- <A HREF="dhcp_convert_wiz.html">Convert Data Store</A><br><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCC"> </td>
-
-<!-- End column rule -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" width="530">
-<P> </P>
-
-
-<H1>Import Data</H1>
-
-The Import Data wizard helps you
-transfer DHCP networks, IP addresses, macros, and
-options from one Solaris DHCP server to another. The
-wizard imports configuration data previously exported from
-another Solaris DHCP server. This effectively moves
-support of a set of DHCP clients from one server to
-another.
-<P>
-After you fill in the requested information in each
-dialog, click the right-arrow button to advance to the
-next dialog.
-<P>
-The Import Data wizard asks you for the
-following information.
-<P><HR NOSHADE><P>
-
-<table border=0 cellspacing=4 cellpadding=3 width=490>
- <tr>
- <td width=125 valign="top"><A
- NAME="import_file"><STRONG>Import file</STRONG></A><br>
- </td>
- <td valign="top">Type the full path to the
- file containing the data you want to import to
- this DHCP server. The file must be an export file that
- was produced by exporting data from a Solaris
- DHCP server. The file is in a compressed binary data format.
- </td>
- </tr>
-
- <tr>
- <td width=125 valign="top"><A
- NAME="overwrite_data"><STRONG>Overwrite existing data</STRONG></A><br>
- </td>
- <td valign="top">If the DHCP server on which
- you are importing data has configuration data
- for any of the same networks, IP addresses,
- macros, or options being imported, that data will be
- replaced with the imported data when
- you select this option. By default,
- conflicting data will not be overwritten.
- </td>
- </tr>
-
- <TR><TD COLSPAN="2"> <A HREF="#top"><small>return to top</small></A></TD></TR>
-
- </table>
-
-<HR noshade size=2>
-
-
-
-<p> </p>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_create.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_create.html deleted file mode 100644 index 8bc76d24fd..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_create.html +++ /dev/null @@ -1,196 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Create Macro</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
-
-
-<A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><BR>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Create<BR>
- <a href="#name"><EM>Name</EM></a><BR>
- <a href="#option"><EM>Option</EM></a><BR>
- <a href="#order"><EM>Up/Down</EM></a><BR>
- <a href="#del"><EM>Delete</EM></A><BR>
- <A HREF="dhcp_macro_dup.html">Duplicate</A><BR>
- <A HREF="dhcp_macro_mod.html">Modify</A><BR>
- <A HREF="dhcp_macro_del.html">Delete</A><P>
-
-<A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-<h1>Create Macro</h1>
-
-The Create Macro dialog box lets you to define a new macro in the <tt>dhcptab</tt> on the selected DHCP server. <p>
-See <a href="dhcp_macros_about.html#using">Using Macros and Options
-</a> for more information about defining DHCP macros.<P>
-
-
-The settings available in the Create Macro dialog box are described below.<p>
-<P><HR NOSHADE><P>
-
-
- <table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
- <td width=105 valign="top"><A NAME="name"><STRONG>Name</STRONG></A></td>
- <td valign="top">Specify the name of the new macro. Remember, the name you choose determines the <A HREF="dhcp_macros_about.html#macrocat">macro category</a>. Macro names can be
- a maximum of 128 alphanumeric characters.<P>
-
- The important thing to remember when naming your macro is to give
- it the same name as the resource or device in the category you want
- to control. For example, to create a Client Class macro for
- configuring an Ultra-5<small><sup>TM</sup></small> (which has the client class name
- <tt>SUNW,Ultra5_10</tt>), name your macro <tt>SUNW.Ultra5_10</tt>.
- </td>
- </tr>
-
- <tr>
- <td width=105 valign="top"><A NAME="option"><STRONG>Option</STRONG></A></td>
- <td valign="top">Specify the names of options and/or macros to include in the macro. The options or macros must
-already exist in the <tt>dhcptab</tt>. If the option does not exist, you
-can create it using the <A HREF="dhcp_option_create.html">Create Option</A> dialog box.
-To browse a list of defined options, right-click in the
-Options column. Options are displayed by category and type.
-To view the list of standard options, see <A HREF="dhcp_option_tags.html">Standard Options</A>.<P>
-
-To include a nested macro, enter Include in the Option column
-and then enter the name of the macro in the Value column.<P>
-To specify an option, enter the name of the option in the Option
-column, and the value of the option in the Value column. <P></TD>
- </tr>
-
- <tr>
- <td width=125 valign="top"><A NAME="order"><STRONG>Move Up/Move Down</STRONG></A></td>
- <td valign="top">Click Move Up or Move Down to change the processing order of
- options and nested macros. The processing order is significant, as options and
- macros processed last supersede conflicting values in those that are
- processed first. </td>
- </tr>
-
- <tr>
- <td width=125 valign="top"><A NAME="del"><STRONG>Delete</STRONG></A></td>
- <td valign="top">Select an option and click Delete to remove it from the macro. </td>
- </tr>
-
-
- </table>
-
-
-
-<p>
-<strong>Notify DHCP Server of Change:</STRONG> Check the box if
-you want the DHCP server to reload the <tt>dhcptab</tt> after
-the changed macro information is written. Normally, you will want
-the server to reload the <tt>dhcptab</tt> so that clients will
-start receiving the new configuration data immediately.
-However, in some cases, you may wish to delay this reload.
-For example, you may need to modify several macros in order for
-configurations to be correct. <P>
-
- <A HREF="#top"><small>return to top</small></A>
-
-
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_del.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_del.html deleted file mode 100644 index 21d9db779e..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_del.html +++ /dev/null @@ -1,133 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Delete Macro</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html">Servers and Relays</A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
-
-
-<A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><BR>
- <A HREF="dhcp_macro_create.html">Create</A><BR>
- <A HREF="dhcp_macro_dup.html">Duplicate</A><BR>
- <A HREF="dhcp_macro_mod.html">Modify</A><BR>
-
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Delete<P>
-
-<A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-<h1>Delete Macro</h1>
-Click OK to remove the macro from the <tt>dhcptab</tt>.
-<P>
-
-<strong>Notify DHCP Server of Change:</STRONG> Check the box if
-you want the DHCP server to reload the <tt>dhcptab</tt> after
-the changed macro information is written. Normally, you want
-the server to reload the <tt>dhcptab</tt> so that clients
-start receiving the new configuration data immediately.
-However, in some cases, you may want to delay this reload.
-For example, you may need to make several changes in order for
-configurations to be correct. <P>
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_dup.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_dup.html deleted file mode 100644 index e658cc0c05..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_dup.html +++ /dev/null @@ -1,181 +0,0 @@ -<!-- - -- ident "%W% %E% SMI" - -- - Copyright 2005 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - --> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Duplicate Macro</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
-
-
-<A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><BR>
- <A HREF="dhcp_macro_create.html">Create</A><BR>
-
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Duplicate<BR>
- <a href="#name"><EM>Name</EM></a><BR>
- <a href="#option"><EM>Option</EM></a><BR>
- <a href="#order"><EM>Up/Down</EM></a><BR>
- <a href="#del"><EM>Delete</EM></A><BR>
-
- <A HREF="dhcp_macro_mod.html">Modify</A><BR>
- <A HREF="dhcp_macro_del.html">Delete</A><P>
-
-<A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-<h1>Duplicate Macro</h1>
-
-The Duplicate Macro dialog box provides a simple way for you to create a
-new macro by copying some or all of the settings of an existing macro.<p>
-
-Refer to <a href="dhcp_macros_about.html">About Macros and Options</a>, for more information about defining DHCP macros.<p>
-
-The settings in the Duplicate Macro dialog box are described below.<p>
-<P><HR NOSHADE><P>
-
-
- <table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
- <td width=105 valign="top"><A NAME="name"><STRONG>Name</STRONG></A></td>
- <td valign="top">Specify a name for the new macro.
- Macro names can be a maximum of 128 alphanumeric characters.<br></td>
- </tr>
-
- <tr>
- <td width=105 valign="top"><A NAME="option"><STRONG>Option</STRONG></A></td>
- <td valign="top">Name of the options and/or other macros included in the macro.
- You can add or delete options from this list.
-To display a list of defined options, right-click in the Options field. Options are displayed by category and type.
-</TD>
-
- </tr>
-
- <tr>
- <td width=105 valign="top"><A NAME="order"><STRONG>Move Up/Move Down</STRONG></A></td>
- <td valign="top">Click Move Up or Move Down to change the processing order of
- options and nested macros. The processing order is significant, as options and
- macros processed last supersede conflicting values in those that are
- processed first. </td>
- </tr>
-
- <tr>
- <td width=105 valign="top"><A NAME="del"><STRONG>Delete</STRONG></A></td>
- <td valign="top">Select an option and click Delete to remove it from the macro. </td>
- </tr>
-
-
- </table>
-
-
-<P>
-<strong>Notify DHCP Server of Change:</STRONG> Check the box if
-you want the DHCP server to reload the <tt>dhcptab</tt> after
-the changed macro information is written. Normally, you want
-the server to reload the <tt>dhcptab</tt> so that clients
-start receiving the new configuration data immediately.
-However, in some cases, you may wish to delay this reload.
-For example, you may need to modify several macros in order for
-configurations to be correct. <P>
- <A HREF="#top"><small>return to top</small></A>
-
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_how.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_how.html deleted file mode 100644 index f05336b414..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_how.html +++ /dev/null @@ -1,235 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: How To... Macros</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relay Agents</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><BR>
- <A HREF="dhcp_relay_how.html">Servers/Relays</A><BR>
- <A HREF="dhcp_addr_how.html">Addresses</A><BR>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Macros<BR>
- <a href="#viewmacro"><EM>View</EM></a><BR>
- <a href="#newmacro"><EM>Create</EM></a><BR>
- <a href="#dupmacro"><EM>Duplicate</EM></a><BR>
- <a href="#modmacro"><EM>Modify</EM></a><BR>
- <a href="#delmacro"><EM>Delete</EM></a><BR>
-
- <A HREF="dhcp_option_how.html">Options</A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff">
-<P> </P>
-<H1>How To: Macros</H1>
-
-<strong><big><A NAME="viewmacro">View Macros</A></big></strong><p>
-
-<strong>Choose the <A HREF="dhcp_macro_ref.html">Macros</A> tab in the main window.</strong><BR>
-DHCP Manager displays a list of macros that have been configured
-for this network. You can view the relationship between macros. Click on a macro to view its associated options. Click Properties from
-the Edit menu to view a list of options and their values. <P>
-
-<p>
-<hr noshade>
-<strong><big><A NAME="newmacro">Create a New Macro</A></big></strong><p>
-
- <ol type=1>
-
- <LI><strong>Choose the <A HREF="dhcp_macro_ref.html">Macros</A> tab in the main window.</strong><BR>
- The DHCP Manager displays a list of macros that have been configured
- for this network.</LI><P>
- <LI><STRONG>Choose Create from the Edit menu.</STRONG><BR>
- The <A HREF="dhcp_macro_create.html">Create Macro</A> dialog box opens.</LI><P>
- <LI><strong>Enter a unique name for the new macro.</strong><BR>
- The name must be unique within the server's DHCP table (<tt>dhcptab</TT>).<br>
- (See the note about macro names at the end of this procedure.)
-</LI><P>
- <LI><strong>Enter the definition of the macro.</strong><BR>
- This can be built by including other macros, or by defining values for
- options to be included in the macro. The <A HREF="dhcp_option_tags.html">standard options</A> are described in the <tt>dhcp_inittab</tt>(4) man page</LI><P>
-
- <li><strong>Click OK to accept your settings.</strong><BR>
-
- The new macro definition is stored in the <tt>dhcptab</tt>.<p></li>
-
- </ol><P>
-
-<center>
- <table border=1 cellspacing=3 cellpadding=5 WIDTH="380">
-
- <tr>
- <td valign="middle" align="left" BGCOLOR="#EBEBEB"><a name="name">The</a>
- important thing to remember when naming your macro is to give it the
- same name as the resource or device in the category you want to control.
- For example, to create a Client Class macro for configuring Ultra-5s<small><sup>TM</sup></small>
- (which have the client class name <tt>SUNW,Ultra5_10</tt>), name your
- macro <tt>SUNW.Ultra5_10</tt>. See <a
- href="dhcp_macros_about.html#using">Using Macros and Options</a> for more
- information.</td>
- </tr>
-
- </table>
-
-</center>
-<P><HR NOSHADE><P>
-<strong><big><A NAME="dupmacro">Duplicate a Macro</A></big></strong>
-<P>
-The Duplicate command provides a simple way to create a
-new macro with some or all of the properties of an
-existing macro.<P>
-
- <ol type=1>
-
- <LI><strong>Choose the <A HREF="dhcp_macro_ref.html">Macros</A> tab in the main window.</strong><BR>
-
- DHCP Manager displays a list of macros that have been configured for this network.<p></li>
-
- <li><strong>Select the macro you want to copy, and then choose <A HREF="dhcp_macro_dup.html">Duplicate</A> from the
- Edit window.</strong><BR>
- The Duplicate Macro dialog box opens.</li><P>
-
- <li><strong>Enter a name for the new macro.</strong><br>
- (See the <a href="#name">note</a> about macro names at the end of the
-previous procedure.)<P></LI>
- <LI><strong>Modify the macro settings as desired.</strong></LI>
-<P>
-<LI><STRONG>Click OK to accept your
-settings.</strong><BR>
-The new macro definition is stored in the <tt>dhcptab</tt>.</li>
-
- </ol>
-
-<p><hr noshade><P>
-<strong><big><A NAME="modmacro">Modify a Macro</A></big></strong><p>
-
- <ol type=1>
-
- <LI><strong>Choose the <A HREF="dhcp_macro_ref.html">Macros</A> tab in the main window.</strong><BR>
-
- DHCP Manager displays a list of macros that have been configured for this network.<p></li>
-
- <li><strong>Select the macro you want to edit, and then choose <A HREF="dhcp_macro_mod.html">Properties</A> from the
- Edit window.</strong><BR>
- The Macro Properties dialog box opens.<P></li>
-
- <li><strong>Modify the macro settings as desired and click OK.</strong></LI>
- </ol>
-
-
-<p><HR noshade><P>
-<strong><big><A NAME="delmacro">Delete a Macro</A></big></strong><p>
-
- <ol type=1>
-
- <LI><strong>Choose the <A HREF="dhcp_macro_ref.html">Macros</A> tab in the main window.</strong><BR>
- DHCP Manager displays a list of macros that have been configured
- for this network.</LI><P>
-
- <li><strong>Select the macro to delete, and then choose <A HREF="dhcp_macro_del.html">Delete</A> from the
- Edit window.</strong><BR>
- The Delete Macro dialog box opens.<P></li>
-
- <LI><strong>Click OK.</strong><BR>
- The macro definition is deleted from the <tt>dhcptab</tt>
- database.<p></li>
-
- </ol>
-
-
-
- <A HREF="#top"><small>return to top</small></A>
-<p> </p>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_mod.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_mod.html deleted file mode 100644 index 9b23fde512..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_mod.html +++ /dev/null @@ -1,189 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Modify Macro</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
-
-
-<A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><BR>
- <A HREF="dhcp_macro_create.html">Create</A><BR>
- <A HREF="dhcp_macro_dup.html">Duplicate</A><BR>
-
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Modify<BR>
- <a href="#name"><EM>Name</EM></a><BR>
- <a href="#option"><EM>Option</EM></a><BR>
- <a href="#order"><EM>Up/Down</EM></a><BR>
- <a href="#del"><EM>Delete</EM></A><BR>
-
- <A HREF="dhcp_macro_del.html">Delete</A><P>
-
-<A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-<h1>Modify Macro</h1>
-
-The Macro Properties dialog box displays the current settings for a macro, and lets you modify these settings in the <tt>dhcptab</tt> on the selected DHCP server. <p>
-<p>
-To modify an entry, double-click the entry, enter the new value, and then press Enter.
-To display a list of defined options, right-click in the Options or Values field. Options are listed by category and type.<P>
-The settings in the Macro Properties menu are described below.
-<P><HR NOSHADE><P>
-
-
- <table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
- <td width=105 valign="top"><a name="name"><STRONG>Name</STRONG></a></td>
- <td valign="top">The macro name; specify a new name, if
- desired. Remember, the name you choose determines the <a
- href="dhcp_macros_about.html#using">macro category</a>. Macro names can be
- a maximum of 128 alphanumeric characters.<P>
- The important thing to remember when naming your macro is to give
- it the same name as the resource or device in the category you want
- to control. For example, to create a Client Class macro for
- configuring a Ultra-5<small><sup>TM</sup></small> (which has the client class name
- <tt>SUNW,Ultra5_10</tt>), name your macro <tt>SUNW.Ultra5_10</tt>.
-</td>
- </tr>
-
- <tr>
- <td width=105 valign="top"><A NAME="option"><STRONG>Option</STRONG></A></td>
- <td valign="top">The options and/or other macros included in the macro. You can add or delete options, and change the order of options in the list.<P>
-To browse a list of defined options, right-click in the
-Options column. Options are displayed by category and type.<P>
-To include a nested macro, enter Include in the Option column
-and then enter the name of the macro in the Value column.<P>
-To specify an option, enter the name of the option in the Option
-column, and the value of the option in the Value column. <P></td>
- </tr>
-
- <tr>
- <td width=105 valign="top"><A NAME="order"><STRONG>Move Up/Move Down</STRONG></A></td>
- <td valign="top">Click Move Up or Move Down to change the processing order of
- options and nested macros. The processing order is significant, as options and
- macros processed last supersede conflicting values in those that are
- processed first. </td>
- </tr>
-
- <tr>
- <td width=105 valign="top"><A NAME="del"><STRONG>Delete</STRONG></A></td>
- <td valign="top">Select an option and click Delete to remove it from the macro. </td>
- </tr>
-
-
- </table>
-
-<p> </p>
-<strong>Notify DHCP Server of Change:</STRONG> Check the box if
-you want the DHCP server to reload the <tt>dhcptab</tt> after
-the changed macro information is written. Normally, you want
-the server to reload the <tt>dhcptab</tt> so that clients
-start receiving the new configuration data immediately.
-However, in some cases, you may want to delay this reload.
-For example, you may need to modify several macros in order for
-configurations to be correct. <P>
- <A HREF="#top"><small>return to top</small></A>
-
-
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_ref.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_ref.html deleted file mode 100644 index fa19afe858..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_ref.html +++ /dev/null @@ -1,155 +0,0 @@ -<!-- - -- ident "%W% %E% SMI" - -- - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc. - -- All rights reserved. - --> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Macros</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
-
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
-
-
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT=""><STRONG>Macros</STRONG><BR>
- <A HREF="dhcp_macro_create.html">Create</A><BR>
- <A HREF="dhcp_macro_dup.html">Duplicate</A><BR>
- <A HREF="dhcp_macro_mod.html">Modify</A><BR>
- <A HREF="dhcp_macro_del.html">Delete</A><P>
-
-<A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-<h1>Macros</h1>
-
-When you select the Macros tab in the main window, DHCP Manager displays a list of
-macros in the server's <tt>dhcptab</tt>. <p>
-The macros are listed alphabetically by name. Macros that include other macros
-are identified by a folder icon<IMG SRC="art/dot2.gif" WIDTH=14 HEIGHT=13 BORDER=0 ALT=""><IMG SRC="art/folder.gif" WIDTH=25 HEIGHT=15 BORDER=0>. To view the included macro(s), click
-the open button to the left of the folder icon. Click a macro icon <IMG SRC="art/macro2.gif" BORDER=0> to view a list of options assigned to this macro, and their values. <P>
-You can <A HREF="dhcp_macro_create.html">create</A> a new macro, <A HREF="dhcp_macro_mod.html">modify</A>, <A HREF="dhcp_macro_dup.html">copy</A>, or <A HREF="dhcp_macro_del.html">delete</A> an existing macro by selecting it and
-clicking the appropriate entry in the Edit menu.<P>
-For more information about macros and how to use them, see <A HREF="dhcp_macros_about.html">About Macros and Options</A>.<P>
-The column settings are described below.
-<P><HR NOSHADE><P>
-<table border=0 cellspacing=4 cellpadding=3>
-
-
- <TR>
- <td width=100 valign="top"><a name="name"><STRONG>Macro</STRONG></a></td>
- <td valign="top">The name of the macro. A macro may include one or more macros.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a name="option"><STRONG>Option</STRONG></a></td>
- <td valign="top">The name of the option(s) included in the selected macro. </td>
- </tr>
- <tr>
- <td width=100 valign="top"><a name="val"><STRONG>Value</STRONG></a></td>
- <td valign="top">The value of the option.</td>
-</tr>
-
- </table>
-
-
-
-
-
-<p> </p>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_view.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_view.html deleted file mode 100644 index 82e2a67126..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macro_view.html +++ /dev/null @@ -1,279 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Macro Menus</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head><body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=625>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><BR>
- <A HREF="dhcp_macro_view.html">Address View</A><BR>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Macro View<BR>
- <A HREF="dhcp_option_view.html">Option View</A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff" WIDTH="495">
-
- <P> </P>
-
-<H1>Macro View Menus</H1>
-
-<table ALIGN="LEFT" BORDER="0" CELLPADDING="3" WIDTH="495">
-
-<TR>
-<td colspan=1 width=20> </td>
-<TH colspan=1 align=left valign="top" width=150>
- <FONT SIZE="+1">Titles</FONT><P></TH>
- <TH align=left valign="top"><FONT SIZE="+1">Description</FONT><P></TH>
-
-</TR>
-
-
-<tr>
-<td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF"><U>File Menu</U></td>
- <Td></Td>
- </TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150> <STRONG>Exit</STRONG></TD>
- <TD ALIGN="LEFT" VALIGN="TOP">Exit from the application.<P> </P></TD>
- </TR>
-
-<tr>
-<td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF"><U>Edit Menu</U></td>
- <Td></Td>
- </TR>
-
- <tr><td colspan=1 width=20> </td>
-<TD COLSPAN="1" ALIGN="left" VALIGN="TOP" width="150"> <STRONG>Create</STRONG></TD>
-
- <TD COLSPAN="2" ALIGN="LEFT" VALIGN="TOP">
-Create new macro.</TD></TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Delete</STRONG></TD>
-<TD COLSPAN="2" ALIGN="LEFT" VALIGN="TOP">Delete the selected macro(s).</TD>
-</TR>
-
-<tr>
-<td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top" width=150> <STRONG>Duplicate</STRONG></TD>
-<TD COLSPAN="2" ALIGN="LEFT" VALIGN="TOP">Copy the selected macro.</TD>
-</TR>
-
-<tr>
-<td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top" width=150> <STRONG>Properties</STRONG></TD>
-<TD COLSPAN="2" ALIGN="LEFT" VALIGN="TOP">Modify the properties of the selected macro.
-<P> </P></TD>
-</TR>
-
-
-
-<tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>View Menu</U><P></td>
-<TD></TD></TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Refresh</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Refresh the data from the server.</TD>
-</TR>
-
- <tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Show Grid</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Turn on grid lines in display.<P> </P></TD>
-</TR>
-
-
-<tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>Service Menu</U><P></td>
- <Td></Td></TR>
-
- <tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Restart</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Stop and restart the DHCP daemon.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Stop</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Stop the DHCP daemon.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Start</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Start the DHCP daemon.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Disable</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Disable the DHCP server or BOOTP relay agent.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Enable</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Enable the DHCP server or BOOTP relay agent.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Modify</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Customize services of DHCP server or BOOTP relay agent.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Export Data</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Copy from the DHCP data store selected IP addresses, macros, and options to a file for the purpose of importing to a DHCP server.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Import Data</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Bring into the DHCP data store IP addresses, macros, and options that were exported from a DHCP server. </TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Convert Data Store</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Configure the DHCP server to use a new data store and convert existing data to new data store format. </TD>
-</TR>
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Unconfigure</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Unconfigure the DHCP server or BOOTP relay agent.<P> </P></TD>
-</TR>
-
-
-
-<tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>Help Menu</U></td>
- <Td>Display the online help.<P> </P></Td></TR>
- <tr><td colspan=1 width=20> </td>
- </TR>
-
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>Find</U></td>
- <Td>Search for a Macro entry.<P> </P></Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>Column Entries</U></td>
- <Td></Td></TR>
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
- <STRONG>Macros</STRONG></td>
- <Td>Macros are listed by name. Click the macro to view included macros and options.
- Double-click to display the Macro Properties dialog box.</Td></TR>
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
- <STRONG>Option</STRONG></td>
- <Td>Name of the selected option</Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
- <STRONG>Value</STRONG></td>
- <Td>Option value<P> </P></Td></TR><TR>
- <TD COLSPAN="3"> <A HREF="#top"><small>return to top</small></A>
- </TD></TR>
- </TABLE>
-
-
-
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macros_about.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macros_about.html deleted file mode 100644 index 63be531bd5..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_macros_about.html +++ /dev/null @@ -1,296 +0,0 @@ -<!--
- -- ident "%Z%%M% %I% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright 2003 Sun Microsystems, Inc. All rights reserved.
- -- Use is subject to license terms.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: About Macros and Options</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=645>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><BR>
- <A HREF="dhcp_solaris_about.html">Solaris DHCP</A><BR>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">About Macros<BR>
- <A HREF="dhcp_main_hlp.html">Getting Help</A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_net_ref.html"><STRONG>Networks</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" width=495>
-
-
-
-<P> </P>
-
-<h1>About Macros and Options</H1>
-
-
-In a DHCP environment, <em>macros</em> are containers for <em>option values</em> that are
-passed as configuration parameters from the DHCP server to the DHCP client. For example,
-you might define a macro that contains options specifying a DNS server and print server
-to be used by all clients using IP addresses owned by a particular DHCP server.<p>
-
-<em>Options</em> specify the format in which option values are
-defined in the DHCP server's <tt>dhcptab</tt> (in which all DHCP
-options and macros are stored). For example, option category, data type, vendor, and granularity all determine the <em>shape</em> of the options
-contained in your macros. Creating and modifying options is described
-further in the help pages for <a href="dhcp_option_create.html">Create Option</a> and
-<a href="dhcp_option_mod.html">Modify Option</a>.<p>
-
-<h1> - Macro Processing - </h1> - <p> - Remember the following points when naming DHCP macros and adding - options to macros: - </p> - <ol> - <li> - <strong>Automatic processing</strong> occurs for Client Class, - Network, and Client ID category macros when the macro category - matches the client's class, network address, or client - identifier. - <br> - </li> - <li> - <strong>Macro categories</strong> determine the order in which - macros are processed automatically. - <br> - </li> - <li> - <strong>Macro names</strong> determine macro categories, with the - exception of IP address macros, which are categorized by their - assignment to an IP address.<br> - - <p> - For most macros, make your macro names <strong>match the names - of the resources or devices</strong> to which you want the - macros to apply. For example: - </p> - <br> - <table cellpadding="4" cellspacing="4" border="1"> - <tr> - <td bgcolor="#CCCFFF" valign="middle" align="left"> - <p> - For Clients... - </p> - </td> - <td bgcolor="#CCCFFF" valign="middle" align="left"> - <p> - Name Your Macro - </p> - </td> - </tr> - <tr> - <td valign="top"> - <p> - Of a particular client class - </p> - </td> - <td valign="top"> - <p> - Same name as the DHCP client's client class. The - client class is determined by the client vendor. For - example, the client class name for a Sun Blade <sup><font - size="-2"> TM</font></sup> 150 client is SUNW,Sun-Blade-100 so - you must name your macro <tt> SUNW.Sun-Blade-100</tt> . On - Solaris DHCP client systems, you - can determine the client class by typing the command - <tt> uname -i</tt> on the client machine. Note that - macro names cannot contain commas; if a comma appears - in the client class, replace it with a period in the - macro name. - </p> - </td> - </tr> - <tr> - <td valign="top"> - <p> - On a particular network - </p> - </td> - <td valign="top"> - <p> - Same as the IP address of the network through which the - client is connecting; for example, name your macro <tt> - 10.0.0.0</tt>. - </p> - </td> - </tr> - <tr> - <td valign="top"> - <p> - Using a particular IP Address - </p> - </td> - <td valign="top"> - <p> - Any name, but using the DHCP server's hostname or IP - address is recommended; for example, name your macro - <tt> shiva</tt> or <tt> 125.53.224.45</tt> . This kind - of macro is valuable for use as a configuration macro - for all clients obtaining configuration information - from this DHCP server. - </p> - </td> - </tr> - <tr> - <td valign="top"> - <p> - Identified by a particular client ID - </p> - </td> - <td valign="top"> - <p> - Same as the unique client identifier; for example, - name your macro <tt> 010800201112B7</tt> . - </p> - </td> - </tr> - </table> - <br> - </li> - <li> - <strong>Order is important.</strong> The order in which macros are - processed is significant. If an option is contained in more than - one macro, the option value passed to the client is the value - assigned in the macro processed last. Macros are processed in the - order shown in the illustration.<br> - <br> - - <p> - <img src="art/macroflow.gif" alt="order of macro processing" vspace="0" hspace="0" border="0" - height="225" width="400"> - </p> - <p> - As shown in the illustration, macro processing progresses from - the general to the specific. - </p> - <ul type="disc"> - <li> - <p> - Client Class macros are processed first.<br> - </p> - </li> - <li> - <p> - Network macros are processed second, superseding any - competing settings in Client Class macros.<br> - </p> - </li> - <li> - <p> - IP Address macros are processed third, superseding any - competing settings in previous macros.<br> - </p> - </li> - <li> - <p> - Client ID macros are processed last, superseding any - competing settings in all previous macros.<br> - </p> - </li> - </ul> - </li> - <li> - <p> - <strong>Macros can include other macros.</strong> Regardless of a - macro's category, it can include other macros so that, for example, - a client class macro could be called from an IP Address macro.<br> - <br> - </li> - </ol> - <p> - - </p> - <br> - <A HREF="#top"><small>return to top</small></A>
-
-<p> </p>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_hlp.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_hlp.html deleted file mode 100644 index e8813f89f1..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_hlp.html +++ /dev/null @@ -1,192 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Getting Help</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=625>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><BR>
- <A HREF="dhcp_solaris_about.html">Solaris DHCP</A><BR>
- <A HREF="dhcp_macros_about.html">About Macros</A><BR>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Getting Help<P>
-
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
- <A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" WIDTH="495">
-
-
-
-<P> </P>
-
-
-<h1>Getting Help</h1>
-
-This help system provides reference information and instructions for using Solaris<small><sup>TM</sup></small> DHCP Manager.<p>
-
-<p>Use the links in the contents area on the left to get to the topics you are interested in. The arrow <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT=""> indicates your position in the help system.<p>
-
-The topics in this help system are divided into the following categories.<p>
-
-
-
- <table border=0 cellspacing=3 cellpadding=3 width=475>
-
- <tr>
- <td width=115 valign="top"><a href="dhcp_main_top.html"><STRONG>Overview</STRONG></a></td>
- <td valign="top">Introduction and background information about DHCP Manager, Solaris DHCP, macros, and options.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a href="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></a></td>
- <td valign="top">Reference and context-specific topics about how to manage and configure DHCP servers, BOOTP relay agents, and networks; how to convert to a new data store, or move data to another DHCP server.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a href="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></a></td>
- <td valign="top">Reference and context-specific topics about how to manage and configure IP addresses in the DHCP network.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a href="dhcp_macro_ref.html"><STRONG>Macros</STRONG></a></td>
- <td valign="top">Reference and context-specific topics about how to define, create, and manage DHCP macros.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a href="dhcp_option_ref.html"><STRONG>Options</STRONG></a></td>
- <td valign="top">Reference and contex-specific topics about how to define, create, and manage DHCP options or symbols.</td>
- </tr>
-
-
-
- <tr>
- <td width=100 valign="top"><a href="dhcp_main_how.html"><STRONG>How To...</STRONG></a>
- </td>
- <td valign="top">Step-by-step instructions
- for using DHCP Manager.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a href="dhcp_main_menus.html"><STRONG>Menus</STRONG></a>
- </td>
- <td valign="top">Descriptions of menus and options in the three views
-displayed by DHCP Manager.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a href="dhcp_main_idx.html"><STRONG>Index</STRONG></a></td>
- <td valign="top">Index to topics in the help system.</td>
- </tr>
-
- </table>
-
-
-<P><HR noshade><P>
-<strong><big><a name="info">Further Reading</a></big></strong><P>
-
-This help system is not meant to be an exhaustive reference on DHCP or network-based
-system management. You may want to check the following resources for further information:<p>
-
- <ul>
- <li> <a href="http://docs.sun.com/ab2/coll.47.11/SYSADV3/@Ab2TocView/7898?Ab2Lang=C&Ab2Enc=iso-8859-1"><em>Solaris System Administration Guide, Volume 3</em></a> on Sun's web site for more extensive documentation on Solaris DHCP<p></li>
-
- <li><a href="http://www.ietf.org/html.charters/dhc-charter.html"><em>IETF DHC Charter</em></a><p></li>
-
- <li><a href="http://www.dhcp.org"><em>Web site of the DHC Working Group</em> </a><p></li>
-
- <li> <a href="http://www.rfc-editor.org"><em>Requests for Comments (RFCs)</em></a><p></li>
-
- </ul>
-
-<p> </p>
-
- <A HREF="#top"><small>return to top</small></A>
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_how.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_how.html deleted file mode 100644 index 210c9cf573..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_how.html +++ /dev/null @@ -1,165 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: How To...</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers/Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT=""><STRONG>How To..</STRONG><BR>
- <A HREF="dhcp_relay_how.html">Servers/Relays</A><BR>
- <A HREF="dhcp_addr_how.html">Addresses</A><BR>
- <A HREF="dhcp_macro_how.html">Macros</A><BR>
- <A HREF="dhcp_option_how.html">Options</A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" WIDTH="495">
-<P> </P>
-<H1>How To...</H1>
-
-<a name="relay"></a><p><strong>Manage DHCP Servers and BOOTP Relay Agents</strong><p>
-
-<ul>
-<li><a href="dhcp_relay_how.html#srvr">Configure a DHCP server</a></li>
-<li><a href="dhcp_relay_how.html#relay">Configure a BOOTP relay agent</a></li>
-<li><a href="dhcp_relay_how.html#adv">Customize DHCP/BOOTP services</a></li>
-<li><a href="dhcp_relay_how.html#ntwrk">Configure a network</a></li>
-<li><a href="dhcp_relay_how.html#delnet">Delete a network</a></li>
-<li><a href="dhcp_relay_how.html#start">Start, stop, or restart a DHCP server or BOOTP relay agent</a></li>
-<li><a href="dhcp_relay_how.html#dis">Enable or disable a DHCP server or BOOTP relay agent</a></li>
-<li><a href="dhcp_relay_how.html#exp">Export and import DHCP data between servers</a></li>
-<li><a href="dhcp_relay_how.html#conv">Convert a DHCP server to use a new data store</a></li>
-<li><a href="dhcp_relay_how.html#uncon">Unconfigure a DHCP server</a></li>
-<li><a href="dhcp_relay_how.html#uncon2">Unconfigure a BOOTP relay agent</a></li>
-</ul>
-<P>
-
-<strong>Manage IP Addresses</strong><p>
-
-<ul>
-<li><a href="dhcp_addr_how.html#viewtable">View IP addresses</a></li>
-<li><a href="dhcp_addr_how.html#newtable">Add a single IP address</a></li>
-<li><a href="dhcp_addr_how.html#addwiz">Add multiple IP addresses</a></li>
-<li><a href="dhcp_addr_how.html#copy">Duplicate an IP address</a></li>
-<li><a href="dhcp_addr_how.html#modaddr">Modify a single IP address</a></li>
-<li><a href="dhcp_addr_how.html#modmulti">Modify multiple IP addresses</a></li>
-<li><a href="dhcp_addr_how.html#reladdr">Release IP addresses</a></li>
-<li><a href="dhcp_addr_how.html#deltable">Delete IP addresses</a></li>
-</ul>
-<P>
-
-<strong>Manage DHCP Client Macros</strong><p>
-
-<ul>
-<li><a href="dhcp_macro_how.html#viewmacro">View macros</a></li>
-<li><a href="dhcp_macro_how.html#newmacro">Create a new macro</a></li>
-<li><a href="dhcp_macro_how.html#dupmacro">Duplicate a macro</a></li>
-<li><a href="dhcp_macro_how.html#modmacro">Modify a macro</a></li>
-<li><a href="dhcp_macro_how.html#delmacro">Delete a macro</a></li>
-</UL>
-<P>
-
-<strong>Manage DHCP Client Options</strong><p>
-
-<UL>
-<li><a href="dhcp_option_how.html#viewoption">View options</a></li>
-<li><a href="dhcp_option_how.html#newoption">Create a new option</a></li>
-<li><a href="dhcp_option_how.html#dupoption">Duplicate an option</a></li>
-<li><a href="dhcp_option_how.html#modoption">Modify an option</a></li>
-<li><a href="dhcp_option_how.html#deloption">Delete an option</a></li>
-</ul>
-<P>
- <A HREF="#top"><small>return to top</small></A>
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_idx.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_idx.html deleted file mode 100644 index a539891065..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_idx.html +++ /dev/null @@ -1,620 +0,0 @@ -<!--
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License (the "License"). - You may not use this file except in compliance with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- -- Use is subject to license terms.^M - -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Index</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=625>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT=""><STRONG>Index</STRONG><BR>
- <a href="#a-c"><em>A - C</em></a><BR>
- <a href="#d-g"><em>D - G</em></a><BR>
- <a href="#h-m"><em>H - M</em></a><BR>
- <a href="#n-r"><em>N - R</em></a><BR>
- <a href="#s-z"><em>S - Z</em></a>
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff" WIDTH="495">
-
- <P> </P>
-
-<h1>Index</h1>
-
-
-<!-- Index head -->
-
-<a name="a-c"></a>
-<p> <img src="art/dot1.gif" border="0"> <strong><em>A</em></strong> <img src="art/dot1.gif" border="0"><p>
-
-about<br>
- <A HREF="dhcp_main_top.html">DHCP Manager</A><BR>
-
- <a
- href="dhcp_macros_about.html">macros and options</a><br>
-
- <a href="dhcp_solaris_about.html">Solaris
- DHCP</a><br>
-
-<A HREF="dhcp_addr_wiz.html">Address Wizard</A><BR>
-addresses<BR>
- <A HREF="dhcp_addr_wiz.html">adding a block of</A><BR>
-
- <A HREF="dhcp_addr_ref.html#macro">configuration macro</A><BR>
- <A HREF="dhcp_addr_how.html#newtable">creating</A><BR>
- <A HREF="dhcp_addr_how.html#deltable">deleting</A><BR>
- <A HREF="dhcp_server_serv.html#dupaddr">detecting duplicate</A><BR>
- <A HREF="dhcp_addr_ref.html">displaying</A><BR>
- <A HREF="dhcp_addr_how.html#copy">duplicating</A><BR>
-
- <A HREF="dhcp_addr_how.html#modaddr">modifying</A><BR>
-
- <A HREF="dhcp_addr_rel.html">releasing</A><BR>
-
- type of lease<BR>
- <A HREF="dhcp_addr_ref.html#status">BOOTP clients</A><BR>
- <A HREF="dhcp_addr_ref.html#status">dynamic</A><BR>
- <A HREF="dhcp_addr_ref.html#status">manual</A><BR>
- <A HREF="dhcp_addr_ref.html#status">permanent</A><BR>
- <A HREF="dhcp_addr_ref.html#status">reserved</A><BR>
-
- <A HREF="dhcp_addr_ref.html#status">unusable</A><BR>
- <A HREF="dhcp_addr_how.html#viewtable">viewing</A><BR>
-
-
-<!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>B</em></strong> <img src="art/dot1.gif" border="0"><p>
-
-<A HREF="dhcp_addr_ref.html#status">BOOTP client, reserving address for</A><BR>
-
-<A HREF="dhcp_server_serv.html#compat">BOOTP compatibility</A><BR>
-
-BOOTP relay agent<br>
- <a href="dhcp_relay_config.html">configuring</a><br>
- <a href="dhcp_relay_serv.html#srvrs">DHCP servers, adding</a><BR>
- <A HREF="dhcp_relay_how.html#dis">enabling/disabling</A><BR>
- <a href="dhcp_relay_serv.html#inter">interfaces, monitoring</a><br>
- <A HREF="dhcp_relay_serv.html#log">log messages</A><BR>
- <a href="dhcp_relay_serv.html#hops">relay hops</a><br>
- <A HREF="dhcp_relay_how.html#start">restarting</A><BR>
- <A HREF="dhcp_relay_how.html#start">starting/stopping</A><BR>
- <A HREF="dhcp_relay_how.html#uncon2">unconfiguring</A><BR>
-
-
-<!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>C</em></strong> <img src="art/dot1.gif" border="0"> --<A HREF="#top"><small>return to top</small></A>--<p>
-
-<A HREF="dhcp_server_serv.html#cache">cache data</A><BR>
-
-<A HREF="dhcp_macros_about.html#macrocat">categories, macro</A><BR>
-Client Class macro<BR>
- <A HREF="dhcp_solaris_about.html" NAME="class">allocating</A><BR>
- <A HREF="dhcp_macros_about.html" NAME="class">description of</A><BR>
-Client ID macro<BR>
- <A HREF="dhcp_solaris_about.html#cid">allocating</A><BR>
- <A HREF="dhcp_macros_about.html#cid">description of</A><BR>
-
-<A HREF="dhcp_macros_about.html#cid">client-specific parameters</A><BR>
-clients<br>
- <a href="dhcp_relay_ref.html">BOOTP</a><br>
- <a href="dhcp_option_ref.html#class">class</a><br>
- <a href="dhcp_addr_ref.html">configuring</a><br>
- <A HREF="dhcp_addr_ref.html">host names</A><BR>
- <a href="dhcp_addr_ref.html">ID</a><br>
- <a href="dhcp_addr_ref.html">records</a><br>
-
-configuration<BR>
- <A HREF="dhcp_relay_config.html">BOOTP relay agent</A><br>
- <A HREF="dhcp_addr_how.html">client</A><BR>
- <a href="dhcp_config_wiz.html">DHCP server</a><BR>
- <A HREF="dhcp_addr_ref.html#macro">macro</A><BR>
- <A HREF="dhcp_net_wiz.html">network</A><BR>
-
-<A HREF="dhcp_addr_view.html">Create menu option</A><BR>
-
-<!-- Index head -->
-
-<a name="d-g"></a>
-<p> <img src="art/dot1.gif" border="0"> <strong><em>D</em></strong> <img src="art/dot1.gif" border="0"><p>
-data store<BR>
- <A HREF="dhcp_config_wiz.html#store">selecting</A><BR>
- <A HREF="dhcp_convert_wiz.html">converting</A><BR>
-database<BR>
-
-
- <a href="dhcp_solaris_about.html"><tt>dhcptab</tt></a><br>
-
-<A HREF="dhcp_addr_view.html">Delete menu option</A><BR>
-
-<A HREF="dhcp_addr_view.html">Delete Networks menu option</A><BR>
-
-<A HREF="dhcp_addr_view.html">Duplicate menu option</A><BR>
-
-
-DHCP<br>
-
- <a href="dhcp_solaris_about.html">about
- Solaris</a><br>
-
- <a href="dhcp_addr_ref.html">client
- configuration</a><br>
-
-
-
-DHCP servers<BR>
- <a href="dhcp_relay_ref.html">about</a><br>
- <a href="dhcp_config_wiz.html">configuring</a><br>
- <A HREF="dhcp_relay_how.html#conv">converting data store on</A><BR>
- <A HREF="dhcp_relay_how.html#dis">enabling/disabling</A><BR>
- <a href="dhcp_config_wiz.html#lease">lease offer</a><br>
- <A HREF="dhcp_relay_how.html#exp">moving data between</A><BR>
- <A HREF="dhcp_relay_how.html#start">restarting</A><BR>
- <A HREF="dhcp_relay_how.html#start">starting/stopping</A><BR>
- <A HREF="dhcp_relay_how.html#uncon">unconfiguring</A><BR>
-
-<a href="dhcp_main_top.html">DHCP Manager, overview</a><br>
-
-<A HREF="dhcp_main_top.html"><tt>dhtadm</tt> utility</A><BR>
-
-<a href="dhcp_main_top.html"><tt>dhcpconfig</tt> utility</a><br>
-
-<A HREF="dhcp_addr_view.html">Disable menu option</A><BR>
-DNS<BR>
- <A HREF="dhcp_config_wiz.html#dns">DNS domain server</A><BR>
- <A HREF="dhcp_server_serv.html#dnsup">DNS update by DHCP server</A><BR>
- <A HREF="dhcp_config_wiz.html#hostnmserv">host name service</A><BR>
-
-<A HREF="dhcp_addr_ref.html#status">dynamic address</A>
-
-
-
-<!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>E</em></strong> <img src="art/dot1.gif" border="0"> --<A HREF="#top"><small>return to top</small></A>--<p>
-
-<A HREF="dhcp_addr_view.html">Edit menu</A><BR>
-
-<A HREF="dhcp_addr_view.html">Enable menu option</A><BR>
-
-<A HREF="dhcp_addr_view.html">Exit</A><BR>
-
-<A HREF="dhcp_addr_ref.html">expiration, of lease</A><BR>
-
-<A HREF="dhcp_option_ref.html#cat">extended option</A><BR>
-
-
-
-
-<!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>F</em></strong> <img src="art/dot1.gif" border="0"><p>
-
-<a href="dhcp_main_hlp.html#info">FAQ, DHCP</a><br>
-
-<A HREF="dhcp_addr_view.html">File menu</A><BR>
-
-<A HREF="dhcp_addr_view.html">Find utility</A><BR>
-
-<a href="dhcp_addr_ref.html#status">flags, lease</a><br>
-
-<a href="dhcp_relay_ref.html">forwarding IP address</a><br>
-
-
-
-<!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>G</em></strong> <img src="art/dot1.gif" border="0"><p>
-
-<a href="dhcp_main_top.html">getting started</a><br>
-
-<a href="dhcp_option_ref.html#gran">granularity, option</a><br>
-
-
-
-<!-- Index head -->
-
-<a name="h-m"></a>
-<p> <img src="art/dot1.gif" border="0"> <strong><em>H</em></strong> <img src="art/dot1.gif" border="0"> --<A HREF="#top"><small>return to top</small></A>--<p>
-
-<A HREF="dhcp_addr_view.html">Help menu</A><BR>
-
-<a href="dhcp_main_hlp.html">help on help</a><br>
-
-<a href="dhcp_relay_serv.html#hops">hops, relay</a><br>
-
-host name<BR>
- <A HREF="dhcp_addr_ref.html">addresses listed by</A><BR>
- <A HREF="dhcp_addr_wiz.html#name">generating</A><BR>
- <A HREF="dhcp_config_wiz.html#dns">resolution of</A><BR>
-
-How To...<br>
-
-
- <a href="dhcp_addr_how.html">manage addresses</a><br>
- <a href="dhcp_relay_how.html#adv">manage BOOTP relay agents</a><br>
- <a href="dhcp_main_how.html">list of procedures</a><br>
- <a href="dhcp_relay_how.html#adv">manage DHCP servers</a><br>
- <a href="dhcp_macro_how.html">manage macros</a><br>
- <a href="dhcp_relay_how.html#ntwrk">manage networks</a><br>
- <a href="dhcp_option_how.html">manage options</a><br>
-
-
-<!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>I</em></strong> <img src="art/dot1.gif" border="0"><p>
-
-<a href="dhcp_main_top.html"><tt>in.dhcpd</tt> command</a><br>
-
-interfaces<BR>
- <A HREF="dhcp_relay_serv.html#inter">monitored by BOOTP relay agent</A><BR>
- <a href="dhcp_server_serv.html#inter">monitored by DHCP server</a><br>
-
-IP address<br>
-
- <a
- href="dhcp_solaris_about.html#ip">allocating</a><br>
-
- <a
- href="dhcp_relay_ref.html">BOOTP forwarding</a><br>
-
- <a href="dhcp_addr_ref.html">client</a><br>
-
- <a
- href="dhcp_addr_ref.html#status">lease offer</a><br>
-
- <a href="dhcp_macros_about.html#ip">macro</a><br>
-
- <a
- href="dhcp_addr_ref.html#server">owning server</a><br>
-
- <a href="dhcp_addr_wiz.html#startaddr">range</a><br>
-
-<!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>L</em></strong> <img src="art/dot1.gif" border="0"><p>
-
-lease<br>
-
- <a href="dhcp_addr_ref.html#status">attributes</a><br>
-
- <a
- href="dhcp_config_wiz.html#lease">policy</a><br>
-
- <a href="dhcp_addr_ref.html#status">time</a><br>
-
-<a href="dhcp_server_serv.html#log">logging, verbose</a><br>
-
-
-
-<!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>M</em></strong> <img src="art/dot1.gif" border="0"> --<A HREF="#top"><small>return to top</small></A>--<p>
-
-macros<br>
-
- <a href="dhcp_macros_about.html">about</a><br>
- <a href="dhcp_macros_about.html#macrocat">categories</a><br>
- <a href="dhcp_macros_about.html#class">Client Class</a><br>
- <a href="dhcp_macros_about.html#cid">client ID</a><br>
- <a href="dhcp_macro_how.html#newmacro">creating</a><br>
- <a href="dhcp_macro_how.html#delmacro">deleting</a><br>
- <a href="dhcp_macro_how.html#dupmacro">duplicating</a><br>
- <a href="dhcp_macros_about.html#ip">IP address</a><br>
- <a href="dhcp_macro_how.html#modmacro">modifying</a><br>
- <a href="dhcp_macro_how.html#newmacro">naming</a><br>
- <A HREF="dhcp_macros_about.html#nest">nesting</A><BR>
- <a href="dhcp_macros_about.html#net">network</a><br>
- <a href="dhcp_macros_about.html#using">processing order</a><br>
- <a href="dhcp_macro_mod.html#name">properties</a><br>
- <a href="dhcp_macro_how.html#viewmacro">viewing</a><br>
-
-<A HREF="dhcp_addr_ref.html#status">manual address</A><BR>
-
-<a href="dhcp_option_ref.html#max">maximum, option</a><br>
-menus<BR>
- <A HREF="dhcp_addr_view.html">in address view</A><BR>
- <A HREF="dhcp_macro_view.html">in macro view</A><BR>
- <A HREF="dhcp_option_view.html">in option view</A><BR>
-
-<A HREF="dhcp_addr_view.html">Modify menu option</A><BR>
-
-modifying<br>
-
- <A HREF="dhcp_addr_how.html#modaddr">addresses</A><BR>
-
- <a href="dhcp_macro_how.html">macros</a><br>
-
- <a href="dhcp_addr_how.html#modaddr">network records</a><br>
-
- <a href="dhcp_option_how.html#modoption">option definitions</a><br>
-
-<!-- Index head -->
-
-<a name="n-r"></a>
-<p> <img src="art/dot1.gif" border="0"> <strong><em>N</em></strong> <img src="art/dot1.gif" border="0"><p>
-
-network<br>
-
- <a href="dhcp_addr_ref.html">DHCP network table</a><br>
- <A HREF="dhcp_relay_how.html#delnet">deleting</A><BR>
-
- <a href="dhcp_server_serv.html#inter">interfaces</a><br>
- <a href="dhcp_solaris_about.html#ntwrk">macros</a><br>
-
- <a href="dhcp_addr_ref.html">records</a><br>
-network macro<BR>
- <A HREF="dhcp_solaris_about.html#ntwrk">allocating</A><BR>
- <A HREF="dhcp_macros_about.html#net">description of</A><BR>
-
-<A HREF="dhcp_addr_view.html">Network scroll list</A><BR>
-
-<A HREF="dhcp_net_wiz.html">Network Wizard</A><BR>
-
-
-network tables<br>
-
- <a href="dhcp_addr_create.html">creating</a><br>
- <a href="dhcp_addr_ref.html">managing</a><br>
-
- <a href="dhcp_addr_ref.html">viewing properties</a><br>
-
-<A HREF="dhcp_config_wiz.html#nis">NIS name service, specifying</A><BR>
-
-
-
-<!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>O</em></strong> <img src="art/dot1.gif" border="0"> --<A HREF="#top"><small>return to top</small></A>--<p>
-
-options<br>
-
- <a href="dhcp_macros_about.html">about</a><br>
-
- category<BR>
- <A HREF="dhcp_option_ref.html#cat">Extended</A><BR>
- <A HREF="dhcp_option_ref.html#cat">Site</A><BR>
- <A HREF="dhcp_option_ref.html#cat">Standard</A><BR>
- <A HREF="dhcp_option_ref.html#cat">Vendor</A><BR>
-
- <a href="dhcp_option_ref.html#class">class</a><BR>
- <a href="dhcp_option_ref.html#code">code</a><br>
- <a href="dhcp_option_how.html#newoption">creating</a><br>
-
- data type<BR>
- <A HREF="dhcp_option_ref.html#type">ASCII</A><BR>
- <A HREF="dhcp_option_ref.html#type">Boolean</A><BR>
- <A HREF="dhcp_option_ref.html#type">IP</A><BR>
- <A HREF="dhcp_option_ref.html#type">Number</A><BR>
- <A HREF="dhcp_option_ref.html#type">Octet</A><BR>
-
- <a href="dhcp_option_how.html#deloption">deleting</a><br>
- <a href="dhcp_macros_about.html"><tt>dhcptab</tt></a><br>
- <a href="dhcp_option_how.html#dupoption">duplicating</a><br>
- <a href="dhcp_option_ref.html#gran">granularity</a><br>
- <a href="dhcp_option_ref.html#max">maximum</a><br>
- <a href="dhcp_option_how.html#modoption">modifying</a><br>
- <A HREF="dhcp_option_ref.html#name">naming</A><BR>
- <a href="dhcp_option_ref.html">overview</a><br>
- <a href="dhcp_option_mod.html">properties</a><br>
- <A HREF="dhcp_option_tags.html">standard, list of</A><BR>
- <a href="dhcp_option_ref.html#type">type</a><br>
- <a href="dhcp_option_create.html#class">Vendor Client Class</a><br>
- <a href="dhcp_option_how.html">viewing</a><br>
-
-<a href="dhcp_macros_about.html#using">order of processing</a><br>
-
-<a href="dhcp_server_serv.html#addrs">ownership of server addresses</a><br>
-
-<a href="dhcp_addr_ref.html#server">owning server</a><br>
-
-<!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>P</em></strong> <img src="art/dot1.gif" border="0"><p>
-
-<A HREF="dhcp_addr_ref.html" NAME="status">permanent address</A><BR>
-<a href="dhcp_main_top.html"><tt>pntadm</tt> command</a><br>
-
-<A HREF="dhcp_addr_view.html">Properties menu option</A><BR>
-
-<!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>R</em></strong> <img src="art/dot1.gif" border="0"> --<A HREF="#top"><small>return to top</small></A>--<p>
-
-<a href="dhcp_addr_ref.html">records, network</a><br>
-
-<A HREF="dhcp_addr_view.html">Refresh menu option</a><br>
-
-<a href="dhcp_main_hlp.html#info">related reading</a><br>
-
-<a href="dhcp_relay_ref.html">relay agents, BOOTP</a><br>
-
-<A HREF="dhcp_addr_how.html#reladdr">release address</A><BR>
-
-<A HREF="dhcp_addr_view.html">Restart menu option</A><BR>
-
-<a href="dhcp_relay_how.html#start">restart server</a><br>
-
-<A HREF="dhcp_config_wiz.html#router">router</A><BR>
-
-
-<!-- Index head -->
-
-<a name="s-z"></a>
-<p> <img src="art/dot1.gif" border="0"> <strong><em>S</em></strong> <img src="art/dot1.gif" border="0"><p>
-
-<A HREF="dhcp_addr_view.html">Service menu</A><BR>
-
-<A HREF="dhcp_macros_about.html#ip">server-specific parameters</A><BR>
-
-servers<BR>
- <a href="dhcp_relay_ref.html">and relay agents</a><BR>
- <A HREF="dhcp_addr_ref.html#server">owning</A><BR>
-
- <A HREF="dhcp_addr_view.html">Show Grid menu option</A><BR>
-
-<A HREF="dhcp_addr_view.html">Show Hostnames menu option</A><BR>
-
-<A HREF="dhcp_option_ref.html#cat">site option</A><BR>
-
-<a href="dhcp_solaris_about.html">Solaris DHCP, about</a><br>
-
-<A HREF="dhcp_option_ref.html">standard option</A><BR>
-
-<A HREF="dhcp_addr_view.html">Start menu option</A><BR>
-
-<A HREF="dhcp_addr_view.html">Stop menu option</A><BR>
-
-<A HREF="dhcp_config_wiz.html#net">subnet mask</A><BR>
-
-<A HREF="dhcp_server_serv.html#log"><TT>syslogd</TT> facility</A><BR>
-
-<!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>T</em></strong> <img src="art/dot1.gif" border="0"> --<A HREF="#top"><small>return to top</small></A>--<p>
-
-tables<br>
-
- <a href="dhcp_addr_ref.html">client records</a><br>
-
- <a href="dhcp_solaris_about.html"><tt>dhcptab</tt></a><br>
-
- <br>
- <a href="dhcp_addr_ref.html">network</a><br>
-
- <a href="dhcp_server_serv.html#rescan">rescan interval</a><br>
-
-
- <!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>U</em></strong> <img src="art/dot1.gif" border="0"><p>
-
-<A HREF="dhcp_addr_view.html">Unconfigure menu option</A><BR>
-
-<A HREF="dhcp_addr_create.html#unusable">unusable address</A><BR>
-
-<A HREF="dhcp_addr_view.html">update server data</A><BR>
-
-
-<!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>V</em></strong> <img src="art/dot1.gif" border="0"><p>
-
-<A HREF="dhcp_option_ref.html#cat">vendor option</A><BR>
-
-<a href="dhcp_server_serv.html#log">verbose logging</a><br>
-
-<A HREF="dhcp_addr_view.html">View menu</A><BR>
-
-viewing<br>
- <a href="dhcp_addr_ref.html">addresses</a><br>
- <a href="dhcp_macro_ref.html">macros</a><br>
- <a href="dhcp_option_ref.html">options</a><br>
-
-
-
-
-<!-- Index head -->
-
-<p> <img src="art/dot1.gif" border="0"> <strong><em>W</em></strong> <img src="art/dot1.gif" border="0"><p>
-
-wizards<BR>
- <a href="dhcp_addr_wiz.html">Address Wizard</a><br>
- <a href="dhcp_config_wiz.html">DHCP Server Configuration Wizard</a><br>
- <a href="dhcp_net_wiz.html">Network Wizard</a><br>
-
-<p> </p>
- <A HREF="#top"><small>return to top</small></A>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_menus.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_menus.html deleted file mode 100644 index 7064c6c5b4..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_menus.html +++ /dev/null @@ -1,128 +0,0 @@ -<!-- - -- ident "%W% %E% SMI" - -- - Copyright 2005 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - --> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Menus</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=625>
-
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="left" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
-
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
-
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT=""><STRONG>Menus</STRONG><BR>
- <A HREF="dhcp_addr_view.html">Address View</A><BR>
- <A HREF="dhcp_macro_view.html">Macro View</A><BR>
- <A HREF="dhcp_option_view.html">Option View</A><P>
-
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" WIDTH="495">
-<P> </P>
-
-
- <H1>Menus</H1>
-The DHCP Manager windows have five menu buttons: File, Edit, View, Service, and Help.
-The menu options differ depending on which view being displayed.
-<UL>
-<LI><A HREF="dhcp_addr_view.html">Address View</A>
-<LI><A HREF="dhcp_macro_view.html">Macro View</A>
-<LI><A HREF="dhcp_option_view.html">Option View</A>
-</UL>
-The Network scroll box is available only with the Address view.
-
-
-<p> </p>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_top.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_top.html deleted file mode 100644 index a592cffec6..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_main_top.html +++ /dev/null @@ -1,182 +0,0 @@ -<!-- - -- ident "%W% %E% SMI" - -- - Copyright 2005 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - --> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Introduction</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#ffffff">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="left" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT=""><STRONG>Overview</STRONG><BR>
- <A HREF="dhcp_solaris_about.html">Solaris DHCP</A><BR>
- <A HREF="dhcp_macros_about.html">About Macros</A><BR>
- <A HREF="dhcp_main_hlp.html">Getting Help</A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" width="495">
-
-
-
-<P> </P>
-
-
-<H1>About DHCP Manager</H1>
-
-DHCP Manager provides an integrated Java-based graphical
-interface for Solaris<FONT SIZE="-1"><sup>TM</sup></FONT> DHCP management functions that can also be performed from the Solaris
-command line. DHCP Manager provides functions that are analogous to those available from:<p>
-
- <ul>
-
- <li><tt>dhcpconfig</tt> -- DHCP service
- configuration utility</li>
- <li><tt>dhtadm</tt> -- DHCP configuration table
- management utility</li>
- <li><tt>pntadm</tt> -- DHCP network table
- management utility</li>
- <li><tt>in.dhcpd</tt> -- DHCP server and BOOTP relay
- daemon</li>
-
- </ul>
-
-<p>You can use DHCP Manager in place of, or in combination with, all command-line-based Solaris DHCP functions.<p>
-
-DHCP Manager provides several benefits, compared with its command-line counterparts:<p>
-
- <ul>
-
- <li>A convenient, integrated "point-and-click" interface for the Solaris
- DHCP server's most sophisticated functions.<p></li>
-
- <li>A graphical view of the relationships between <tt>dhcptab</tt> macros and options, making it easier for
- you to determine where to place option values for the most efficient
- client configurations.<p></li>
-
- <li>DHCP management wizards that guide you through tasks such as
- configuring the DHCP server, configuring networks, and adding addresses.<p></li>
-
- </ul>
-
-Of course, the command-line utilities are still useful for creating shell scripts for batch-processing administrative tasks.<P>
-
-<STRONG>Use DHCP Manager to</STRONG>
-
-<UL>
-<LI><a href="dhcp_relay_ref.html">Manage DHCP servers and BOOTP relay agents</a></LI>
-<LI><a href="dhcp_net_wiz.html">Manage networks</a></LI>
-<LI><a href="dhcp_addr_ref.html">Manage IP addresses</a></LI>
-<LI><a href="dhcp_macro_ref.html">Manage DHCP macros</a></LI>
-<LI><a href="dhcp_option_ref.html">Manage DHCP options</a></LI>
-</UL>
-
-<STRONG>For more information, see</STRONG>
-
-<UL>
-<LI><A HREF="dhcp_solaris_about.html">About Solaris DHCP</A></LI>
-<LI><A HREF="dhcp_macros_about.html">About Macros and Options</A></LI>
-<LI><A HREF="dhcp_main_menus.html">Menus</A></LI>
-<LI><A HREF="dhcp_main_hlp.html">Getting Help</A></LI>
-</UL>
-<P>
-
- <A HREF="#top"><small>return to top</small></A>
-<P> </P>
-
-
-
-
-
-
-
-<!-- Don't go past this line! -->
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-
-</table>
-
-
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_net_del.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_net_del.html deleted file mode 100644 index 0e762416a0..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_net_del.html +++ /dev/null @@ -1,119 +0,0 @@ -<!-- - -- ident "%W% %E% SMI" - -- - Copyright 2005 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - --> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Delete Networks</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-<TR>
-
-<!-- Start navigation banner -->
-<td colspan=4 valign="top" WIDTH="615">
-
-<IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help"></TD></TR>
-</TABLE>
-
-<!-- End navigation banner -->
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-<tr>
-
-<!-- Start contents block -->
-
-
- <td colspan=1 valign="top" WIDTH="105">
- <BR>
-
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
-
-<BR>
-
-<h1>Delete Networks</h1>
-The Keep Networks list displays the networks configured for this server. To delete a network is to remove it from the list of networks for this server to monitor.<P>
-Use the arrow keys to move a network into the Delete Networks list.<P>
-<STRONG>Delete Hosts Table Entries:</STRONG> Check this box to remove from the <tt>hosts</tt> table all host names associated with the deleted network(s).
-<P>
-To restore or add a network to the list of configured networks, you must configure it using the <A HREF="dhcp_net_wiz.html">Network Wizard</A>.
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_net_ref.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_net_ref.html deleted file mode 100644 index 7b81dd8f6d..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_net_ref.html +++ /dev/null @@ -1,121 +0,0 @@ -<!-- - -- ident "%W% %E% SMI" - -- - Copyright 2005 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - --> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Networks</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head><body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relay Agents</STRONG></A><P>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT=""><STRONG>Networks</STRONG><BR>
- <A HREF="dhcp_net_wiz.html">Network Wizard</A>
- <A HREF="dhcp_net_del.html">Delete Networks</A><P>
-
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-<h1>Networks</h1>
-The DHCP server is connected to one or more networks. One network is configured when the DHCP server is first configured.<P>
-To add one or more networks to those monitored by the DHCP server, choose the <A HREF="dhcp_net_wiz.html">Network Wizard</A>, available from the Edit menu, when the Address view is displayed.<P>
-To remove configured networks from those monitored by the DHCP server, choose <A HREF="dhcp_net_del.html">Delete Networks</A> from the Edit menu .
-
-
-<p> </p>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_net_wiz.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_net_wiz.html deleted file mode 100644 index 67ec2f8e9b..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_net_wiz.html +++ /dev/null @@ -1,185 +0,0 @@ -<!--
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License (the "License"). - You may not use this file except in compliance with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- -- Use is subject to license terms.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Adding a Network</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="left" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
-
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><BR>
- <A HREF="dhcp_config_wiz.html">DHCP Config</A><BR>
- <A HREF="dhcp_relay_config.html">Relay Config</A><BR>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Net Config<BR>
- <a href="#addr"><EM>Address</EM></a><br>
- <a href="#info"><EM>Net Type</EM></a><br>
- <a href="#router"><EM>Router</EM></a><br>
- <a href="#nis"><EM>NIS</EM></a><br>
- <A HREF="dhcp_server_serv.html">DHCP Services</A><BR>
- <A HREF="dhcp_relay_serv.html">Relay Services</A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff">
-
-
-
-<P> </P>
-
-
-
-<h1>Network Wizard</h1>
-The Network Wizard guides you through the steps to add a new network to the DHCP server's list of configured networks. The Network Wizard is available from the Edit menu, when the Address view is displayed.<P>
-<p>
-
-To enter information, double-click in the field, enter the desired value, and then press Enter.
-
-The following table describes the information required to add a network to the DHCP server.
-<P><HR NOSHADE><P>
-<P>
-
- <table border=0 cellspacing=3 cellpadding=3>
- <tr>
- <td width=125 valign="top"><A NAME="addr"><STRONG>Network Address</STRONG></A></td>
- <td valign="top">
- Enter the IP address of the network you are configuring.<p>
- </td>
- </tr>
-
- <tr>
- <td width=125 valign="top"><A NAME="info"><STRONG>Subnet Mask</STRONG></A><br></td>
- <td valign="top">
- Enter the subnet mask for this network. A subnet mask is a way of dividing
- up the host portion of an Internet address to form local subnetworks.
- </TD></TR>
-
- <tr>
- <td width=125 valign="top"><A NAME="info"><STRONG>Network Type</STRONG></A><br></td>
- <td valign="top">
- Specify whether the network is a local area network (LAN) or point-to-point (PPP).<p>
-
-
- </TD>
- </tr>
-
- <tr>
- <td width=125 valign="top"><A NAME="router"><STRONG>Routing</STRONG></A></td>
- <td valign="top">A router is a machine with multiple network
- interfaces that can forward IP packets from one network to
- another. In most cases, your clients should use router discovery to
- connect to a router. If you have clients in your network that cannot
- use router discovery, enter the IP address of a router which
- they can use to communicate with systems on another network.
- </td>
- </tr>
-
-
-
- <tr>
- <td width=125 valign="top"><A NAME="nis"><STRONG>NIS Domain</STRONG></A><br>
- <STRONG>NIS Servers</STRONG></td>
- <td width=315 valign="top">If the server is configured to use NIS naming service,
- the NIS server information will be filled in. If not, you can enter the domain
- name and IP address of one or more NIS name servers.<P>
-
- The order in which the address appears in the list determines the order in
- which the servers are queried.
- </td>
- </tr>
-
-</table>
- <A HREF="#top"><small>return to top</small></A>
-
-
-
-<p> </p>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_create.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_create.html deleted file mode 100644 index 7ba6f4b04b..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_create.html +++ /dev/null @@ -1,311 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Create Option</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><BR>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Create<BR>
- <A HREF="#name"><EM>Name</EM></A><BR>
- <A HREF="#cat"><EM>Category</EM></A><BR>
- <A HREF="#code"><EM>Code</EM></A><BR>
- <A HREF="#type"><EM>Data Type</EM></A><BR>
- <A HREF="#gran"><EM>Granularity</EM></A><BR>
- <A HREF="#max"><EM>Maximum</EM></A><BR>
- <A HREF="#class"><EM>Class</EM></A><BR>
- <A HREF="dhcp_option_dup.html">Duplicate</A><BR>
- <A HREF="dhcp_option_mod.html">Modify</A><BR>
- <A HREF="dhcp_option_del.html">Delete</A><BR>
- <A HREF="dhcp_option_tags.html">Standard options</A> <P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-<h1>Create Option</h1>
-
-The Create Option dialog box lets you create new option definitions in the
-<tt>dhcptab</tt> on the selected DHCP server. <p>
-
-See <a href="dhcp_macros_about.html">
-About Macros and Options</a>, for more information about defining DHCP options.<p>
-The settings in the Create Option dialog box are described in the following table.
-<P><HR NOSHADE><P>
-
-
- <table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><a name="name"><STRONG>Name</STRONG></a></td>
- <td valign="top">The name of the option.
- Option names can be a maximum of 128 alphanumeric characters including spaces.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a name="cat"><STRONG>Category</STRONG></a></td>
- <td valign="top">The category of the option:
- The category can be one of Site, Extend, or Vendor.<P>
- <table border=0 cellspacing=3 cellpadding=3>
-
-
- <tr>
- <td width=100 valign="top"><U>Site</U></td>
- <td valign="top">User-defined option definitions, used for
- unique or custom purposes; accepts <a href="#code">Option
- Codes</a> <tt>128-254</tt>.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Extend</U></td>
- <td valign="top">Option definitions beyond the standard set,
- which may already be present in versions of the DHCP protocol
- being used on your server. Rather than upgrading your DHCP
- implementation, you can add extended options; accepts Option
- Codes <tt>77-127</tt>.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Vendor</U></td>
- <td valign="top">Hardware-, vendor-, or platform-specific option
- definitions; accepts Option Codes <tt>1-254</tt>. Selecting this
- context enables the <a href="#class">Client Class</a>
- parameter.</td>
- </tr>
-
- </table>
- </td>
- </tr>
-
-
- <tr>
- <td width=115 valign="top"><a name="code"><STRONG>Code</STRONG></a></td>
- <td valign="top">A unique numeric code to
- identify the option. Valid values depend on the option <a
- href="#cat">category</a>:<P>
-
- <table border=0 cellspacing=3 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><U>Extend</U></td>
- <td valign="top">Accepts code values of <tt>77-127</tt><P></TD>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Site</U></td>
- <td valign="top">Accepts code values of <tt>128-254</tt><P></TD>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Vendor</U></td>
- <td valign="top">Accepts code values of <tt>1-254</tt></td>
- </tr>
-
-</table>
-<P>
-</td>
-
- </tr>
-
- <tr>
- <td width=100 valign="top"><A NAME="type"><STRONG>Data Type</STRONG></A></td>
- <td valign="top">The type of data that is acceptable
- for options values:<P>
-
- <table border=0 cellspacing=3 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><u>Ascii</u></td>
- <td valign="top">ASCII text.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><u>Boolean</u></td>
- <td valign="top">No value is associated with this data type.
- Presence of options of this type denote Boolean TRUE; absence
- denotes FALSE.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><u>IP</u></td>
- <td valign="top">One or more Internet addresses in dotted decimal format.</td>
- </tr>
- <tr>
- <td width=100 valign="top"><u>Octet</u></td>
- <td valign="top">Uninterpreted ASCII representation of binary
- data; for example, a client ID.</td>
- </tr>
- <tr>
- <td width=100 valign="top"><u>Unumber8</u><BR><u>Unumber16</u><BR>
-<u>Unumber32</u><BR><u>Unumber64</u><BR>
-
-</td>
- <td valign="top">Unsigned number, where the trailing number indicates the number of bits in the number.</td>
- </tr>
- <tr>
- <td width=100 valign="top"><u>Snumber8</u><BR><u>Snumber16</u><BR>
-<u>Snumber32</u><BR><u>Snumber64</u><BR>
-</td>
- <td valign="top">Signed number, where the trailing number indicates the number of bits in the number.</td>
- </tr>
-
- </table>
- </td>
- </tr>
-
-
- <tr>
- <td width=100 valign="top"><a name="gran"><STRONG>Granularity</STRONG></a></td>
- <td valign="top">Specifies how many values of the given <a
- href="#type">data type</a> are required to make a complete option value.
- For example, a data type of <tt>IP</tt> and a granularity of <tt>2</tt> would
- mean that the option value would need to contain two IP addresses.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a name="max"><STRONG>Maximum</STRONG></a></td>
- <td valign="top">The maximum number of values of a
- given granularity that can be specified for the option. Building on the
- previous example, a maximum of <tt>2</tt>, with a granularity of
- <tt>2</tt> and a data type of <tt>IP</tt> would mean that the option
- value could contain a maximum of two pairs of IP addresses.<P>
-
- <table border=0>
-
- <tr>
- <td width=100 valign="top"><U>Unlimited</U></td>
- <td valign="top">No limit to the number of values; implies a
- maximum setting of <tt>0</tt>.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Specify</U></td>
- <td valign="top">A specific number indicating the maximum.</td>
- </tr>
-
- </table>
- </td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><A NAME="class"><STRONG>Vendor Client Classes</STRONG></A></td>
- <td valign="top">This option is enabled only when the option
- <a href="#cat">category</a> is Vendor. It identifies the client class(es) with which the Vendor option is
- associated.<P>
- The Class is an ASCII string representing the client machine type and/or operating system, for example, <TT>SUNW.Ultra5_10</TT>. This type of option makes it possible to define configuration parameters that are passed to all clients of the same class. <P>
- Enter the client class and then press Enter. You can
- specify multiple client classes. Only those DHCP clients with a client
- class value matching one listed here will use the option.</td>
- </tr>
-
- </table>
- <P>
-
-
-<strong>Notify DHCP Server of Change:</STRONG> Check the box if
-you want the DHCP server to reload the <tt>dhcptab</tt> immediately after
-the data is written. Normally, you will want this to
-happen. However, if you are making multiple changes, you may choose
-to wait so that the server reloads only after all the
-changes are written. <P>
- <A HREF="#top"><small>return to top</small></A>
-
-<p> </p>
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_del.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_del.html deleted file mode 100644 index a8d556e7f3..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_del.html +++ /dev/null @@ -1,128 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Delete Option</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><BR>
- <A HREF="dhcp_option_create.html">Create</A><BR>
- <A HREF="dhcp_option_mod.html">Modify</A><BR>
- <A HREF="dhcp_option_dup.html">Duplicate</A><BR>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Delete<P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-<h1>Delete Option</h1>
-
-Click OK to remove the selected option from the <tt>dhcptab</tt>.
-<P>
-<strong>Notify DHCP Server of Change:</STRONG> Check the box if
-you want the DHCP server to reload the <tt>dhcptab</tt> immediately after
-the data is written. Normally, you will want this to
-happen. However, if you are making multiple changes, you may choose
-to wait so that the server reloads only after all the
-changes are written. <P>
-
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_dup.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_dup.html deleted file mode 100644 index a9fccd9d41..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_dup.html +++ /dev/null @@ -1,310 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Duplicate Option</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
-<STRONG>Options</STRONG><BR>
-
- <A HREF="dhcp_option_create.html">Create</A><BR>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Duplicate<BR>
- <A HREF="#name"><EM>Name</EM></A><BR>
- <A HREF="#cat"><EM>Category</EM></A><BR>
- <A HREF="#code"><EM>Code</EM></A><BR>
- <A HREF="#type"><EM>Data Type</EM></A><BR>
- <A HREF="#gran"><EM>Granularity</EM></A><BR>
- <A HREF="#max"><EM>Maximum</EM></A><BR>
- <A HREF="#class"><EM>Class</EM></A><BR>
- <A HREF="dhcp_option_mod.html">Modify</A><BR>
- <A HREF="dhcp_option_del.html">Delete</A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-
-<h1>Duplicate Option</h1>
-
-The Duplicate Option dialog box provides a simple way to create a new option by copying some
-or all the properties of an existing option in the DHCP network tables. <p>
-
-See <a href="dhcp_macro_ref.html">
-About Macros and Options</a>, for more information about defining DHCP options.<p>
-The settings in the Duplicate Option dialog box are described in the following table.<P>
-
-<P><HR NOSHADE><P>
-
-<table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><a name="name"><STRONG>Name</STRONG></a></td>
- <td valign="top">The name of the option.
- Option names can be a maximum of 128 alphanumeric characters including spaces.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a name="cat"><STRONG>Category</STRONG></a></td>
- <td valign="top">The category of the option:
- The category can be one of Site, Extend, or Vendor.<P>
- <table border=0 cellspacing=3 cellpadding=3>
-
-
- <tr>
- <td width=100 valign="top"><U>Site</U></td>
- <td valign="top">User-defined option definitions, used for
- unique or custom purposes; accepts <a href="#code">Option
- Codes</a> <tt>128-254</tt>.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Extend</U></td>
- <td valign="top">Option definitions beyond the standard set,
- which may already be present in versions of the DHCP protocol
- being used on your server. Rather than upgrading your DHCP
- implementation, you can add extended options; accepts Option
- Codes <tt>77-127</tt>.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Vendor</U></td>
- <td valign="top">Hardware-, vendor-, or platform-specific option
- definitions; accepts Option Codes <tt>1-254</tt>. Selecting this
- context enables the <a href="#class">Client Class</a>
- parameter.</td>
- </tr>
-
- </table>
- </td>
- </tr>
-
-
- <tr>
- <td width=115 valign="top"><a name="code"><STRONG>Code</STRONG></a></td>
- <td valign="top">A unique numeric code to
- identify the option. Valid values depend on the option <a
- href="#cat">category</a>:<P>
-
- <table border=0 cellspacing=3 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><U>Extend</U></td>
- <td valign="top">Accepts code values of <tt>77-127</tt><P></TD>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Site</U></td>
- <td valign="top">Accepts code values of <tt>128-254</tt><P></TD>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Vendor</U></td>
- <td valign="top">Accepts code values of <tt>1-254</tt></td>
- </tr>
-
-</table>
-
-
-<P>
-</td>
-
- </tr>
-
- <tr>
- <td width=100 valign="top"><A NAME="type"><STRONG>Data Type</STRONG></A></td>
- <td valign="top">The type of data that is acceptable
- for options values:<P>
- <table border=0 cellspacing=3 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><u>Ascii</u></td>
- <td valign="top">ASCII text.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><u>Boolean</u></td>
- <td valign="top">No value is associated with this data type.
- Presence of options of this type denote Boolean TRUE; absence
- denotes FALSE.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><u>IP</u></td>
- <td valign="top">One or more Internet addresses in dotted decimal format.</td>
- </tr>
- <tr>
- <td width=100 valign="top"><u>Octet</u></td>
- <td valign="top">Uninterpreted ASCII representation of binary
- data; for example, a client ID.</td>
- </tr>
- <tr>
- <td width=100 valign="top"><u>Unumber8</u><BR><u>Unumber16</u><BR>
-<u>Unumber32</u><BR><u>Unumber64</u><BR>
-
-</td>
- <td valign="top">Unsigned number, where the trailing number indicates the number of bits in the number.</td>
- </tr>
- <tr>
- <td width=100 valign="top"><u>Snumber8</u><BR><u>Snumber16</u><BR>
-<u>Snumber32</u><BR><u>Snumber64</u><BR>
-</td>
- <td valign="top">Signed number, where the trailing number indicates the number of bits in the number.</td>
- </tr>
-
- </table>
- </td>
- </tr>
-
-
- <tr>
- <td width=100 valign="top"><a name="gran"><STRONG>Granularity</STRONG></a></td>
- <td valign="top">Specifies how many values of the given <a
- href="#type">data type</a> are required to make a complete option value.
- For example, a data type of <tt>IP</tt> and a granularity of <tt>2</tt> would
- mean that the option value would need to contain two IP addresses.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a name="max"><STRONG>Maximum</STRONG></a></td>
- <td valign="top">The maximum number of values of a
- given granularity that can be specified for the option. Building on the
- previous example, a maximum of <tt>2</tt>, with a granularity of
- <tt>2</tt> and a data type of <tt>IP</tt> would mean that the option
- value could contain a maximum of two pairs of IP addresses.<P>
-
- <table border=0>
-
- <tr>
- <td width=100 valign="top"><U>Unlimited</U></td>
- <td valign="top">No limit to the number of values; implies a
- maximum setting of <tt>0</tt>.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Specify</U></td>
- <td valign="top">A specific number indicating the maximum.</td>
- </tr>
-
- </table>
- </td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><A NAME="class"><STRONG>Vendor Client Classes</STRONG></A></td>
- <td valign="top">This option is enabled only when the option
- <a href="#cat">category</a> is Vendor. It identifies the client class(es) with which the Vendor option is
- associated.<P>
- The Class is an ASCII string representing the client machine type and/or operating system, for example, <TT>SUNW.Ultra5_10</TT>. This type of option makes it possible to define configuration parameters that are passed to all clients of the same class. <P>
- Enter the client class and then press Enter. You can
- specify multiple client classes. Only those DHCP clients with a client
- class value matching one listed here will use the option.</td>
- </tr>
-
- </table>
-<p>
-<strong>Notify DHCP Server of Change:</STRONG> Check the box if
-you want the DHCP server to reload the <tt>dhcptab</tt> immediately after
-the data is written. Normally, you will want this to
-happen. However, if you are making multiple changes, you may choose
-to wait so that the server reloads only after all the
-changes are written. <P>
- <A HREF="#top"><small>return to top</small></A>
-
-<p> </p>
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_how.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_how.html deleted file mode 100644 index a958929ac1..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_how.html +++ /dev/null @@ -1,225 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: How To... Options</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relay Agents</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><BR>
- <A HREF="dhcp_relay_how.html">Servers</A><BR>
- <A HREF="dhcp_addr_how.html">Addresses</A><BR>
- <A HREF="dhcp_macro_how.html">Macros</A><BR>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Options<BR>
- <a href="#viewoption"><EM>View</EM></a><BR>
- <a href="#newoption"><EM>Create</EM></a><BR>
- <a href="#dupoption"><EM>Duplicate</EM></a><BR>
- <a href="#modoption"><EM>Modify</EM></a><BR>
- <a href="#deloption"><EM>Delete</EM></a><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff">
-<P> </P>
-<H1>How To: Options</H1>
-
-<strong><big><A NAME="viewoption">View Options</A></big></strong><p>
-
-<strong>Choose the <A HREF="dhcp_option_ref.html">Options</A> tab in the main window.</strong>
- <p>
-
- DHCP Manager displays a list of options in the
- DHCP server's <tt>dhcptab</tt>.<p>
-
-
-<HR NOSHADE>
-
-<strong><big><A NAME="newoption">Create</A> a New Option</big></strong><p>
-
- <ol type=1>
-
- <LI><strong>Choose the <A HREF="dhcp_option_ref.html">Options</A> tab in the main window.</strong><BR>
- DHCP Manager displays a list of options in the DHCP
-database.<P></li>
- <LI><strong>Choose <a href="dhcp_option_create.html">Create</A> from the Edit menu.</strong><BR>
-
- The Create Option dialog box opens.<p></li>
-
- <li><strong>Enter the desired settings for the new
- option.</strong><BR>
- You can enter the following settings in the Create Option dialog box:
-<UL TYPE="DISC">
-<LI>Option name</LI>
-<LI>Category</LI>
-<LI>Client Class</LI>
-<LI>Code</LI>
-<LI>Data type</LI>
-<LI>Granularity</LI>
-<LI>Maximum</LI>
-</UL><P>
- <li><strong>Click OK to accept your settings.</strong><BR>
-
- The new option definition is stored in the <tt>dhcptab</tt>,
- and is available to include in a macro.
- <p></li>
-
- </ol>
-
-<HR NOSHADE>
-
-<strong><big><A NAME="dupoption">Duplicate an Option Definition</A></big></strong><p>
-
- <ol type=1>
-
- <LI><strong>Choose the <A HREF="dhcp_option_ref.html">Options</A> tab in the main window.</strong><BR>
-
- DHCP Manager displays a list of options.<P></LI>
-
- <li><strong>Choose the option definition you want to
- duplicate.</strong></li><P>
-
- <li><strong>Choose <A HREF="dhcp_option_dup.html">Duplicate</A> from the Edit menu.</strong><BR>
-
- The Duplicate Option Properties dialog box is displayed. The fields display the settings of the selected option.<p></li>
-
- <li><strong>Enter a name for the new option.</strong></li><p>
-
- <li><strong>Modify the option definition settings as desired, and then
- click OK.</strong><BR>
- The new option definition is stored in the <tt>dhcptab</tt>.</li>
-</OL>
-
-
-<HR NOSHADE>
-<strong><big><A NAME="modoption">Modify an Option Definition</A></big></strong><p>
- <ol type=1>
-
- <LI><strong>Choose the <A HREF="dhcp_option_ref.html">Options</A> tab in the main window.</strong><BR>
- DHCP Manager displays a list of options.<P></LI>
-
- <li><strong>Choose the option definition you want to
- modify.</strong><p></li>
-
- <li><strong>Double-click the option or choose <A HREF="dhcp_option_mod.html">Properties</A> from the
- Edit menu.</strong><BR>
- The Option Properties dialog box is displayed.<p></li>
-
- <li><strong>Modify the option definition settings as desired, and then
- click OK.</strong><BR>
- The new settings are updated in the <tt>dhcptab</tt>.</li>
-
- </ol>
-
-<HR NOSHADE>
-
-<strong><big><A NAME="deloption">Delete an Option Definition</A></big></strong><p>
-
- <ol type=1>
-
- <LI><strong>Choose the <A HREF="dhcp_option_ref.html">Options</A> tab in the main window.</strong><BR>
-
- DHCP Manager displays the list of defined options. <p></li>
-
- <li><strong>Choose the option definition you want to
- delete.</strong><p></li>
-
- <li><strong>Choose <A HREF="dhcp_option_del.html">Delete</A> from the Edit menu.</strong><BR>
-
- The option definition is deleted from the <tt>dhcptab</tt>
- database.<p></li>
-
- </ol>
- <A HREF="#top"><small>return to top</small></A>
-
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_mod.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_mod.html deleted file mode 100644 index f074c4d040..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_mod.html +++ /dev/null @@ -1,316 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Modify Option</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><BR>
- <A HREF="dhcp_option_create.html">Create</A><BR>
- <A HREF="dhcp_option_dup.html">Duplicate</A><BR>
-
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Modify<BR>
- <A HREF="#name"><EM>Name</EM></A><BR>
- <A HREF="#cat"><EM>Category</EM></A><BR>
- <A HREF="#code"><EM>Code</EM></A><BR>
- <A HREF="#type"><EM>Data Type</EM></A><BR>
- <A HREF="#gran"><EM>Granularity</EM></A><BR>
- <A HREF="#max"><EM>Maximum</EM></A><BR>
- <A HREF="#class"><EM>Class</EM></A><BR>
-
- <A HREF="dhcp_option_del.html">Delete</A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-
-<h1>Modify Option</h1>
-
-The Option Properties dialog box lets you modify existing settings for an option in the
-DHCP server's network database. <p>
-
-See <a href="dhcp_macros_about.html">
-About Macros and Options</a>, for more information about defining DHCP options.<p>
-The settings in the Modify Option dialog box are described in the following table.<P>
-<P><HR NOSHADE><P>
-
-
-<table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><a name="name"><STRONG>Name</STRONG></a></td>
- <td valign="top">The name of the option.
- Option names can be a maximum of 128 alphanumeric characters including spaces.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a name="cat"><STRONG>Category</STRONG></a></td>
- <td valign="top">The category of the option:
- The category can be one of Site, Extend, or Vendor.<P>
- <table border=0 cellspacing=3 cellpadding=3>
-
-
- <tr>
- <td width=100 valign="top"><U>Site</U></td>
- <td valign="top">User-defined option definitions, used for
- unique or custom purposes; accepts <a href="#code">Option
- Codes</a> <tt>128-254</tt>.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Extend</U></td>
- <td valign="top">Option definitions beyond the standard set,
- which may already be present in versions of the DHCP protocol
- being used on your server. Rather than upgrading your DHCP
- implementation, you can add extended options; accepts Option
- Codes <tt>77-127</tt>.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Vendor</U></td>
- <td valign="top">Hardware-, vendor-, or platform-specific option
- definitions; accepts Option Codes <tt>1-254</tt>. Selecting this
- context enables the <a href="#class">Client Class</a>
- parameter.</td>
- </tr>
-
- </table>
- </td>
- </tr>
-
-
- <tr>
- <td width=115 valign="top"><a name="code"><STRONG>Code</STRONG></a></td>
- <td valign="top">A unique numeric code to
- identify the option. Valid values depend on the option <a
- href="#cat">category</a>:<P>
-
- <table border=0 cellspacing=3 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><U>Extend</U></td>
- <td valign="top">Accepts code values of <tt>77-127</tt><P></TD>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Site</U></td>
- <td valign="top">Accepts code values of <tt>128-254</tt><P></TD>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Vendor</U></td>
- <td valign="top">Accepts code values of <tt>1-254</tt></td>
- </tr>
-
-</table>
-
-<P>
-</td>
-
- </tr>
-
- <tr>
- <td width=100 valign="top"><A NAME="type"><STRONG>Data Type</STRONG></A></td>
- <td valign="top">The type of data that is acceptable
- for options values:<P>
-
- <table border=0 cellspacing=3 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><u>Ascii</u></td>
- <td valign="top">ASCII text.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><u>Boolean</u></td>
- <td valign="top">No value is associated with this data type.
- Presence of options of this type denote Boolean TRUE; absence
- denotes FALSE.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><u>IP</u></td>
- <td valign="top">One or more Internet addresses in dotted decimal format.</td>
- </tr>
- <tr>
- <td width=100 valign="top"><u>Octet</u></td>
- <td valign="top">Uninterpreted ASCII representation of binary
- data; for example, a client ID.</td>
- </tr>
- <tr>
- <td width=100 valign="top"><u>Unumber8</u><BR><u>Unumber16</u><BR>
-<u>Unumber32</u><BR><u>Unumber64</u><BR>
-
-</td>
- <td valign="top">Unsigned number, where the trailing number indicates the number of bits in the number.</td>
- </tr>
- <tr>
- <td width=100 valign="top"><u>Snumber8</u><BR><u>Snumber16</u><BR>
-<u>Snumber32</u><BR><u>Snumber64</u><BR>
-</td>
- <td valign="top">Signed number, where the trailing number indicates the number of bits in the number.</td>
- </tr>
-
- </table>
- </td>
- </tr>
-
-
- <tr>
- <td width=100 valign="top"><a name="gran"><STRONG>Granularity</STRONG></a></td>
- <td valign="top">Specifies how many values of the given <a
- href="#type">data type</a> are required to make a complete option value.
- For example, a data type of <tt>IP</tt> and a granularity of <tt>2</tt> would
- mean that the option value would need to contain two IP addresses.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a name="max"><STRONG>Maximum</STRONG></a></td>
- <td valign="top">The maximum number of values of a
- given granularity that can be specified for the option. Building on the
- previous example, a maximum of <tt>2</tt>, with a granularity of
- <tt>2</tt> and a data type of <tt>IP</tt> would mean that the option
- value could contain a maximum of two pairs of IP addresses.<P>
-
- <table border=0>
-
- <tr>
- <td width=100 valign="top"><U>Unlimited</U></td>
- <td valign="top">No limit to the number of values; implies a
- maximum setting of <tt>0</tt>.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Specify</U></td>
- <td valign="top">A specific number indicating the maximum.</td>
- </tr>
-
- </table>
- </td>
- </tr>
-
- - <tr>
- <td width=100 valign="top"><A NAME="class"><STRONG>Vendor Client Classes</STRONG></A></td>
- <td valign="top">This option is enabled only when the option
- <a href="#cat">category</a> is Vendor. It identifies the client class(es) with which the Vendor option is
- associated.<P>
- The Class is an ASCII string representing the client machine type and/or operating system, for example, <TT>SUNW.Ultra5_10</TT>. This type of option makes it possible to define configuration parameters that are passed to all clients of the same class. <P>
- Enter the client class and then press Enter. You can
- specify multiple client classes. Only those DHCP clients with a client
- class value matching one listed here will use the option.</td>
- </tr>
-
-
- </table>
- <P>
-
-<strong>Notify DHCP Server of Change:</STRONG> Check the box if
-you want the DHCP server to reload the <tt>dhcptab</tt> immediately after
-the data is written. Normally, you will want this to
-happen. However, if you are making multiple changes, you may choose
-to wait so that the server reloads only after all the
-changes are written. <P>
- <A HREF="#top"><small>return to top</small></A>
-
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_ref.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_ref.html deleted file mode 100644 index 724655b7f2..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_ref.html +++ /dev/null @@ -1,307 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Options</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT=""><STRONG>Options</STRONG><BR>
- <A HREF="#name"><EM>Name</EM></A><BR>
- <A HREF="#cat"><EM>Category</EM></A><BR>
- <A HREF="#code"><EM>Code</EM></A><BR>
- <A HREF="#type"><EM>Type</EM></A><BR>
- <A HREF="#gran"><EM>Granularity</EM></A><BR>
- <A HREF="#max"><EM>Maximum</EM></A><BR>
- <A HREF="#class"><EM>Class</EM></A><BR>
-
- <A HREF="dhcp_option_create.html">Create</A><BR>
- <A HREF="dhcp_option_dup.html">Duplicate</A><BR>
- <A HREF="dhcp_option_mod.html">Modify</A><BR>
- <A HREF="dhcp_option_del.html">Delete</A><BR>
- <A HREF="dhcp_option_tags.html">Standard options</A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-<h1>Options</h1>
-
-Select the Options tab in the main window to see a list of options defined
-for this DHCP server. Options are listed alphabetically by name.<P>
-
-Options (or symbols) define the configuration parameters that the DHCP server passes to the clients. See <A HREF="dhcp_macros_about.html">About Macros and Options</A> for a discussion of how to use macros and options and of the relationship between them.<P>
-You can <A HREF="dhcp_option_create.html">add</A>, <A HREF="dhcp_option_mod.html">modify</A>, or <A HREF="dhcp_option_del.html">delete</A> an option by selecting it and
-clicking the appropriate entry in the Edit menu.<P>
-
-The option settings are described below.
-<P><HR NOSHADE><P>
-
- <table border=0 cellspacing=4 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><a name="name"><STRONG>Name</STRONG></a></td>
- <td valign="top">The name of the option.
- Option names can be a maximum of 128 alphanumeric characters including spaces.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a name="cat"><STRONG>Category</STRONG></a></td>
- <td valign="top">The category of the option:
- The category can be one of Site, Extend, or Vendor.<P>
- <table border=0 cellspacing=3 cellpadding=3>
-
- - <tr>
- <td width=100 valign="top"><U>Site</U></td>
- <td valign="top">User-defined option definitions, used for
- unique or custom purposes; accepts <a href="#code">Option
- Codes</a> <tt>128-254</tt>.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Extend</U></td>
- <td valign="top">Option definitions beyond the standard set,
- which may already be present in versions of the DHCP protocol
- being used on your server. Rather than upgrading your DHCP
- implementation, you can add extended options; accepts Option
- Codes <tt>77-127</tt>.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Vendor</U></td>
- <td valign="top">Hardware-, vendor-, or platform-specific option
- definitions; accepts Option Codes <tt>1-254</tt>. Selecting this
- context enables the <a href="#class">Client Class</a>
- parameter.</td>
- </tr>
-
- </table>
- </td>
- </tr>
-
-
- <tr>
- <td width=115 valign="top"><a name="code"><STRONG>Code</STRONG></a></td>
- <td valign="top">A unique numeric code to
- identify the option. Valid values depend on the option <a
- href="#cat">category</a>:<P>
-
- <table border=0 cellspacing=3 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><U>Extend</U></td>
- <td valign="top">Accepts code values of <tt>77-127</tt><P></TD>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Site</U></td>
- <td valign="top">Accepts code values of <tt>128-254</tt><P></TD>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Vendor</U></td>
- <td valign="top">Accepts code values of <tt>1-254</tt></td>
- </tr>
-
-</table>
-<P>
-</td>
-
- </tr>
-
- <tr>
- <td width=100 valign="top"><A NAME="type"><STRONG>Data Type</STRONG></A></td>
- <td valign="top">The type of data that is acceptable
- for options values:<P>
-
- <table border=0 cellspacing=3 cellpadding=3>
-
- <tr>
- <td width=100 valign="top"><u>Ascii</u></td>
- <td valign="top">ASCII text.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><u>Boolean</u></td>
- <td valign="top">No value is associated with this data type.
- Presence of options of this type denote Boolean TRUE; absence
- denotes FALSE.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><u>IP</u></td>
- <td valign="top">One or more Internet addresses in dotted decimal format.</td>
- </tr>
- <tr>
- <td width=100 valign="top"><u>Octet</u></td>
- <td valign="top">Uninterpreted ASCII representation of binary
- data; for example, a client ID.</td>
- </tr>
- <tr>
- <td width=100 valign="top"><u>Unumber8</u><BR><u>Unumber16</u><BR>
-<u>Unumber32</u><BR><u>Unumber64</u><BR>
-
-</td>
- <td valign="top">Unsigned number, where the trailing number indicates the number of bits in the number.</td>
- </tr>
- <tr>
- <td width=100 valign="top"><u>Snumber8</u><BR><u>Snumber16</u><BR>
-<u>Snumber32</u><BR><u>Snumber64</u><BR>
-</td>
- <td valign="top">Signed number, where the trailing number indicates the number of bits in the number.</td>
- </tr>
-
- </table>
- </td>
- </tr>
-
-
- <tr>
- <td width=100 valign="top"><a name="gran"><STRONG>Granularity</STRONG></a></td>
- <td valign="top">Specifies how many values of the given <a
- href="#type">data type</a> are required to make a complete option value.
- For example, a data type of <tt>IP</tt> and a granularity of <tt>2</tt> would
- mean that the option value would need to contain two IP addresses.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><a name="max"><STRONG>Maximum</STRONG></a></td>
- <td valign="top">The maximum number of values of a
- given granularity that can be specified for the option. Building on the
- previous example, a maximum of <tt>2</tt>, with a granularity of
- <tt>2</tt> and a data type of <tt>IP</tt> would mean that the option
- value could contain a maximum of two pairs of IP addresses.<P>
-
- <table border=0>
-
- <tr>
- <td width=100 valign="top"><U>Unlimited</U></td>
- <td valign="top">No limit to the number of values; implies a
- maximum setting of <tt>0</tt>.</td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><U>Specify</U></td>
- <td valign="top">A specific number indicating the maximum.</td>
- </tr>
-
- </table>
- </td>
- </tr>
-
- <tr>
- <td width=100 valign="top"><A NAME="class"><STRONG>Vendor Client Classes</STRONG></A></td>
- <td valign="top">This option is enabled only when the option
- <a href="#cat">category</a> is Vendor. It identifies the client class(es) with which the Vendor option is
- associated.<P>
- The Class is an ASCII string representing the client machine type and/or operating system, for example, <TT>SUNW.Ultra5_10</TT>. This type of option makes it possible to define configuration parameters that are passed to all clients of the same class. <P>
- Enter the client class and then press Enter. You can
- specify multiple client classes. Only those DHCP clients with a client
- class value matching one listed here will use the option.</td>
- </tr>
- </table>
-
-
- <A HREF="#top"><small>return to top</small></A>
-
-
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_tags.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_tags.html deleted file mode 100644 index 72228b2fb1..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_tags.html +++ /dev/null @@ -1,542 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Options</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><BR>
- <A HREF="dhcp_option_create.html">Create</A><BR>
-
- <A HREF="dhcp_option_mod.html">Modify</A><BR>
- <A HREF="dhcp_option_del.html">Delete</A><BR>
- <A HREF="dhcp_option_dup.html">Duplicate</A><BR>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT=""> <A name="#tags">Standard Options</A><P>
-
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-<h1>Standard Options</h1>
-
-The standard DHCP options are defined by a short name (or tag), which is a mnemonic. The names are listed below with their code number, name, data type, and description. <P>
-
-<P><HR NOSHADE><P>
-
- <table border=0 cellspacing=3 cellpadding=3>
-
- <tr>
- <td valign="top"><a name="numb"><STRONG>Code</STRONG></a></td>
-<td width=80 valign="top"><a name="tag"><STRONG>Name</STRONG></a></td>
-<td width=50 valign="top"><a name="type"><STRONG>Type</STRONG></a></td>
- <td valign="top"><a name="descr"><STRONG>Description</STRONG></a></td>
- </tr>
-
-<tr>
-<td valign="top">1</td>
-<td valign="top">Subnet</td>
-<td valign="top">IP</td>
-<td valign="top">Subnet mask, dotted Internet address</td></TR>
-
-<TR><td valign="top">2</td>
-<td valign="top">UTCoffst</td>
-<td valign="top">Number</td>
-<td valign="top">Coordinated universal Number offset (seconds)</td> </TR>
-
-<TR><td valign="top">3</td>
-<td valign="top">Router</td>
-<td valign="top">IP</td>
-<td valign="top">List of routers</td></TR>
-
-<TR><td valign="top">4 </td>
-<td>Timeserv</td>
-<td valign="top">IP</td>
-<td>List of RFC-868 servers</td></TR>
-
-<TR><td valign="top">5</td>
-<td valign="top">IEN116ns</td>
-<td valign="top">IP</td>
-<td valign="top">List of IEN-116 name servers</td></TR>
-
-<TR><td valign="top">6</td>
-<td valign="top">DNSserv</td><td valign="top">IP</td>
-<td valign="top">List of DNS name servers</td></TR>
-
-<TR><td valign="top">7</td>
-<td valign="top">Logserv </td>
-<td valign="top">IP</td>
-<td valign="top">List of MIT-LCS UDP log servers</td></tr>
-
-<TR><td valign="top">8</td>
-<td valign="top">Cookie</td>
-<td valign="top">IP</td>
-<td valign="top">List of RFC-865 cookie servers</td></tr>
-
-<TR><td valign="top">9</td>
-<td valign="top">Lprserv</td>
-<td valign="top">IP</td>
-<td valign="top">List of RFC-1179 line printer servers</td></tr>
-
-<TR><td valign="top">10</td>
-<td valign="top">Impress</td>
-<td valign="top">IP</td>
-<td valign="top">List of Imagen Impress servers</td></tr>
-
-<TR><td valign="top">11</td>
-<td valign="top">Resource</td>
-<td valign="top">IP</td>
-<td valign="top">List of RFC-887 resource location servers</td></tr>
-
-<TR><td valign="top">12</td>
-<td valign="top">Hostname</td>
-<td valign="top">Boolean</td>
-<td valign="top">Return client's host name, value from hosts database</td></tr>
-
-<TR><td valign="top">13</td>
-<td valign="top">Bootsize</td>
-<td valign="top">Number</td>
-<td valign="top">Number of 512 octet blocks in boot image</td></TR>
-
-<TR><td valign="top">14</td>
-<td valign="top">Dumpfile</td>
-<td valign="top">ASCII</td>
-<td valign="top">Path where core image should be dumped</td></TR>
-
-<TR><td valign="top">15</td>
-<td valign="top">DNSdmain</td>
-<td valign="top">ASCII</td>
-<td valign="top">DNS domain name</td></TR>
-
-<TR><td valign="top">16</td>
-<td valign="top">Swapserv </td>
-<td valign="top">IP</td>
-<td valign="top">Client's swap server</td></TR>
-
-<TR><td valign="top">17</td>
-<td valign="top">Rootpath</td>
-<td valign="top">ASCII</td>
-<td valign="top">Client's root path</td></TR>
-
-<TR><td valign="top">18</td>
-<td valign="top">ExtendP</td>
-<td valign="top">ASCII</td>
-<td valign="top">Extensions path</td></TR>
-
-<TR><td valign="top">19 </td>
-<td valign="top">IpFwdF</TD>
-<TD>Number</td>
-<td valign="top">IP forwarding enable/disable (1/0)</td></TR>
-
-<TR><td valign="top">20</td>
-<td valign="top">NLrouteF</td>
-<td valign="top">Number</td>
-<td valign="top">Non-local source routing</td></TR>
-
-<TR><td valign="top">21</td>
-<td valign="top">PFilter</td>
-<td valign="top">IP</td>
-<td valign="top">Policy filter</td></TR>
-
-<TR><td valign="top">22</td>
-<td valign="top">MaxIpSiz</td>
-<td valign="top">Number</td>
-<td valign="top">Maximum datagram reassembly size</td></TR>
-
-<TR><td width=10 valign="top">23</td>
-<td valign="top">IpTTL</td>
-<td valign="top">Byte</td>
-<td valign="top">Default IP time to live (1=< x <=225)</td></TR>
-
-<TR><td width=10 valign="top">24</td>
-<td valign="top">PathTO</td>
-<td valign="top">Number</td>
-<td valign="top">RFC-1191 Path MTU aging timeout</td></TR>
-
-<TR><td width=10 valign="top">25</td>
-<td valign="top">PathTbl</td>
-<td valign="top">Number</td>
-<td valign="top">RFC-1191 Path MTU plateau table</td></TR>
-
-<TR><td width=10 valign="top">26</td>
-<td valign="top">MTU</td>
-<td valign="top">Number</TD>
-<TD>Interface MTU, (x <=68)</td></TR>
-
-<TR><td valign="top">27</td>
-<td valign="top">SameMtuF</td>
-<td valign="top">Number </td>
-<td valign="top">All subnets are local</td></TR>
-
-<TR><td valign="top">28</td>
-<td valign="top">Broadcst</td>
-<td valign="top">IP</td>
-<td valign="top">Broadcast address</td></TR>
-
-<TR><td valign="top">29</td>
-<td valign="top">MaskDscF</td>
-<td valign="top">Number</td>
-<td valign="top">Perform mask discovery</td></TR>
-
-<TR><td width=10 valign="top">30</td>
-<td valign="top">MaskSupF</td>
-<td valign="top">Number</td>
-<td valign="top">Mask supplier</td></TR>
-
-<TR><td width=10 valign="top">31</td>
-<td valign="top">RDiscvyF</td>
-<td valign="top">Number</td>
-<td valign="top">Perform route discovery</td></TR>
-
-<TR><td valign="top">32</td>
-<td valign="top">RSolictS</td>
-<td valign="top">IP</td>
-<td valign="top">Router solicitation address</td></TR>
-
-<TR><td valign="top">33</td>
-<td valign="top">StaticRt</td>
-<td valign="top">IP</td>
-<td valign="top">Static routes, double IP (network router)</td></TR>
-
-<TR><td valign="top">34</td>
-<td valign="top">TrailerF</td>
-<td valign="top">Number</td>
-<td valign="top">Trailer encapsulation</td></TR>
-
-<TR><td valign="top">35</td>
-<td valign="top">ArpTimeO</td>
-<td valign="top">Number</td>
-<td valign="top">Arp cache timeout</td></TR>
-
-<TR><td valign="top">36</td>
-<td valign="top">EthEncap</td>
-<td valign="top">Number</td>
-<td valign="top">Ethernet encapsulation</td></TR>
-
-<TR><td valign="top">37</td>
-<td valign="top">TcpTTL</td>
-<td valign="top">Number</td>
-<td valign="top">TCP default time to live</td></TR>
-
-<TR><td valign="top">38</td>
-<td valign="top">TcpKaInt</td>
-<td valign="top">Number</td>
-<td valign="top">TCP keep alive interval</td></TR>
-
-<TR><td valign="top">39</td>
-<td valign="top">TcpKaGbF</td>
-<td valign="top">Number</td>
-<td valign="top">Keep alive garbage</td></TR>
-
-<TR><td valign="top">40</td>
-<td valign="top">NISdmain</td>
-<td valign="top">ASCII</td>
-<td valign="top">NIS domain_ name</td></TR>
-
-<TR><td valign="top">41</td>
-<td valign="top">NISservs</td>
-<td valign="top">IP</td>
-<td valign="top">List of NIS servers</td></TR>
-
-<TR><td valign="top">42</td>
-<td valign="top">NTPservs</td>
-<td valign="top">IP</td>
-<td valign="top">List of NTP servers</td></TR>
-
-<TR><td valign="top">44 </td>
-<td valign="top">NetBNms</td>
-<td valign="top">IP</td>
-<td valign="top">List of Netbios name servers</td></TR>
-
-<TR><td valign="top">45</td>
-<td valign="top">NetBDsts </td>
-<td valign="top">IP</td>
-<td valign="top">List of Netbios distribution servers</td></TR>
-
-<TR><td valign="top">46</td>
-<td valign="top"> NetBNdT</td>
-<td valign="top">Number</td>
-<td valign="top">Netbios node type (1=B-node, 2=P, 4=M, 8=H)</td></TR>
-
-<TR><td valign="top">47</td>
-<td valign="top">NetBScop</td>
-<td valign="top">ASCII</td>
-<td valign="top">Netbios scope</td></TR>
-
-<TR><td valign="top">48</td>
-<td valign="top">XFontSrv</td>
-<td valign="top">IP</td>
-<td valign="top">List of X Window font servers</td></TR>
-
-<TR><td valign="top">49</td>
-<td valign="top">XDispMgr</td>
-<td valign="top">IP</td>
-<td valign="top">X Window display managers</td></TR>
-
-
-<TR><td valign="top">51</td>
-<td valign="top">LeaseTim</td>
-<td valign="top">Number</td>
-<td valign="top">Lease time policy</td></TR>
-
-<TR><td valign="top">56</td>
-<td valign="top">Message</td>
-<td valign="top">ASCII</td>
-<td valign="top">Message to be displayed on client</td></TR>
-
-<TR><td valign="top">58</td>
-<td valign="top">T1Time</td>
-<td valign="top">Number</td>
-<td valign="top">Renewal (T1) time</td></TR>
-
-<TR><td valign="top">59</td>
-<td valign="top">T2Time</td>
-<td valign="top">Number</td>
-<td valign="top">Rebinding (T2) time</td></TR>
-
-<TR><td valign="top">62</td>
-<td valign="top">NW_dmain</td>
-<td valign="top">ASCII</td>
-<td valign="top">Netware/IP domain name</td></TR>
-
-<TR><td valign="top">63</td>
-<td valign="top">NWIPOpts</td>
-<td valign="top">Octet</td>
-<td valign="top">Netware/IP options</td></TR>
-
-<TR><td valign="top">64</td>
-<td valign="top">NIS+dom</td>
-<td valign="top">ASCII</td>
-<td valign="top">NIS+ domain name</td></TR>
-
-<TR><td valign="top">65</td>
-<td valign="top">NIS+serv</td>
-<td valign="top">IP</td>
-<td valign="top">List of NIS+ servers</td></TR>
-
-<TR><td valign="top">66</td>
-<td valign="top">TFTPsrvN</td>
-<td valign="top">ASCII</td>
-<td valign="top">Trivial File Transfer Protocol (TFTP) server hostname</td></TR>
-
-<TR><td valign="top">67</td>
-<td valign="top">OptBootF</td>
-<td valign="top">ASCII</td>
-<td valign="top">Optional bootfile name</td></TR>
-
-<TR><td valign="top">68</td>
-<td valign="top">MblIPAgt</td>
-<td valign="top">IP</td>
-<td valign="top">Mobile IP home agents</td></TR>
-
-<TR><td valign="top">69</td>
-<td valign="top">SMTPserv </td>
-<td valign="top">IP</td>
-<td valign="top">Simple Mail Transport Protocol (SMTP) server</td></TR>
-
-<TR><td valign="top">70</td>
-<td valign="top">POP3serv</td>
-<td valign="top">IP</td>
-<td valign="top">Post Office Protocol (POP3) server</td></TR>
-
-<TR><td valign="top">71</td>
-<td valign="top">NNTPserv</td>
-<td valign="top">IP</td>
-<td valign="top">Network News Transport Protocol (NNTP) server</td></TR>
-
-<TR><td valign="top">72</td>
-<td valign="top">WWWservs</td>
-<td valign="top">IP</td>
-<td valign="top">Default World Wide Web server</td></TR>
-
-<TR><td valign="top">73</td>
-<td valign="top">Fingersv</td>
-<td valign="top">IP</td>
-<td valign="top">Default finger server</td></TR>
-
-<TR><td valign="top">74</td>
-<td valign="top">IRCservs</td>
-<td valign="top">IP</td>
-<td valign="top">Internet Relay Chat (IRC) server</td></TR>
-
-<TR><td valign="top">75</td>
-<td valign="top">STservs </td>
-<td valign="top">IP</td>
-<td valign="top">StreetTalk server</td></TR>
-
-<TR><td valign="top">76</td>
-<td valign="top">STDAservs</td>
-<td valign="top">IP</td>
-<td valign="top">StreetTalk directory assistance server</td></TR>
-
-<TR><td valign="top">77</td>
-<td valign="top">UserClas</td>
-<td valign="top">ASCII</td>
-<td valign="top">User class information</td></TR>
-
-<TR><td valign="top">78</td>
-<td valign="top">SLP_DA</td>
-<td valign="top">Octet</td>
-<td valign="top">Directory agent</td></TR>
-
-<TR><td valign="top">79</td>
-<td valign="top">SLP_SS</td>
-<td valign="top">Octet</td>
-<td valign="top">Service scope</td></TR>
-
-<TR><td valign="top">82</td>
-<td valign="top">AgentOpt</td>
-<td valign="top">Octet</td>
-<td valign="top">Agent circuit ID</td></TR>
-
-<TR><td valign="top">89</td>
-<td valign="top">FQDN</td>
-<td valign="top">Octet</td>
-<td valign="top">Fully Qualified Domain Name</td></TR>
-
-<TR><td valign="top">93</td>
-<td valign="top">PXEarch</td>
-<td valign="top">Number</td>
-<td valign="top">Client system architecture</td></TR>
-
-<TR><td valign="top">94</td>
-<td valign="top">PXEnii</td>
-<td valign="top">Octet</td>
-<td valign="top">Client Network Device Interface</td></TR>
-
-<TR><td valign="top">97</td>
-<td valign="top">PXEcid</td>
-<td valign="top">Octet</td>
-<td valign="top">UUID/GUID-based client identifier</td></TR>
-
-<TR><td valign="top">N/A</td>
-<td valign="top">BootFile</td>
-<td valign="top">ASCII</td>
-<td valign="top">File to boot</td></TR>
-
-<TR><td valign="top">N/A</td>
-<td valign="top">BootSrvA</td>
-<td valign="top">IP</td>
-<td valign="top">Boot server</td></TR>
-
-<TR><td valign="top">N/A</td>
-<td valign="top">BootSrvN</td>
-<td valign="top">ASCII</td>
-<td valign="top">Boot server host name</td></TR>
-
-<TR><td valign="top">NA</td>
-<td valign="top">LeaseNeg</td>
-<td valign="top">Boolean</td>
-<td valign="top">Lease is negotiable flag (present=true)</td></TR>
-
-<TR><td valign="top">NA</td>
-<td valign="top">Include</td>
-<td valign="top">ASCII</td>
-<td valign="top">Include listed macro values in this macro</td></TR>
-
-</table>
-
-<p> </p>
- <A HREF="#top"><small>return to top</small></A>
-
-
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_view.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_view.html deleted file mode 100644 index 3d32c1176e..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_option_view.html +++ /dev/null @@ -1,293 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Option Menus</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=625>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
-
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><BR>
- <A HREF="dhcp_addr_view.html">Address View</A><BR>
- <A HREF="dhcp_macro_view.html">Macro View</A><BR>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Option View<P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
-
- </td>
-
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
-
- <P> </P>
-<H1> Option View Menus</H1>
-
-<table ALIGN="LEFT" BORDER="0" CELLPADDING="3" WIDTH="495">
-<TR>
-<td colspan=1 width=20> </td>
-<th colspan=1 align=left valign="top" width=150>
- <FONT SIZE="+1">Titles</FONT><P></TH>
- <TH align=left valign="top"><FONT SIZE="+1">Description</FONT><P></TH>
-
-</TR>
-
-
-<tr>
-<td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF"><U>File Menu</U></td>
- <Td></Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150> <STRONG>Exit</STRONG></TD>
- <TD ALIGN="LEFT" VALIGN="TOP">Exit from the application.<P> </P></TD>
-
-</TR>
-<tr>
-<td colspan=1 width=20> </td>
-
-
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>Edit Menu</U></td>
- <Td></Td></TR>
-
- <tr>
-<td colspan=1 width=20> </td>
-
-<TD ALIGN="left" VALIGN="TOP" width="150"> <STRONG>Create</STRONG></TD>
-
- <TD ALIGN="LEFT" VALIGN="TOP">
-Create new option.</TD></TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Delete</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Delete the selected option(s).</TD>
-</TR>
-<tr>
-<td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top" width=150> <STRONG>Duplicate</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Copy the selected option.</TD>
-</TR>
-
-<tr>
-<td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top" width=150> <STRONG>Properties</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Modify the properties of the selected option.<P> </P></TD>
-</TR>
-
-
-<tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>View Menu</U><P></td>
-<TD></TD></TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Refresh</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Refresh the data from the server.</TD>
-</TR>
-
- <tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Show Grid</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Turn on grid lines in display.<P> </P></TD>
-</TR>
-
-
-<tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>Service Menu</U><P></td>
- <Td></Td></TR>
-
- <tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Restart</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Stop and restart the DHCP daemon.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Stop</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Stop the DHCP daemon.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Start</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Start the DHCP daemon.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Disable</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Disable the DHCP server or BOOTP relay agent.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Enable</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Enable the DHCP server or BOOTP relay agent.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Modify</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Customize services of DHCP server or BOOTP relay agent.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Export Data</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Copy from the DHCP data store selected IP addresses, macros, and options to a file for the purpose of importing to a DHCP server.</TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Import Data</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Bring into the DHCP data store IP addresses, macros, and options that were exported from a DHCP server. </TD>
-</TR>
-
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Convert Data Store</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Configure the DHCP server to use a new data store and convert existing data to new data store format. </TD>
-</TR>
-<tr><td colspan=1 width=20> </td>
-<td colspan=1 align=left valign="top"> <STRONG>Unconfigure</STRONG></TD>
-<TD ALIGN="LEFT" VALIGN="TOP">Unconfigure the DHCP server or BOOTP relay agent.<P> </P></TD>
-</TR>
-
-
-
-<tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>Help</U></td>
- <Td>Display the online help.<P> </P></Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>Find</U></td>
- <Td>Search for an Option entry.<P> </P></Td></TR>
-
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
-<U>Column Entries</U></td>
- <Td></Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
- <STRONG>Name</STRONG></td>
- <Td>Name of the option</Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
- <STRONG>Category</STRONG></td>
- <Td>Category of the option</Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
- <STRONG>Code</STRONG></td>
- <Td>Numeric code that identifies the option</Td></TR>
-
- <tr><td colspan=1 width=20> </td>
-
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
- <STRONG>Type</STRONG></td>
- <Td>Data type of the option</Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
- <STRONG>Granularity</STRONG></td>
- <Td>Number of values required for the data type</Td></TR>
-
- <tr><td colspan=1 width=20> </td>
- <td colspan=1 align=left valign="top" width=150 bgcolor="#FFFFFF">
- <STRONG>Maximum</STRONG></td>
-
- <Td>Maximum number of values to specify for the option<P></td>
- </tr>
- <TR><TD COLSPAN="3"> <A HREF="#top"><small>return to top</small></A></TD></TR>
-
- </TABLE>
-
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_choose.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_choose.html deleted file mode 100644 index 677fa30a5c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_choose.html +++ /dev/null @@ -1,117 +0,0 @@ -<!-- - -- ident "%W% %E% SMI" - -- - Copyright 2005 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - --> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Choose Configuration</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-<body bgcolor="#ffffff">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="left" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
-<A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
-<A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
-<A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
-<A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
-<A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" width="495">
-
-
-
-<P> </P>
-
-
-<H1>Choose Server Configuration</H1>
-
-You can choose to configure your server as either a DHCP server or as a BOOTP relay agent.<P>
-The DHCP server manages the IP address space of networks connected to the server.<P>
-The BOOTP relay agent can receive requests for configuration from a client in a network not directly connected to a DHCP server and forward the request to a DHCP server.
-
-<p> </p>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_config.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_config.html deleted file mode 100644 index 3537433d8f..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_config.html +++ /dev/null @@ -1,135 +0,0 @@ -<!-- - -- ident "%W% %E% SMI" - -- - Copyright 2005 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - --> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Configuring BOOTP Relay Agent</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#ffffff">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=625>
-
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="left" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
- <STRONG><A HREF="dhcp_relay_ref.html">Servers and Relays</A></STRONG><BR>
- <A HREF="dhcp_config_wiz.html">DHCP Config</A><BR>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Relay Config<BR>
- <A HREF="dhcp_net_wiz.html">Network Config</A><BR>
- <A HREF="dhcp_server_serv.html">DHCP Services</A><BR>
- <A HREF="dhcp_relay_serv.html">Relay Services</A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" width="495">
-<P> </P>
-
-
-<h1>Configuring a BOOTP Relay Agent</h1>
-
-If you start the DHCP Manager for a system that has not been configured as either a DHCP server or as a BOOTP relay agent, you can choose how to configure the system. <P>
-
-If you choose to configure the system as a BOOTP relay agent, the Configure BOOTP Relay dialog box is displayed.
-<P><HR NOSHADE><P>
-
-
-<TABLE BORDER="0" CELLSPACING="3" CELLPADDING="3" ALIGN="CENTER">
-<TR>
-
-<TD WIDTH="100" VALIGN="TOP"><STRONG>DHCP Servers</STRONG></TD>
-<TD>Enter the IP address(es) or host name(s) of the <A NAME="srvrs">DHCP servers</A> to which this relay agent will forward requests for configuration.
-</TD>
-</TR>
-</TABLE>
-
- <P>
-
-After initial configuration, use the <A HREF="dhcp_relay_serv.html">Modify</A> option in the Service menu to configure additional options, such as the number of relay hops and which network interfaces to monitor.
-
-<p> </p>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_dis.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_dis.html deleted file mode 100644 index cda8a709f3..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_dis.html +++ /dev/null @@ -1,114 +0,0 @@ -<!-- - -- ident "%W% %E% SMI" - -- - Copyright 2005 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - --> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Disable Service</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-<h1>Disable Service</h1>
-
-Click OK to remove the DHCP daemon from the boot sequence. When the DHCP service is disabled, it will not start automatically when you reboot the server.<P>
-Choose <A HREF="dhcp_relay_how.html#dis">Enable</A> from the Service menu to restore the DHCP daemon to the boot sequence. <P>
-Choose <A HREF="dhcp_relay_how.html#start">Stop</A> from the Service menu to temporarily halt DHCP service.
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_enable.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_enable.html deleted file mode 100644 index 51ae620343..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_enable.html +++ /dev/null @@ -1,113 +0,0 @@ -<!-- - -- ident "%W% %E% SMI" - -- - Copyright 2005 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - --> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Enable Service</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-<h1>Enable Service</h1>
-
-Choose <A HREF="dhcp_relay_how.html#dis">Enable</A> to restore service that has been disabled. This restores the DHCP daemon to the boot sequence.<P>
-Choose <A HREF="dhcp_relay_how.html#start">Start</A> from the Service menu to start a server that has been stopped or halted temporarily.
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_how.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_how.html deleted file mode 100644 index b5b505f6df..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_how.html +++ /dev/null @@ -1,326 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- Copyright 2005 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: How To... Servers and Relays</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>IP Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><BR>
-<IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">Servers and Relays<BR>
- <A HREF="#srvr"><EM>Configure DHCP</EM></A><BR>
- <a href="#relay"><EM>Configure BOOTP</EM></a><BR>
- <a href="#ntwrk"><EM>Configure Network</EM></a><BR>
- <a href="#delnet"><EM>Delete Network</EM></a><BR>
- <a href="#adv"><EM>Customize Service</EM></a><BR>
- <a href="#start"><EM>Start/Stop/Restart</EM></a><BR>
- <a href="#dis"><EM>Enable/Disable</EM></a><BR>
- <a href="#exp"><EM>Export/Import</EM></a><BR>
- <a href="#conv"><EM>Convert Data Store</EM></a><BR>
- <a href="#uncon"><EM>Unconfigure DHCP</EM></a><BR>
- <a href="#uncon2"><EM>Unconfigure BOOTP</EM></a><BR>
- <A HREF="dhcp_addr_how.html">Addresses</A><BR>
- <A HREF="dhcp_macro_how.html">Macros</A><BR>
- <A HREF="dhcp_option_how.html">Options</A><P>
-
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff">
-
-
-
-<P> </P>
-<H1>How To: Servers and Relays</H1>
-
-<strong><big><a name="srvr">Configure a DHCP Server</A></big></strong><P>
-When you start DHCP Manager on a Solaris system that has not been configured as either a DHCP server or as a BOOTP relay agent, the Choose Server Configuration dialog box is displayed. You can choose to configure a server as either a DHCP server or as a BOOTP relay agent, but not both.<p>
-<OL>
-<LI><STRONG>Select Configure as DHCP Server.</STRONG><BR>
-The DHCP Server Configuration Wizard starts.<P></LI>
-<LI><STRONG>Step through the configuration, providing the <A HREF="dhcp_config_wiz.html">information</A> requested.</STRONG><BR>
-When the configuration is completed, the DHCP server starts.
-</LI>
-</OL>
-<P>
-To change any of the configuration parameters, you can later <a href="dhcp_macro_how.html#modmacro">modify</a> the macros containing the configuration parameters. Alternatively, you can <A href="#uncon">unconfigure</A> the server and then use the Configuration Wizard to reconfigure the server.<P>
-To customize <A HREF="#adv">DHCP services</A>, select Modify from the Services menu.<P>
-
-<HR NOSHADE><P>
-<strong><big><A NAME="relay">Configure a BOOTP Relay Agent</A></big></strong><P>
-When you start DHCP Manager on a Solaris system that has not been configured as either a DHCP server or as a BOOTP relay agent, the Choose Server Configuration dialog box is displayed. You can choose to configure a server as either a DHCP server or as a BOOTP relay agent, but not both.<p>
-<OL>
-<LI><STRONG>Select Configure as BOOTP Relay.</STRONG><BR>
-The Configure BOOTP Relay dialog box is displayed.<P></LI>
-
-<LI><STRONG>Enter DHCP servers.</STRONG><BR>
-Type the names or IP addresses of one or more DHCP servers to which to relay configuration requests, and click OK.
-<p>
-</LI>
-</OL>
-When the configuration is completed, the BOOTP relay agent starts.<P>
-To customize <A HREF="#adv">BOOTP relay services</A>, select Modify from the Services menu.<P>
-<HR NOSHADE>
-<P>
-<big><STRONG><A NAME="ntwrk">Configure a Network</A></STRONG></big><p>
-When you first configure the DHCP server, the Configuration Wizard configures the first network. To add additional networks, follow these steps.<P>
-<OL>
-<LI><STRONG>Choose Network Wizard from the Edit menu of the View Addresses window.</STRONG><P></LI>
-<LI><STRONG>Enter configuration <A HREF="dhcp_net_wiz.html">information</A> for the new network.</STRONG><P></LI>
-<LI><STRONG>Click OK to confirm your action.</STRONG><P></LI>
-</OL>
-<HR NOSHADE>
-<P>
-<big><STRONG><A NAME="delnet">Delete a Network</A></STRONG></big><p>
-To delete a network is to remove it from the list of networks monitored by the DHCP server.
-<P>
-<OL>
-<LI><STRONG>Click the Addresses tab and choose Delete Network from the Edit menu.</STRONG><BR>
-The Delete Network dialog box is displayed. Configured networks are listed in the Keep Networks list. <P></LI>
-<LI><STRONG>Select the network to delete and use the arrow keys to move it to the Delete Networks list.</STRONG><P></LI>
-<LI><STRONG>Click OK to confirm your actions.</STRONG><P></LI>
-</OL>
-You cannot add a network using this dialog box. To add or restore a network to the DHCP server's list of monitored networks, you must <a href="#ntwrk">configure the network</a>. <P>
-<HR NOSHADE>
-<P>
-<big><STRONG><A NAME="adv">Customize Services</A></STRONG></big><p>
-You can configure DHCP or BOOTP services for your server or BOOTP relay agent.
-<P><OL>
-<LI><STRONG>Choose Modify from the Services menu.</STRONG><br></LI>
-The Modify Service Options dialog is displayed.
-<LI><P><STRONG>Enter configuration information</strong><BR>
-Use the Modify Service Options dialog to customize the <A HREF="dhcp_server_serv.html">DHCP</A> or <A HREF="dhcp_relay_serv.html">Relay</A> services.<P>
-You can configure options such as BOOTP compatibility mode (for the DHCP server) or modify the list of DHCP servers to which to forward requests (relay agent).<P></LI>
-<LI><STRONG>Click OK.</STRONG></LI>
-</OL><P>
-
-<HR NOSHADE><P>
-<strong><big><A NAME="start">Start, Stop, or Restart a Server or Relay Agent</A></big></strong><p>
-The DHCP server or BOOTP relay agent starts
-automatically when you have completed the
-initial configuration. You can stop or start the service by
-choosing Stop or Start from the Services menu. This is analogous
-to running the <tt>/etc/init.d/dhcp</tt>
-script with the <tt>stop</tt> or <tt>start</tt> command.<P>
-
- <ol type=1>
-
- <li><STRONG>Choose the Services menu in the main window.</STRONG><p></LI>
- <li><STRONG>Choose Start, Stop, or Restart from the Service
-menu.</STRONG>
- <TABLE BORDER="0" CELLSPACING="3" CELLPADDING="3" COLS="2">
-
-<TR ALIGN="LEFT" VALIGN="TOP">
- <TD WIDTH="60" ALIGN="LEFT" VALIGN="TOP"><STRONG>Start</STRONG></TD>
- <TD ALIGN="LEFT" VALIGN="TOP">Click Start to start DHCP or BOOTP relay
-service that has been stopped.</TD>
- </TR>
-
- <TR ALIGN="LEFT" VALIGN="TOP">
- <TD WIDTH="60" ALIGN="LEFT" VALIGN="TOP"><STRONG>Stop</STRONG></TD>
- <TD ALIGN="LEFT" VALIGN="TOP">Click Stop to stop the DHCP or
-BOOTP daemon.</TD>
- </TR>
-
-<TR ALIGN="LEFT" VALIGN="TOP">
- <TD WIDTH="60" ALIGN="LEFT" VALIGN="TOP"><STRONG>Restart</STRONG></TD>
- <TD ALIGN="LEFT" VALIGN="TOP">Click Restart to force the DHCP server to reread the <tt>dhcptab</tt>.</TD>
- </TR>
-
- </TABLE></LI>
- <LI><STRONG>Click OK to confirm your actions.</STRONG></LI>
-
- </ol><P>
-
- <HR NOSHADE><P>
-<strong><big><A NAME="dis">Enable or Disable a Server or Relay Agent</A></big></strong><p>
-Disabling DHCP stops the DHCP daemon and removes it from the boot sequence. When the DHCP service is disabled, it will not start automatically when you reboot the server.<P>
-Enabling DHCP starts the DHCP daemon and restores it to the boot sequence.<P>
-
- <ol type=1>
-
- <li><STRONG>Choose the Services menu in the main window.</STRONG><p></LI>
- <li><STRONG>Choose Enable or Disable from the Services menu.</STRONG>
- <TABLE BORDER="0" CELLSPACING="3" CELLPADDING="3" COLS="2">
-
-<TR ALIGN="LEFT" VALIGN="TOP">
- <TD WIDTH="60" ALIGN="LEFT" VALIGN="TOP"><STRONG>Enable</STRONG></TD>
- <TD ALIGN="LEFT" VALIGN="TOP">Click Enable to restore a DHCP service that has been disabled.</TD>
- </TR>
-
- <TR ALIGN="LEFT" VALIGN="TOP">
- <TD WIDTH="60" ALIGN="LEFT" VALIGN="TOP"><STRONG>Disable</STRONG></TD>
- <TD ALIGN="LEFT" VALIGN="TOP">Click Disable to remove DHCP service from the boot sequence.</TD>
- </TR>
-
- </TABLE></LI>
- <LI><STRONG>Click OK to confirm your actions.</STRONG></LI>
- </OL>
-
- <HR NOSHADE><P>
-<STRONG><big><a name="exp">Export Data From a DHCP Server</a></BIG></STRONG><p>
-If you want to move IP addresses, macros, or options to another Solaris DHCP server, you must first export the data from the owning DHCP server. <p>
-<ol>
-<li><Strong>From the Services menu, choose Export Data.</strong><BR>
-The Export Data wizard is displayed.<p></li>
-<li><strong>Answer the <a href="dhcp_export_wiz.html">prompts</a> to indicate what you want to export.</strong><p></li>
-<li><strong>Click OK to confirm your actions.</strong></li></ol>
-
-<HR NOSHADE><P>
-<STRONG><big><a name="imp">Import Data to a DHCP Server</a></BIG></STRONG><p>
-After exporting IP addresses, macros, or options from a DHCP server, you can import it to another Solaris DHCP server. <p>
-<ol>
-<li><Strong>From the Services menu, choose Import Data.</strong><BR>
-The Import Data wizard is displayed.<p></li>
-<li><strong>Type the full path to the file containing the data you want to import to
- this DHCP server. </strong><P>This file must have been created by exporting data from a Solaris DHCP server.<p></li>
-<li><strong>Choose Overwrite Existing Data if you want conflicting information on the new server to be replaced with data being imported.</strong><p>
-If the DHCP server on which
- you are importing data has configuration data
- for any of the same networks, IP addresses,
- macros, or options being imported, that data will be
- replaced with the imported data when
- you select this option. By default,
- conflicting data will not be overwritten.<p>
-<li><strong>Click OK to confirm your actions.</strong></li></ol>
-
-<HR NOSHADE> <P>
-<STRONG><BIG><a name="conv">Convert to a New Data Store</a></BIG></STRONG><p>
-The Solaris DHCP service supports several data stores, which are designed for use by
-sites with varying requirements. <p>
-You may need to convert to a new data store if, for
-example, your number of DHCP clients increases to the point that you need higher
-performance or higher capacity from the DHCP service, or if you want to share the
-DHCP server duties among multiple servers.<p>
-<ol>
-<li><Strong>From the Services menu, choose Convert Data Store.</strong><BR>
-The Data Store Conversion wizard is displayed.<p></li>
-<li><strong>Answer the <a href="dhcp_convert_wiz.html">prompts</a> to indicate what you want to export.</strong><p></li>
-<li><strong>Click OK to confirm your actions.</strong></li></ol>
-
-
-<HR NOSHADE><P>
-<STRONG><BIG><a name="#uncon">Unconfigure a DHCP Server</a></BIG></STRONG><p>
-If you no longer want the DHCP server to run on this machine, you can unconfigure the DHCP server. Be sure that responsibility for the addresses owned by the server has been transferred to another DHCP server before you unconfigure the server. See <a href="#exp">Export Data From a DHCP Server</a><P>
-<OL>
-<LI><STRONG>From the Services menu, choose Unconfigure.</STRONG><BR>
-The Unconfigure Service dialog box is displayed.<p></li>
-
-<LI><STRONG>Choose one or both options.</STRONG>
-
-<TABLE BORDER="0" CELLSPACING="3" CELLPADDING="3" COLS="2">
-
-<TR ALIGN="LEFT" VALIGN="TOP">
- <TD WIDTH="160" ALIGN="LEFT" VALIGN="TOP"><STRONG>Remove <tt>dhcptab</tt> and all DHCP network tables</STRONG></TD>
- <TD ALIGN="LEFT" VALIGN="TOP">Use this option with caution. If you use NIS+, removing these tables may cause a problem for other DHCP servers that share these databases.</TD>
- </TR>
- <TR ALIGN="LEFT" VALIGN="TOP">
- <TD WIDTH="160" ALIGN="LEFT" VALIGN="TOP"><STRONG>Remove all hosts table entries for DHCP addresses</STRONG>
- </TD>
-
-<TD>Check this box to also remove entries from the server's hosts name service.</TD></TR>
-</table>
-</LI>
-<LI><STRONG>Click OK to confirm your actions.</STRONG></LI>
-</OL>
- <P><HR NOSHADE><P>
- <STRONG><BIG><a name="uncon2">Unconfigure a BOOTP Relay Agent</a></BIG></STRONG><p>
-<OL>
-<LI><STRONG>From the Services menu, choose Unconfigure.</STRONG><BR>
-The Unconfigure Service dialog box is displayed.<p></li>
-<LI><STRONG>Click OK to confirm your actions.</STRONG></LI>
-</OL>
- <P>
- <A HREF="#top"><small>return to top</small></A>
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_ref.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_ref.html deleted file mode 100644 index 7815d8caae..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_ref.html +++ /dev/null @@ -1,138 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Servers and Relays</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-<body bgcolor="#ffffff">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="left" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT=""><STRONG>Servers and Relays</STRONG><BR>
- <A HREF="dhcp_config_wiz.html">DHCP Config</A><BR>
- <A HREF="dhcp_relay_config.html">Relay Config</A><BR>
- <A HREF="dhcp_net_wiz.html">Network Config</A><BR>
- <A HREF="dhcp_server_serv.html">DHCP Services</A><BR>
- <A HREF="dhcp_relay_serv.html">Relay Services</A><BR>
- <A HREF="dhcp_relay_how.html#start">Start/Stop</A><BR>
- <A HREF="dhcp_relay_how.html#dis">Enable/Disable</A><BR>
- <A HREF="dhcp_relay_how.html#exp">Export/Import Data</A><BR>
- <A HREF="dhcp_relay_how.html#conv">Convert Data Store</A><BR>
- <A HREF="dhcp_relay_how.html#uncon">Unconfigure</A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" width="495">
-
-
-
-<P> </P>
-
-
-<H1>DHCP Servers and BOOTP Relay Agents</H1>
-
-You can use DHCP Manager to configure and manage your DHCP server or BOOTP relay agent, and their associated networks.<P>
-<H2>DHCP Server</H2>
-The DHCP server manages the IP address space of networks connected to the server. Use the <A HREF="dhcp_config_wiz.html">DHCP Configuration Wizard</A> to configure your DHCP server.
-The DHCP Configuration Wizard steps through the procedure to configure the system as a DHCP server and configures the first network. The wizard performs the same steps as the Solaris <tt>dhcpconfig</tt> command.<p>
-After initial configuration, you can configure additional options to customize the behavior of the DHCP server using the Modify option from the Service menu to open the <A HREF="dhcp_server_serv.html">Modify Service Options</A> dialog box. Use the Service menu to <A HREF="dhcp_relay_how.html#start"> stop, start,</A> <A HREF="dhcp_relay_how.html#dis">disable, enable, </A>and <A HREF="dhcp_relay_how.html#uncon">unconfigure</A> the DHCP server. The Service menu also provides selections for <A HREF="dhcp_relay_how.html#exp">exporting and importing data</A>, and <A HREF="dhcp_relay_how.html#conv">converting the data store</A>.
-
-<H2>BOOTP Relay Agent</H2>
-The BOOTP relay agent can receive requests for configuration from a client in a network not directly connected to a DHCP server and forward the request to a DHCP server. Use the <A HREF="dhcp_relay_config.html">BOOTP Configuration</A> dialog box for initial configuration. You can configure additional options using the Modify option from the Service menu to open the <A HREF="dhcp_relay_serv.html">Modify Service Options</A> dialog box. Use the Service menu to <A HREF="dhcp_relay_how.html#start"> stop, start,</A> <A HREF="dhcp_relay_how.html#dis">disable, enable, </A>and <A HREF="dhcp_relay_how.html#uncon2">unconfigure</A> the BOOTP relay agent. <P>
-
-<H2>Networks</H2>
-The DHCP server can manage clients and addresses on configured networks. Use the <A HREF="dhcp_config_wiz.html">DHCP Configuration Wizard</A> to configure the first network. After initial configuration, you can configure additional networks with the <A HREF="dhcp_net_wiz.html">Network Wizard</A>, available from the Edit menu.<P>
-Select <A HREF="dhcp_net_del.html">Delete Network</A> from the Edit menu to remove a network from the list of monitored networks.
-
-
-<p> </p>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_serv.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_serv.html deleted file mode 100644 index 0c2bfeed94..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_serv.html +++ /dev/null @@ -1,161 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Relay Agent Services</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=625>
-
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="left" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
-
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><BR>
- <A HREF="dhcp_config_wiz.html">DHCP Config</A><BR>
- <A HREF="dhcp_relay_config.html">BOOTP Config</A><BR>
- <A HREF="dhcp_net_wiz.html">Net Config</A><BR>
- <A HREF="dhcp_server_serv.html">DHCP Services</A><BR>
-
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">BOOTP Services<BR>
- <a href="#log"><EM>Verbose</EM></a><BR>
- <a href="#hops"><EM>Hops</EM></a><BR>
- <a href="#srvrs"><EM>Servers</EM></a><BR>
- <a href="#inter"><EM>Interfaces</EM></a><P>
-
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" WIDTH="495">
-
-<P> </P>
-
-<h1>Modifying Service Options <BR>on a BOOTP Relay Agent</h1>
-
-After the initial configuration, choose Modify from the Service menu to customize additional settings for the BOOTP Relay Agent. <P>
-The Modify Service Options dialog lets you configure the following options.
-<P>
-
-<table border=0 cellspacing=4 cellpadding=3 width=440>
- <tr>
- <td width=125 valign="top"><A NAME="log"><STRONG>Verbose Log Messages </STRONG></A></td>
- <td width=315 valign="top">
-The DHCP daemon writes messages to the <TT>syslogd</TT> facility. <P>In verbose mode, the DHCP daemon displays more messages than in non-verbose mode. This can reduce efficiency due to the time taken to write and display the messages, so it should be reserved for troubleshooting. The default is for non-verbose mode.
- </TD>
- </tr>
-
- <tr>
- <td width=125 valign="top"><A NAME="hops"><STRONG>Maximum Relay Agent Hops</STRONG></A>
- </td>
- <td width=315 valign="top">Specify the maximum number of times the request can be relayed to another server before the receiving BOOTP relay agent drops the request. The default is 4.
- </td>
- </tr>
-
- <tr>
- <td width=125 valign="top"><A NAME="srvrs"><STRONG>DHCP Servers</STRONG></A>
- </td>
- <td width=315 valign="top">Enter the host names or IP addresses of the DHCP servers to which this BOOTP relay agent will forward requests. Use this option to add to the list of servers that were configured during initial configuration. You can also use this option to delete configured servers.<P>
- </td>
- </tr>
-
-
- <tr>
- <td width=125 valign="top"><A NAME="inter"><STRONG>Interfaces</STRONG></A></td>
- <td valign="top">Click the Interfaces tab to choose the network interfaces the DHCP server will monitor.<P> The interfaces are listed by device name and IP network address. Use the arrow keys to remove or restore a network interface to the list of monitored interfaces.<P> The default is to allow the server to monitor all network interfaces.
-
- </td>
- </TR>
-
-</table>
-
-
-
-<p> </p>
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_unconfig.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_unconfig.html deleted file mode 100644 index 2eeb79bcff..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_relay_unconfig.html +++ /dev/null @@ -1,113 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Unconfigure BOOTP Relay Agent</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-<h1>Unconfigure BOOTP Service</h1>
-
-Click OK to unconfigure the BOOTP relay service for this server. The server will cease to relay requests for DHCP configuration. To restore BOOTP service, you must reconfigure the server using the BOOTP configuration dialog box.<P>
-Use <A HREF="dhcp_relay_how.html#start">Stop</A> or <A HREF="dhcp_relay_how.html#dis">Disable</A> from the Service menu to halt or disable DHCP service.
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_server_serv.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_server_serv.html deleted file mode 100644 index 505680d924..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_server_serv.html +++ /dev/null @@ -1,247 +0,0 @@ -<!--
- -- #ident "%Z%%M% %I% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- -- Use is subject to license terms.^M - -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: DHCP Services</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=625>
-
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="left" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
-
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><BR>
- <A HREF="dhcp_config_wiz.html">DHCP Config</A><BR>
- <A HREF="dhcp_relay_config.html">BOOTP Config</A><BR>
- <A HREF="dhcp_net_wiz.html">Net Config</A><BR>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">DHCP Services<BR>
- <a href="#hops"><EM>Hops</EM></a><BR>
- <a href="#log"><EM>Verbose</EM></a><BR>
- <a href="#trans"><EM>Log Trans</EM></a><BR>
- <a href="#dupaddr"><EM>Detect Addr</EM></a><BR>
- <a href="#rescan"><EM>Reload</EM></a><BR>
- <a href="#dnsup"><EM>Update DNS</EM></a><BR>
- <a href="#dnstime"><EM>Timeout DNS</EM></a><BR>
- <a href="#cache"><EM>Cache</EM></a><BR>
- <a href="#compat"><EM>BOOTP</EM></a><BR>
- <a href="#inter"><EM>Interfaces</EM></a><BR>
- <a href="#addrs"><EM>Addresses</EM></a><BR>
- <A HREF="dhcp_relay_serv.html">BOOTP Services</A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
-<A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" WIDTH="495">
-
-<P> </P>
-
-<h1>Modifying Service Options <BR>on a DHCP Server</h1>
-
-After the initial configuration, choose Modify in the Service menu to customize additional settings for the DHCP server. Changes you make here become the default settings used by the server in this session and each subsequent session.<P>
-Use the Modify Service Options dialog box to configure the following options.
-<P>
-
-<table border=0 cellspacing=4 cellpadding=3 width=430>
-
- <tr>
- <td width=125 valign="top"><A NAME="hops"><STRONG>Maximum Relay Agent Hops</STRONG></A><br>
- </td>
- <td valign="top">Specify the maximum number of relay hops that can occur before the DHCP server drops the request. The default is 4.
- </td>
- </tr>
-
- <TR>
- <td width=145 valign="top"><A NAME="log"><STRONG>Verbose Log Messages</STRONG></A><br></td>
- <td valign="top">
-The DHCP daemon writes messages to the <TT>syslogd</TT> facility.
-In verbose mode, the DHCP daemon displays more messages than in non-verbose mode. This can reduce efficiency due to the time taken to write and display the messages. The default is for non-verbose mode.
- </TD>
- </tr>
-
- <tr>
- <td VALIGN=TOP WIDTH="145"><a name="trans"><STRONG>Log Transactions to syslog Facility</STRONG></A><br></td>
-
-<td valign="top">
-Select whether to have the DHCP daemon log transactions using
- <tt>syslogd</tt>, and select an integer from 0 through 7 to
-specify the local syslog facility. The local syslog facility can be used to selectively
-view transaction messages generated by the DHCP daemon. Transactions include
-all DHCP messages between the daemon and clients. This feature may be useful
-in troubleshooting problems with DHCP.</td>
-</tr>
-
-
-
- <TR><TD VALIGN="top"><A NAME="dupaddr"><STRONG>Detect Duplicate IP Addresses</STRONG></A></TD>
-
-<TD>By default, the DHCP server pings an IP address before offering it to
-a DHCP or BOOTP client to verify that the address is not in use by
-another client. Uncheck the box to disable this action. (Disabling this feature is not recommended.)<BR></TD></TR>
-
-
- <tr>
- <td width=125 valign="top"><A NAME="rescan"><STRONG>Reload <tt>dhcptab</tt></STRONG></A></td>
- <td valign="top">
-Specify the interval, in minutes, that the DHCP server should use to schedule the rereading of the <tt>dhcptab</tt> information.<P>
-The DHCP server reads the <tt>dhcptab</tt> at startup and not again until told to do so.<p>
-Typically, the DHCP Manager causes the server to reread the <tt>dhcptab</tt> whenever you make a change to the data. The default is to turn off this option to avoid needless re-initialization of the <tt>dhcptab</tt>.
- </td>
- </tr>
-
-<tr>
- <td width=125 valign="top"><A NAME="dnsup"><STRONG>Update DNS host information</STRONG></A></td>
- <td valign="top">
-Select this option if this DHCP server supports clients that can specify their host names, and you want to have those host names added to the DNS tables. The DNS server must be set up to accept update requests from the DHCP server. See the Solaris <em>DHCP Administration Guide</em> for more information.</td>
- </tr>
-
-<tr> <td width=125 valign="top"><A NAME="dnstime"><STRONG>Timeout DNS update</STRONG></A></td>
- <td valign="top">
-Specify the number of seconds to wait for a response from the DNS server
-before timing out. The default is 15 seconds. This option is available only if you selected Update DNS host information.</tr>
- <tr>
- <td width=125 valign="top"><A NAME="cache"><STRONG>Cache Offers</STRONG></A> <br>
- </td>
- <td valign="top">Specify the number of seconds the server will hold open the offer to a client request for configuration. The default is 10 seconds.<P>
-You can increase this time to compensate for slow performance on a slow network.
- </td>
- </tr>
- <tr>
- <td width=145 valign="top"><A NAME="compat"><STRONG>BOOTP Compatibility</STRONG></A><br>
- </td>
- <td valign="top">Select whether to allow the DHCP server to operate in BOOTP compatibility mode. In this mode, the DHCP server will respond to requests for configuration from BOOTP clients.
-
-<table border=0 cellspacing=3 cellpadding=3 width=300>
-<TR>
-<TD width=80 valign="top"><B>None</b></TD>
-<td valign="top">Do not support BOOTP clients.<P></TD>
-</TR>
-
-<TR>
-<TD WIDTH="80" VALIGN="TOP"><strong>Automatic</strong></TD>
-<TD>Automatically allocate permanent IP addresses to any requesting BOOTP clients.</TD>
-</TR>
-
-<TR>
-<TD WIDTH="80" VALIGN="TOP"><b>Manual</b></TD>
-<TD>Respond only to clients that have been assigned a reserved address in the server's network tables.</TD>
-</TR>
-</table>
-
- </td>
- </tr>
-
- <tr>
- <td width=125 valign="top"><A NAME="inter"><STRONG>Interfaces</STRONG></A></td>
- <td valign="top">Click the Interfaces tab to choose which network interfaces the DHCP server will monitor.<P> The interfaces are listed by device name and network IP address. Use the arrow keys to remove or restore a network interface to the list of monitored interfaces.<P> The default is to allow the server to monitor all network interfaces.
-
- </td>
-
- </tr>
- - <tr>
- <td width=125 valign="top"><A NAME="addrs"><STRONG>Addresses</STRONG></A></td>
- <td valign="top">Click the Addresses tab to choose which server addresses the DHCP server will own.<P> The DHCP server will manage all client records that are owned by the server addresses listed.<P> The default is to manage records owned by the server's primary IP address.
-
- </td>
-
- </tr>
-
-
-
-
-</table>
- <A HREF="#top"><small>return to top</small></A>
-
-
-
-
-<p> </p>
-
-
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_server_unconfig.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_server_unconfig.html deleted file mode 100644 index df2396c8bf..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_server_unconfig.html +++ /dev/null @@ -1,122 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: Unconfigure DHCP Server</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=615>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" WIDTH="105">
- <P> </P>
- <STRONG><A HREF="dhcp_main_top.html">Overview</A></STRONG><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
-<A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-
- <td colspan=1 valign="top" bgcolor="#ffffff">
- <P> </P>
-
-
-<h1>Unconfigure DHCP Service</h1>
-
-If you no longer want a system to run the DHCP service, you can unconfigure the DHCP service. If you want the DHCP service to be halted temporarily, use <A HREF="dhcp_relay_how.html#start">Stop</A> or <A HREF="dhcp_relay_how.html#dis">Disable</A> from the Service menu to halt or disable DHCP service.
-<p>
-If you want to unconfigure the DHCP server, but the networks and addresses served by this server are still to be used as DHCP addresses, be sure that you have transferred those addresses to another working DHCP server before unconfiguring the original server. See <a href="dhcp_relay_how.html#exp">instructions for exporting and importing data</a> .<p>
-When you unconfigure the server, you must decide what to do with the server's data: <P>
-<STRONG>Remove all hosts table entries for DHCP addresses:</STRONG>
-Unconfiguring the DHCP server will remove all DHCP tables. Be aware that if you are sharing the DHCP data using NIS+ or through files shared in NFS, you should not remove the DHCP data. <P>
-
-<STRONG>Remove the dhcptab and all DHCP network tables:</STRONG>
-Check this box to also remove entries from the server's hosts resource.<P>
-
-
-<p> </p>
-
-<!-- Don't go past this line! -->
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_solaris_about.html b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_solaris_about.html deleted file mode 100644 index a066785c37..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/help/dhcp_solaris_about.html +++ /dev/null @@ -1,169 +0,0 @@ -<!--
- -- ident "%W% %E% SMI"
- --
- CDDL HEADER START - - The contents of this file are subject to the terms of the - Common Development and Distribution License, Version 1.0 only - (the "License"). You may not use this file except in compliance - with the License. - - You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - or http://www.opensolaris.org/os/licensing. - See the License for the specific language governing permissions - and limitations under the License. - - When distributing Covered Code, include this CDDL HEADER in each - file and include the License file at usr/src/OPENSOLARIS.LICENSE. - If applicable, add the following below this CDDL HEADER, with the - fields enclosed by brackets "[]" replaced with your own identifying - information: Portions Copyright [yyyy] [name of copyright owner] - - CDDL HEADER END - - -- Copyright (c) 2000-2001 by Sun Microsystems, Inc.
- -- All rights reserved.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<html>
-
-<head>
-<title>DHCP Manager Help: About Solaris DHCP</title>
-<meta NAME="AUTHOR" CONTENT="smorgan">
-<meta NAME="KEYWORDS" CONTENT="DHCP">
-
-</head>
-
-<body bgcolor="#FFFFFF">
-
-<a name="top"></a>
-
-<table border=0 cellspacing=0 cellpadding=0 width=625>
-
-<!-- Start navigation banner -->
-
-<tr><td colspan=4 WIDTH="615" align="center" valign="top"><IMG SRC="art/bannersmc.gif" WIDTH=615 BORDER=0 ALT="DHCP Manager Help">
-
- </td>
- </tr>
-
-<!-- End navigation banner -->
-
-
-<tr>
-
-<!-- Start contents block -->
-
- <td colspan=1 valign="top" width=105>
- <P> </P>
- <A HREF="dhcp_main_top.html"><STRONG>Overview</STRONG></A><BR>
- <IMG SRC="art/tip2.gif" WIDTH=12 HEIGHT=10 BORDER=0 ALT="">About Solaris DHCP<BR>
- <A HREF="dhcp_macros_about.html">About Macros</A><BR>
- <A HREF="dhcp_main_hlp.html">Getting Help</A><P>
- <A HREF="dhcp_relay_ref.html"><STRONG>Servers and Relays</STRONG></A><P>
- <A HREF="dhcp_addr_ref.html"><STRONG>Addresses</STRONG></A><P>
- <A HREF="dhcp_macro_ref.html"><STRONG>Macros</STRONG></A><P>
- <A HREF="dhcp_option_ref.html"><STRONG>Options</STRONG></A><P>
- <A HREF="dhcp_main_how.html"><STRONG>How To..</STRONG></A><P>
- <A HREF="dhcp_main_menus.html"><STRONG>Menus</STRONG></A><P>
- <A HREF="dhcp_main_idx.html"><STRONG>Index</STRONG></A>
-
- </td>
-
-<!-- End contents block -->
-
-<!-- Start column rule -->
-
- <td colspan=1 width=5 bgcolor="#CCCCCC"> </td>
-
-<!-- End column spacer -->
-
-<!-- Start column spacer -->
-
- <td colspan=1 width=10 bgcolor="#FFFFFF"> </td>
-
-<!-- End column spacer -->
-
-
-
-<!-- Start topic block -->
-
-<td colspan=1 valign="top" bgcolor="#ffffff" width=495>
-
-
-
-<P> </P>
-
-
-<H1>About Solaris DHCP</H1>
-
-The Solaris<FONT SIZE="-1"><sup>TM</sup></FONT> DHCP server (<tt>in.dhcpd</tt>) provides DHCP services for DHCP and BOOTP clients. The Solaris DHCP implementation allows flexibility in the assignment of network configuration through the use of <a href="dhcp_macros_about.html">macros </a> containing network parameter values. Macros are processed selectively to assign appropriate parameters to clients.<p>
-
-The following illustration provides a high-level description of the DHCP/BOOTP client boot process, including macro processing, under Solaris DHCP.<p>
-
-<center>
-<a href="dhcp_macro_ref.html"><img src="art/macroflow.gif" border=0></a>
-</center>
-
-<p>In the illustration:<p>
-
- <ol type=1>
-
- <li>A DHCP/BOOTP client initiates a DHCP request.<p></li>
-
- <li>An available DHCP server accepts the request and initiates the DHCP
- allocation process:<p>
-
- <ol type=a>
-
- <li>An available <A NAME="addr"><strong>IP address</strong></A> is found in the
- DHCP network tables and assigned to the
- client.<p></li>
-
- <li> Option values in the <A NAME="class"><strong>Client Class</strong></A> macro
- (platform/operating system), located in the server's <tt>dhcptab</tt>
- table, are bundled and passed to the next stage.<p></li>
-
- <li>Option values in the <A NAME="ntwrk"><strong>Network</strong></A> macro (client
- network), located in the server's <A NAME="dhcptab"><tt>dhcptab</tt></A>, are bundled and passed to
- the next stage.<p></li>
-
- <li>Option values in the <A NAME="ip"><strong>IP Address</strong></A> macro
- (server-specific), located in the server's <tt>dhcptab</tt>, are bundled and
- passed to the next stage.<p></li>
-
- <li> Option values in the <A NAME="cid"><strong>Client ID</strong></A> macro
- (unique to client, for example, Ethernet/MAC ID), located in the
- server's <tt>dhcptab</tt>, are bundled and passed to the next stage.<p></li>
- </ol>
-
- <p></li>
-
- <li>All option values are bundled together, along with the IP address
- assigned by the DHCP server, and passed back to the DHCP client.<p></li>
-
- <li>The client completes the boot process, using the IP address and
- values passed from the DHCP server.<p></li>
- </ol>
-
-Refer to the help pages for more information about <A HREF="dhcp_macro_ref.html">
-macros</A> and <A HREF="dhcp_option_ref.html">options</A>.
-
-<p> </p>
- <A HREF="#top"><FONT SIZE="2">return to top</FONT></A>
-
-<!-- Don't go past this line! -->
-
-
- </td>
-
-<!-- End topic block -->
-
-</tr>
-
-</table>
-
-<!-- End topic table -->
-
-</body>
-</html>
diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/inc.flg b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/inc.flg deleted file mode 100644 index 9e8d46aefc..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/inc.flg +++ /dev/null @@ -1,32 +0,0 @@ -#! /bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 1999-2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -find_files "s.*" usr/src/lib/libdhcpsvc -find_files "s.*" usr/src/cmd/cmd-inet/usr.lib/dhcp -exec_file usr/src/lib/req.flg diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/Makefile b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/Makefile deleted file mode 100644 index 5ac8ee0d63..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/Makefile +++ /dev/null @@ -1,71 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -LIBRARY= dhcpmgr.a -VERS= .1 -OBJECTS= dhcptab.o exception.o network.o optiondefs.o service.o \ - inittab.o dd_misc.o dd_opt.o class_cache.o - -include $(SRC)/lib/Makefile.lib - -SRCDIR = . - -# Override install location -ROOTLIBDIR= $(ROOT)/usr/sadm/admin/dhcpmgr - -LIBS= $(DYNLIB) - -# There should be a mapfile here -MAPFILES = - -CPPFLAGS += -I../com/sun/dhcpmgr/bridge \ - -I$(JAVA_ROOT)/include \ - -I$(JAVA_ROOT)/include/solaris \ - -I$(SRC)/common/net/dhcp \ - -I. - -CERRWARN += -_gcc=-Wno-type-limits -CERRWARN += -_gcc=-Wno-uninitialized - -LDLIBS += -ldhcpsvc -ldhcputil -linetutil -lscf -lsocket -lresolv -lnsl -lc - -# definitions for i18n -POFILE= $(LIBRARY:%.a=%.po) -MSGFILES = `$(GREP) -l gettext *.[ch]` - -.KEEP_STATE: -.PARALLEL: $(OBJECTS) -.WAIT: $(DYNLIB) - -all: $(LIBS) - -install: all $(ROOTLIBS) - -lint: lintcheck - -_msg: pofile_MSGFILES - -include $(SRC)/lib/Makefile.targ -include $(SRC)/Makefile.msg.targ diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/class_cache.c b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/class_cache.c deleted file mode 100644 index 6f83980d08..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/class_cache.c +++ /dev/null @@ -1,265 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <assert.h> -#include <synch.h> -#include <jni.h> - -#include "class_cache.h" - -/* - * Only certain classes are deemed worthy of caching. These be them. - */ -#define DCR_NAME "com/sun/dhcpmgr/data/DhcpClientRecord" -#define DTR_NAME "com/sun/dhcpmgr/data/DhcptabRecord" -#define NET_NAME "com/sun/dhcpmgr/data/Network" -#define MAC_NAME "com/sun/dhcpmgr/data/Macro" -#define OPT_NAME "com/sun/dhcpmgr/data/Option" -#define DS_NAME "com/sun/dhcpmgr/data/DhcpDatastore" -#define CFG_NAME "com/sun/dhcpmgr/data/DhcpdOptions" -#define RES_NAME "com/sun/dhcpmgr/data/DhcpResource" -#define IP_NAME "com/sun/dhcpmgr/data/IPAddress" -#define IPIF_NAME "com/sun/dhcpmgr/data/IPInterface" - -/* - * As with classes, only certain methods are cached. - */ -#define DCR_CONS_NAME "<init>" -#define DCR_GETCID_NAME "getClientId" -#define DCR_GETFLAG_NAME "getFlagString" -#define DCR_GETCIP_NAME "getClientIPAddress" -#define DCR_GETSIP_NAME "getServerIPAddress" -#define DCR_GETEXP_NAME "getExpirationTime" -#define DCR_GETSIG_NAME "getSignature" -#define DCR_GETMAC_NAME "getMacro" -#define DCR_GETCMT_NAME "getComment" -#define DTR_GETKEY_NAME "getKey" -#define DTR_GETFLAG_NAME "getFlag" -#define DTR_GETSIG_NAME "getSignature" -#define DTR_GETVAL_NAME "getValue" -#define NET_CONS_NAME "<init>" -#define MAC_CONS_NAME "<init>" -#define OPT_CONS_NAME "<init>" -#define DS_CONS_NAME "<init>" -#define DS_GETRSRC_NAME "getResource" -#define DS_GETLOC_NAME "getLocation" -#define DS_GETRSRCCFG_NAME "getConfig" -#define DS_GETVER_NAME "getVersion" -#define CFG_CONS_NAME "<init>" -#define CFG_SET_NAME "set" -#define CFG_GETALL_NAME "getAll" -#define RES_GETKEY_NAME "getKey" -#define RES_GETVAL_NAME "getValue" -#define RES_ISCOM_NAME "isComment" -#define IP_CONS_NAME "<init>" -#define IPIF_CONS_NAME "<init>" - -/* - * Signatures for the methods can be found below. - */ -#define DCR_CONS_SIG "(Ljava/lang/String;Ljava/lang/String;"\ - "Ljava/lang/String;Ljava/lang/String;"\ - "Ljava/lang/String;Ljava/lang/String;"\ - "Ljava/lang/String;Ljava/lang/String;)V" - -#define DCR_GETCID_SIG "()Ljava/lang/String;" -#define DCR_GETFLAG_SIG "()Ljava/lang/String;" -#define DCR_GETCIP_SIG "()Ljava/lang/String;" -#define DCR_GETSIP_SIG "()Ljava/lang/String;" -#define DCR_GETEXP_SIG "()Ljava/lang/String;" -#define DCR_GETSIG_SIG "()Ljava/lang/String;" -#define DCR_GETMAC_SIG "()Ljava/lang/String;" -#define DCR_GETCMT_SIG "()Ljava/lang/String;" -#define DTR_GETKEY_SIG "()Ljava/lang/String;" -#define DTR_GETFLAG_SIG "()Ljava/lang/String;" -#define DTR_GETSIG_SIG "()Ljava/lang/String;" -#define DTR_GETVAL_SIG "()Ljava/lang/String;" -#define NET_CONS_SIG "(Ljava/lang/String;I)V" -#define MAC_CONS_SIG "(Ljava/lang/String;Ljava/lang/String;"\ - "Ljava/lang/String;)V" -#define OPT_CONS_SIG "(Ljava/lang/String;B[Ljava/lang/String;"\ - "SBIILjava/lang/String;Z)V" -#define DS_CONS_SIG "(Ljava/lang/String;IZ)V" -#define DS_GETRSRC_SIG "()Ljava/lang/String;" -#define DS_GETLOC_SIG "()Ljava/lang/String;" -#define DS_GETRSRCCFG_SIG "()Ljava/lang/String;" -#define DS_GETVER_SIG "()I" -#define CFG_CONS_SIG "()V" -#define CFG_SET_SIG "(Ljava/lang/String;Ljava/lang/String;Z)V" -#define CFG_GETALL_SIG "()[Ljava/lang/Object;" -#define RES_GETKEY_SIG "()Ljava/lang/String;" -#define RES_GETVAL_SIG "()Ljava/lang/String;" -#define RES_ISCOM_SIG "()Z" -#define IP_CONS_SIG "(Ljava/lang/String;)V" -#define IPIF_CONS_SIG "(Ljava/lang/String;Ljava/lang/String;"\ - "Ljava/lang/String;)V" -/* - * Class map. - */ -typedef struct { - jclass cl_class; - char *cl_name; -} cl_map_t; - -/* - * Note that the order of the entries in this table must match - * exactly with the CC_CLASSMAP_ID enumeration in class_cache.h. - */ -static cl_map_t classMap[] = { - { NULL, DCR_NAME }, /* DCR_CLASS */ - { NULL, DTR_NAME }, /* DTR_CLASS */ - { NULL, NET_NAME }, /* NET_CLASS */ - { NULL, MAC_NAME }, /* MAC_CLASS */ - { NULL, OPT_NAME }, /* OPT_CLASS */ - { NULL, DS_NAME }, /* DS_CLASS */ - { NULL, CFG_NAME }, /* CFG_CLASS */ - { NULL, RES_NAME }, /* RES_CLASS */ - { NULL, IP_NAME }, /* IP_CLASS */ - { NULL, IPIF_NAME } /* IPIF_CLASS */ -}; - -/* - * Method ID map. - */ -typedef struct { - jmethodID mi_methodID; - char *mi_name; - char *mi_signature; -} mi_map_t; - -/* - * Note that the order of the entries in this table must match - * exactly with the CC_METHODMAP_ID enumeration in class_cache.h. - */ -static mi_map_t methodIDMap[] = { - { NULL, DCR_CONS_NAME, DCR_CONS_SIG }, /* DCR_CONS */ - { NULL, DCR_GETCID_NAME, DCR_GETCID_SIG }, /* DCR_GETCID */ - { NULL, DCR_GETFLAG_NAME, DCR_GETFLAG_SIG }, /* DCR_GETFLAG */ - { NULL, DCR_GETCIP_NAME, DCR_GETCIP_SIG }, /* DCR_GETCIP */ - { NULL, DCR_GETSIP_NAME, DCR_GETSIP_SIG }, /* DCR_GETSIP */ - { NULL, DCR_GETEXP_NAME, DCR_GETEXP_SIG }, /* DCR_GETEXP */ - { NULL, DCR_GETSIG_NAME, DCR_GETSIG_SIG }, /* DCR_GETSIG */ - { NULL, DCR_GETMAC_NAME, DCR_GETMAC_SIG }, /* DCR_GETMAC */ - { NULL, DCR_GETCMT_NAME, DCR_GETCMT_SIG }, /* DCR_GETCMT */ - { NULL, DTR_GETKEY_NAME, DTR_GETKEY_SIG }, /* DTR_GETKEY */ - { NULL, DTR_GETFLAG_NAME, DTR_GETFLAG_SIG }, /* DTR_GETFLAG */ - { NULL, DTR_GETSIG_NAME, DTR_GETSIG_SIG }, /* DTR_GETSIG */ - { NULL, DTR_GETVAL_NAME, DTR_GETVAL_SIG }, /* DTR_GETVAL */ - { NULL, NET_CONS_NAME, NET_CONS_SIG }, /* NET_CONS */ - { NULL, MAC_CONS_NAME, MAC_CONS_SIG }, /* MAC_CONS */ - { NULL, OPT_CONS_NAME, OPT_CONS_SIG }, /* OPT_CONS */ - { NULL, DS_CONS_NAME, DS_CONS_SIG }, /* DS_CONS */ - { NULL, DS_GETRSRC_NAME, DS_GETRSRC_SIG }, /* DS_GETRSRC */ - { NULL, DS_GETLOC_NAME, DS_GETLOC_SIG }, /* DS_GETLOC */ - { NULL, DS_GETRSRCCFG_NAME, DS_GETRSRCCFG_SIG }, /* DS_GETRSRCCFG */ - { NULL, DS_GETVER_NAME, DS_GETVER_SIG }, /* DS_GETVER */ - { NULL, CFG_CONS_NAME, CFG_CONS_SIG }, /* CFG_CONS */ - { NULL, CFG_SET_NAME, CFG_SET_SIG }, /* CFG_SET */ - { NULL, CFG_GETALL_NAME, CFG_GETALL_SIG }, /* CFG_GETALL */ - { NULL, RES_GETKEY_NAME, RES_GETKEY_SIG }, /* RES_GETKEY */ - { NULL, RES_GETVAL_NAME, RES_GETVAL_SIG }, /* RES_GETVAL */ - { NULL, RES_ISCOM_NAME, RES_ISCOM_SIG }, /* RES_ISCOM */ - { NULL, IP_CONS_NAME, IP_CONS_SIG }, /* IP_CONS */ - { NULL, IPIF_CONS_NAME, IPIF_CONS_SIG } /* IPIF_CONS */ -}; - -/* - * The locks to protect the class and method maps. - */ -static mutex_t cmap_lock; -static mutex_t mmap_lock; - -void -init_class_cache(void) { - (void) mutex_init(&cmap_lock, USYNC_THREAD, NULL); - (void) mutex_init(&mmap_lock, USYNC_THREAD, NULL); -} - -/* - * Get a dhcpmgr class from the cache. - */ -jclass -find_class(JNIEnv *env, CC_CLASSMAP_ID id) { - - jclass *class; - - assert(id >= 0 && id <= CC_CLASSMAP_NUM); - - /* - * If the class has not been cached yet, go find it and cache it. - */ - class = &classMap[id].cl_class; - if (*class == NULL) { - /* - * Check again with the lock held this time. - */ - (void) mutex_lock(&cmap_lock); - if (*class == NULL) { - char *name = classMap[id].cl_name; - jclass local = (*env)->FindClass(env, name); - if (local != NULL) { - *class = (*env)->NewGlobalRef(env, local); - (*env)->DeleteLocalRef(env, local); - } - } - (void) mutex_unlock(&cmap_lock); - } - - return (*class); -} - -/* - * Get a dhcpmgr class methodid from the cache. - */ -jmethodID -get_methodID(JNIEnv *env, jclass class, CC_METHODMAP_ID id) { - - jmethodID *methodID; - - assert(id >= 0 && id <= CC_METHODMAP_NUM); - - /* - * If the methodID has not been cached, go find it and cache it. - */ - methodID = &methodIDMap[id].mi_methodID; - if (*methodID == NULL) { - /* - * Check again with the lock held this time. - */ - (void) mutex_lock(&mmap_lock); - if (*methodID == NULL) { - char *name = methodIDMap[id].mi_name; - char *signature = methodIDMap[id].mi_signature; - *methodID = (*env)->GetMethodID(env, class, name, - signature); - } - (void) mutex_unlock(&mmap_lock); - } - - return (*methodID); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/class_cache.h b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/class_cache.h deleted file mode 100644 index 3d2f10ac79..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/class_cache.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _CLASS_CACHE_H -#define _CLASS_CACHE_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <jni.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - DCR_CLASS, DTR_CLASS, NET_CLASS, MAC_CLASS, OPT_CLASS, DS_CLASS, - CFG_CLASS, RES_CLASS, IP_CLASS, IPIF_CLASS -} CC_CLASSMAP_ID; -#define CC_CLASSMAP_NUM IPIF_CLASS + 1 - -typedef enum { - DCR_CONS, DCR_GETCID, DCR_GETFLAG, DCR_GETCIP, DCR_GETSIP, DCR_GETEXP, - DCR_GETSIG, DCR_GETMAC, DCR_GETCMT, DTR_GETKEY, DTR_GETFLAG, - DTR_GETSIG, DTR_GETVAL, NET_CONS, MAC_CONS, OPT_CONS, DS_CONS, - DS_GETRSRC, DS_GETLOC, DS_GETRSRCCFG, DS_GETVER, CFG_CONS, CFG_SET, - CFG_GETALL, RES_GETKEY, RES_GETVAL, RES_ISCOM, IP_CONS, IPIF_CONS -} CC_METHODMAP_ID; -#define CC_METHODMAP_NUM IPIF_CONS + 1 - -extern void init_class_cache(void); -extern jclass find_class(JNIEnv *, CC_CLASSMAP_ID); -extern jmethodID get_methodID(JNIEnv *, jclass, CC_METHODMAP_ID); - -#ifdef __cplusplus -} -#endif - -#endif /* !_CLASS_CACHE_H */ diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dd_misc.c b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dd_misc.c deleted file mode 100644 index 5b0c976dc8..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dd_misc.c +++ /dev/null @@ -1,677 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include <dhcp_svc_private.h> -#include <dirent.h> -#include <stdlib.h> -#include <string.h> -#include <stdio.h> -#include <errno.h> -#include <signal.h> -#include <fcntl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/socket.h> -#include <sys/sockio.h> -#include <net/if.h> -#include <libintl.h> -#include <procfs.h> -#include <rpcsvc/nis.h> -#include <malloc.h> -#include <ctype.h> -#include <jni.h> - -#include "exception.h" -#include "class_cache.h" -#include "dd_misc.h" - -#define PROCFS_DIR "/proc" - -/* - * Frees the list of data store strings. - */ -static void -free_enumerated_dd(char **module, int count) -{ - while (count-- > 0) { - free(module[count]); - } - free(module); -} - -/* - * Determines if a given data store name is valid. - */ -static boolean_t -dd_is_valid_data_store(JNIEnv *env, const char *name) -{ - char **module; - int count; - int ndx; - int rcode; - boolean_t isValid = B_FALSE; - - if (name != NULL) { - rcode = enumerate_dd(&module, &count); - if (rcode != DSVC_SUCCESS) { - throw_libdhcpsvc_exception(env, rcode); - } else { - for (ndx = 0; !isValid && ndx < count; ndx++) { - if (strcmp(module[ndx], name) == 0) { - isValid = B_TRUE; - } - } - free_enumerated_dd(module, count); - } - } - return (isValid); -} - -/* - * Call a java object's int getter method. - */ -static boolean_t -dd_get_int_attr( - JNIEnv *env, - jclass class, - int id, - jobject obj, - int *value) { - - jmethodID methodID; - jint jval; - boolean_t noException = B_TRUE; - - methodID = get_methodID(env, class, id); - if (methodID == NULL) { - noException = B_FALSE; - } else { - jval = (*env)->CallIntMethod(env, obj, methodID); - if ((*env)->ExceptionOccurred(env) != NULL) { - noException = B_FALSE; - } else { - *value = jval; - } - } - return (noException); -} - -/* - * Convert a possibly multi-byte string to a jstring. - */ -jstring -dd_native_to_jstring(JNIEnv *env, const char *str) -{ - jstring result; - jbyteArray bytes = 0; - int len; - - jclass strclass; - jmethodID mid; - - strclass = (*env)->FindClass(env, "java/lang/String"); - if (strclass == NULL) { - /* exception thrown */ - return (NULL); - } - - mid = (*env)->GetMethodID(env, strclass, "<init>", "([B)V"); - if (mid == NULL) { - /* exception thrown */ - return (NULL); - } - - len = strlen(str); - bytes = (*env)->NewByteArray(env, len); - if (bytes == NULL) { - /* exception thrown */ - return (NULL); - } - - (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte *) str); - result = (*env)->NewObject(env, strclass, mid, bytes); - - (*env)->DeleteLocalRef(env, bytes); - return (result); -} - -/* - * Convert a jstring to a possibly multi-byte string. - */ -char * -dd_jstring_to_native(JNIEnv *env, jstring jstr) { - - jbyteArray bytes = 0; - jint len; - char *result; - - jclass strclass; - jmethodID mid; - - strclass = (*env)->FindClass(env, "java/lang/String"); - if (strclass == NULL) { - /* exception thrown */ - return (NULL); - } - - mid = (*env)->GetMethodID(env, strclass, "getBytes", "()[B"); - if (mid == NULL) { - /* exception thrown */ - return (NULL); - } - - bytes = (*env)->CallObjectMethod(env, jstr, mid); - if ((*env)->ExceptionOccurred(env)) { - /* exception thrown */ - return (NULL); - } - - len = (*env)->GetArrayLength(env, bytes); - result = (char *)malloc(len + 1); - if (result == NULL) { - throw_memory_exception(env); - (*env)->DeleteLocalRef(env, bytes); - return (NULL); - } - - (*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *) result); - result[len] = 0; - - (*env)->DeleteLocalRef(env, bytes); - return (result); -} - -/* - * Convert a jstring to a UTF-8 string. - */ -boolean_t -dd_jstring_to_UTF( - JNIEnv *env, - jstring javaString, - char **nativeString) -{ - boolean_t noException = B_TRUE; - - if (javaString != NULL) { - const char *str; - str = (*env)->GetStringUTFChars(env, javaString, NULL); - if (str == NULL) { - noException = B_FALSE; - } else { - *nativeString = strdup(str); - (*env)->ReleaseStringUTFChars(env, javaString, str); - if (*nativeString == NULL) { - throw_memory_exception(env); - noException = B_FALSE; - } - } - } else { - *nativeString = NULL; - } - - return (noException); -} - - -/* - * Call a java object's string getter method. - */ -boolean_t -dd_get_str_attr( - JNIEnv *env, - jclass class, - int id, - jobject obj, - char **value) { - - jmethodID methodID; - jstring jstr; - - *value = NULL; - - methodID = get_methodID(env, class, id); - if (methodID == NULL) { - return (B_FALSE); - } - - jstr = (*env)->CallObjectMethod(env, obj, methodID); - if ((*env)->ExceptionOccurred(env) != NULL) { - return (B_FALSE); - } - - if (jstr != NULL) { - *value = dd_jstring_to_native(env, jstr); - (*env)->DeleteLocalRef(env, jstr); - if (*value == NULL) { - return (B_FALSE); - } - } - - return (B_TRUE); -} - -/* - * Reads the DHCP configuration file and creates a dsvc_datastore_t. - */ -boolean_t -dd_get_conf_datastore_t(JNIEnv *env, dsvc_datastore_t *dsp) { - - dhcp_confopt_t *confopts; - int result; - boolean_t noException = B_TRUE; - - dsp->d_resource = NULL; - dsp->d_location = NULL; - dsp->d_config = NULL; - - result = read_dsvc_conf(&confopts); - if (result != 0) { - throw_no_defaults_exception(env); - noException = B_FALSE; - } else { - result = confopt_to_datastore(confopts, dsp); - if (result != DSVC_SUCCESS) { - throw_libdhcpsvc_exception(env, result); - noException = B_FALSE; - } - free_dsvc_conf(confopts); - } - return (noException); -} - -/* - * Makes a dsvc_datastore_t using the DHCP configuration file and overriding - * the settings with the arguments if they are non-NULL. - */ -boolean_t -dd_make_datastore_t(JNIEnv *env, - dsvc_datastore_t *dsp, - jobject jdatastore) { - - jclass ds_class; - jthrowable e; - - char *resource = NULL; - char *location = NULL; - char *config = NULL; - int version = DSVC_CUR_CONVER; - - dsp->d_resource = NULL; - dsp->d_location = NULL; - dsp->d_config = NULL; - - /* Locate the class we need */ - ds_class = find_class(env, DS_CLASS); - if (ds_class == NULL) { - /* exception thrown */ - return (B_FALSE); - } - - /* Obtain the DHCP config file data store settings */ - if (!dd_get_conf_datastore_t(env, dsp)) { - e = (*env)->ExceptionOccurred(env); - (*env)->ExceptionClear(env); - if (!is_no_defaults_exception(env, e)) { - (*env)->Throw(env, e); - return (B_FALSE); - } - } - - /* Get the resource */ - if (jdatastore != NULL && !dd_get_str_attr(env, ds_class, DS_GETRSRC, - jdatastore, &resource)) { - /* exception thrown */ - dd_free_datastore_t(dsp); - return (B_FALSE); - } - - /* If resource was passed in, then override config setting */ - if (resource != NULL) { - free(dsp->d_resource); - dsp->d_resource = resource; - dsp->d_conver = DSVC_CUR_CONVER; - } - - /* Validate the resource */ - if (!dd_is_valid_data_store(env, dsp->d_resource)) { - if ((*env)->ExceptionOccurred(env) == NULL) { - throw_invalid_resource_exception(env, dsp->d_resource); - } - dd_free_datastore_t(dsp); - return (B_FALSE); - } - - /* Get the location */ - if (jdatastore != NULL && !dd_get_str_attr(env, ds_class, DS_GETLOC, - jdatastore, &location)) { - /* exception thrown */ - dd_free_datastore_t(dsp); - return (B_FALSE); - } - - /* If location was passed in, then override config setting */ - if (location != NULL) { - free(dsp->d_location); - dsp->d_location = location; - } - - /* Must be defined */ - if (dsp->d_location == NULL) { - throw_invalid_path_exception(env, dsp->d_location); - dd_free_datastore_t(dsp); - return (B_FALSE); - } - - /* Get the config string */ - if (jdatastore != NULL && !dd_get_str_attr(env, ds_class, DS_GETRSRCCFG, - jdatastore, &config)) { - /* exception thrown */ - dd_free_datastore_t(dsp); - return (B_FALSE); - } - - /* If config string was passed in, then override config setting */ - if (config != NULL) { - free(dsp->d_config); - dsp->d_config = config; - } - - /* Get the version */ - if (jdatastore != NULL && !dd_get_int_attr(env, ds_class, DS_GETVER, - jdatastore, &version)) { - /* exception thrown */ - dd_free_datastore_t(dsp); - return (B_FALSE); - } - - /* If version was passed in, then override config setting */ - if (version != DSVC_CUR_CONVER) { - dsp->d_conver = version; - } - - return (B_TRUE); -} - -/* - * Frees the strings in a dsvc_datastore_t structure. - */ -void -dd_free_datastore_t(dsvc_datastore_t *dsp) { - free(dsp->d_resource); - free(dsp->d_location); - free(dsp->d_config); -} - -/* - * Returns the list of possible data stores for DHCP data. - * List returned is terminated with a NULL. - */ -char ** -dd_data_stores(JNIEnv *env) -{ - char **dsl = NULL; - char **module; - int count; - int ndx; - int rcode; - - rcode = enumerate_dd(&module, &count); - if (rcode != DSVC_SUCCESS) { - throw_libdhcpsvc_exception(env, rcode); - return (NULL); - } - - if (count == 0) { - return (NULL); - } - - dsl = calloc((count + 1), sizeof (char *)); - if (dsl == NULL) { - free_enumerated_dd(module, count); - throw_memory_exception(env); - return (NULL); - } - - for (ndx = 0; ndx < count; ndx++) { - dsl[ndx] = strdup(module[ndx]); - if (dsl[ndx] == NULL) { - break; - } - } - - free_enumerated_dd(module, count); - - if (ndx != count) { - dd_free_data_stores(dsl); - throw_memory_exception(env); - dsl = NULL; - } - - return (dsl); -} - -/* - * Free a data store list created by dd_data_stores(). - */ -void -dd_free_data_stores(char **dsl) -{ - int i = 0; - - if (dsl != NULL) { - for (i = 0; dsl[i] != NULL; ++i) { - free(dsl[i]); - } - free(dsl); - } -} - -/* - * Send a signal to a process whose command name is as specified - */ -int -dd_signal(char *fname, int sig) -{ - pid_t pid; - - pid = dd_getpid(fname); - if (pid == (pid_t)-1) { - return (-1); - } - - if (kill(pid, sig) != 0) { - return (errno); - } else { - return (0); - } -} - -/* - * Return a process's pid - */ -pid_t -dd_getpid(char *fname) -{ - DIR *dirptr; - dirent_t *direntptr; - psinfo_t psinfo; - int proc_fd; - char buf[MAXPATHLEN]; - pid_t retval = (pid_t)-1; - - /* - * Read entries in /proc, each one is in turn a directory - * containing files relating to the process's state. We read - * the psinfo file to get the command name. - */ - dirptr = opendir(PROCFS_DIR); - if (dirptr == (DIR *) NULL) { - return (retval); - } - while ((direntptr = readdir(dirptr)) != NULL) { - (void) snprintf(buf, sizeof (buf), PROCFS_DIR"/%s/psinfo", - direntptr->d_name); - if ((proc_fd = open(buf, O_RDONLY)) < 0) { - continue; /* skip this one */ - } - if (read(proc_fd, &psinfo, sizeof (psinfo)) > 0) { - if (strncmp(psinfo.pr_fname, fname, PRFNSZ) == 0) { - retval = psinfo.pr_pid; - (void) close(proc_fd); - break; - } - } - (void) close(proc_fd); - } - (void) closedir(dirptr); - return (retval); -} - - -/* - * Get list of physical, non-loopback interfaces for the system. Those are - * the ones in.dhcpd will support. - */ -struct ip_interface ** -dd_get_interfaces() -{ - int s; - struct ifconf ifc; - int num_ifs; - int i; - struct ifreq *ifr; - struct ip_interface **ret = NULL; - struct ip_interface **tmpret; - int retcnt = 0; - struct sockaddr_in *sin; - - /* - * Open socket, needed for doing the ioctls. Then get number of - * interfaces so we know how much memory to allocate, then get - * all the interface configurations. - */ - s = socket(AF_INET, SOCK_DGRAM, 0); - if (ioctl(s, SIOCGIFNUM, &num_ifs) < 0) { - (void) close(s); - return (NULL); - } - ifc.ifc_len = num_ifs * sizeof (struct ifreq); - ifc.ifc_buf = malloc(ifc.ifc_len); - if (ifc.ifc_buf == NULL) { - (void) close(s); - return (NULL); - } - if (ioctl(s, SIOCGIFCONF, &ifc) < 0) { - free(ifc.ifc_buf); - (void) close(s); - return (NULL); - } - - /* - * For each interface, stuff its name, address and netmask into the - * structure that we return. Filter out loopback and virtual - * interfaces as they are of no interest for DHCP. - */ - for (i = 0, ifr = ifc.ifc_req; i < num_ifs; ++i, ++ifr) { - if (strchr(ifr->ifr_name, ':') != NULL) { - continue; /* Ignore a virtual interface */ - } - if (ioctl(s, SIOCGIFFLAGS, ifr) < 0) { - continue; /* Can't get flags? Ignore it. */ - } - - if ((ifr->ifr_flags & IFF_LOOPBACK) || - !(ifr->ifr_flags & IFF_UP)) { - continue; /* Ignore if loopback or down */ - } - /* Get more space to store this in */ - tmpret = realloc(ret, - (retcnt+1)*sizeof (struct ip_interface *)); - if (tmpret == NULL) { - while (retcnt-- > 0) - free(ret[retcnt]); - free(ret); - free(ifc.ifc_buf); - (void) close(s); - return (NULL); - } - ret = tmpret; - ret[retcnt] = malloc(sizeof (struct ip_interface)); - if (ret[retcnt] == NULL) { - while (retcnt-- > 0) - free(ret[retcnt]); - free(ret); - free(ifc.ifc_buf); - (void) close(s); - return (NULL); - } - (void) strcpy(ret[retcnt]->name, ifr->ifr_name); - if (ioctl(s, SIOCGIFADDR, ifr) < 0) { - (void) close(s); - while (retcnt-- > 0) { - free(ret[retcnt]); - } - free(ret); - free(ifc.ifc_buf); - return (NULL); - } - /*LINTED - alignment*/ - sin = (struct sockaddr_in *)&ifr->ifr_addr; - ret[retcnt]->addr = sin->sin_addr; - - if (ioctl(s, SIOCGIFNETMASK, ifr) < 0) { - (void) close(s); - while (retcnt-- > 0) { - free(ret[retcnt]); - } - free(ret); - free(ifc.ifc_buf); - return (NULL); - } - /*LINTED - alignment*/ - sin = (struct sockaddr_in *)&ifr->ifr_addr; - ret[retcnt]->mask = sin->sin_addr; - ++retcnt; - } - - /* Null-terminate the list */ - if (retcnt > 0) { - tmpret = realloc(ret, - (retcnt+1)*sizeof (struct ip_interface *)); - if (tmpret == NULL) { - while (retcnt-- > 0) - free(ret[retcnt]); - free(ret); - free(ifc.ifc_buf); - (void) close(s); - return (NULL); - } - ret = tmpret; - ret[retcnt] = NULL; - } - (void) close(s); - free(ifc.ifc_buf); - return (ret); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dd_misc.h b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dd_misc.h deleted file mode 100644 index fee427dfdb..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dd_misc.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _DD_MISC_H -#define _DD_MISC_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <dhcp_svc_private.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <net/if.h> -#include <unistd.h> -#include <jni.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define DAEMON_FNAME "in.dhcpd" - -struct ip_interface { - char name[IFNAMSIZ]; - struct in_addr addr; - struct in_addr mask; -}; - -extern jstring dd_native_to_jstring(JNIEnv *, const char *); -extern char *dd_jstring_to_native(JNIEnv *, jstring); -extern boolean_t dd_jstring_to_UTF(JNIEnv *, jstring, char **); -extern boolean_t dd_get_str_attr(JNIEnv *, jclass, int, jobject, char **); -extern boolean_t dd_get_conf_datastore_t(JNIEnv *, dsvc_datastore_t *); -extern boolean_t dd_make_datastore_t(JNIEnv *, dsvc_datastore_t *, jobject); -extern void dd_free_datastore_t(dsvc_datastore_t *); -extern char **dd_data_stores(JNIEnv *); -extern void dd_free_data_stores(char **); -extern int dd_signal(char *, int); -extern pid_t dd_getpid(char *); -extern struct ip_interface **dd_get_interfaces(void); - -#ifdef __cplusplus -} -#endif - -#endif /* !_DD_MISC_H */ diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dd_opt.c b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dd_opt.c deleted file mode 100644 index df0bf83c11..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dd_opt.c +++ /dev/null @@ -1,656 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include <sys/types.h> -#include <netinet/in.h> -#include <arpa/nameser.h> -#include <resolv.h> -#include <string.h> -#include <malloc.h> -#include <libintl.h> -#include <stdio.h> -#include <netinet/dhcp.h> -#include <rpcsvc/nis.h> -#include <netdb.h> -#include <errno.h> -#include <sys/sockio.h> -#include <dirent.h> -#include <procfs.h> -#include <netdir.h> -#include <arpa/inet.h> -#include <rpcsvc/ypclnt.h> - -#include "dd_misc.h" -#include "dd_opt.h" - -#define RDISC_FNAME "in.rdisc" - -static struct dhcp_option opt_nomem = { ENOMEM, NULL }; - -/* - * Free an allocated dhcp option structure. - */ -void -dd_freeopt(struct dhcp_option *opt) -{ - int i; - - if (opt->error_code == 0) { - switch (opt->u.ret.datatype) { - case ASCII_OPTION: - for (i = 0; i < opt->u.ret.count; ++i) { - free(opt->u.ret.data.strings[i]); - } - free(opt->u.ret.data.strings); - break; - case BOOLEAN_OPTION: - break; - case IP_OPTION: - for (i = 0; i < opt->u.ret.count; ++i) { - free(opt->u.ret.data.addrs[i]); - } - free(opt->u.ret.data.addrs); - break; - case NUMBER_OPTION: - free(opt->u.ret.data.numbers); - break; - case OCTET_OPTION: - for (i = 0; i < opt->u.ret.count; ++i) { - free(opt->u.ret.data.octets[i]); - } - free(opt->u.ret.data.octets); - break; - default: - return; - } - } - /* Don't free the static no-memory error return */ - if (opt != &opt_nomem) { - free(opt); - } -} - -/* - * Allocate an option structure. - */ - -static struct dhcp_option * -newopt(enum option_type ot, ushort_t count) -{ - struct dhcp_option *opt; - - opt = malloc(sizeof (struct dhcp_option)); - if ((opt != NULL) && (ot != ERROR_OPTION)) { - opt->error_code = 0; - opt->u.ret.datatype = ot; - switch (ot) { - case ASCII_OPTION: - opt->u.ret.data.strings = - calloc(count, sizeof (char *)); - if (opt->u.ret.data.strings == NULL) { - free(opt); - opt = NULL; - } else { - opt->u.ret.count = count; - } - break; - case BOOLEAN_OPTION: - opt->u.ret.count = count; - break; - case IP_OPTION: - opt->u.ret.data.addrs = calloc(count, - sizeof (struct in_addr *)); - if (opt->u.ret.data.addrs == NULL) { - free(opt); - opt = NULL; - } else { - opt->u.ret.count = count; - } - break; - case NUMBER_OPTION: - opt->u.ret.data.numbers = calloc(count, - sizeof (int64_t)); - if (opt->u.ret.data.numbers == NULL) { - free(opt); - opt = NULL; - } else { - opt->u.ret.count = count; - } - break; - case OCTET_OPTION: - opt->u.ret.data.octets = calloc(count, - sizeof (uchar_t *)); - if (opt->u.ret.data.octets == NULL) { - free(opt); - opt = NULL; - } else { - opt->u.ret.count = count; - } - break; - default: - free(opt); - opt = NULL; - } - } - return (opt); -} - -/* - * Return an out of memory error - */ -static struct dhcp_option * -malloc_failure() -{ - if (opt_nomem.u.msg == NULL) { - opt_nomem.u.msg = strerror(opt_nomem.error_code); - } - return (&opt_nomem); -} - -/* - * Return an error based on errno value - */ -static struct dhcp_option * -errno_opt() { - struct dhcp_option *opt; - int serrno; - - /* Save errno value before allocation attempt */ - serrno = errno; - opt = newopt(ERROR_OPTION, 0); - if (opt == NULL) { - return (malloc_failure()); - } - opt->error_code = serrno; - opt->u.msg = strerror(serrno); - return (opt); -} -/* - * Construct list of default routers. - */ -/*ARGSUSED*/ -static struct dhcp_option * -get_default_routers(const char *arg) -{ - struct dhcp_option *opt; - FILE *fp; - char rbuff[BUFSIZ]; - struct in_addr **addrs = NULL; - struct in_addr **tmpaddrs; - int addrcnt = 0; - char *cp; - int i; - - /* - * Method here is completely bogus; read output from netstat and - * grab lines with destination of 'default'. Look at the netstat - * code if you think there's a better way... - */ - if ((fp = popen("netstat -r -n -f inet", "r")) == NULL) { - return (errno_opt()); - } - - while (fgets(rbuff, BUFSIZ, fp) != NULL) { - cp = strtok(rbuff, " \t"); - if (cp == NULL) - continue; - if (strcmp(cp, "default") == 0) { - /* got one, add to list */ - tmpaddrs = realloc(addrs, - (addrcnt+1) * sizeof (struct in_addr *)); - if (tmpaddrs == NULL) { - opt = errno_opt(); - for (i = addrcnt - 1; i >= 0; --i) { - free(addrs[i]); - } - free(addrs); - (void) pclose(fp); - return (opt); - } - addrs = tmpaddrs; - addrs[addrcnt] = malloc(sizeof (struct in_addr)); - if (addrs[addrcnt] == NULL) { - opt = errno_opt(); - for (i = addrcnt - 1; i >= 0; --i) { - free(addrs[i]); - } - free(addrs); - (void) pclose(fp); - return (opt); - } - - cp = strtok(NULL, " \t"); - addrs[addrcnt]->s_addr = inet_addr(cp); - /* LINTED - comparison */ - if (addrs[addrcnt]->s_addr == -1) { - /* inet_addr didn't like it */ - opt = newopt(ERROR_OPTION, 0); - if (opt != NULL) { - opt->error_code = EINVAL; - opt->u.msg = strerror(EINVAL); - } - while (--addrcnt >= 0) - free(addrs[addrcnt]); - free(addrs); - (void) pclose(fp); - return (opt); - } - ++addrcnt; - } - } - (void) pclose(fp); - /* - * Return all the routers we found. - */ - if (addrcnt != 0) { - opt = newopt(IP_OPTION, addrcnt); - if (opt == NULL) { - for (i = 0; i < addrcnt; ++i) { - free(addrs[i]); - free(addrs); - } - return (opt); - } - for (i = 0; i < addrcnt; ++i) { - opt->u.ret.data.addrs[i] = addrs[i]; - } - free(addrs); - } else { - opt = newopt(ERROR_OPTION, 0); - if (opt != NULL) { - opt->error_code = 1; - opt->u.msg = gettext("No default router found"); - } - } - return (opt); -} - -/*ARGSUSED*/ -static struct dhcp_option * -get_dns_domain(const char *arg) -{ - struct dhcp_option *opt; - res_state statp; - - statp = calloc(1, sizeof (*statp)); - if (statp == NULL) { - opt = malloc_failure(); - } else if (res_ninit(statp) == -1) { - /* Resolver failed initialization */ - opt = errno_opt(); - } else { - /* Initialized OK, copy domain name to return structure */ - opt = newopt(ASCII_OPTION, 1); - if (opt != NULL) { - /* - * If first one is loopback address, we return empty - * as this almost certainly means that DNS is not - * configured. - */ - if (statp->nsaddr_list[0].sin_family == AF_INET && - statp->nsaddr_list[0].sin_addr.s_addr == - ntohl(INADDR_LOOPBACK)) - opt->u.ret.data.strings[0] = strdup(""); - else - opt->u.ret.data.strings[0] = - strdup(statp->defdname); - if (opt->u.ret.data.strings[0] == NULL) { - /* Couldn't allocate return memory */ - dd_freeopt(opt); - opt = malloc_failure(); - } - } - } - if (statp != NULL) { - (void) res_ndestroy(statp); - free(statp); - } - return (opt); -} - -/*ARGSUSED*/ -static struct dhcp_option * -get_dns_servers(const char *arg) -{ - struct dhcp_option *opt; - int i, j; - res_state statp; - - statp = calloc(1, sizeof (*statp)); - if (statp == NULL) { - opt = malloc_failure(); - } else if (res_ninit(statp) == -1) { - /* Resolver initialization failed */ - opt = errno_opt(); - } else if (statp->nsaddr_list[0].sin_family == AF_INET && - statp->nsaddr_list[0].sin_addr.s_addr == ntohl(INADDR_LOOPBACK)) { - /* - * If first one is loopback address, we ignore as this - * almost certainly means that DNS is not configured. - */ - opt = newopt(IP_OPTION, 0); - } else { - /* Success, copy the data into our return structure */ - opt = newopt(IP_OPTION, statp->nscount); - if (opt != NULL) { - for (i = 0, j = 0; i < statp->nscount; ++i) { - if (statp->nsaddr_list[i].sin_family != AF_INET) - /* IPv4 only, thanks */ - continue; - opt->u.ret.data.addrs[j] = malloc( - sizeof (struct in_addr)); - if (opt->u.ret.data.addrs[j] == NULL) { - /* Out of memory, return immediately */ - dd_freeopt(opt); - free(statp); - return (malloc_failure()); - } - *opt->u.ret.data.addrs[j++] = - statp->nsaddr_list[i].sin_addr; - } - /* Adjust number of addresses returned to real count */ - opt->u.ret.count = j; - } - } - if (statp != NULL) { - (void) res_ndestroy(statp); - free(statp); - } - return (opt); -} - -/* Get parameters related to a specific interface */ -static struct dhcp_option * -get_if_param(int code, const char *arg) -{ - int s; - struct ifconf ifc; - int num_ifs; - int i; - struct ifreq *ifr; - struct dhcp_option *opt; -#define MY_TRUE 1 -#define MY_FALSE 0 - int found = MY_FALSE; - struct sockaddr_in *sin; - - /* - * Open socket, needed for doing the ioctls. Then get number of - * interfaces so we know how much memory to allocate, then get - * all the interface configurations. - */ - s = socket(AF_INET, SOCK_DGRAM, 0); - if (ioctl(s, SIOCGIFNUM, &num_ifs) < 0) { - return (errno_opt()); - } - ifc.ifc_len = num_ifs * sizeof (struct ifreq); - ifc.ifc_buf = malloc(ifc.ifc_len); - if (ifc.ifc_buf == NULL) { - return (malloc_failure()); - } - if (ioctl(s, SIOCGIFCONF, &ifc) < 0) { - opt = errno_opt(); - free(ifc.ifc_buf); - (void) close(s); - return (opt); - } - - /* - * Find the interface which matches the one requested, and then - * return the parameter requested. - */ - for (i = 0, ifr = ifc.ifc_req; i < num_ifs; ++i, ++ifr) { - if (strcmp(ifr->ifr_name, arg) != 0) { - continue; - } - found = MY_TRUE; - switch (code) { - case CD_SUBNETMASK: - if (ioctl(s, SIOCGIFNETMASK, ifr) < 0) { - opt = errno_opt(); - free(ifc.ifc_buf); - (void) close(s); - return (opt); - } - opt = newopt(IP_OPTION, 1); - if (opt == NULL) { - free(ifc.ifc_buf); - (void) close(s); - return (malloc_failure()); - } - opt->u.ret.data.addrs[0] = - malloc(sizeof (struct in_addr)); - if (opt->u.ret.data.addrs[0] == NULL) { - free(ifc.ifc_buf); - (void) close(s); - return (malloc_failure()); - } - /*LINTED - alignment*/ - sin = (struct sockaddr_in *)&ifr->ifr_addr; - *opt->u.ret.data.addrs[0] = sin->sin_addr; - break; - case CD_MTU: - if (ioctl(s, SIOCGIFMTU, ifr) < 0) { - opt = errno_opt(); - free(ifc.ifc_buf); - (void) close(s); - return (opt); - } - opt = newopt(NUMBER_OPTION, 1); - if (opt == NULL) { - free(ifc.ifc_buf); - (void) close(s); - return (malloc_failure()); - } - opt->u.ret.data.numbers[0] = ifr->ifr_metric; - break; - case CD_BROADCASTADDR: - if (ioctl(s, SIOCGIFBRDADDR, ifr) < 0) { - opt = errno_opt(); - free(ifc.ifc_buf); - (void) close(s); - return (opt); - } - opt = newopt(IP_OPTION, 1); - if (opt == NULL) { - free(ifc.ifc_buf); - (void) close(s); - return (malloc_failure()); - } - opt->u.ret.data.addrs[0] = - malloc(sizeof (struct in_addr)); - if (opt->u.ret.data.addrs[0] == NULL) { - free(ifc.ifc_buf); - (void) close(s); - return (malloc_failure()); - } - /*LINTED - alignment*/ - sin = (struct sockaddr_in *)&ifr->ifr_addr; - *opt->u.ret.data.addrs[0] = sin->sin_addr; - break; - default: - opt = newopt(ERROR_OPTION, 0); - opt->error_code = 1; - opt->u.msg = gettext("Bad option code in get_if_param"); - } - break; - } - free(ifc.ifc_buf); - (void) close(s); - if (found == MY_FALSE) { - opt = newopt(ERROR_OPTION, 0); - opt->error_code = 1; - opt->u.msg = gettext("No such interface"); - } - return (opt); -} - -/* - * See if we are using router discovery on this system. Method is to - * read procfs and find out if the in.rdisc daemon is running. - */ -/*ARGSUSED*/ -static struct dhcp_option * -get_router_discovery(const char *arg) -{ - struct dhcp_option *opt; - - opt = newopt(NUMBER_OPTION, 1); - if (opt == NULL) { - return (malloc_failure()); - } - if (dd_getpid(RDISC_FNAME) != -1) { - opt->u.ret.data.numbers[0] = 1; - } else { - opt->u.ret.data.numbers[0] = 0; - } - return (opt); -} - -/*ARGSUSED*/ -static struct dhcp_option * -get_nis_domain(const char *arg) -{ - struct dhcp_option *opt; - char *d; - int err; - - err = yp_get_default_domain(&d); - if (err != 0) { - opt = newopt(ERROR_OPTION, 0); - if (opt != NULL) { - opt->error_code = err; - opt->u.msg = gettext("Error in yp_get_default_domain"); - } - } else { - opt = newopt(ASCII_OPTION, 1); - if (opt == NULL) { - return (malloc_failure()); - } - opt->u.ret.data.strings[0] = strdup(d); - if (opt->u.ret.data.strings[0] == NULL) { - dd_freeopt(opt); - return (malloc_failure()); - } - } - return (opt); -} - -/* - * Provide a default for the NISserv option. We can only reliably - * find out the master (as that's the only API) so that's what we provide. - */ -/*ARGSUSED*/ -static struct dhcp_option * -get_nis_servers(const char *arg) -{ - struct dhcp_option *opt; - int err; - char *d; - char *m; - struct hostent *hent; - - /* - * Get the default domain name, ask for master of hosts table, - * look master up in hosts table to get address. - */ - err = yp_get_default_domain(&d); - if (err != 0) { - opt = newopt(ERROR_OPTION, 0); - if (opt != NULL) { - opt->error_code = err; - opt->u.msg = gettext("Error in yp_get_default_domain"); - } - } else if ((err = yp_master(d, "hosts.byname", &m)) != 0) { - opt = newopt(ERROR_OPTION, 0); - if (opt != NULL) { - opt->error_code = err; - opt->u.msg = gettext("Error in yp_master"); - } - } else if ((hent = gethostbyname(m)) == NULL) { - free(m); - opt = newopt(ERROR_OPTION, 0); - if (opt != NULL) { - opt->error_code = h_errno; - opt->u.msg = gettext("Error in gethostbyname()"); - } - } else { - free(m); - opt = newopt(IP_OPTION, 1); - if (opt == NULL) { - return (malloc_failure()); - } - opt->u.ret.data.addrs[0] = malloc(sizeof (struct in_addr)); - if (opt->u.ret.data.addrs[0] == NULL) { - dd_freeopt(opt); - return (malloc_failure()); - } - /*LINTED - alignment*/ - *opt->u.ret.data.addrs[0] = *(struct in_addr *)hent->h_addr; - } - return (opt); -} - -/* - * Retrieve the default value for a specified DHCP option. Option code is - * from the lst in dhcp.h, arg is an option-specific string argument, and - * context is a presently unused parameter intended to allow this mechanism - * to extend to vendor options in the future. For now, only standard options - * are supported. Note that in some cases the returned pointer may be NULL, - * so the caller must check for this case. - */ - -/*ARGSUSED*/ -struct dhcp_option * -dd_getopt(ushort_t code, const char *arg, const char *context) -{ - struct dhcp_option *opt; - - switch (code) { - case CD_SUBNETMASK: - case CD_MTU: - case CD_BROADCASTADDR: - return (get_if_param(code, arg)); - case CD_ROUTER: - return (get_default_routers(arg)); - case CD_DNSSERV: - return (get_dns_servers(arg)); - case CD_DNSDOMAIN: - return (get_dns_domain(arg)); - case CD_ROUTER_DISCVRY_ON: - return (get_router_discovery(arg)); - case CD_NIS_DOMAIN: - return (get_nis_domain(arg)); - case CD_NIS_SERV: - return (get_nis_servers(arg)); - default: - opt = newopt(ERROR_OPTION, 0); - if (opt != NULL) { - opt->error_code = 1; - opt->u.msg = gettext("Unimplemented option requested"); - } - return (opt); - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dd_opt.h b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dd_opt.h deleted file mode 100644 index aa376ed98d..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dd_opt.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1998-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _DD_OPT_H -#define _DD_OPT_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/types.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* The different data types of options supported by the service */ -enum option_type { - ERROR_OPTION = -1, - ASCII_OPTION, - BOOLEAN_OPTION, - IP_OPTION, - NUMBER_OPTION, - OCTET_OPTION -}; - -/* Structure returned by dd_getopt */ -struct dhcp_option { - int error_code; /* Error indication; 0 == no error */ - union { - char *msg; /* Error message if error_code != 0 */ - struct { - enum option_type datatype; /* Type of option */ - ushort_t granularity; /* How big is it */ - ushort_t count; /* How many */ - union { /* The data, depending on datatype */ - char **strings; - boolean_t value; - struct in_addr **addrs; - int64_t *numbers; - uchar_t **octets; - } data; - } ret; - } u; -}; - -extern struct dhcp_option *dd_getopt(ushort_t, const char *, const char *); -extern void dd_freeopt(struct dhcp_option *); - -#ifdef __cplusplus -} -#endif - -#endif /* !_DD_OPT_H */ diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dhcptab.c b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dhcptab.c deleted file mode 100644 index 9d36e560fd..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/dhcptab.c +++ /dev/null @@ -1,1014 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <libintl.h> -#include <stdlib.h> -#include <string.h> -#include <malloc.h> -#include <jni.h> -#include <dhcp_svc_private.h> -#include <dhcp_svc_confkey.h> -#include <dhcp_symbol.h> -#include <com_sun_dhcpmgr_bridge_Bridge.h> - -#include "exception.h" -#include "dd_misc.h" -#include "class_cache.h" - -/* - * Validate that a symbol definition in dhcptab(4) format is valid. - */ -static boolean_t -validate_OptionValue(JNIEnv *env, - const char *key, - const char *value) { - - dhcp_symbol_t sym; - char **fields; - int last = 0; - dsym_errcode_t dsymret; - - dsymret = dsym_init_parser(key, value, &fields, &sym); - if (dsymret != DSYM_SUCCESS) { - throw_dsym_parser_init_exception(env, key, dsymret); - return (B_FALSE); - } - - dsymret = dsym_parser(fields, &sym, &last, B_FALSE); - if (dsymret != DSYM_SUCCESS) { - throw_dsym_parser_exception(env, key, fields, last, - dsymret); - } - - dsym_close_parser(fields, &sym); - return (dsymret == DSYM_SUCCESS); -} - -/* - * Create a dt_rec from a DhcptabRecord. - */ -static dt_rec_t * -create_dtrec( - JNIEnv *env, - jobject dhcptabRecord, - boolean_t validate) -{ - jclass dtr_class; - dt_rec_t *dtrec; - char *str; - - /* Locate the class we need */ - dtr_class = find_class(env, DTR_CLASS); - if (dtr_class == NULL) { - /* exception thrown */ - return (NULL); - } - - dtrec = malloc(sizeof (dt_rec_t)); - if (dtrec == NULL) { - throw_memory_exception(env); - return (NULL); - } - - if (!dd_get_str_attr(env, dtr_class, DTR_GETKEY, dhcptabRecord, - &str)) { - /* exception thrown */ - free_dtrec(dtrec); - return (NULL); - } - (void) strlcpy(dtrec->dt_key, str, sizeof (dtrec->dt_key)); - free(str); - - if (!dd_get_str_attr(env, dtr_class, DTR_GETFLAG, dhcptabRecord, - &str)) { - /* exception thrown */ - free_dtrec(dtrec); - return (NULL); - } - dtrec->dt_type = str[0]; - free(str); - - if (!dd_get_str_attr(env, dtr_class, DTR_GETSIG, dhcptabRecord, - &str)) { - /* exception thrown */ - free_dtrec(dtrec); - return (NULL); - } - dtrec->dt_sig = atoll(str); - free(str); - - if (!dd_get_str_attr(env, dtr_class, DTR_GETVAL, dhcptabRecord, - &dtrec->dt_value)) { - /* exception thrown */ - free_dtrec(dtrec); - return (NULL); - } - - if (validate) { - if (dtrec->dt_type == DT_SYMBOL) { - if (!validate_OptionValue(env, dtrec->dt_key, - dtrec->dt_value)) { - /* exception thrown */ - free_dtrec(dtrec); - return (NULL); - } - } - } - return (dtrec); -} - -/* - * Create a Macro from a dt_rec. - */ -static jobject -create_Macro( - JNIEnv *env, - const dt_rec_t *dtrec) -{ - jobject dhcptabRecord; - jclass class; - jmethodID cons; - - char ascii_sig[UINT64_MAX_CHAR + 1]; - - /* Find the class we need */ - class = find_class(env, MAC_CLASS); - if (class == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Locate the class constructor we need */ - cons = get_methodID(env, class, MAC_CONS); - if (cons == NULL) { - /* exception thrown */ - return (NULL); - } - - (void) sprintf(ascii_sig, "%lld", dtrec->dt_sig); - dhcptabRecord = (*env)->NewObject(env, class, cons, - (*env)->NewStringUTF(env, dtrec->dt_key), - (*env)->NewStringUTF(env, dtrec->dt_value), - (*env)->NewStringUTF(env, ascii_sig)); - - if ((*env)->ExceptionOccurred(env) != NULL) { - dhcptabRecord = NULL; - } - - return (dhcptabRecord); -} - -/* - * Create an Array of vendor classes. - */ -static jobjectArray -create_vendors(JNIEnv *env, - dhcp_classes_t *classes) { - - jclass class; - jobjectArray jlist = NULL; - int i; - - class = (*env)->FindClass(env, "java/lang/String"); - if (class == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Construct the array */ - jlist = (*env)->NewObjectArray(env, classes->dc_cnt, class, NULL); - if (jlist == NULL) { - /* exception thrown */ - return (NULL); - } - - /* For each vendor, create an object and add it to the array */ - for (i = 0; i < classes->dc_cnt; i++) { - (*env)->SetObjectArrayElement(env, jlist, i, - (*env)->NewStringUTF(env, classes->dc_names[i])); - if ((*env)->ExceptionOccurred(env) != NULL) { - jlist = NULL; - break; - } - } - return (jlist); -} - -/* - * Create an Option from a dt_rec. - */ -static jobject -create_Option( - JNIEnv *env, - const char *key, - const char *value, - uint64_t sig, - boolean_t force) -{ - jobject dhcptabRecord = NULL; - jclass class; - jmethodID cons; - - char ascii_sig[UINT64_MAX_CHAR + 1]; - - dhcp_symbol_t sym; - char **fields; - int last = 0; - dsym_errcode_t ret = DSYM_SUCCESS; - - /* Find the class we need */ - class = find_class(env, OPT_CLASS); - if (class == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Locate the class constructor we need */ - cons = get_methodID(env, class, OPT_CONS); - if (cons == NULL) { - /* exception thrown */ - return (NULL); - } - - (void) sprintf(ascii_sig, "%lld", sig); - - ret = dsym_init_parser(key, value, &fields, &sym); - if (ret != DSYM_SUCCESS) { - /* throw exception */ - throw_dsym_parser_init_exception(env, key, ret); - return (NULL); - } - - ret = dsym_parser(fields, &sym, &last, force); - if (ret == DSYM_SUCCESS || force) { - jboolean isValid = (ret == DSYM_SUCCESS) ? JNI_TRUE : JNI_FALSE; - dhcptabRecord = (*env)->NewObject(env, class, cons, - (*env)->NewStringUTF(env, sym.ds_name), - (jbyte)sym.ds_category, - create_vendors(env, &sym.ds_classes), - (jshort)sym.ds_code, - (jbyte)sym.ds_type, - (jint)sym.ds_gran, - (jint)sym.ds_max, - (*env)->NewStringUTF(env, ascii_sig), isValid); - - if ((*env)->ExceptionOccurred(env) != NULL) { - dhcptabRecord = NULL; - } - } else { - /* throw exception */ - throw_dsym_parser_exception(env, key, fields, last, ret); - } - - dsym_close_parser(fields, &sym); - return (dhcptabRecord); -} - -/* - * Retrieve an option from the dhcptab. Returns - * the record as a new instance of a Option - */ -/*ARGSUSED*/ -JNIEXPORT jobject JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getOption( - JNIEnv *env, - jobject obj, - jstring jkey, - jobject jdatastore) -{ - dsvc_datastore_t datastore; - dsvc_handle_t handle; - - dt_rec_t record; - dt_rec_list_t *recordList; - uint32_t query; - uint32_t count = 0; - - char *key; - int rcode; - - jobject dhcptabRecord; - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return (NULL); - } - - /* Retrieve the key argument */ - if (!dd_jstring_to_UTF(env, jkey, &key)) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - return (NULL); - } - - /* Open the dhcptab */ - rcode = open_dd(&handle, &datastore, DSVC_DHCPTAB, - DT_DHCPTAB, DSVC_READ); - - dd_free_datastore_t(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, DT_DHCPTAB); - free(key); - return (NULL); - } - - /* Get the records */ - DSVC_QINIT(query); - DSVC_QEQ(query, DT_QTYPE | DT_QKEY); - (void) strlcpy(record.dt_key, key, sizeof (record.dt_key)); - record.dt_type = DT_SYMBOL; - - rcode = lookup_dd(handle, B_FALSE, query, 1, &record, - (void**)&recordList, &count); - - (void) close_dd(&handle); - if (rcode == DSVC_SUCCESS) { - if (count == 1) { - dhcptabRecord = create_Option(env, - recordList->dtl_rec->dt_key, - recordList->dtl_rec->dt_value, - recordList->dtl_rec->dt_sig, B_TRUE); - free_dtrec_list(recordList); - } else { - throw_noent_exception(env, key); - } - } else { - throw_libdhcpsvc_exception(env, rcode); - } - - free(key); - - return (dhcptabRecord); -} - -/* - * Use the current datastore to create a dhcptab table in a new datastore. - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_cvtDhcptab( - JNIEnv *env, - jobject obj, - jobject jdatastore) -{ - - dt_rec_t record; - dt_rec_list_t *recordList; - dt_rec_list_t *originalList = NULL; - uint32_t query; - uint32_t count = 0; - - dsvc_handle_t curHandle; - dsvc_handle_t newHandle; - dsvc_datastore_t curDatastore; - dsvc_datastore_t newDatastore; - - int rcode; - int i; - - /* Get the current data store configuration */ - if (!dd_get_conf_datastore_t(env, &curDatastore)) { - /* exception thrown */ - return; - } - - /* Make a "new" dsvc_datastore_t */ - if (!dd_make_datastore_t(env, &newDatastore, jdatastore)) { - /* exception thrown */ - dd_free_datastore_t(&curDatastore); - return; - } - - /* Open the current dhcptab */ - rcode = open_dd(&curHandle, &curDatastore, DSVC_DHCPTAB, - DT_DHCPTAB, DSVC_READ); - - dd_free_datastore_t(&curDatastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, DT_DHCPTAB); - dd_free_datastore_t(&newDatastore); - return; - } - - /* Open the new dhcptab */ - rcode = open_dd(&newHandle, &newDatastore, DSVC_DHCPTAB, DT_DHCPTAB, - DSVC_CREATE | DSVC_READ | DSVC_WRITE); - - dd_free_datastore_t(&newDatastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, DT_DHCPTAB); - (void) close_dd(&curHandle); - return; - } - - /* Get the records */ - DSVC_QINIT(query); - rcode = lookup_dd(curHandle, B_FALSE, query, -1, &record, - (void**)&recordList, &count); - - (void) close_dd(&curHandle); - if (rcode != DSVC_SUCCESS) { - throw_libdhcpsvc_exception(env, rcode); - (void) close_dd(&newHandle); - return; - } - - if (count != 0) { - originalList = recordList; - } - - /* For each row, write client record to new table */ - for (i = 0; i < count; i++) { - /* Now add the record */ - rcode = add_dd_entry(newHandle, recordList->dtl_rec); - - if (rcode != DSVC_SUCCESS) { - throw_add_dd_entry_exception(env, rcode, - recordList->dtl_rec->dt_key); - break; - } - - recordList = recordList->dtl_next; - } - - (void) close_dd(&newHandle); - - if (originalList != NULL) { - free_dtrec_list(originalList); - } - -} - -/* - * Return all options (aka symbols) currently defined in the dhcptab. - * The options are returned as an array of Options. - */ -/*ARGSUSED*/ -JNIEXPORT jobjectArray JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getOptions( - JNIEnv *env, - jobject obj, - jobject jdatastore) -{ - dsvc_datastore_t datastore; - dsvc_handle_t handle; - - dt_rec_t record; - dt_rec_list_t *recordList; - dt_rec_list_t *originalList = NULL; - uint32_t query; - uint32_t count = 0; - int rcode; - - jclass opt_class; - jobjectArray jlist = NULL; - jobject dhcptabRecord; - int i; - - /* Find the Option class and its constructor */ - opt_class = find_class(env, OPT_CLASS); - if (opt_class == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return (NULL); - } - - /* Open the dhcptab */ - rcode = open_dd(&handle, &datastore, DSVC_DHCPTAB, - DT_DHCPTAB, DSVC_READ); - - dd_free_datastore_t(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, DT_DHCPTAB); - return (NULL); - } - - /* Get the records */ - DSVC_QINIT(query); - DSVC_QEQ(query, DT_QTYPE); - record.dt_type = DT_SYMBOL; - - rcode = lookup_dd(handle, B_FALSE, query, -1, &record, - (void**)&recordList, &count); - - (void) close_dd(&handle); - if (rcode != DSVC_SUCCESS) { - throw_libdhcpsvc_exception(env, rcode); - return (NULL); - } - - if (count != 0) { - originalList = recordList; - } - - /* Construct the array */ - jlist = (*env)->NewObjectArray(env, count, opt_class, NULL); - if (jlist == NULL) { - /* exception thrown */ - if (originalList != NULL) { - free_dtrec_list(originalList); - } - return (NULL); - } - - /* For each option, create an object and add it to the array */ - for (i = 0; i < count; i++) { - dhcptabRecord = create_Option(env, - recordList->dtl_rec->dt_key, - recordList->dtl_rec->dt_value, - recordList->dtl_rec->dt_sig, B_TRUE); - if (dhcptabRecord == NULL) { - /* exception thrown */ - break; - } - - (*env)->SetObjectArrayElement(env, jlist, i, dhcptabRecord); - if ((*env)->ExceptionOccurred(env) != NULL) { - break; - } - - recordList = recordList->dtl_next; - } - - if (originalList != NULL) { - free_dtrec_list(originalList); - } - - return (jlist); -} - -/* - * Retrieve a macro from the dhcptab. Returns - * the record as a new instance of a Macro - */ -/*ARGSUSED*/ -JNIEXPORT jobject JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getMacro( - JNIEnv *env, - jobject obj, - jstring jkey, - jobject jdatastore) -{ - dsvc_datastore_t datastore; - dsvc_handle_t handle; - - dt_rec_t record; - dt_rec_list_t *recordList; - uint32_t query; - uint32_t count = 0; - - char *key; - int rcode; - - jobject dhcptabRecord; - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return (NULL); - } - - /* Retrieve the key argument */ - if (!dd_jstring_to_UTF(env, jkey, &key)) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - return (NULL); - } - - /* Open the dhcptab */ - rcode = open_dd(&handle, &datastore, DSVC_DHCPTAB, - DT_DHCPTAB, DSVC_READ); - - dd_free_datastore_t(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, DT_DHCPTAB); - free(key); - return (NULL); - } - - /* Get the records */ - DSVC_QINIT(query); - DSVC_QEQ(query, DT_QTYPE | DT_QKEY); - (void) strlcpy(record.dt_key, key, sizeof (record.dt_key)); - record.dt_type = DT_MACRO; - - rcode = lookup_dd(handle, B_FALSE, query, 1, &record, - (void**)&recordList, &count); - - (void) close_dd(&handle); - if (rcode == DSVC_SUCCESS) { - if (count == 1) { - dhcptabRecord = create_Macro(env, recordList->dtl_rec); - free_dtrec_list(recordList); - } else { - throw_noent_exception(env, key); - } - } else { - throw_libdhcpsvc_exception(env, rcode); - } - - free(key); - - return (dhcptabRecord); -} - -/* - * Return all macros defined in the dhcptab. Returned as an array of - * Macro objects. - */ -/*ARGSUSED*/ -JNIEXPORT jobjectArray JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getMacros( - JNIEnv *env, - jobject obj, - jobject jdatastore) -{ - dsvc_datastore_t datastore; - dsvc_handle_t handle; - - dt_rec_t record; - dt_rec_list_t *recordList; - dt_rec_list_t *originalList = NULL; - uint32_t query; - uint32_t count = 0; - int rcode; - - jclass mac_class; - jobjectArray jlist = NULL; - jobject dhcptabRecord; - int i; - - /* Locate the Macro class and its constructor */ - mac_class = find_class(env, MAC_CLASS); - if (mac_class == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return (NULL); - } - - /* Open the dhcptab */ - rcode = open_dd(&handle, &datastore, DSVC_DHCPTAB, - DT_DHCPTAB, DSVC_READ); - - dd_free_datastore_t(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, DT_DHCPTAB); - return (NULL); - } - - /* Get the records */ - DSVC_QINIT(query); - DSVC_QEQ(query, DT_QTYPE); - record.dt_type = DT_MACRO; - - rcode = lookup_dd(handle, B_FALSE, query, -1, &record, - (void**)&recordList, &count); - - (void) close_dd(&handle); - if (rcode != DSVC_SUCCESS) { - throw_libdhcpsvc_exception(env, rcode); - return (NULL); - } - - if (count != 0) { - originalList = recordList; - } - - /* Construct the array */ - jlist = (*env)->NewObjectArray(env, count, mac_class, NULL); - if (jlist == NULL) { - /* exception thrown */ - if (originalList != NULL) { - free_dtrec_list(originalList); - } - return (NULL); - } - - /* For each macro, create an object and add it to the array */ - for (i = 0; i < count; i++) { - dhcptabRecord = create_Macro(env, recordList->dtl_rec); - if (dhcptabRecord == NULL) { - /* exception thrown */ - break; - } - - (*env)->SetObjectArrayElement(env, jlist, i, dhcptabRecord); - if ((*env)->ExceptionOccurred(env) != NULL) { - break; - } - - recordList = recordList->dtl_next; - } - - if (originalList != NULL) { - free_dtrec_list(originalList); - } - - return (jlist); -} - -/* - * Function to create an Option object - */ -/*ARGSUSED*/ -JNIEXPORT jobject JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_createOption( - JNIEnv *env, - jobject obj, - jstring jkey, - jstring jvalue) -{ - - jobject option; - char *key; - char *value; - - /* Retrieve the key argument */ - if (!dd_jstring_to_UTF(env, jkey, &key)) { - /* exception thrown */ - return (NULL); - } - - /* Retrieve the value argument */ - if (!dd_jstring_to_UTF(env, jvalue, &value)) { - /* exception thrown */ - free(key); - return (NULL); - } - - option = create_Option(env, key, value, 0, B_FALSE); - - free(key); - free(value); - - return (option); -} - -/* - * Function to create a new dhcptab record. - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_createDhcptabRecord( - JNIEnv *env, - jobject obj, - jobject jrec, - jobject jdatastore) -{ - dsvc_handle_t handle; - dsvc_datastore_t datastore; - dt_rec_t *dtrec; - int rcode; - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return; - } - - dtrec = create_dtrec(env, jrec, B_TRUE); - if (dtrec == NULL) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - return; - } - - /* Open the dhcptab */ - rcode = open_dd(&handle, &datastore, DSVC_DHCPTAB, - DT_DHCPTAB, DSVC_WRITE); - - dd_free_datastore_t(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, DT_DHCPTAB); - free_dtrec(dtrec); - return; - } - - /* Now add the record */ - rcode = add_dd_entry(handle, dtrec); - - (void) close_dd(&handle); - if (rcode != DSVC_SUCCESS) { - throw_add_dd_entry_exception(env, rcode, dtrec->dt_key); - } - - free_dtrec(dtrec); - -} - -/* - * Modify a dhcptab record. - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_modifyDhcptabRecord( - JNIEnv *env, - jobject obj, - jobject joldrec, - jobject jnewrec, - jobject jdatastore) -{ - dsvc_handle_t handle; - dsvc_datastore_t datastore; - dt_rec_t *dtoldrec; - dt_rec_t *dtnewrec; - int rcode; - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return; - } - - dtoldrec = create_dtrec(env, joldrec, B_FALSE); - if (dtoldrec == NULL) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - return; - } - - dtnewrec = create_dtrec(env, jnewrec, B_TRUE); - if (dtnewrec == NULL) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - free_dtrec(dtoldrec); - return; - } - - /* Open the dhcptab */ - rcode = open_dd(&handle, &datastore, DSVC_DHCPTAB, - DT_DHCPTAB, DSVC_WRITE); - - dd_free_datastore_t(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, DT_DHCPTAB); - free_dtrec(dtoldrec); - free_dtrec(dtnewrec); - return; - } - - /* Modify the record */ - rcode = modify_dd_entry(handle, dtoldrec, dtnewrec); - - (void) close_dd(&handle); - if (rcode != DSVC_SUCCESS) { - throw_modify_dd_entry_exception(env, rcode, dtoldrec->dt_key, - dtnewrec->dt_key); - } - - free_dtrec(dtnewrec); - free_dtrec(dtoldrec); - -} - -/* - * Delete a record from the dhcptab - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_deleteDhcptabRecord( - JNIEnv *env, - jobject obj, - jobject jrec, - jobject jdatastore) -{ - dsvc_handle_t handle; - dsvc_datastore_t datastore; - dt_rec_t *dtrec; - int rcode; - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return; - } - - dtrec = create_dtrec(env, jrec, B_FALSE); - if (dtrec == NULL) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - return; - } - - /* Open the dhcptab */ - rcode = open_dd(&handle, &datastore, DSVC_DHCPTAB, - DT_DHCPTAB, DSVC_WRITE); - - dd_free_datastore_t(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, DT_DHCPTAB); - free_dtrec(dtrec); - return; - } - - /* Delete the record */ - rcode = delete_dd_entry(handle, dtrec); - - (void) close_dd(&handle); - if (rcode != DSVC_SUCCESS) { - throw_delete_dd_entry_exception(env, rcode, dtrec->dt_key); - } - - free_dtrec(dtrec); -} - -/* - * Create the dhcptab. - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_createDhcptab( - JNIEnv *env, - jobject obj, - jobject jdatastore) -{ - dsvc_handle_t handle; - dsvc_datastore_t datastore; - int rcode; - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return; - } - - /* Open the dhcptab and in the process create it */ - rcode = open_dd(&handle, &datastore, DSVC_DHCPTAB, DT_DHCPTAB, - DSVC_CREATE | DSVC_READ | DSVC_WRITE); - - dd_free_datastore_t(&datastore); - - /* - * If open was successful, then close. Otherwise, if unsuccessful - * opening table, then map error to exception. - */ - if (rcode == DSVC_SUCCESS) { - (void) close_dd(&handle); - } else { - throw_open_dd_exception(env, rcode, DT_DHCPTAB); - } -} - -/* - * Delete the dhcptab. - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_deleteDhcptab( - JNIEnv *env, - jobject obj, - jobject jdatastore) -{ - dsvc_datastore_t datastore; - int rcode; - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return; - } - - rcode = remove_dd(&datastore, DSVC_DHCPTAB, DT_DHCPTAB); - - if (rcode != DSVC_SUCCESS) { - throw_remove_dd_exception(env, rcode, DT_DHCPTAB); - } - - dd_free_datastore_t(&datastore); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/exception.c b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/exception.c deleted file mode 100644 index 204c20875a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/exception.c +++ /dev/null @@ -1,524 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdarg.h> -#include <dhcp_svc_private.h> -#include <dhcp_symbol.h> -#include <libintl.h> -#include <jni.h> - -#include "dd_misc.h" -#include "exception.h" - -/* - * Note: These must match exactly with the message ids defined in the - * bridge ResourceBundle.properties file. - */ -#define DSVC_EXISTS_EX "dsvc_exists_exception" -#define DSVC_ACCESS_EX "dsvc_access_exception" -#define DSVC_CREDENTIAL_EX "dsvc_credential_exception" -#define DSVC_NO_ENT_EX "dsvc_no_ent_exception" -#define DSVC_BUSY_EX "dsvc_busy_exception" -#define DSVC_INVALID_ARGS_EX "dsvc_invalid_args_exception" -#define DSVC_INTERNAL_EX "dsvc_internal_exception" -#define DSVC_UNAVAILABLE_EX "dsvc_unavailable_exception" -#define DSVC_COLLISION_EX "dsvc_collision_exception" -#define DSVC_UNSUPPORTED_EX "dsvc_unsupported_exception" -#define DSVC_NO_MEMORY_EX "dsvc_no_memory_exception" -#define DSVC_NO_RESOURCES_EX "dsvc_no_resources_exception" -#define DSVC_BAD_RESOURCE_EX "dsvc_bad_resource_exception" -#define DSVC_BAD_PATH_EX "dsvc_bad_path_exception" -#define DSVC_MOD_VERSION_EX "dsvc_mod_version_exception" -#define DSVC_MOD_ERR_EX "dsvc_mod_err_exception" -#define DSVC_MOD_LOAD_ERR_EX "dsvc_mod_load_err_exception" -#define DSVC_MOD_UNLOAD_ERR_EX "dsvc_mod_unload_err_exception" -#define DSVC_MOD_CFG_ERR_EX "dsvc_mod_cfg_err_exception" -#define DSVC_SYNCH_ERR_EX "dsvc_synch_err_exception" -#define DSVC_NO_LOCKMGR_EX "dsvc_no_lockmgr_exception" -#define DSVC_NO_LOCATION_EX "dsvc_no_location_exception" -#define DSVC_NO_TABLE_EX "dsvc_no_table_exception" -#define DSVC_TABLE_EXISTS_EX "dsvc_table_exists_exception" -#define DSVC_BAD_CONVER_EX "dsvc_bad_conver_exception" -#define DSVC_INTERNAL_ERROR "dsvc_internal_error" - -#define DSYM_CODE_OUT_OF_RANGE_EX "dsym_code_out_of_range_exception" -#define DSYM_EXCEEDS_CLASS_SIZE_EX "dsym_exceeds_class_size_exception" -#define DSYM_EXCEEDS_MAX_CLASS_SIZE_EX "dsym_exceeds_max_class_size_exception" -#define DSYM_INTERNAL_EX "dsym_internal_exception" -#define DSYM_INVALID_CAT_EX "dsym_invalid_cat_exception" -#define DSYM_INVALID_TYPE_EX "dsym_invalid_type_exception" -#define DSYM_NO_MEMORY_EX "dsym_no_memory_exception" -#define DSYM_TOO_FEW_FIELDS_EX "dsym_too_few_fields_exception" -#define DSYM_SYNTAX_EX "dsym_syntax_exception" -#define DSYM_TOO_MANY_FIELDS_EX "dsym_too_many_fields_exception" -#define DSYM_VALUE_OUT_OF_RANGE_EX "dsym_value_out_of_range_exception" - -static void -throw_exception(JNIEnv *env, const char *name, const char *msgid, - int nargs, ...) -{ - va_list ap; - - jclass class; - jmethodID mid; - jstring jmsgid = NULL; - jobjectArray jlist = NULL; - jthrowable throwObj; - - va_start(ap, nargs); - - class = (*env)->FindClass(env, name); - if (class == NULL) { - /* exception thrown */ - va_end(ap); - return; - } - - mid = (*env)->GetMethodID(env, class, "<init>", - "(Ljava/lang/String;[Ljava/lang/Object;)V"); - if (mid == NULL) { - /* exception thrown */ - va_end(ap); - return; - } - - if (msgid != NULL) { - jmsgid = dd_native_to_jstring(env, msgid); - if (jmsgid == NULL) { - /* exception thrown */ - va_end(ap); - return; - } - } - - /* The arguments (if any) are arguments to the message */ - if (nargs != 0) { - - jclass strclass; - int i; - strclass = (*env)->FindClass(env, "java/lang/String"); - if (strclass == NULL) { - /* exception thrown */ - va_end(ap); - return; - } - - jlist = (*env)->NewObjectArray(env, nargs, strclass, NULL); - if (jlist == NULL) { - /* exception thrown */ - va_end(ap); - return; - } - - for (i = 0; i < nargs; i++) { - jstring jarg; - char *arg; - - if ((arg = va_arg(ap, char *)) == 0) { - break; - } - - jarg = dd_native_to_jstring(env, arg); - if (jarg == NULL) { - /* exception thrown */ - break; - } - - (*env)->SetObjectArrayElement(env, jlist, i, jarg); - if ((*env)->ExceptionOccurred(env) != NULL) { - break; - } - } - - } - - if ((*env)->ExceptionOccurred(env) == NULL) { - throwObj = (jthrowable)(*env)->NewObject(env, class, mid, - jmsgid, jlist); - if (throwObj == NULL) { - /* exception thrown */ - va_end(ap); - return; - } - - /* finally! */ - (*env)->Throw(env, throwObj); - } - - va_end(ap); -} - -/* Throw an exception indicating record or file exists */ -static void -throw_exists_exception(JNIEnv *env, const char *obj) -{ - throw_exception(env, - "com/sun/dhcpmgr/bridge/ExistsException", NULL, 1, obj); -} - -/* Throw an exception indicating a table already exists */ -static void -throw_table_exists_exception(JNIEnv *env, const char *obj) -{ - throw_exception(env, "com/sun/dhcpmgr/bridge/TableExistsException", - NULL, 1, obj); -} - -/* Throw an exception indicating a table does not exist */ -static void -throw_notable_exception(JNIEnv *env, const char *obj) -{ - throw_exception(env, - "com/sun/dhcpmgr/bridge/NoTableException", NULL, 1, obj); -} - -/* Throw a generic bridge exception with a specified message */ -void -throw_bridge_exception(JNIEnv *env, const char *msgid) -{ - throw_exception(env, - "com/sun/dhcpmgr/bridge/BridgeException", msgid, 0); -} - -/* Throw an exception as a result of an remove_dd() error */ -void -throw_remove_dd_exception(JNIEnv *env, int rcode, const char *obj) -{ - switch (rcode) { - case DSVC_NO_TABLE: - throw_notable_exception(env, obj); - break; - default: - throw_libdhcpsvc_exception(env, rcode); - } -} - -/* Throw an exception as a result of an open_dd() error */ -void -throw_open_dd_exception(JNIEnv *env, int rcode, const char *obj) -{ - switch (rcode) { - case DSVC_TABLE_EXISTS: - throw_table_exists_exception(env, obj); - break; - case DSVC_NO_TABLE: - throw_notable_exception(env, obj); - break; - default: - throw_libdhcpsvc_exception(env, rcode); - } -} - -/* Throw an exception as a result of an add_dd_entry() error */ -void -throw_add_dd_entry_exception(JNIEnv *env, int rcode, const char *obj) -{ - switch (rcode) { - case DSVC_EXISTS: - throw_exists_exception(env, obj); - break; - default: - throw_libdhcpsvc_exception(env, rcode); - } -} - -/* Throw an exception as a result of an delete_dd_entry() error */ -void -throw_delete_dd_entry_exception(JNIEnv *env, int rcode, const char *obj) -{ - switch (rcode) { - case DSVC_NOENT: - throw_noent_exception(env, obj); - break; - default: - throw_libdhcpsvc_exception(env, rcode); - } -} - -/* Throw an exception as a result of an modify_dd_entry() error */ -void -throw_modify_dd_entry_exception(JNIEnv *env, int rcode, const char *orig, - const char *new) -{ - switch (rcode) { - case DSVC_EXISTS: - throw_exists_exception(env, new); - break; - case DSVC_NOENT: - throw_noent_exception(env, orig); - break; - default: - throw_libdhcpsvc_exception(env, rcode); - } -} - -/* Throw an out of memory exception */ -void -throw_memory_exception(JNIEnv *env) -{ - throw_libdhcpsvc_exception(env, DSVC_NO_MEMORY); -} - -/* Throw an exception indicating that there is no DHCP config file */ -void -throw_no_defaults_exception(JNIEnv *env) -{ - throw_exception(env, - "com/sun/dhcpmgr/bridge/NoDefaultsException", NULL, 0); -} - -/* Throw an exception indicating record or file does not exist */ -void -throw_noent_exception(JNIEnv *env, const char *obj) -{ - throw_exception(env, - "com/sun/dhcpmgr/bridge/NoEntryException", NULL, 1, obj); -} - -/* Throw an exception indicating an invalid resource */ -void -throw_invalid_resource_exception(JNIEnv *env, const char *obj) -{ - throw_exception(env, "com/sun/dhcpmgr/bridge/InvalidRsrcException", - NULL, 1, obj); -} - -/* Throw an exception indicating an invalid path */ -void -throw_invalid_path_exception(JNIEnv *env, const char *obj) -{ - throw_exception(env, "com/sun/dhcpmgr/bridge/InvalidPathException", - NULL, 1, obj); -} - -/* Throw an exception indicating that the service is not currently running */ -void -throw_not_running_exception(JNIEnv *env) -{ - throw_exception(env, - "com/sun/dhcpmgr/bridge/NotRunningException", NULL, 0); -} - -/* Throw exception for a libdhcpsvc error that requires no special treatment */ -void -throw_libdhcpsvc_exception(JNIEnv *env, int rcode) -{ - const char *msgid; - - switch (rcode) { - case DSVC_SUCCESS: - break; - case DSVC_EXISTS: - msgid = DSVC_EXISTS_EX; - break; - case DSVC_ACCESS: - msgid = DSVC_ACCESS_EX; - break; - case DSVC_NO_CRED: - msgid = DSVC_CREDENTIAL_EX; - break; - case DSVC_NOENT: - msgid = DSVC_NO_ENT_EX; - break; - case DSVC_BUSY: - msgid = DSVC_BUSY_EX; - break; - case DSVC_INVAL: - msgid = DSVC_INVALID_ARGS_EX; - break; - case DSVC_INTERNAL: - msgid = DSVC_INTERNAL_EX; - break; - case DSVC_UNAVAILABLE: - msgid = DSVC_UNAVAILABLE_EX; - break; - case DSVC_COLLISION: - msgid = DSVC_COLLISION_EX; - break; - case DSVC_UNSUPPORTED: - msgid = DSVC_UNSUPPORTED_EX; - break; - case DSVC_NO_MEMORY: - msgid = DSVC_NO_MEMORY_EX; - break; - case DSVC_NO_RESOURCES: - msgid = DSVC_NO_RESOURCES_EX; - break; - case DSVC_BAD_RESOURCE: - msgid = DSVC_BAD_RESOURCE_EX; - break; - case DSVC_BAD_PATH: - msgid = DSVC_BAD_PATH_EX; - break; - case DSVC_MODULE_VERSION: - msgid = DSVC_MOD_VERSION_EX; - break; - case DSVC_MODULE_ERR: - msgid = DSVC_MOD_ERR_EX; - break; - case DSVC_MODULE_LOAD_ERR: - msgid = DSVC_MOD_LOAD_ERR_EX; - break; - case DSVC_MODULE_UNLOAD_ERR: - msgid = DSVC_MOD_UNLOAD_ERR_EX; - break; - case DSVC_MODULE_CFG_ERR: - msgid = DSVC_MOD_CFG_ERR_EX; - break; - case DSVC_SYNCH_ERR: - msgid = DSVC_SYNCH_ERR_EX; - break; - case DSVC_NO_LOCKMGR: - msgid = DSVC_NO_LOCKMGR_EX; - break; - case DSVC_NO_LOCATION: - msgid = DSVC_NO_LOCATION_EX; - break; - case DSVC_BAD_CONVER: - msgid = DSVC_BAD_CONVER_EX; - break; - default: - msgid = DSVC_INTERNAL_ERROR; - } - - throw_bridge_exception(env, msgid); -} - -/* Determine whether an exception is a defaults file doesn't exist exception */ -boolean_t -is_no_defaults_exception(JNIEnv *env, jthrowable e) -{ - jclass class; - boolean_t result = B_FALSE; - - class = (*env)->FindClass(env, - "com/sun/dhcpmgr/bridge/NoDefaultsException"); - if (class != NULL) { - if ((*env)->IsInstanceOf(env, e, class) == JNI_TRUE && - e != NULL) { - result = B_TRUE; - } - } - - return (result); -} - -/* Throw a symbol parsing error */ -/* ARGSUSED [one day we should use the `key' argument in messages] */ -void -throw_dsym_parser_exception(JNIEnv *env, const char *key, char **fields, - int field, dsym_errcode_t rcode) -{ - const char *dsym_exception = "com/sun/dhcpmgr/bridge/DsymException"; - - char ascii_long_1[ULONG_MAX_CHAR + 1]; - char ascii_long_2[ULONG_MAX_CHAR + 1]; - ushort_t min; - ushort_t max; - - switch (rcode) { - case DSYM_SUCCESS: - break; - case DSYM_SYNTAX_ERROR: - throw_exception(env, - dsym_exception, DSYM_SYNTAX_EX, 1, fields[field]); - break; - case DSYM_CODE_OUT_OF_RANGE: - (void) dsym_get_code_ranges(fields[DSYM_CAT_FIELD], - &min, &max, B_TRUE); - (void) sprintf(ascii_long_1, "%d", min); - (void) sprintf(ascii_long_2, "%d", max); - throw_exception(env, dsym_exception, DSYM_CODE_OUT_OF_RANGE_EX, - 3, fields[DSYM_CAT_FIELD], ascii_long_1, ascii_long_2); - break; - case DSYM_VALUE_OUT_OF_RANGE: - throw_exception(env, dsym_exception, - DSYM_VALUE_OUT_OF_RANGE_EX, 1, fields[field]); - break; - case DSYM_INVALID_CAT: - throw_exception(env, dsym_exception, - DSYM_INVALID_CAT_EX, 1, fields[DSYM_CAT_FIELD]); - break; - case DSYM_INVALID_TYPE: - throw_exception(env, dsym_exception, - DSYM_INVALID_TYPE_EX, 1, fields[DSYM_TYPE_FIELD]); - break; - case DSYM_EXCEEDS_CLASS_SIZE: - (void) sprintf(ascii_long_1, "%d", DSYM_CLASS_SIZE); - throw_exception(env, dsym_exception, - DSYM_EXCEEDS_CLASS_SIZE_EX, 1, ascii_long_1); - break; - case DSYM_EXCEEDS_MAX_CLASS_SIZE: - (void) sprintf(ascii_long_1, "%d", DSYM_MAX_CLASS_SIZE); - throw_exception(env, dsym_exception, - DSYM_EXCEEDS_MAX_CLASS_SIZE_EX, 1, ascii_long_1); - break; - case DSYM_NO_MEMORY: - throw_exception(env, dsym_exception, DSYM_NO_MEMORY_EX, 0); - break; - default: - throw_exception(env, dsym_exception, DSYM_INTERNAL_EX, 0); - } -} - -/* Throw a symbol init parsing error */ -void -throw_dsym_parser_init_exception(JNIEnv *env, const char *key, - dsym_errcode_t rcode) -{ - const char *dsym_exception = "com/sun/dhcpmgr/bridge/DsymException"; - - switch (rcode) { - case DSYM_SUCCESS: - break; - case DSYM_NULL_FIELD: - throw_exception(env, - dsym_exception, DSYM_TOO_FEW_FIELDS_EX, 1, key); - break; - case DSYM_TOO_MANY_FIELDS: - throw_exception(env, - dsym_exception, DSYM_TOO_MANY_FIELDS_EX, 1, key); - break; - case DSYM_NO_MEMORY: - throw_exception(env, dsym_exception, DSYM_NO_MEMORY_EX, 0); - break; - default: - throw_exception(env, dsym_exception, DSYM_INTERNAL_EX, 0); - } -} - -/* Throw an exception indicating an error in wordexp */ -void -throw_wordexp_exception(JNIEnv *env, int code) -{ - char buf[UINT64_MAX_CHAR + 1]; - - (void) snprintf(buf, sizeof (buf), "%d", code); - throw_exception(env, "com/sun/dhcpmgr/bridge/WordexpException", - NULL, 1, buf); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/exception.h b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/exception.h deleted file mode 100644 index 269d3ef4b1..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/exception.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _EXCEPTION_H -#define _EXCEPTION_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <jni.h> -#include <dhcp_symbol.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This really doesn't belong here, but rather than create another whole - * header file just for this macro, we stuck it here. - */ -#define ARRAY_LENGTH(arr, len) for (len = 0; arr[len] != NULL; ++len); - -#define ULONG_MAX_CHAR (sizeof ("4294967295")) -#define UINT64_MAX_CHAR (sizeof ("18446744073709551615")) -#define IPADDR_MAX_CHAR (sizeof ("255.255.255.255")) - -extern void throw_libdhcpsvc_exception(JNIEnv *, int); -extern void throw_remove_dd_exception(JNIEnv *, int, const char *); -extern void throw_open_dd_exception(JNIEnv *, int, const char *); -extern void throw_add_dd_entry_exception(JNIEnv *, int, const char *); -extern void throw_delete_dd_entry_exception(JNIEnv *, int, const char *); -extern void throw_modify_dd_entry_exception(JNIEnv *, int, const char *, - const char *); -extern void throw_bridge_exception(JNIEnv *, const char *); -extern void throw_memory_exception(JNIEnv *); -extern void throw_no_defaults_exception(JNIEnv *); -extern void throw_noent_exception(JNIEnv *, const char *); -extern void throw_not_running_exception(JNIEnv *); -extern void throw_invalid_resource_exception(JNIEnv *, const char *); -extern void throw_invalid_path_exception(JNIEnv *, const char *); -extern void throw_dsym_parser_exception(JNIEnv *, const char *, char **, int, - dsym_errcode_t); -extern void throw_dsym_parser_init_exception(JNIEnv *, const char *, - dsym_errcode_t); -extern void throw_wordexp_exception(JNIEnv *, int); -extern boolean_t is_no_defaults_exception(JNIEnv *, jthrowable); -#ifdef __cplusplus -} -#endif - -#endif /* !_EXCEPTION_H */ diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/inc.flg b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/inc.flg deleted file mode 100644 index d7246ea4b0..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/inc.flg +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2003 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -find_files "s.*" usr/src/common/net/dhcp diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/inittab.c b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/inittab.c deleted file mode 100644 index b05b29392a..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/inittab.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdlib.h> -#include <jni.h> -#include <dhcp_inittab.h> -#include <dhcp_symbol.h> -#include <exception.h> -#include <com_sun_dhcpmgr_bridge_Bridge.h> -#include <dhcp_svc_private.h> - -#include "class_cache.h" - -/* - * Retrieve a list of DHCP options from the dhcp inittab. - */ -/*ARGSUSED*/ -JNIEXPORT jobjectArray JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getInittabOptions( - JNIEnv *env, - jobject obj, - jbyte jcategory) { - - jclass opt_class; - jmethodID opt_cons; - jobjectArray jlist = NULL; - jobject jobj; - jstring jname; - jshort jcode; - jbyte jtype; - jint jgran; - jint jmax; - - uchar_t category; - dhcp_symbol_t *entryptr; - dhcp_symbol_t *list; - dhcp_symbol_t internal; - size_t num; - int i; - - /* Make sure we have the classes & methods we need */ - opt_class = find_class(env, OPT_CLASS); - if (opt_class == NULL) { - /* exception thrown */ - return (NULL); - } - opt_cons = get_methodID(env, opt_class, OPT_CONS); - if (opt_cons == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Translate the dhcpmgr category to the inittab category */ - if (jcategory == DSYM_STANDARD) { - category = ITAB_CAT_STANDARD | ITAB_CAT_INTERNAL | - ITAB_CAT_FIELD; - } else { - category = jcategory; - } - - /* Get the list of options */ - list = inittab_load(category, ITAB_CONS_MANAGER, &num); - if (list == NULL) { - return (NULL); - } - - /* Construct the array */ - jlist = (*env)->NewObjectArray(env, num, opt_class, NULL); - if (jlist == NULL) { - /* exception thrown */ - free(list); - return (NULL); - } - - /* For each option, create an object and add it to the array */ - for (i = 0; i < num; ++i) { - - /* Verify the entry. Use the internal if necessary. */ - if (inittab_verify(&list[i], &internal) == ITAB_FAILURE) { - entryptr = &internal; - } else { - entryptr = &list[i]; - } - - jtype = entryptr->ds_type; - jname = (*env)->NewStringUTF(env, entryptr->ds_name); - if (jname == NULL) { - /* exception thrown */ - break; - } - - /* HACK. Since the codes for fields can overlap the */ - /* codes for STANDARD options, we will just set the */ - /* code to zero and ignore the need for these codes to */ - /* be unique. We do the same for internal but not */ - /* for the same reason. For internal we have no need */ - /* for the actual code and since we expect them to */ - /* change in the future, we'll just go ahead and */ - /* set them to zero too. */ - if (entryptr->ds_category == DSYM_INTERNAL || - entryptr->ds_category == DSYM_FIELD) { - jcode = (jshort)0; - } else { - jcode = entryptr->ds_code; - } - - jmax = entryptr->ds_max; - jgran = entryptr->ds_gran; - - /* Create an 'Option' */ - jobj = (*env)->NewObject(env, opt_class, opt_cons, jname, - jcategory, NULL, jcode, jtype, jgran, jmax, NULL, - JNI_TRUE); - if (jobj == NULL) { - /* exception thrown */ - break; - } - - (*env)->SetObjectArrayElement(env, jlist, i, jobj); - if ((*env)->ExceptionOccurred(env) != NULL) { - break; - } - } - - free(list); - - return (jlist); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/network.c b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/network.c deleted file mode 100644 index c61e2b6bf7..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/network.c +++ /dev/null @@ -1,1102 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <string.h> -#include <dhcp_svc_private.h> -#include <dhcp_svc_confkey.h> -#include <libinetutil.h> -#include <libintl.h> -#include <stdlib.h> -#include <ctype.h> -#include <malloc.h> -#include <netdb.h> -#include <arpa/inet.h> -#include <jni.h> -#include <com_sun_dhcpmgr_bridge_Bridge.h> - -#include "exception.h" -#include "dd_misc.h" -#include "class_cache.h" - -/* - * Create a dn_rec from a DhcpClientRecord. - */ -static dn_rec_t * -create_dnrec(JNIEnv *env, - jobject dhcpClientRecord) -{ - jclass dcr_class; - - dn_rec_t *dnrec = NULL; - char *str; - unsigned int cid_len; - - /* Locate the class we need */ - dcr_class = find_class(env, DCR_CLASS); - if (dcr_class == NULL) { - /* exception thrown */ - return (NULL); - } - - dnrec = malloc(sizeof (dn_rec_t)); - if (dnrec == NULL) { - throw_memory_exception(env); - return (NULL); - } - - /* - * Get the cid and the cid_len. - */ - if (!dd_get_str_attr(env, dcr_class, DCR_GETCID, dhcpClientRecord, - &str)) { - /* exception thrown */ - free_dnrec(dnrec); - return (NULL); - } - cid_len = DN_MAX_CID_LEN; - if (hexascii_to_octet(str, strlen(str), dnrec->dn_cid, &cid_len) != 0) { - free(str); - free_dnrec(dnrec); - throw_memory_exception(env); - return (NULL); - } - dnrec->dn_cid_len = cid_len; - free(str); - - /* - * Get the flags. - */ - if (!dd_get_str_attr(env, dcr_class, DCR_GETFLAG, dhcpClientRecord, - &str)) { - /* exception thrown */ - free_dnrec(dnrec); - return (NULL); - } - dnrec->dn_flags = atoi(str); - free(str); - - /* - * Get the client IP. - */ - if (!dd_get_str_attr(env, dcr_class, DCR_GETCIP, dhcpClientRecord, - &str)) { - /* exception thrown */ - free_dnrec(dnrec); - return (NULL); - } - dnrec->dn_cip.s_addr = ntohl(inet_addr(str)); - free(str); - - /* - * Get the server IP. - */ - if (!dd_get_str_attr(env, dcr_class, DCR_GETSIP, dhcpClientRecord, - &str)) { - /* exception thrown */ - free_dnrec(dnrec); - return (NULL); - } - dnrec->dn_sip.s_addr = ntohl(inet_addr(str)); - free(str); - - /* - * Get the expiration. - */ - if (!dd_get_str_attr(env, dcr_class, DCR_GETEXP, dhcpClientRecord, - &str)) { - /* exception thrown */ - free_dnrec(dnrec); - return (NULL); - } - dnrec->dn_lease = atol(str); - free(str); - - /* - * Get the signature. - */ - if (!dd_get_str_attr(env, dcr_class, DCR_GETSIG, dhcpClientRecord, - &str)) { - /* exception thrown */ - free_dnrec(dnrec); - return (NULL); - } - dnrec->dn_sig = atoll(str); - free(str); - - /* - * Get the macro. - */ - if (!dd_get_str_attr(env, dcr_class, DCR_GETMAC, dhcpClientRecord, - &str)) { - /* exception thrown */ - free_dnrec(dnrec); - return (NULL); - } - (void) strlcpy(dnrec->dn_macro, str, sizeof (dnrec->dn_macro)); - free(str); - - /* - * Get the comment. - */ - if (!dd_get_str_attr(env, dcr_class, DCR_GETCMT, dhcpClientRecord, - &str)) { - /* exception thrown */ - free_dnrec(dnrec); - return (NULL); - } - (void) strlcpy(dnrec->dn_comment, str, sizeof (dnrec->dn_comment)); - free(str); - - return (dnrec); -} - -/* - * Create a DhcpClientRecord from a dn_rec. - */ -static jobject -create_DhcpClientRecord( - JNIEnv *env, - dn_rec_t *dnrec) -{ - jclass dcr_class; - jmethodID dcr_cons; - jobject dhcpClientRecord; - struct in_addr tmpaddr; - - char ascii_cid[DN_MAX_CID_LEN * 2 + 1]; - char ascii_flags[2 + 1]; - char ascii_cip[IPADDR_MAX_CHAR + 1]; - char ascii_sip[IPADDR_MAX_CHAR + 1]; - char ascii_lease[ULONG_MAX_CHAR + 1]; - char ascii_sig[UINT64_MAX_CHAR + 1]; - char ascii_macro[DSVC_MAX_MACSYM_LEN + 1]; - char ascii_comment[DN_MAX_COMMENT_LEN + 1]; - - uint_t cid_len; - int err; - - /* Find the class */ - dcr_class = find_class(env, DCR_CLASS); - if (dcr_class == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Locate the constructor we need */ - dcr_cons = get_methodID(env, dcr_class, DCR_CONS); - if (dcr_cons == NULL) { - /* exception thrown */ - return (NULL); - } - - cid_len = DN_MAX_CID_LEN * 2 + 1; - err = octet_to_hexascii(dnrec->dn_cid, dnrec->dn_cid_len, ascii_cid, - &cid_len); - if (err != 0) { - throw_bridge_exception(env, strerror(err)); - return (NULL); - } - ascii_cid[cid_len] = '\0'; - - (void) sprintf(ascii_flags, "%02hu", dnrec->dn_flags); - - tmpaddr.s_addr = htonl(dnrec->dn_cip.s_addr); - (void) strcpy(ascii_cip, inet_ntoa(tmpaddr)); - tmpaddr.s_addr = htonl(dnrec->dn_sip.s_addr); - (void) strcpy(ascii_sip, inet_ntoa(tmpaddr)); - - (void) sprintf(ascii_lease, "%d", dnrec->dn_lease); - (void) sprintf(ascii_sig, "%lld", dnrec->dn_sig); - - (void) strlcpy(ascii_macro, dnrec->dn_macro, sizeof (ascii_macro)); - (void) strlcpy(ascii_comment, dnrec->dn_comment, - sizeof (ascii_comment)); - - dhcpClientRecord = (*env)->NewObject(env, dcr_class, dcr_cons, - (*env)->NewStringUTF(env, ascii_cid), - (*env)->NewStringUTF(env, ascii_flags), - (*env)->NewStringUTF(env, ascii_cip), - (*env)->NewStringUTF(env, ascii_sip), - (*env)->NewStringUTF(env, ascii_lease), - (*env)->NewStringUTF(env, ascii_macro), - (*env)->NewStringUTF(env, ascii_comment), - (*env)->NewStringUTF(env, ascii_sig)); - - return (dhcpClientRecord); -} - -/* - * Given a network name, find it's IP address. - */ -static boolean_t -getNetIPByName(const char *netname, char *netip) { - - struct netent *ne; - ulong_t addr; - boolean_t result = B_FALSE; - - if ((ne = getnetbyname(netname)) != NULL && - ne->n_addrtype == AF_INET) { - - int i; - ulong_t tl; - int count; - - for (i = 0, tl = (ulong_t)0xff000000, count = 0; - i < 4; i++, tl >>= 8) { - - if ((ne->n_net & tl) == 0) - count += 8; - else - break; - } - - addr = ne->n_net << count; - (void) sprintf(netip, "%ld.%ld.%ld.%ld", - ((addr & 0xff000000) >> 24), ((addr & 0x00ff0000) >> 16), - ((addr & 0x0000ff00) >> 8), (addr & 0x000000ff)); - - result = B_TRUE; - } - - return (result); -} - -/* - * Create a Network object for a network IP address. - */ -static jobject -createNetwork( - JNIEnv *env, - const char *network) -{ - jclass net_class; - jmethodID net_cons; - jobject net; - - struct in_addr addr; - struct in_addr mask; - jstring jstr; - - /* Locate the class and methods we need */ - net_class = find_class(env, NET_CLASS); - if (net_class == NULL) { - /* exception thrown */ - return (NULL); - } - net_cons = get_methodID(env, net_class, NET_CONS); - if (net_cons == NULL) { - /* exception thrown */ - return (NULL); - } - - addr.s_addr = ntohl(inet_addr(network)); - get_netmask4(&addr, &mask); - - jstr = (*env)->NewStringUTF(env, network); - if (jstr == NULL) { - /* exception thrown */ - return (NULL); - } - - net = (*env)->NewObject(env, net_class, net_cons, jstr, mask.s_addr); - - return (net); -} - - -/* - * Get the Network object for the network argument. - */ -/*ARGSUSED*/ -JNIEXPORT jobject JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getNetwork( - JNIEnv *env, - jobject obj, - jstring jnet) -{ - - jobject netObj; - char *net; - - char *netip = NULL; - char ascii_ip[IPADDR_MAX_CHAR + 1]; - - /* Retrieve the net argument */ - if (!dd_jstring_to_UTF(env, jnet, &net)) { - /* exception thrown */ - return (NULL); - } - - /* - * If net looks like an IP address, assume it is, - * otherwise go get its IP - */ - if (!isdigit(*net)) { - if (getNetIPByName(net, ascii_ip)) { - netip = ascii_ip; - } - } else { - netip = net; - } - - /* If we could not find an IP for net, then return NULL object */ - if (netip == NULL) { - free(net); - return (NULL); - } - - /* Create a Network object */ - netObj = createNetwork(env, netip); - if (netObj == NULL) { - /* exception thrown */ - free(net); - return (NULL); - } - - /* free up resources */ - free(net); - - /* return the object */ - return (netObj); -} - -/* - * List the networks currently under DHCP management. Return as an array - * of Network objects including the subnet mask for each network. - */ -/*ARGSUSED*/ -JNIEXPORT jobjectArray JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getNetworks( - JNIEnv *env, - jobject obj, - jobject jdatastore) -{ - jclass net_class; - jobjectArray jlist = NULL; - jobject net; - uint32_t count; - char **list = NULL; - dsvc_datastore_t datastore; - int rcode; - int i; - - /* Locate the class. */ - net_class = find_class(env, NET_CLASS); - if (net_class == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return (NULL); - } - - /* Get the list of network tables */ - rcode = list_dd(&datastore, DSVC_DHCPNETWORK, &list, &count); - - dd_free_datastore_t(&datastore); - - if (rcode != DSVC_SUCCESS) { - throw_libdhcpsvc_exception(env, rcode); - return (NULL); - } - - /* Construct the array */ - jlist = (*env)->NewObjectArray(env, count, net_class, NULL); - if (jlist == NULL) { - /* exception thrown */ - for (i = 0; i < count; i++) { - free(list[i]); - } - free(list); - return (NULL); - } - - /* For each network, create an object and add it to the array */ - for (i = 0; i < count; i++) { - net = createNetwork(env, list[i]); - if (net == NULL) { - /* exception thrown */ - break; - } - - (*env)->SetObjectArrayElement(env, jlist, i, net); - if ((*env)->ExceptionOccurred(env) != NULL) { - break; - } - } - - /* - * Free the list now. - */ - for (i = 0; i < count; i++) { - free(list[i]); - } - free(list); - - return (jlist); -} - -/* - * Use the current datastore to create a network table in a new datastore. - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_cvtNetwork( - JNIEnv *env, - jobject obj, - jstring jnet, - jobject jdatastore) -{ - dn_rec_t record; - dn_rec_list_t *recordList; - dn_rec_list_t *originalList = NULL; - uint32_t query; - uint32_t count = 0; - struct in_addr tmpaddr; - char ascii_cip[IPADDR_MAX_CHAR + 1]; - - dsvc_handle_t curHandle; - dsvc_handle_t newHandle; - dsvc_datastore_t curDatastore; - dsvc_datastore_t newDatastore; - - char *net; - int rcode; - int i; - - /* Get the current data store configuration */ - if (!dd_get_conf_datastore_t(env, &curDatastore)) { - /* exception thrown */ - return; - } - - /* Make a "new" dsvc_datastore_t */ - if (!dd_make_datastore_t(env, &newDatastore, jdatastore)) { - /* exception thrown */ - dd_free_datastore_t(&curDatastore); - return; - } - - /* Retrieve the net argument */ - if (!dd_jstring_to_UTF(env, jnet, &net)) { - /* exception thrown */ - dd_free_datastore_t(&curDatastore); - dd_free_datastore_t(&newDatastore); - return; - } - - /* Open the current network table */ - rcode = open_dd(&curHandle, &curDatastore, DSVC_DHCPNETWORK, net, - DSVC_READ); - - dd_free_datastore_t(&curDatastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, net); - dd_free_datastore_t(&newDatastore); - free(net); - return; - } - - /* Open the new network table */ - rcode = open_dd(&newHandle, &newDatastore, DSVC_DHCPNETWORK, net, - DSVC_CREATE | DSVC_READ | DSVC_WRITE); - - dd_free_datastore_t(&newDatastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, net); - (void) close_dd(&curHandle); - free(net); - return; - } - free(net); - - /* Get the records */ - DSVC_QINIT(query); - rcode = lookup_dd(curHandle, B_FALSE, query, -1, &record, - (void**)&recordList, &count); - - (void) close_dd(&curHandle); - if (rcode != DSVC_SUCCESS) { - throw_libdhcpsvc_exception(env, rcode); - (void) close_dd(&newHandle); - return; - } - - if (count != 0) { - originalList = recordList; - } - - /* For each row, write client record to new table */ - for (i = 0; i < count; i++) { - /* Now add the record */ - rcode = add_dd_entry(newHandle, recordList->dnl_rec); - - if (rcode != DSVC_SUCCESS) { - tmpaddr.s_addr = - htonl(recordList->dnl_rec->dn_cip.s_addr); - (void) strcpy(ascii_cip, inet_ntoa(tmpaddr)); - throw_add_dd_entry_exception(env, rcode, ascii_cip); - break; - } - - recordList = recordList->dnl_next; - } - - (void) close_dd(&newHandle); - - if (originalList != NULL) { - free_dnrec_list(originalList); - } -} - -/* - * Retrieve all of the records in a particular network table. Returns an - * array of DhcpClientRecord. - */ -/*ARGSUSED*/ -JNIEXPORT jobjectArray JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_loadNetwork( - JNIEnv *env, - jobject obj, - jstring jnet, - jobject jdatastore) -{ - jclass dcr_class; - jobjectArray jlist = NULL; - jobject dhcpClientRecord; - int i; - - dsvc_handle_t handle; - dsvc_datastore_t datastore; - - dn_rec_t record; - dn_rec_list_t *recordList = NULL; - dn_rec_list_t *originalList = NULL; - uint32_t query; - uint32_t count = 0; - - char *net; - int rcode; - - /* Locate the class and constructor we need */ - dcr_class = find_class(env, DCR_CLASS); - if (dcr_class == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return (NULL); - } - - /* Retrieve the net argument */ - if (!dd_jstring_to_UTF(env, jnet, &net)) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - return (NULL); - } - - rcode = open_dd(&handle, &datastore, DSVC_DHCPNETWORK, net, DSVC_READ); - - dd_free_datastore_t(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, net); - free(net); - return (NULL); - } - free(net); - - /* Get the records */ - DSVC_QINIT(query); - rcode = lookup_dd(handle, B_FALSE, query, -1, &record, - (void**)&recordList, &count); - - (void) close_dd(&handle); - if (rcode != DSVC_SUCCESS) { - throw_libdhcpsvc_exception(env, rcode); - return (NULL); - } - - /* Save original pointer so we can free it correctly at end */ - originalList = recordList; - - /* Construct the array */ - jlist = (*env)->NewObjectArray(env, count, dcr_class, NULL); - if (jlist == NULL) { - /* exception thrown */ - if (originalList != NULL) { - free_dnrec_list(originalList); - } - return (NULL); - } - - /* For each client, create an object and add it to the array */ - for (i = 0; i < count; i++) { - dhcpClientRecord = create_DhcpClientRecord(env, - recordList->dnl_rec); - if (dhcpClientRecord == NULL) { - /* exception thrown */ - break; - } - recordList = recordList->dnl_next; - - (*env)->SetObjectArrayElement(env, jlist, i, dhcpClientRecord); - if ((*env)->ExceptionOccurred(env) != NULL) { - break; - } - } - - if (originalList != NULL) { - free_dnrec_list(originalList); - } - - return (jlist); -} - -/* - * Create a client record - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_createDhcpClientRecord( - JNIEnv *env, - jobject obj, - jobject jrec, - jstring jnet, - jobject jdatastore) -{ - dsvc_handle_t handle; - dsvc_datastore_t datastore; - dn_rec_t *dnrec; - char *net; - int rcode; - - struct in_addr tmpaddr; - char ascii_cip[IPADDR_MAX_CHAR + 1]; - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return; - } - - /* Retrieve the net argument */ - if (!dd_jstring_to_UTF(env, jnet, &net)) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - return; - } - - dnrec = create_dnrec(env, jrec); - if (dnrec == NULL) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - free(net); - return; - } - - rcode = open_dd(&handle, &datastore, DSVC_DHCPNETWORK, - net, DSVC_WRITE); - - dd_free_datastore_t(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, net); - free(net); - free_dnrec(dnrec); - return; - } - free(net); - - /* Now add the record */ - rcode = add_dd_entry(handle, dnrec); - - (void) close_dd(&handle); - if (rcode != DSVC_SUCCESS) { - tmpaddr.s_addr = htonl(dnrec->dn_cip.s_addr); - (void) strcpy(ascii_cip, inet_ntoa(tmpaddr)); - throw_add_dd_entry_exception(env, rcode, ascii_cip); - } - - free_dnrec(dnrec); - -} - -/* - * Modify a client record. Supply both old and new record and table in - * which they're to be modified. - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_modifyDhcpClientRecord( - JNIEnv *env, - jobject obj, - jobject joldrec, - jobject jnewrec, - jstring jnet, - jobject jdatastore) -{ - dsvc_handle_t handle; - dsvc_datastore_t datastore; - dn_rec_t *dnoldrec; - dn_rec_t *dnnewrec; - - struct in_addr tmpaddr; - char old_ascii_cip[IPADDR_MAX_CHAR + 1]; - char new_ascii_cip[IPADDR_MAX_CHAR + 1]; - - char *net; - int rcode; - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return; - } - - /* Retrieve the net argument */ - if (!dd_jstring_to_UTF(env, jnet, &net)) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - return; - } - - dnoldrec = create_dnrec(env, joldrec); - if (dnoldrec == NULL) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - free(net); - return; - } - - dnnewrec = create_dnrec(env, jnewrec); - if (dnnewrec == NULL) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - free(net); - free_dnrec(dnoldrec); - return; - } - - rcode = open_dd(&handle, &datastore, DSVC_DHCPNETWORK, - net, DSVC_WRITE); - - dd_free_datastore_t(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, net); - free(net); - free_dnrec(dnoldrec); - free_dnrec(dnnewrec); - return; - } - free(net); - - /* Modify the record */ - rcode = modify_dd_entry(handle, dnoldrec, dnnewrec); - - (void) close_dd(&handle); - if (rcode != DSVC_SUCCESS) { - tmpaddr.s_addr = htonl(dnoldrec->dn_cip.s_addr); - (void) strcpy(old_ascii_cip, inet_ntoa(tmpaddr)); - tmpaddr.s_addr = htonl(dnnewrec->dn_cip.s_addr); - (void) strcpy(new_ascii_cip, inet_ntoa(tmpaddr)); - throw_modify_dd_entry_exception(env, rcode, old_ascii_cip, - new_ascii_cip); - } - - free_dnrec(dnnewrec); - free_dnrec(dnoldrec); -} - -/* - * Delete a client record - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_deleteDhcpClientRecord( - JNIEnv *env, - jobject obj, - jobject jrec, - jstring jnet, - jobject jdatastore) -{ - dsvc_handle_t handle; - dsvc_datastore_t datastore; - dn_rec_t *dnrec; - - struct in_addr tmpaddr; - char ascii_cip[IPADDR_MAX_CHAR + 1]; - - char *net; - int rcode; - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return; - } - - /* Retrieve the net argument */ - if (!dd_jstring_to_UTF(env, jnet, &net)) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - return; - } - - dnrec = create_dnrec(env, jrec); - if (dnrec == NULL) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - free(net); - return; - } - - rcode = open_dd(&handle, &datastore, DSVC_DHCPNETWORK, - net, DSVC_WRITE); - - dd_free_datastore_t(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, net); - free(net); - free_dnrec(dnrec); - return; - } - free(net); - - /* Delete the record */ - rcode = delete_dd_entry(handle, dnrec); - - (void) close_dd(&handle); - if (rcode != DSVC_SUCCESS) { - tmpaddr.s_addr = htonl(dnrec->dn_cip.s_addr); - (void) strcpy(ascii_cip, inet_ntoa(tmpaddr)); - throw_delete_dd_entry_exception(env, rcode, ascii_cip); - } - - free_dnrec(dnrec); -} - -/* - * Retrieve a client record - */ -/*ARGSUSED*/ -JNIEXPORT jobject JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getDhcpClientRecord( - JNIEnv *env, - jobject obj, - jobject jrec, - jstring jnet, - jobject jdatastore) -{ - jclass dcr_class; - jmethodID dcr_getcip; - jobject dhcpClientRecord = NULL; - jstring jaddr; - - dsvc_handle_t handle; - dsvc_datastore_t datastore; - - char *net; - char *addr; - int rcode; - - dn_rec_t record; - dn_rec_list_t *recordList; - uint32_t query; - uint32_t count = 0; - - /* Find the class and method we need */ - dcr_class = find_class(env, DCR_CLASS); - if (dcr_class == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Locate the method id we need */ - dcr_getcip = get_methodID(env, dcr_class, DCR_GETCIP); - if (dcr_getcip == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Get the address from the record */ - jaddr = (*env)->CallObjectMethod(env, jrec, dcr_getcip); - if (jaddr == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return (NULL); - } - - /* Retrieve the net argument */ - if (!dd_jstring_to_UTF(env, jnet, &net)) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - return (NULL); - } - - /* Convert the address to a native string */ - if (!dd_jstring_to_UTF(env, jaddr, &addr)) { - /* exception thrown */ - throw_memory_exception(env); - dd_free_datastore_t(&datastore); - free(net); - return (NULL); - } - - rcode = open_dd(&handle, &datastore, DSVC_DHCPNETWORK, net, DSVC_READ); - - dd_free_datastore_t(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_open_dd_exception(env, rcode, net); - free(addr); - free(net); - return (NULL); - } - free(net); - - /* Get the record */ - DSVC_QINIT(query); - DSVC_QEQ(query, DN_QCIP); - record.dn_cip.s_addr = ntohl(inet_addr(addr)); - - rcode = lookup_dd(handle, B_FALSE, query, 1, &record, - (void **)&recordList, &count); - - (void) close_dd(&handle); - if (rcode == DSVC_SUCCESS) { - if (count == 1) { - dhcpClientRecord = create_DhcpClientRecord(env, - recordList->dnl_rec); - free_dnrec_list(recordList); - } else { - throw_noent_exception(env, addr); - } - } else { - throw_libdhcpsvc_exception(env, rcode); - } - - free(addr); - - - return (dhcpClientRecord); -} - -/* - * Create a network table. - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_createDhcpNetwork( - JNIEnv *env, - jobject obj, - jstring jnet, - jobject jdatastore) -{ - dsvc_handle_t handle; - dsvc_datastore_t datastore; - char *net; - int rcode; - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return; - } - - /* Retrieve the net argument */ - if (!dd_jstring_to_UTF(env, jnet, &net)) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - return; - } - - rcode = open_dd(&handle, &datastore, DSVC_DHCPNETWORK, net, - DSVC_CREATE | DSVC_READ | DSVC_WRITE); - - dd_free_datastore_t(&datastore); - - /* - * If open was successful, then close. Otherwise, if unsuccessful - * opening table, then map error to exception. - */ - if (rcode == DSVC_SUCCESS) { - (void) close_dd(&handle); - } else { - throw_open_dd_exception(env, rcode, net); - } - - free(net); -} - -/* - * Delete a network table. - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_deleteDhcpNetwork( - JNIEnv *env, - jobject obj, - jstring jnet, - jobject jdatastore) -{ - dsvc_datastore_t datastore; - char *net; - int rcode; - - /* Create a dsvc_datastore_t using args and DHCP config settings */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return; - } - - /* Retrieve the net argument */ - if (!dd_jstring_to_UTF(env, jnet, &net)) { - /* exception thrown */ - dd_free_datastore_t(&datastore); - return; - } - - rcode = remove_dd(&datastore, DSVC_DHCPNETWORK, net); - - dd_free_datastore_t(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_remove_dd_exception(env, rcode, net); - } - - free(net); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/optiondefs.c b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/optiondefs.c deleted file mode 100644 index a8e18908c1..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/optiondefs.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <libintl.h> -#include <arpa/inet.h> -#include <jni.h> -#include <com_sun_dhcpmgr_bridge_Bridge.h> - -#include "exception.h" -#include "dd_opt.h" -#include "class_cache.h" - -/* - * Retrieve default value for an option with a string value. Returns a - * single String. - */ -/*ARGSUSED*/ -JNIEXPORT jstring JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getStringOption( - JNIEnv *env, - jobject obj, - jshort code, - jstring jarg) -{ - jstring jstr; - struct dhcp_option *opt; - ushort_t scode = (ushort_t)code; - const char *arg; - - /* Get the option whose default value we want to generate. */ - arg = (*env)->GetStringUTFChars(env, jarg, NULL); - if (arg == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Get the option data */ - opt = dd_getopt(scode, arg, NULL); - (*env)->ReleaseStringUTFChars(env, jarg, arg); - - if (opt == NULL) { - throw_memory_exception(env); - return (NULL); - } - - if (opt->error_code != 0) { - throw_bridge_exception(env, opt->u.msg); - dd_freeopt(opt); - return (NULL); - } - - /* Set the return value */ - jstr = (*env)->NewStringUTF(env, opt->u.ret.data.strings[0]); - dd_freeopt(opt); - return (jstr); -} - -/* - * Get the default value for an option whose value is one or more IP - * addresses. Returns an array of IPAddress objects. - */ -/*ARGSUSED*/ -JNIEXPORT jobjectArray JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getIPOption( - JNIEnv *env, - jobject obj, - jshort code, - jstring jarg) -{ - jclass ip_class; - jmethodID ip_cons; - jobjectArray jlist = NULL; - jobject jaddr; - jstring jstr; - struct dhcp_option *opt; - ushort_t scode = (ushort_t)code; - int i; - const char *arg; - - /* Get classes and methods we need */ - ip_class = find_class(env, IP_CLASS); - if (ip_class == NULL) { - /* exception thrown */ - return (NULL); - } - ip_cons = get_methodID(env, ip_class, IP_CONS); - if (ip_cons == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Retrieve option to generate value for */ - arg = (*env)->GetStringUTFChars(env, jarg, NULL); - if (arg == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Go get the default value */ - opt = dd_getopt(scode, arg, NULL); - (*env)->ReleaseStringUTFChars(env, jarg, arg); - - if (opt == NULL) { - throw_memory_exception(env); - return (NULL); - } - - if (opt->error_code != 0) { - throw_bridge_exception(env, opt->u.msg); - dd_freeopt(opt); - return (NULL); - } - - /* Construct the array */ - jlist = (*env)->NewObjectArray(env, opt->u.ret.count, ip_class, NULL); - if (jlist == NULL) { - /* exception thrown */ - dd_freeopt(opt); - return (NULL); - } - - /* For each address, create an object and add it to the array */ - for (i = 0; i < opt->u.ret.count; ++i) { - jstr = (*env)->NewStringUTF(env, - inet_ntoa(*opt->u.ret.data.addrs[i])); - if (jstr == NULL) { - /* exception thrown */ - break; - } - jaddr = (*env)->NewObject(env, ip_class, ip_cons, jstr); - if (jaddr == NULL) { - /* exception thrown */ - break; - } - - (*env)->SetObjectArrayElement(env, jlist, i, jaddr); - if ((*env)->ExceptionOccurred(env) != NULL) { - break; - } - } - - dd_freeopt(opt); - return (jlist); -} - -/* - * Generate the default value for an option whose value is a list of numbers. - * Returns an array of longs. - */ -/*ARGSUSED*/ -JNIEXPORT jlongArray JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getNumberOption( - JNIEnv *env, - jobject obj, - jshort code, - jstring jarg) -{ - jlongArray list; - struct dhcp_option *opt; - const char *arg; - ushort_t scode = (ushort_t)code; - jlong *listel; - int i; - - /* Get option to retrieve */ - arg = (*env)->GetStringUTFChars(env, jarg, NULL); - if (arg == NULL) { - /* exception thrown */ - return (NULL); - } - - opt = dd_getopt(scode, arg, NULL); - (*env)->ReleaseStringUTFChars(env, jarg, arg); - - if (opt == NULL) { - throw_memory_exception(env); - return (NULL); - } - - if (opt->error_code != 0) { - throw_bridge_exception(env, opt->u.msg); - dd_freeopt(opt); - return (NULL); - } - - /* Allocate return array */ - list = (*env)->NewLongArray(env, opt->u.ret.count); - if (list == NULL) { - /* exception thrown */ - dd_freeopt(opt); - return (NULL); - } - - /* Get access to elements of return array, then copy data in */ - listel = (*env)->GetLongArrayElements(env, list, NULL); - if (listel == NULL) { - /* exception thrown */ - dd_freeopt(opt); - return (NULL); - } - - for (i = 0; i < opt->u.ret.count; ++i) { - listel[i] = opt->u.ret.data.numbers[i]; - } - - /* Tell VM we're done so it can finish putting data back */ - (*env)->ReleaseLongArrayElements(env, list, listel, 0); - - dd_freeopt(opt); - return (list); -} diff --git a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/service.c b/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/service.c deleted file mode 100644 index 628d481825..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sadm/dhcpmgr/lib/service.c +++ /dev/null @@ -1,713 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include <wordexp.h> -#include <string.h> -#include <malloc.h> -#include <sys/signal.h> -#include <libintl.h> -#include <arpa/inet.h> -#include <errno.h> -#include <dhcp_svc_private.h> -#include <dhcp_svc_confkey.h> -#include <jni.h> -#include <libscf.h> -#include <com_sun_dhcpmgr_bridge_Bridge.h> - -#include "exception.h" -#include "dd_misc.h" -#include "class_cache.h" - -#define DHCP_SERVER_INST "svc:/network/dhcp-server:default" - -#define DHCPD_FNAME "in.dhcpd" -#define CONFOPT_MODE 0644 - -/* - * Gets called when the library is loaded. - */ -/*ARGSUSED*/ -JNIEXPORT jint JNICALL -JNI_OnLoad( - JavaVM *jvm, - void *reserved) -{ - JNIEnv *env; - - if ((*jvm)->GetEnv(jvm, (void**)&env, JNI_VERSION_1_2)) { - return (JNI_ERR); - } - - init_class_cache(); - return (JNI_VERSION_1_2); -} - -/* - * Determine whether an upgrade of the datastore is necessary. - */ -/*ARGSUSED*/ -JNIEXPORT jboolean JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_isVersionCurrent( - JNIEnv *env, - jobject obj) -{ - dsvc_datastore_t datastore; - int cfgVersion; - int curVersion; - int rcode; - jboolean result = JNI_FALSE; - - /* Get the data store configuration */ - if (dd_get_conf_datastore_t(env, &datastore)) { - cfgVersion = datastore.d_conver; - - datastore.d_conver = DSVC_CUR_CONVER; - free(datastore.d_location); - datastore.d_location = NULL; - rcode = status_dd(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_libdhcpsvc_exception(env, rcode); - } else { - curVersion = datastore.d_conver; - - if (curVersion == cfgVersion) { - result = JNI_TRUE; - } - } - dd_free_datastore_t(&datastore); - } - - return (result); -} - -/* - * Retrieve the data store object for the specified resource. - */ -/*ARGSUSED*/ -JNIEXPORT jobject JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getDataStore( - JNIEnv *env, - jobject obj, - jstring jresource) -{ - jclass ds_class; - jmethodID ds_cons; - jobject dsObject; - jboolean avail; - jint version; - dsvc_datastore_t datastore; - char *resource; - - /* Make sure we have the classes & methods we need */ - ds_class = find_class(env, DS_CLASS); - if (ds_class == NULL) { - /* exception thrown */ - return (NULL); - } - ds_cons = get_methodID(env, ds_class, DS_CONS); - if (ds_cons == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Retrieve the resource argument */ - if (!dd_jstring_to_UTF(env, jresource, &resource)) { - /* exception thrown */ - return (NULL); - } - - datastore.d_conver = DSVC_CUR_CONVER; - datastore.d_resource = resource; - datastore.d_location = NULL; - avail = JNI_FALSE; - if (status_dd(&datastore) == DSVC_SUCCESS) { - avail = JNI_TRUE; - version = datastore.d_conver; - } - - dsObject = (*env)->NewObject(env, ds_class, ds_cons, - jresource, version, avail); - - free(resource); - return (dsObject); -} - -/* - * Retrieve the list of data stores available for DHCP. Returns an array of - * DHCP datastore names. - */ -/*ARGSUSED*/ -JNIEXPORT jobjectArray JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getDataStores( - JNIEnv *env, - jobject obj) -{ - jclass ds_class; - jmethodID ds_cons; - jobjectArray jlist = NULL; - jobject jobj; - jstring jstr; - jboolean avail; - jint version; - char **list; - dsvc_datastore_t datastore; - int i, len; - - /* Make sure we have the classes & methods we need */ - ds_class = find_class(env, DS_CLASS); - if (ds_class == NULL) { - /* exception thrown */ - return (NULL); - } - ds_cons = get_methodID(env, ds_class, DS_CONS); - if (ds_cons == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Get the list */ - list = dd_data_stores(env); - if ((*env)->ExceptionOccurred(env) != NULL) { - return (NULL); - } - - /* Compute the length of the array, store in len */ - ARRAY_LENGTH(list, len); - - /* Construct the array */ - jlist = (*env)->NewObjectArray(env, len, ds_class, NULL); - if (jlist == NULL) { - /* exception thrown */ - dd_free_data_stores(list); - return (NULL); - } - - /* For each store, create an object and add it to the array */ - for (i = 0; i < len; ++i) { - - jstr = (*env)->NewStringUTF(env, list[i]); - if (jstr == NULL) { - /* exception thrown */ - break; - } - - datastore.d_conver = DSVC_CUR_CONVER; - datastore.d_resource = list[i]; - datastore.d_location = NULL; - avail = JNI_FALSE; - if (status_dd(&datastore) == DSVC_SUCCESS) { - avail = JNI_TRUE; - version = datastore.d_conver; - } - - jobj = (*env)->NewObject(env, ds_class, ds_cons, - jstr, version, avail); - if (jobj == NULL) { - /* exception thrown */ - break; - } - - (*env)->SetObjectArrayElement(env, jlist, i, jobj); - if ((*env)->ExceptionOccurred(env) != NULL) { - break; - } - } - - dd_free_data_stores(list); - return (jlist); -} - -/* - * Read the config file for DHCP and return its contents as a DhcpdOptions - * object. - */ -/*ARGSUSED*/ -JNIEXPORT jobject JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_readDefaults( - JNIEnv *env, - jobject obj) -{ - jclass cfg_class; - jmethodID cfg_cons; - jmethodID cfg_set; - jobject cfgobj = NULL; - dhcp_confopt_t *cfgs, *tcfgs; - - /* Make sure we have the classes & methods we need */ - cfg_class = find_class(env, CFG_CLASS); - if (cfg_class == NULL) { - /* exception thrown */ - return (NULL); - } - cfg_cons = get_methodID(env, cfg_class, CFG_CONS); - if (cfg_cons == NULL) { - /* exception thrown */ - return (NULL); - } - cfg_set = get_methodID(env, cfg_class, CFG_SET); - if (cfg_set == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Get the data */ - if (read_dsvc_conf(&cfgs) != 0) { - throw_bridge_exception(env, strerror(errno)); - } else { - /* Construct returned options object */ - cfgobj = (*env)->NewObject(env, cfg_class, cfg_cons); - if (cfgobj == NULL) { - /* exception thrown */ - free_dsvc_conf(cfgs); - return (NULL); - } - - /* Load the option settings into the options object */ - tcfgs = cfgs; - for (;;) { - if (cfgs->co_type == DHCP_COMMENT) { - (*env)->CallVoidMethod(env, cfgobj, cfg_set, - (*env)->NewStringUTF(env, cfgs->co_key), - (*env)->NewStringUTF(env, ""), JNI_TRUE); - } else { - if (cfgs->co_key == NULL) { - break; - } - (*env)->CallVoidMethod(env, cfgobj, cfg_set, - (*env)->NewStringUTF(env, cfgs->co_key), - (*env)->NewStringUTF(env, cfgs->co_value), - JNI_FALSE); - } - if ((*env)->ExceptionOccurred(env) != NULL) { - free_dsvc_conf(tcfgs); - return (NULL); - } - ++cfgs; - } - free_dsvc_conf(tcfgs); - } - return (cfgobj); -} - -/* - * Write the DHCP config file. Takes a DhcpdOptions object as input - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_writeDefaults( - JNIEnv *env, - jobject obj, - jobject jcfgs) -{ - jclass cfg_class; - jmethodID cfg_getall; - jclass res_class; - jmethodID res_getkey; - jmethodID res_getval; - jmethodID res_iscom; - jobjectArray resArray; - jsize reslen; - jobject jobj, resobj; - dhcp_confopt_t *cfgs; - int i; - jboolean comment; - const char *tmpstr; - - /* Make sure we can get at the classes we need */ - cfg_class = find_class(env, CFG_CLASS); - if (cfg_class == NULL) { - /* exception thrown */ - return; - } - cfg_getall = get_methodID(env, cfg_class, CFG_GETALL); - if (cfg_getall == NULL) { - /* exception thrown */ - return; - } - res_class = find_class(env, RES_CLASS); - if (res_class == NULL) { - /* exception thrown */ - return; - } - res_getkey = get_methodID(env, res_class, RES_GETKEY); - res_getval = get_methodID(env, res_class, RES_GETVAL); - res_iscom = get_methodID(env, res_class, RES_ISCOM); - if (res_getkey == NULL || res_getval == NULL || res_iscom == NULL) { - /* exception thrown */ - return; - } - - /* Get the resource array from the config object */ - resArray = (*env)->CallObjectMethod(env, jcfgs, cfg_getall); - if ((*env)->ExceptionOccurred(env) != NULL) { - return; - } - reslen = (*env)->GetArrayLength(env, resArray); - /* Allocate array to convert into; extra zero'd item to signal end */ - cfgs = calloc(reslen+1, sizeof (dhcp_confopt_t)); - if (cfgs == NULL) { - throw_memory_exception(env); - return; - } - - /* Now copy data into local array */ - for (i = 0; i < reslen; ++i) { - jobj = (*env)->GetObjectArrayElement(env, resArray, i); - if (jobj == NULL) { - /* exception thrown */ - free_dsvc_conf(cfgs); - return; - } - /* Set record type */ - comment = (*env)->CallBooleanMethod(env, jobj, res_iscom); - if ((*env)->ExceptionOccurred(env) != NULL) { - return; - } - if (comment == JNI_TRUE) { - cfgs[i].co_type = DHCP_COMMENT; - } else { - cfgs[i].co_type = DHCP_KEY; - } - /* - * Get the key from the object, convert to a char *, - * and then duplicate into the cfgs array so that - * free_dsvc_conf can be used correctly. - * Do the same thing for the value. - */ - resobj = (*env)->CallObjectMethod(env, jobj, res_getkey); - tmpstr = (*env)->GetStringUTFChars(env, resobj, NULL); - if (tmpstr == NULL) { - /* exception thrown */ - free_dsvc_conf(cfgs); - throw_bridge_exception(env, - gettext("Error converting key")); - return; - } - cfgs[i].co_key = strdup(tmpstr); - (*env)->ReleaseStringUTFChars(env, resobj, tmpstr); - if (cfgs[i].co_key == NULL) { - /* Out of memory, fail */ - free_dsvc_conf(cfgs); - throw_memory_exception(env); - return; - } - resobj = (*env)->CallObjectMethod(env, jobj, res_getval); - tmpstr = (*env)->GetStringUTFChars(env, resobj, NULL); - if (tmpstr == NULL) { - free_dsvc_conf(cfgs); - throw_bridge_exception(env, - gettext("Error converting value")); - return; - } - cfgs[i].co_value = strdup(tmpstr); - (*env)->ReleaseStringUTFChars(env, resobj, tmpstr); - if (cfgs[i].co_value == NULL) { - /* Out of memory, fail */ - free_dsvc_conf(cfgs); - throw_memory_exception(env); - return; - } - } - - /* Now write the new data */ - if (write_dsvc_conf(cfgs, CONFOPT_MODE) != 0) { - throw_bridge_exception(env, strerror(errno)); - } - free_dsvc_conf(cfgs); -} - -/* - * Remove the DHCP config file - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_removeDefaults( - JNIEnv *env, - jobject obj) -{ - if (delete_dsvc_conf() != 0) { - throw_bridge_exception(env, strerror(errno)); - } -} - -/* - * Start up the daemon. - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_startup( - JNIEnv *env, - jobject obj) -{ - char *s; - int ret; - - /* - * We first get the current state of the server according to - * svc.startd; if it's "disabled", we can just enable it. - * In any other case, we want to send a refresh so that - * dependencies are re-evaluated, which will be the case if the - * service was marked enabled by the profile, yet the - * config file didn't exist to allow it to run. - */ - if ((s = smf_get_state(DHCP_SERVER_INST)) != NULL) { - if (strcmp(SCF_STATE_STRING_DISABLED, s) == 0) - ret = smf_enable_instance(DHCP_SERVER_INST, 0); - else - ret = smf_refresh_instance(DHCP_SERVER_INST); - free(s); - if (ret == 0) - return; - } - - /* Something wasn't right, return exception with error from smf */ - throw_bridge_exception(env, scf_strerror(scf_error())); -} - -/* - * Shut down the daemon. - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_shutdown( - JNIEnv *env, - jobject obj) -{ - if (smf_disable_instance(DHCP_SERVER_INST, 0) != 0) { - throw_bridge_exception(env, scf_strerror(scf_error())); - } -} - -/* - * Tell the daemon to re-read the dhcptab. - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_reload( - JNIEnv *env, - jobject obj) -{ - int err; - - if ((err = dd_signal(DHCPD_FNAME, SIGHUP)) != 0) { - if (err == -1) { - /* dd_signal couldn't find in.dhcpd running */ - throw_not_running_exception(env); - } else { - throw_bridge_exception(env, strerror(err)); - } - } -} - -/* - * Make the resource location. - */ -/*ARGSUSED*/ -JNIEXPORT void JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_makeLocation( - JNIEnv *env, - jobject obj, - jobject jdatastore) -{ - dsvc_datastore_t datastore; - int rcode; - - /* Create a dsvc_datastore_t using args and DHCP config file */ - if (!dd_make_datastore_t(env, &datastore, jdatastore)) { - /* exception thrown */ - return; - } - - /* If the location does not already exist, go create it. */ - if (status_dd(&datastore) != DSVC_SUCCESS) { - rcode = mklocation_dd(&datastore); - if (rcode != DSVC_SUCCESS) { - throw_libdhcpsvc_exception(env, rcode); - } - } - - dd_free_datastore_t(&datastore); -} - -/* - * Check if the server is running; returns true if so, false if not. - */ -/*ARGSUSED*/ -JNIEXPORT jboolean JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_isServerRunning( - JNIEnv *env, - jobject obj) -{ - if (dd_getpid(DAEMON_FNAME) != (pid_t)-1) { - return (JNI_TRUE); - } else { - return (JNI_FALSE); - } -} - -/* - * Retrieve the list of interfaces on the system which are candidates for - * use by the DHCP daemon. Returns an array of IPInterface objects. - */ -/*ARGSUSED*/ -JNIEXPORT jobjectArray JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getInterfaces( - JNIEnv *env, - jobject obj) -{ - jclass ipif_class; - jmethodID ipif_cons; - jobjectArray jlist = NULL; - jobject jobj; - jsize len; - struct ip_interface **list; - int i; - - /* Locate the class and constructor we need */ - ipif_class = find_class(env, IPIF_CLASS); - if (ipif_class == NULL) { - /* exception thrown */ - return (NULL); - } - ipif_cons = get_methodID(env, ipif_class, IPIF_CONS); - if (ipif_cons == NULL) { - return (NULL); - } - - /* Retrieve interface list */ - list = dd_get_interfaces(); - if (list == NULL) { - throw_bridge_exception(env, - gettext("Error in dd_get_interfaces")); - return (NULL); - } - /* Compute length of list */ - ARRAY_LENGTH(list, len); - - /* Construct the array */ - jlist = (*env)->NewObjectArray(env, len, ipif_class, NULL); - if (jlist == NULL) { - /* exception thrown */ - for (i = 0; i < len; i++) { - free(list[i]); - } - free(list); - return (NULL); - } - - /* For each interface, construct an object and add to the array */ - for (i = 0; i < len; ++i) { - jobj = (*env)->NewObject(env, ipif_class, ipif_cons, - (*env)->NewStringUTF(env, list[i]->name), - (*env)->NewStringUTF(env, inet_ntoa(list[i]->addr)), - (*env)->NewStringUTF(env, inet_ntoa(list[i]->mask))); - - if (jobj == NULL) { - /* exception thrown */ - break; - } - - (*env)->SetObjectArrayElement(env, jlist, i, jobj); - if ((*env)->ExceptionOccurred(env) != NULL) { - break; - } - } - - for (i = 0; i < len; i++) { - free(list[i]); - } - free(list); - - return (jlist); -} - -/* - * Parse a line into arguments. - */ -/*ARGSUSED*/ -JNIEXPORT jobjectArray JNICALL -Java_com_sun_dhcpmgr_bridge_Bridge_getArguments( - JNIEnv *env, - jobject obj, - jstring jline) -{ - wordexp_t exp; - int flags = WRDE_NOCMD; - char *line; - jclass str_class; - jobjectArray jlist = NULL; - jstring jarg; - int i, ret; - - /* Go ahead and get the class for a String class */ - str_class = (*env)->GetObjectClass(env, jline); - if (str_class == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Retrieve the line argument */ - if (jline != NULL && - (line = dd_jstring_to_native(env, jline)) == NULL) { - /* exception thrown */ - return (NULL); - } - - /* Retrieve argument list */ - ret = wordexp(line, &exp, flags); - free(line); - if (ret != 0) { - throw_wordexp_exception(env, ret); - /* Free memory for the one error case where it's allocated */ - if (ret == WRDE_NOSPACE) - wordfree(&exp); - return (NULL); - } - - /* Construct the array */ - jlist = (*env)->NewObjectArray(env, exp.we_wordc, str_class, NULL); - if (jlist == NULL) { - /* exception thrown */ - wordfree(&exp); - return (NULL); - } - - /* For each argument, create an object and add it to the array */ - for (i = 0; i < exp.we_wordc; i++) { - jarg = dd_native_to_jstring(env, exp.we_wordv[i]); - if (jarg == NULL) { - /* exception thrown */ - break; - } - - (*env)->SetObjectArrayElement(env, jlist, i, jarg); - if ((*env)->ExceptionOccurred(env) != NULL) { - break; - } - } - - wordfree(&exp); - return (jlist); -} diff --git a/usr/src/cmd/cmd-inet/usr.sbin/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/Makefile index deb6016891..3c8672d154 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/Makefile +++ b/usr/src/cmd/cmd-inet/usr.sbin/Makefile @@ -25,12 +25,11 @@ # SYNCPROG= syncinit syncloop syncstat -DHCPPROG= dhcpconfig dhtadm pntadm PROG= 6to4relay arp if_mpadm \ in.comsat in.fingerd in.rarpd in.rexecd in.rlogind \ in.rshd in.rwhod in.telnetd in.tftpd ipaddrsel \ - ndd $(SYNCPROG) $(DHCPPROG) wanbootutil + ndd $(SYNCPROG) wanbootutil MANIFEST= rarp.xml telnet.xml comsat.xml finger.xml \ login.xml shell.xml rexec.xml socket-filter-kssl.xml diff --git a/usr/src/cmd/cmd-inet/usr.sbin/dhcpconfig.sh b/usr/src/cmd/cmd-inet/usr.sbin/dhcpconfig.sh deleted file mode 100644 index 2091831f1c..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sbin/dhcpconfig.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/pfsh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -exec /usr/lib/inet/dhcp/svcadm/dhcpconfig "$@" diff --git a/usr/src/cmd/cmd-inet/usr.sbin/dhtadm.sh b/usr/src/cmd/cmd-inet/usr.sbin/dhtadm.sh deleted file mode 100644 index 18f7a43d10..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sbin/dhtadm.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/pfsh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -exec /usr/lib/inet/dhcp/svcadm/dhtadm "$@" diff --git a/usr/src/cmd/cmd-inet/usr.sbin/pntadm.sh b/usr/src/cmd/cmd-inet/usr.sbin/pntadm.sh deleted file mode 100644 index 9ca8c16d28..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sbin/pntadm.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/pfsh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -exec /usr/lib/inet/dhcp/svcadm/pntadm "$@" diff --git a/usr/src/cmd/initpkg/init.d/Makefile b/usr/src/cmd/initpkg/init.d/Makefile index 98e1c89f2c..6eab9ec100 100644 --- a/usr/src/cmd/initpkg/init.d/Makefile +++ b/usr/src/cmd/initpkg/init.d/Makefile @@ -21,6 +21,7 @@ # # Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2014 Garrett D'Amore <garrett@damore.org> # include ../../Makefile.cmd @@ -32,7 +33,6 @@ PROG= \ README \ cachefs.daemon \ devlinks \ - dhcp \ drvconfig \ ldap.client \ nfs.server \ diff --git a/usr/src/cmd/initpkg/init.d/dhcp b/usr/src/cmd/initpkg/init.d/dhcp deleted file mode 100644 index 808f0c7fdb..0000000000 --- a/usr/src/cmd/initpkg/init.d/dhcp +++ /dev/null @@ -1,55 +0,0 @@ -#!/sbin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#ident "%Z%%M% %I% %E% SMI" - -# This service is managed by smf(5). Thus, this script provides -# compatibility with previously documented init.d script behaviour. - -FMRI=network/dhcp-server:default - -case "$1" in -'start') - [ -x /usr/lib/inet/in.dhcpd ] && [ -f /etc/inet/dhcpsvc.conf ] && { - eval `grep '^DAEMON_ENABLED=' /etc/inet/dhcpsvc.conf` - GO=`echo ${DAEMON_ENABLED} | /usr/bin/cut -c1` - if [ "${GO}" = "t" -o "${GO}" = "T" ]; then - /usr/sbin/svcadm enable -t $FMRI - fi - } - ;; - -'stop') - /usr/sbin/svcadm disable -t $FMRI - ;; - -*) - echo "Usage: $0 { start | stop }" - exit 1 - ;; -esac - -exit 0 diff --git a/usr/src/cmd/syseventd/modules/zfs_mod/zfs_mod.c b/usr/src/cmd/syseventd/modules/zfs_mod/zfs_mod.c index f05aeeabfa..8fff5c748a 100644 --- a/usr/src/cmd/syseventd/modules/zfs_mod/zfs_mod.c +++ b/usr/src/cmd/syseventd/modules/zfs_mod/zfs_mod.c @@ -21,7 +21,7 @@ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012 by Delphix. All rights reserved. - * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. */ /* @@ -152,6 +152,7 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t isdisk) vdev_state_t newstate; nvlist_t *nvroot, *newvd; uint64_t wholedisk = 0ULL; + uint64_t offline = 0ULL; char *physpath = NULL; char rawpath[PATH_MAX], fullpath[PATH_MAX]; size_t len; @@ -161,6 +162,7 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t isdisk) (void) nvlist_lookup_string(vdev, ZPOOL_CONFIG_PHYS_PATH, &physpath); (void) nvlist_lookup_uint64(vdev, ZPOOL_CONFIG_WHOLE_DISK, &wholedisk); + (void) nvlist_lookup_uint64(vdev, ZPOOL_CONFIG_OFFLINE, &offline); /* * We should have a way to online a device by guid. With the current @@ -174,9 +176,11 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t isdisk) * Attempt to online the device. It would be nice to online this by * GUID, but the current interface only supports lookup by path. */ - if (zpool_vdev_online(zhp, fullpath, + if (offline || + (zpool_vdev_online(zhp, fullpath, ZFS_ONLINE_CHECKREMOVE | ZFS_ONLINE_UNSPARE, &newstate) == 0 && - (newstate == VDEV_STATE_HEALTHY || newstate == VDEV_STATE_DEGRADED)) + (newstate == VDEV_STATE_HEALTHY || + newstate == VDEV_STATE_DEGRADED))) return; /* diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile index 4b365a670c..372fc4327c 100644 --- a/usr/src/lib/Makefile +++ b/usr/src/lib/Makefile @@ -24,6 +24,7 @@ # Copyright (c) 2012 by Delphix. All rights reserved. # Copyright (c) 2012, Joyent, Inc. All rights reserved. # Copyright (c) 2013 Gary Mills +# Copyright 2014 Garrett D'Amore <garrett@damore.org> include ../Makefile.master @@ -173,7 +174,6 @@ SUBDIRS += \ libvolmgt \ libdevice \ libdevid \ - libdhcpsvc \ libc_db \ libndmp \ libsec \ @@ -181,7 +181,6 @@ SUBDIRS += \ libtnf \ libtnfctl \ libdhcpagent \ - libdhcpdu \ libdhcputil \ libxnet \ libipsecutil \ @@ -312,7 +311,6 @@ MSGSUBDIRS= \ libcmd \ libcontract \ libcurses \ - libdhcpsvc \ libdhcputil \ libipsecutil \ libdiskmgt \ @@ -391,7 +389,6 @@ HDRSUBDIRS= \ libdll \ libdlpi \ libdhcpagent \ - libdhcpsvc \ libdhcputil \ libdisasm \ libdns_sd \ @@ -569,7 +566,6 @@ libcontract: libnvpair libdevid: libdevinfo libdevinfo: libnvpair libsec libdhcpagent: libsocket libdhcputil libuuid libdlpi libcontract -libdhcpsvc: libinetutil libdhcputil: libnsl libgen libinetutil libdlpi libdladm: libdevinfo libinetutil libsocket libscf librcm libnvpair \ libexacct libnsl libkstat libcurses diff --git a/usr/src/lib/libdhcpdu/Makefile b/usr/src/lib/libdhcpdu/Makefile deleted file mode 100644 index 3c16d641e3..0000000000 --- a/usr/src/lib/libdhcpdu/Makefile +++ /dev/null @@ -1,65 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2000 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpdu/%M% - -# include library definitions -include $(SRC)/lib/Makefile.lib - -SUBDIRS= $(MACH) - -# conditional assignments -all := TARGET= all -clean := TARGET= clean -clobber := TARGET= clobber -install := TARGET= install -lint := TARGET= lint -_msg := TARGET= _msg - - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -_msg: $(MSGDOMAIN) $(POFILE) - $(RM) $(MSGDOMAIN)/$(POFILE) - $(CP) $(POFILE) $(MSGDOMAIN) - -$(POFILE): $(POFILES) - $(RM) $@ - $(CAT) $(POFILES) > $@ - -$(POFILES): - $(RM) messages.po - $(XGETTEXT) $(XGETFLAGS) *.[ch]* - $(SED) -e '/^# msg/d' -e '/^domain/d' messages.po > $@ - $(RM) messages.po - -$(MACH): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/libdhcpdu/Makefile.com b/usr/src/lib/libdhcpdu/Makefile.com deleted file mode 100644 index cbab028471..0000000000 --- a/usr/src/lib/libdhcpdu/Makefile.com +++ /dev/null @@ -1,56 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -LIBRARY = rfc2136.a -VERS = .1 -OBJECTS = rfc2136.o - -include $(SRC)/lib/Makefile.lib - -LIBS = $(DYNLIB) -LDLIBS += -lnvpair -lresolv -lnsl -lc - -ROOTLIBDIR = $(ROOT)/usr/lib/inet/dhcp/nsu -SRCDIR = ../common - -# -# Since lint is not smart enough to grok `do { } while (0)' in macros, -# we're forced to turn off constant-in-conditional checks. -# -LINTFLAGS += -erroff=E_CONSTANT_CONDITION -CPPFLAGS += -D_REENTRANT -I../../libresolv2/include - -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += -_gcc=-Wno-uninitialized - -MAPFILES = ../common/mapfile - -.KEEP_STATE: - -all: $(LIBS) - -lint: lintcheck - -include $(SRC)/lib/Makefile.targ diff --git a/usr/src/lib/libdhcpdu/common/mapfile b/usr/src/lib/libdhcpdu/common/mapfile deleted file mode 100644 index c8ecabfab5..0000000000 --- a/usr/src/lib/libdhcpdu/common/mapfile +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -$mapfile_version 2 - -SYMBOL_VERSION SUNWprivate_1.1 { - global: - dns_puthostent; - local: - *; -}; diff --git a/usr/src/lib/libdhcpdu/common/rfc2136.c b/usr/src/lib/libdhcpdu/common/rfc2136.c deleted file mode 100644 index 2b4485063c..0000000000 --- a/usr/src/lib/libdhcpdu/common/rfc2136.c +++ /dev/null @@ -1,916 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <thread.h> -#include <stdlib.h> -#include <netdb.h> -#include <strings.h> -#include <alloca.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <arpa/nameser.h> -#include "res_update.h" -#include <stdio.h> -#include <errno.h> -#include <resolv.h> -#include <assert.h> -#include <stdarg.h> -#include <libnvpair.h> - -#define MAX_RETRIES 5 /* times to loop on TRY_AGAIN errors */ -#define LEASEMIN 3600 /* minimum lease time allowed by RFC 1531 */ - -static boolean_t getNS(char *, struct in_addr *); -static void cacheNS(char *, struct in_addr *, int); -static boolean_t lookupNS(char *, struct in_addr *); -static boolean_t send_update(struct hostent *, struct in_addr *); -static unsigned short parse_ushort(const char **); -static unsigned int parse_uint(const char **); -static void freeupdrecs(ns_updque); -static void freehost(struct hostent *); -static boolean_t delA(struct __res_state *, char *); -static boolean_t delPTR(struct __res_state *, char *, char *); -static boolean_t addA(struct __res_state *, char *, struct in_addr); -static boolean_t addPTR(struct __res_state *, char *, char *); -static boolean_t retry_update(struct __res_state *, ns_updrec *); - -extern char *inet_ntoa_r(struct in_addr, char *); - -/* - * The parent (calling) thread and the child thread it spawns to do an - * update use this structure to rendezvous. The child thread sets the - * ``done'' variable to B_TRUE when it's completed its work. The nusers - * variable lets us arbitrate to see who has to clean up (via the - * provided childstat_cleanup() function) the dynamically-allocated - * structure - last one to wake up loses, and has to do the work. - */ -struct childstat { - mutex_t m; - cond_t cv; - struct hostent *hp; - boolean_t synchflag; - boolean_t done; - int ret; - int nusers; -}; -static void childstat_cleanup(struct childstat *); - -static void update_thread(void *); - -/* - * The given environment variable, if present, will contain the name - * of a file (or the distinguished values "stdout" and "stderr") into - * which we should place the debugging output from this shared object. - * - * The debugging output is basically free-form but uses the dprint() - * function to ensure that each message is tagged with its thread ID, - * so we have some hope of sorting out later what actually happened. - */ -static char env_filetoken[] = "DHCP_DNS_OUTPUT"; -static void dprint(char *, ...); -static FILE *debug_fp; - -static boolean_t dns_config_ok; /* did res_ninit() work? */ - -static nvlist_t *nvl; - -/* CSTYLED */ -#pragma init (init) - -/* - * This is the shared object startup function, called once when we - * are dlopen()ed. - */ -static void -init(void) -{ - char *cp; - struct __res_state res; - - if (cp = getenv(env_filetoken)) { - if (strcmp(cp, "stdout") == 0) - debug_fp = stdout; - else if (strcmp(cp, "stderr") == 0) - debug_fp = stderr; - else { - debug_fp = fopen(cp, "a"); - } - if (debug_fp) - (void) setvbuf(debug_fp, NULL, _IOLBF, BUFSIZ); - } - - /* - * Use res_ninit(3RESOLV) to see whether DNS has been configured - * on the host running this code. In practice, life must be very - * bad for res_ninit() to fail. - */ - (void) memset(&res, 0, sizeof (res)); - if (res_ninit(&res) == -1) { - dprint("res_ninit() failed - dns_config_ok FALSE\n"); - dns_config_ok = B_FALSE; - } else { - dprint("res_ninit() succeeded\n"); - dns_config_ok = B_TRUE; - } - res_ndestroy(&res); -} - -/* - * This is the interface exported to the outside world. Control over - * the hostent structure is assumed to pass to dns_puthostent(); it will - * free the associated space when done. - */ -int -dns_puthostent(struct hostent *hp, time_t timeout) -{ - struct childstat *sp; - timestruc_t t; - int ret; - thread_t tid; - - - /* - * Check the consistency of the hostent structure: - * both the name and address fields should be valid, - * h_addrtype must be AF_INET, and h_length must be - * sizeof (struct in_addr); - */ - if (hp == NULL) { - dprint("hp is NULL - return -1\n"); - return (-1); - } - if (hp->h_addr_list == NULL) { - dprint("h_addr_list is NULL - return -1\n"); - freehost(hp); - return (-1); - } - if (hp->h_addr_list[0] == NULL) { - dprint("h_addr_list is zero-length - return -1\n"); - freehost(hp); - return (-1); - } - if (hp->h_name == NULL) { - dprint("h_name is NULL - return -1\n"); - freehost(hp); - return (-1); - } - if (hp->h_name[0] == '\0') { - dprint("h_name[0] is NUL - return -1\n"); - freehost(hp); - return (-1); - } - if (hp->h_addrtype != AF_INET) { - dprint("h_addrtype (%d) != AF_INET - return -1\n", - hp->h_addrtype); - freehost(hp); - return (-1); - } - if (hp->h_length != sizeof (struct in_addr)) { - dprint("h_length (%d) != sizeof (struct in_addr) - return -1\n", - hp->h_length); - freehost(hp); - return (-1); - } - - dprint("dns_puthostent(%s, %d)\n", hp->h_name, (int)timeout); - - if (dns_config_ok == B_FALSE) { - dprint("dns_config_ok FALSE - return -1\n"); - freehost(hp); - return (-1); - } - - if ((sp = malloc(sizeof (struct childstat))) == NULL) { - dprint("malloc (sizeof struct childstat) failed\n"); - freehost(hp); - return (-1); - } - - /* - * From this point on, both hp and sp are cleaned up and freed via - * childstat_cleanup(), with bookkeeping done to see whether the - * parent thread or the child one should be the one in charge of - * cleaning up. - */ - sp->hp = hp; - - if (timeout > 0) - sp->synchflag = B_TRUE; - else - sp->synchflag = B_FALSE; - sp->done = B_FALSE; - sp->ret = 0; - sp->nusers = 1; - (void) mutex_init(&sp->m, USYNC_THREAD, 0); - (void) cond_init(&sp->cv, USYNC_THREAD, 0); - (void) time(&t.tv_sec); - t.tv_sec += timeout; - t.tv_nsec = 0; - - if (thr_create(NULL, NULL, (void *(*)(void *))update_thread, - (void *) sp, THR_DAEMON|THR_DETACHED, &tid)) { - dprint("thr_create failed (errno %d) - return -1\n", errno); - childstat_cleanup(sp); - return (-1); - } - else - dprint("thread %u created\n", tid); - - if (!sp->done) { /* we might already have finished */ - (void) mutex_lock(&sp->m); - - /* if asynchronous, and child still working, just return; */ - if ((!sp->done) && (timeout == 0)) { - sp->nusers--; - (void) mutex_unlock(&sp->m); - dprint("done 0, timeout 0\n"); - return (0); - } - - /* otherwise, wait for child to finish or time to expire */ - while (!sp->done) - if (cond_timedwait(&sp->cv, &sp->m, &t) == ETIME) { - /* - * Child thread did not return before the - * timeout. One might think we could - * assert(sp->nusers > 1); - * here, but we can't: we must protect - * against this sequence of events: - * cond_timedwait() times out - * - * child finishes, grabs mutex, - * decrements nusers, sets done, - * and exits. - * - * cond_timedwait() reacquires the - * mutex and returns ETIME - * - * If this happens, nusers will now be 1, - * even though cond_timedwait() returned - * ETIME. - */ - if (sp->nusers == 1) - /* child must have also set done */ - break; - else - /* child thread has not returned */ - sp->nusers--; - (void) mutex_unlock(&sp->m); - dprint("update for %s timed out\n", hp->h_name); - return (0); - } - assert(sp->done); - ret = sp->ret; - } - - childstat_cleanup(sp); - return (ret); -} - -/* - * This worker thread, spawned by dns_puthostent(), is responsible for - * seeing that the update work gets done and cleaning up afterward - * if necessary. - */ -static void -update_thread(void *arg) -{ - char *p; - int num_updated = 0; - struct in_addr ia; - struct hostent *hp; - struct childstat *sp; - - dprint("update_thread running\n"); - - sp = (struct childstat *)arg; - - (void) mutex_lock(&sp->m); - /* - * Paranoia: if nusers was 0 and we were asked to do a - * synchronous update, our parent must have incremented - * it, called cond_timedwait(), timed out, and decremented it, - * all before we got this far. In this case, we do nothing - * except clean up and exit. - */ - if ((++sp->nusers == 1) && sp->synchflag) { - childstat_cleanup(sp); - thr_exit(0); - } - - (void) mutex_unlock(&sp->m); - - hp = sp->hp; - - /* - * h_name should be full-qualified; find the name servers for - * its domain ... - */ - for (p = hp->h_name; *p != NULL; p++) - if (*p == '.') { - if (getNS(++p, &ia)) { - char ntoab[INET_ADDRSTRLEN]; - - (void) inet_ntoa_r(ia, ntoab); - dprint("update for %s goes to %s\n", - hp->h_name, ntoab); - /* ... and send the update to one of them. */ - if (send_update(hp, &ia)) { - dprint("send_update succeeded\n"); - num_updated = 1; - } else { - dprint("send_update failed\n"); - num_updated = 0; - } - } else { - dprint("getNS failed\n"); - num_updated = -1; - } - break; - } - dprint("update for %s returning %d\n", hp->h_name, num_updated); - - (void) mutex_lock(&sp->m); - if (--sp->nusers == 0) { - /* parent timed out and abandoned us - our turn to clean up */ - childstat_cleanup(sp); - } else { - sp->done = B_TRUE; - sp->ret = num_updated; - (void) cond_signal(&sp->cv); - (void) mutex_unlock(&sp->m); - } - - thr_exit(0); -} - -/* - * Find a name server for the supplied domain and return its IP address. - * Sadly, in order to do this we have to parse the actual DNS reply - * packet - no functions are provided for doing this work for us. - */ -static boolean_t -getNS(char *domain, struct in_addr *iap) -{ - HEADER *hp; - union { - HEADER h; - char buf[NS_PACKETSZ]; - } abuf; - int alen; - int count; - int retries; - unsigned char name[MAXDNAME]; - int qdcount, ancount, nscount, arcount; - unsigned char *data; - unsigned char *m_bound; - int type, class, ttl, dlen; - struct hostent *ep; - unsigned char *NS_data; - boolean_t found_NS = B_FALSE; - struct __res_state res; - extern struct hostent *res_gethostbyname(const char *); - - if (lookupNS(domain, iap)) { - dprint("getNS: found cached IP address for domain %s\n", - domain); - return (B_TRUE); - } - (void) memset(&res, 0, sizeof (res)); - if (res_ninit(&res) == -1) { - dprint("getNS(\"%s\"): res_ninit failed\n", domain); - return (B_FALSE); - } - for (retries = 0; retries < MAX_RETRIES; retries++) { - alen = res_nquery(&res, domain, C_IN, T_NS, (uchar_t *)&abuf, - sizeof (abuf)); - - if (alen <= 0) { - /* - * Look for indicators from libresolv:res_nsend() - * that we should retry a request. - */ - if ((errno == ECONNREFUSED) || - ((h_errno == TRY_AGAIN) && (errno == ETIMEDOUT))) { - dprint("getNS retry: errno %d, h_errno %d\n", - errno, h_errno); - continue; - } else { - dprint("getNS(\"%s\"): res_nquery failed " - "(h_errno %d)\n", domain, h_errno); - res_ndestroy(&res); - return (B_FALSE); - } - } - } - if (alen <= 0) { - dprint("getNS(\"%s\"): res_nquery failed " "(h_errno %d)\n", - domain, h_errno); - res_ndestroy(&res); - return (B_FALSE); - } - - m_bound = ((unsigned char *)&abuf) + alen; - - hp = (HEADER *)&abuf; - data = (unsigned char *)&hp[1]; /* a DNS paradigm - actually abuf.buf */ - - qdcount = ntohs(hp->qdcount); - ancount = ntohs(hp->ancount); - nscount = ntohs(hp->nscount); - arcount = ntohs(hp->arcount); - - dprint("getNS(\"%s\"):\n", domain); - dprint("\tqdcount %d\n", qdcount); - dprint("\tancount %d\n", ancount); - dprint("\tnscount %d\n", nscount); - dprint("\tarcount %d\n", arcount); - - while (--qdcount >= 0) { - dlen = dn_skipname(data, m_bound); - if (dlen < 0) { - dprint("dn_skipname returned < 0\n"); - res_ndestroy(&res); - return (B_FALSE); - } - data += dlen + QFIXEDSZ; - } - - count = ancount; - count += arcount; - while (--count >= 0 && data < m_bound) { - if ((dlen = dn_expand((unsigned char *) &abuf, m_bound, - data, (char *)name, sizeof (name))) < 0) { - dprint("dn_expand() dom failed\n"); - res_ndestroy(&res); - return (B_FALSE); - } - data += dlen; - type = parse_ushort((const char **)&data); - class = parse_ushort((const char **)&data); - ttl = parse_uint((const char **)&data); - dlen = parse_ushort((const char **)&data); - - switch (type) { - case T_NS: - dprint("\ttype T_NS\n"); - break; - case T_CNAME: - dprint("\ttype T_CNAME\n"); - break; - case T_A: - dprint("\ttype T_A\n"); - break; - case T_SOA: - dprint("\ttype T_SOA\n"); - break; - case T_MX: - dprint("\ttype T_MX\n"); - break; - case T_TXT: - dprint("\ttype T_TXT\n"); - break; - default: - dprint("\ttype %d\n", type); - } - if (class == C_IN) - dprint("\tclass C_IN\n"); - else - dprint("\tclass %d\n", class); - dprint("\tttl %d secs\n", ttl); - dprint("\tlen %d bytes\n", dlen); - - switch (type) { - case T_A: - (void) memcpy(iap, data, sizeof (struct in_addr)); - cacheNS(domain, iap, ttl); - res_ndestroy(&res); - return (B_TRUE); - - case T_NS: - found_NS = B_TRUE; - NS_data = data; /* we may need this name below */ - if (dn_expand((unsigned char *) &abuf, m_bound, data, - (char *)name, sizeof (name)) < 0) { - dprint("\tdn_expand() T_NS failed\n"); - res_ndestroy(&res); - return (B_FALSE); - } - dprint("\tname %s\n", name); - break; - } - data += dlen; - } - dprint("getNS: fell through res_nquery results - no A records\n"); - - /* - * The reply contained NS records, but no A records. Use - * res_gethostbyname() to get the name server's address - * via DNS. - */ - if (found_NS) { - if (dn_expand((unsigned char *) &abuf, m_bound, NS_data, - (char *)name, sizeof (name)) < 0) { - dprint("\tdn_expand() T_NS failed\n"); - res_ndestroy(&res); - return (B_FALSE); - } - - if (ep = res_gethostbyname((const char *)name)) { - (void) memcpy(iap, ep->h_addr, sizeof (struct in_addr)); - cacheNS(domain, iap, ttl); - res_ndestroy(&res); - return (B_TRUE); - } else - dprint("getNS: res_gethostbyname(%s) failed\n", name); - } else { - dprint("getNS: reply contained no NS records\n"); - } - - res_ndestroy(&res); - return (B_FALSE); -} - -/* - * Cache the <domain, IP address> tuple (which is assumed to not already - * be cached) for ttl seconds. - */ -static void -cacheNS(char *domain, struct in_addr *iap, int ttl) -{ - if (ttl > 0) { - time_t now; - - if (nvl == NULL && - nvlist_alloc(&nvl, NV_UNIQUE_NAME_TYPE, 0) != 0) { - dprint("cacheNS: nvlist_alloc failed\n"); - return; - } - - (void) time(&now); - now += ttl; - if ((nvlist_add_int32(nvl, domain, iap->s_addr) != 0) || - (nvlist_add_byte_array(nvl, domain, (uchar_t *)&now, - sizeof (now)) != 0)) { - dprint("cacheNS: nvlist_add failed\n"); - nvlist_free(nvl); - nvl = NULL; - } - } else - dprint("cacheNS: ttl 0 - nothing to cache\n"); -} - -/* - * See whether the <domain, IP address> tuple has been cached. - */ -static boolean_t -lookupNS(char *domain, struct in_addr *iap) -{ - int32_t i; - - if (nvlist_lookup_int32(nvl, domain, &i) == 0) { - time_t *ttlptr; - uint_t nelem = sizeof (*ttlptr); - - if (nvlist_lookup_byte_array(nvl, domain, (uchar_t **)&ttlptr, - &nelem) != 0) - return (B_FALSE); - - if (*ttlptr >= time(0)) { /* still OK to use */ - iap->s_addr = i; - return (B_TRUE); - } else { - (void) nvlist_remove_all(nvl, domain); - } - } - - return (B_FALSE); -} - -/* - * Do the work of updating DNS to have the <hp->h_name <-> hp->h_addr> - * pairing. - */ -static boolean_t -send_update(struct hostent *hp, struct in_addr *to_server) -{ - char *forfqhost; - struct __res_state res; - struct in_addr netaddr; - char revnamebuf[MAXDNAME]; - - (void) memset(&res, 0, sizeof (res)); - if (res_ninit(&res) == -1) { - dprint("send_updated res_ninit failed!"); - return (B_FALSE); - } - res.nscount = 1; - res.nsaddr.sin_family = AF_INET; - res.nsaddr.sin_port = htons(NAMESERVER_PORT); - res.nsaddr.sin_addr.s_addr = to_server->s_addr; - - /* If debugging output desired, then ask resolver to do it, too */ - if (debug_fp != NULL) - res.options |= RES_DEBUG; - - if (strchr(hp->h_name, '.') == NULL) { - dprint("send_update handed non-FQDN: %s\n", hp->h_name); - res_ndestroy(&res); - return (B_FALSE); - } - forfqhost = hp->h_name; - - /* Construct the fully-qualified name for PTR record updates */ - /* LINTED - alignment */ - netaddr.s_addr = ((struct in_addr *)hp->h_addr)->s_addr; - (void) snprintf(revnamebuf, sizeof (revnamebuf), - "%u.%u.%u.%u.in-addr.ARPA", - netaddr.S_un.S_un_b.s_b4, netaddr.S_un.S_un_b.s_b3, - netaddr.S_un.S_un_b.s_b2, netaddr.S_un.S_un_b.s_b1); - dprint("send_update %s: revname %s\n", hp->h_name, revnamebuf); - - /* - * The steps in doing an update: - * - delete any A records - * - delete any PTR records - * - add an A record - * - add a PTR record - */ - - if (!delA(&res, forfqhost) || - !delPTR(&res, forfqhost, revnamebuf) || - !addA(&res, forfqhost, netaddr) || - !addPTR(&res, forfqhost, revnamebuf)) { - res_ndestroy(&res); - return (B_FALSE); - } - res_ndestroy(&res); - return (B_TRUE); -} - -/* delete A records for this fully-qualified name */ -static boolean_t -delA(struct __res_state *resp, char *fqdn) -{ - ns_updque q; - ns_updrec *updreqp; - - INIT_LIST(q); - updreqp = res_mkupdrec(S_UPDATE, fqdn, C_IN, T_A, 0); - if (updreqp == NULL) { - dprint("res_mkupdrec (del A) failed\n"); - return (B_FALSE); - } - updreqp->r_opcode = DELETE; - updreqp->r_data = NULL; - updreqp->r_size = 0; - APPEND(q, updreqp, r_link); - if (retry_update(resp, HEAD(q)) != 1) { - dprint("res_nupdate (del A) failed - errno %d, h_errno %d\n", - errno, h_errno); - freeupdrecs(q); - return (B_FALSE); - } - freeupdrecs(q); - return (B_TRUE); -} - -/* delete PTR records for this address */ -static boolean_t -delPTR(struct __res_state *resp, char *fqdn, char *revname) -{ - ns_updque q; - ns_updrec *updreqp; - - INIT_LIST(q); - updreqp = res_mkupdrec(S_UPDATE, revname, C_IN, T_PTR, 0); - if (updreqp == NULL) { - dprint("res_mkupdrec (del PTR) failed\n"); - return (B_FALSE); - } - updreqp->r_opcode = DELETE; - updreqp->r_data = (unsigned char *)fqdn; - updreqp->r_size = strlen(fqdn); - APPEND(q, updreqp, r_link); - if (retry_update(resp, HEAD(q)) != 1) { - dprint("res_nupdate (del PTR) failed - errno %d, h_errno %d\n", - errno, h_errno); - freeupdrecs(q); - return (B_FALSE); - } - freeupdrecs(q); - return (B_TRUE); -} - -/* add an A record for this fqdn <-> addr pair */ -static boolean_t -addA(struct __res_state *resp, char *fqdn, struct in_addr na) -{ - ns_updque q; - ns_updrec *prereqp, *updreqp; - int ttl = LEASEMIN; - char ntoab[INET_ADDRSTRLEN]; - - INIT_LIST(q); - prereqp = res_mkupdrec(S_PREREQ, fqdn, C_IN, T_A, 0); - if (prereqp == NULL) { - dprint("res_mkupdrec (add A PREREQ) failed\n"); - return (B_FALSE); - } - prereqp->r_opcode = NXRRSET; - prereqp->r_data = NULL; - prereqp->r_size = 0; - APPEND(q, prereqp, r_link); - updreqp = res_mkupdrec(S_UPDATE, fqdn, C_IN, T_A, ttl); - if (updreqp == NULL) { - dprint("res_mkupdrec (add A UPDATE) failed\n"); - freeupdrecs(q); - return (B_FALSE); - } - - (void) inet_ntoa_r(na, ntoab); - updreqp->r_opcode = ADD; - updreqp->r_data = (unsigned char *)ntoab; - updreqp->r_size = strlen(ntoab); - APPEND(q, updreqp, r_link); - if (retry_update(resp, HEAD(q)) != 1) { - dprint("res_nupdate (ADD A) failed - errno %d, h_errno %d\n", - errno, h_errno); - freeupdrecs(q); - return (B_FALSE); - } - freeupdrecs(q); - return (B_TRUE); -} - -/* add a PTR record for this fqdn <-> address pair */ -static boolean_t -addPTR(struct __res_state *resp, char *fqdn, char *revname) -{ - ns_updque q; - ns_updrec *prereqp, *updreqp; - int ttl = LEASEMIN; - - INIT_LIST(q); - prereqp = res_mkupdrec(S_UPDATE, revname, C_IN, T_PTR, 0); - if (prereqp == NULL) { - dprint("res_mkupdrec (add PTR DELETE) failed\n"); - return (B_FALSE); - } - prereqp->r_opcode = DELETE; - prereqp->r_data = NULL; - prereqp->r_size = 0; - APPEND(q, prereqp, r_link); - updreqp = res_mkupdrec(S_UPDATE, revname, C_IN, T_PTR, ttl); - if (updreqp == NULL) { - dprint("res_mkupdrec (add PTR ADD) failed\n"); - freeupdrecs(q); - return (B_FALSE); - } - updreqp->r_opcode = ADD; - updreqp->r_data = (unsigned char *)fqdn; - updreqp->r_size = strlen(fqdn); - APPEND(q, updreqp, r_link); - if (retry_update(resp, HEAD(q)) != 1) { - dprint("res_nupdate (ADD PTR) failed - errno %d, h_errno %d\n", - errno, h_errno); - freeupdrecs(q); - return (B_FALSE); - } - freeupdrecs(q); - - return (B_TRUE); -} - -/* retry an update request when appropriate */ -static boolean_t -retry_update(struct __res_state *resp, ns_updrec *h) -{ - int retries; - - for (retries = 0; retries < MAX_RETRIES; retries++) - if (res_nupdate(resp, h, NULL) == 1) { - return (B_TRUE); - } else { - /* - * Look for indicators from libresolv:res_nsend() - * that we should retry a request. - */ - if ((errno == ECONNREFUSED) || - ((h_errno == TRY_AGAIN) && (errno == ETIMEDOUT))) { - dprint("retry_update - errno %d, h_errno %d\n", - errno, h_errno); - continue; - } else - return (B_FALSE); - } - - return (B_FALSE); -} - -static void -freeupdrecs(ns_updque q) -{ - while (!EMPTY(q)) { - ns_updrec *tmp; - - tmp = HEAD(q); - UNLINK(q, tmp, r_link); - res_freeupdrec(tmp); - } -} - -/* - * Parse a 16-bit quantity from a DNS reply packet. - */ -static unsigned short -parse_ushort(const char **pp) -{ - const uchar_t *p = (const uchar_t *)*pp; - unsigned short val; - - val = (p[0] << 8) | p[1]; - *pp += 2; - return (val); -} - - -/* - * Parse a 32-bit quantity from a DNS reply packet. - */ -static unsigned int -parse_uint(const char **pp) -{ - const uchar_t *p = (const uchar_t *)*pp; - unsigned int val; - - val = ((uint_t)p[0] << 24) | ((uint_t)p[1] << 16) | - ((uint_t)p[2] << 8) | (uint_t)p[3]; - *pp += 4; - return (val); -} - -/* - * Clean up a childstat structure's synchronization variables and free - * the allocated memory. - */ -static void -childstat_cleanup(struct childstat *sp) -{ - (void) cond_destroy(&sp->cv); - (void) mutex_destroy(&sp->m); - freehost(sp->hp); - free(sp); -} - -/* - * Format and print a debug message, prepending the thread ID of the - * thread logging the message. - */ -/* PRINTFLIKE1 */ -static void -dprint(char *format, ...) -{ - va_list ap; - - va_start(ap, format); - if (debug_fp) { - (void) fprintf(debug_fp, "%u: ", thr_self()); - (void) vfprintf(debug_fp, format, ap); - va_end(ap); - } -} - -static void -freehost(struct hostent *hp) -{ - free(hp->h_addr); - free(hp->h_addr_list); - free(hp->h_name); - free(hp); -} diff --git a/usr/src/lib/libdhcpdu/i386/Makefile b/usr/src/lib/libdhcpdu/i386/Makefile deleted file mode 100644 index cd83f517b1..0000000000 --- a/usr/src/lib/libdhcpdu/i386/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include ../Makefile.com - -install: all $(ROOTLIBS) diff --git a/usr/src/lib/libdhcpdu/inc.flg b/usr/src/lib/libdhcpdu/inc.flg deleted file mode 100644 index dfc3b66ca4..0000000000 --- a/usr/src/lib/libdhcpdu/inc.flg +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -find_files "s.*" usr/src/lib/libresolv2/include diff --git a/usr/src/lib/libdhcpdu/sparc/Makefile b/usr/src/lib/libdhcpdu/sparc/Makefile deleted file mode 100644 index 8ebe3056c0..0000000000 --- a/usr/src/lib/libdhcpdu/sparc/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpdu/sparc/%M% - -include ../Makefile.com - -install: all $(ROOTLIBS) diff --git a/usr/src/lib/libdhcpsvc/Makefile b/usr/src/lib/libdhcpsvc/Makefile deleted file mode 100644 index 738d261ac3..0000000000 --- a/usr/src/lib/libdhcpsvc/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2000 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/Makefile -# - -SUBDIRS = head private modules -include Makefile.subdirs - -_msg: - @cd private; pwd; $(MAKE) _msg - -check install_h: - @cd head; pwd; $(MAKE) $@ diff --git a/usr/src/lib/libdhcpsvc/Makefile.com b/usr/src/lib/libdhcpsvc/Makefile.com deleted file mode 100644 index 30ba2e8b04..0000000000 --- a/usr/src/lib/libdhcpsvc/Makefile.com +++ /dev/null @@ -1,32 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -include $(SRC)/lib/Makefile.lib - -COMDIR = $(SRC)/common/net/dhcp - -CPPFLAGS += -I$(SRC)/lib/libdhcpsvc/head -D_REENTRANT - -CERRWARN += -_gcc=-Wno-uninitialized diff --git a/usr/src/lib/libdhcpsvc/Makefile.subdirs b/usr/src/lib/libdhcpsvc/Makefile.subdirs deleted file mode 100644 index 182f89afae..0000000000 --- a/usr/src/lib/libdhcpsvc/Makefile.subdirs +++ /dev/null @@ -1,44 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2000 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/Makefile.subdirs -# - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/libdhcpsvc/Makefile.targ b/usr/src/lib/libdhcpsvc/Makefile.targ deleted file mode 100644 index 761b704953..0000000000 --- a/usr/src/lib/libdhcpsvc/Makefile.targ +++ /dev/null @@ -1,33 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2000-2001 by Sun Microsystems, Inc. -# All rights reserved. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include $(SRC)/lib/Makefile.targ - -pics/%.o: $(COMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) diff --git a/usr/src/lib/libdhcpsvc/head/Makefile b/usr/src/lib/libdhcpsvc/head/Makefile deleted file mode 100644 index d2b1288c77..0000000000 --- a/usr/src/lib/libdhcpsvc/head/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include ../Makefile.com - -HDRS = dhcp_svc_confopt.h dhcp_svc_confkey.h dhcp_svc_private.h \ - dhcp_svc_public.h -HDRDIR = . -CLEANFILES = dhcp_svc_confkey.h - -.SUFFIXES: .m4 $(SUFFIXES) -.KEEP_STATE: - -all install lint: - @$(ECHO) "Nothing to $@" - -install_h: $(ROOTHDRS) - -check: $(CHECKHDRS) - -dhcp_svc_confkey.check: dhcp_svc_confkey.h - -.m4.h: - $(M4) $< > $@ - -include ../Makefile.targ diff --git a/usr/src/lib/libdhcpsvc/head/dhcp_svc_confkey.m4 b/usr/src/lib/libdhcpsvc/head/dhcp_svc_confkey.m4 deleted file mode 100644 index 55b649c206..0000000000 --- a/usr/src/lib/libdhcpsvc/head/dhcp_svc_confkey.m4 +++ /dev/null @@ -1,122 +0,0 @@ -divert(-1) -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -#ident "%Z%%M% %I% %E% SMI" -# -# Select the appropriate type of output format based on whether -Djava is set -# on the command line -ifdef(`java', `define(defdef, ` public static final String $1 = "$1";')', `define(defdef, `defint($1,"$1")')') -ifdef(`java', `define(defstr, ` public static final String $1 = $2;')', `define(defstr, `defint($1,$2)')') -ifdef(`java', `define(defint, ` public static final int $1 = $2;')', `define(defint, `#define $1 $2')') -# End of opening definitions; everything after next line is going in the output -divert(0)dnl -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - * This include file is generated from a m4 source file. Do not - * modify this file. - */ - -ifdef(`java', `package com.sun.dhcpmgr.data; -', `#ifndef _DHCP_SVC_CONFKEY_H -#define _DHCP_SVC_CONFKEY_H - -#pragma ident "%Z'`%%'`M% %'`I% %'`E% SMI"') -ifdef(`java', `/** - * DHCP server configuration parameters. - */ -public interface DhcpConfigOpts {', ` -#ifdef __cplusplus') -ifdef(`java', `dnl', extern "C" {) -ifdef(`java', `dnl', `#endif -') -/* Definitions for valid config file parameters */ -defstr(DSVC_CK_DAEMON_ENABLED, "DAEMON_ENABLED") -defstr(DSVC_CK_RUN_MODE, "RUN_MODE") -defstr(DSVC_CK_VERBOSE, "VERBOSE") -defstr(DSVC_CK_RELAY_HOPS, "RELAY_HOPS") -defstr(DSVC_CK_INTERFACES, "INTERFACES") -defstr(DSVC_CK_ICMP_VERIFY, "ICMP_VERIFY") -defstr(DSVC_CK_OFFER_CACHE_TIMEOUT, "OFFER_CACHE_TIMEOUT") -defstr(DSVC_CK_RESCAN_INTERVAL, "RESCAN_INTERVAL") -defstr(DSVC_CK_LOGGING_FACILITY, "LOGGING_FACILITY") -defstr(DSVC_CK_BOOTP_COMPAT, "BOOTP_COMPAT") -defstr(DSVC_CK_RELAY_DESTINATIONS, "RELAY_DESTINATIONS") -defstr(DSVC_CK_RESOURCE, "RESOURCE") -defstr(DSVC_CK_RESOURCE_CONFIG, "RESOURCE_CONFIG") -defstr(DSVC_CK_NSU_TIMEOUT, "UPDATE_TIMEOUT") -defstr(DSVC_CK_PATH, "PATH") -defstr(DSVC_CK_CONVER, "CONVER") -defstr(DSVC_CK_HOSTS_RESOURCE, "HOSTS_RESOURCE") -defstr(DSVC_CK_HOSTS_DOMAIN, "HOSTS_DOMAIN") -defstr(DSVC_CK_MAX_THREADS, "MAX_THREADS") -defstr(DSVC_CK_MAX_CLIENTS, "MAX_CLIENTS") -defstr(DSVC_CK_LEASE_MIN_LRU, "LEASE_MIN_LRU") -defstr(DSVC_CK_CACHE_TIMEOUT, "CACHE_TIMEOUT") -defstr(DSVC_CK_RENOG_INTERVAL, "SECONDARY_SERVER_TIMEOUT") -defstr(DSVC_CK_OWNER_IP, "OWNER_IP") - -/* Definitions for DEBUG config file parameters */ -defstr(DSVC_CK_DBG_PORT_OFFSET, "DEBUG_PORT_OFFSET") -defstr(DSVC_CK_DBG_MEMORY_NET, "DEBUG_MEMORY_NET") - -/* Definitions for valid HOSTS_RESOURCE settings */ -defstr(DSVC_CV_NISPLUS, "nisplus") -defstr(DSVC_CV_FILES, "files") -defstr(DSVC_CV_DNS, "dns") - -/* Definitions for valid BOOTP_COMPAT settings */ -defstr(DSVC_CV_AUTOMATIC, "automatic") -defstr(DSVC_CV_MANUAL, "manual") - -/* Definitions for valid LOGGING_FACILITY settings */ -defint(DSVC_CV_LOGGING_FACILITY_MIN, 0) -defint(DSVC_CV_LOGGING_FACILITY_MAX, 7) - -/* Definitions for valid RUN_MODE settings */ -defstr(DSVC_CV_RELAY, "relay") -defstr(DSVC_CV_SERVER, "server") - -/* Definitions for valid boolean values */ -defstr(DSVC_CV_TRUE, "TRUE") -defstr(DSVC_CV_FALSE, "FALSE") - -/* Definitions for server config for unspecified options */ -defint(DSVC_CV_HOPS, 4) -defint(DSVC_CV_OFFER_TTL, 10) -defint(DSVC_CV_CACHE_TTL, 10) -defint(DSVC_CV_NSU_TO, 15) -defint(DSVC_CV_MIN_LRU, 60) -defint(DSVC_CV_RENOG_INT, 20) - -/* Definitions for server config for DEBUG options */ -defint(DSVC_CV_DBG_PORT_OFFSET, 0) -ifdef(`java', `dnl', ` -#ifdef __cplusplus') -} -ifdef(`java', `dnl', `#endif -') -ifdef(`java', `dnl', `#endif /* !_DHCP_SVC_CONFKEY_H */') diff --git a/usr/src/lib/libdhcpsvc/head/dhcp_svc_confopt.h b/usr/src/lib/libdhcpsvc/head/dhcp_svc_confopt.h deleted file mode 100644 index 7dd76ea70c..0000000000 --- a/usr/src/lib/libdhcpsvc/head/dhcp_svc_confopt.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _DHCP_SVC_CONFOPT_H -#define _DHCP_SVC_CONFOPT_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Contains SMI-private interfaces to /etc/inet/dhcpsvc.conf file. DO NOT SHIP! - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/types.h> - -#define DHCP_CONFOPT_FILE "/etc/inet/dhcpsvc.conf" - -enum dhcp_confopt { - DHCP_END, /* final entry, must be 0 */ - DHCP_KEY, /* key / value form */ - DHCP_COMMENT /* comment form */ -}; - -/* - * Records in the /etc/inet/dhcpsvc.conf file are of key=value form. Comments - * begin a line with '#', and end with newline (\n). See dhcpsvc(4) for more - * details. This structure is used to represent them within a program. - */ - -typedef struct { - enum dhcp_confopt co_type; - char *co_key; /* identifier */ - char *co_value; /* data */ -} dhcp_confopt_t; -#define co_comment co_key /* key doubles as comment */ - -extern int add_dsvc_conf(dhcp_confopt_t **, const char *, const char *); -extern int read_dsvc_conf(dhcp_confopt_t **); -extern int replace_dsvc_conf(dhcp_confopt_t **, const char *, - const char *); -extern int write_dsvc_conf(dhcp_confopt_t *, mode_t); -extern void free_dsvc_conf(dhcp_confopt_t *); -extern int delete_dsvc_conf(void); -extern int query_dsvc_conf(dhcp_confopt_t *, const char *, char **); - -#ifdef __cplusplus -} -#endif - -#endif /* !_DHCP_SVC_CONFOPT_H */ diff --git a/usr/src/lib/libdhcpsvc/head/dhcp_svc_private.h b/usr/src/lib/libdhcpsvc/head/dhcp_svc_private.h deleted file mode 100644 index 1a3555e367..0000000000 --- a/usr/src/lib/libdhcpsvc/head/dhcp_svc_private.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _DHCP_SVC_PRIVATE_H -#define _DHCP_SVC_PRIVATE_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Contains SMI-private interfaces to DHCP data service. DO NOT SHIP! - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/types.h> -#include <stddef.h> -#include <dhcp_svc_confopt.h> -#include <dhcp_svc_public.h> - -#define DSVC_PRIVATE_VERSION 1 /* Version of private layer API */ -#define DSVC_MODULE_DIR "/usr/lib/inet/dhcp/svc" -#define DSVC_PUBLIC_PREFIX "ds" - -/* - * Public (service provider) layer definitions at boundary with private layer. - */ -typedef int (*dsvc_splfuncp_t)(); - -typedef struct { - dsvc_splfuncp_t status; - dsvc_splfuncp_t version; - dsvc_splfuncp_t mklocation; - dsvc_splfuncp_t list_dt; - dsvc_splfuncp_t open_dt; - dsvc_splfuncp_t close_dt; - dsvc_splfuncp_t remove_dt; - dsvc_splfuncp_t lookup_dt; - dsvc_splfuncp_t add_dt; - dsvc_splfuncp_t modify_dt; - dsvc_splfuncp_t delete_dt; - dsvc_splfuncp_t list_dn; - dsvc_splfuncp_t open_dn; - dsvc_splfuncp_t close_dn; - dsvc_splfuncp_t remove_dn; - dsvc_splfuncp_t lookup_dn; - dsvc_splfuncp_t add_dn; - dsvc_splfuncp_t modify_dn; - dsvc_splfuncp_t delete_dn; -} dsvc_splapi_t; - -#define DSVC_NSPLFUNCS (sizeof (dsvc_splapi_t) / sizeof (dsvc_splfuncp_t)) -#define DSVC_CUR_CONVER (-1) /* magic "get the current version" token */ - -typedef struct { - char *d_resource; /* datastore name; e.g. "SUNWfiles" */ - char *d_location; /* location of datastore containers */ - char *d_config; /* datastore-specific config data */ - int d_conver; /* container version */ -} dsvc_datastore_t; - -/* - * Container types. - */ -typedef enum { - DSVC_DHCPTAB, - DSVC_DHCPNETWORK -} dsvc_contype_t; - -/* - * Container ID: so far just the network and netmask for DSVC_DHCPNETWORK - * containers, but may include more information in the future. - */ -typedef struct { - struct in_addr c_net; /* network number */ - struct in_addr c_mask; /* netmask */ -} dsvc_conid_t; - -struct dsvc_synch_ops; /* forward declaration */ - -/* - * Per-handle synchronization information, used when modules require - * private-layer synchronization. - */ -typedef struct { - dsvc_datastore_t *s_datastore; /* datastore backpointer */ - char s_loctoken[MAXPATHLEN]; - char *s_conname; /* container name */ - boolean_t s_nonblock; /* container opened NONBLOCK */ - struct dsvc_synch_ops *s_ops; /* pointer to ops vector */ - void *s_data; /* synch-layer private data */ -} dsvc_synch_t; - -/* - * Synchronization operations; each synchronization strategy must implement - * these operations. Right now, we only have one synchronization strategy, - * but this may change someday. - */ -typedef struct dsvc_synch_ops { - int (*synch_init)(dsvc_synch_t *, unsigned int); - void (*synch_fini)(dsvc_synch_t *); - int (*synch_rdlock)(dsvc_synch_t *, void **); - int (*synch_wrlock)(dsvc_synch_t *, void **); - int (*synch_unlock)(dsvc_synch_t *, void *); -} dsvc_synch_ops_t; - -#define DSVC_SYNCH_INIT(sp, flags) ((sp)->s_ops->synch_init((sp), (flags))) -#define DSVC_SYNCH_FINI(sp) ((sp)->s_ops->synch_fini((sp))) -#define DSVC_SYNCH_RDLOCK(sp, cp) ((sp)->s_ops->synch_rdlock((sp), (cp))) -#define DSVC_SYNCH_WRLOCK(sp, cp) ((sp)->s_ops->synch_wrlock((sp), (cp))) -#define DSVC_SYNCH_UNLOCK(sp, c) ((sp)->s_ops->synch_unlock((sp), (c))) - -/* - * We divide the dsvc_synchtype_t up into two parts: a strategy part and a - * flags part. Right now, the only flag tells private layer to request - * cross-host synchronization. This is here instead of <dhcp_svc_public.h> - * since it's not a public interface and there's nowhere better to put it. - */ -#define DSVC_SYNCH_FLAGMASK 0xffff0000 -#define DSVC_SYNCH_STRATMASK 0x0000ffff -#define DSVC_SYNCH_CROSSHOST 0x00010000 - -/* - * Private layer handle, one per open instance of a container. - * Allocated by open_dd(), destroyed by close_dd(). - */ -typedef struct dsvc_handle { - dsvc_datastore_t d_desc; /* datastore descriptor */ - void *d_instance; /* dlopen() instance */ - dsvc_contype_t d_type; /* container type */ - dsvc_conid_t d_conid; /* container id */ - void *d_hand; /* public module handle */ - dsvc_synch_t *d_synch; /* synchronization state */ - dsvc_splapi_t d_api; /* service provider layer API */ -} *dsvc_handle_t; - -/* - * Quick-n-dirty check for an invalid dsvc_handle_t. - */ -#define DSVC_HANDLE_INVAL(h) ((h) == NULL || (h)->d_instance == NULL || \ - (h)->d_hand == NULL) - -extern int enumerate_dd(char ***, int *); -extern int list_dd(dsvc_datastore_t *, dsvc_contype_t, char ***, uint_t *); -extern int status_dd(dsvc_datastore_t *); -extern int mklocation_dd(dsvc_datastore_t *); -extern int add_dd_entry(dsvc_handle_t, void *); -extern int modify_dd_entry(dsvc_handle_t, const void *, void *); -extern int delete_dd_entry(dsvc_handle_t, void *); -extern int close_dd(dsvc_handle_t *); -extern int remove_dd(dsvc_datastore_t *, dsvc_contype_t, const char *); -extern int open_dd(dsvc_handle_t *, dsvc_datastore_t *, dsvc_contype_t, - const char *, uint_t); -extern int lookup_dd(dsvc_handle_t, boolean_t, uint_t, int, const void *, - void **, uint_t *); -extern void free_dd(dsvc_handle_t, void *); -extern void free_dd_list(dsvc_handle_t, void *); -extern int confopt_to_datastore(dhcp_confopt_t *, dsvc_datastore_t *); -extern int module_synchtype(dsvc_datastore_t *, dsvc_synchtype_t *); - -/* - * Under DEBUG, the DHCP_CONFOPT_ROOT environment variable can be set to - * the path of a directory for the DHCP server to use an alternate root - * for its configuration information and datastores. - */ -#ifdef DEBUG -#define DHCP_CONFOPT_ROOT ((getenv("DHCP_CONFOPT_ROOT") != NULL) ? \ - getenv("DHCP_CONFOPT_ROOT") : "") -#else -#define DHCP_CONFOPT_ROOT "" -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* !_DHCP_SVC_PRIVATE_H */ diff --git a/usr/src/lib/libdhcpsvc/head/dhcp_svc_public.h b/usr/src/lib/libdhcpsvc/head/dhcp_svc_public.h deleted file mode 100644 index 315fe38809..0000000000 --- a/usr/src/lib/libdhcpsvc/head/dhcp_svc_public.h +++ /dev/null @@ -1,261 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _DHCP_SVC_PUBLIC_H -#define _DHCP_SVC_PUBLIC_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Contains published interfaces to the DHCP data service. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/types.h> -#include <netinet/in.h> /* struct in_addr */ -#include <netinet/dhcp.h> - -#define DSVC_PUBLIC_VERSION 1 /* version of public layer interface */ - -/* - * Errors which can be returned from the defined API - * Note: must be kept in sync with errmsgs[] in private/errmsgs.c. - */ -#define DSVC_SUCCESS 0 /* success */ -#define DSVC_EXISTS 1 /* object already exists */ -#define DSVC_ACCESS 2 /* access denied */ -#define DSVC_NO_CRED 3 /* no underlying credential */ -#define DSVC_NOENT 4 /* object doesn't exist */ -#define DSVC_BUSY 5 /* object temporarily busy (again) */ -#define DSVC_INVAL 6 /* invalid argument(s) */ -#define DSVC_INTERNAL 7 /* internal data store error */ -#define DSVC_UNAVAILABLE 8 /* underlying service required by */ - /* public module unavailable */ -#define DSVC_COLLISION 9 /* update collision */ -#define DSVC_UNSUPPORTED 10 /* operation not supported */ -#define DSVC_NO_MEMORY 11 /* operation ran out of memory */ -#define DSVC_NO_RESOURCES 12 /* non-memory resources unavailable */ -#define DSVC_BAD_RESOURCE 13 /* malformed/missing RESOURCE setting */ -#define DSVC_BAD_PATH 14 /* malformed/missing PATH setting */ -#define DSVC_MODULE_VERSION 15 /* public layer version mismatch */ -#define DSVC_MODULE_ERR 16 /* internal public module error */ -#define DSVC_MODULE_LOAD_ERR 17 /* error loading public module */ -#define DSVC_MODULE_UNLOAD_ERR 18 /* error unloading public module */ -#define DSVC_MODULE_CFG_ERR 19 /* Module configuration failure */ -#define DSVC_SYNCH_ERR 20 /* error in synchronization protocol */ -#define DSVC_NO_LOCKMGR 21 /* cannot contact lock manager */ -#define DSVC_NO_LOCATION 22 /* location nonexistent */ -#define DSVC_BAD_CONVER 23 /* malformed/missing CONVER setting */ -#define DSVC_NO_TABLE 24 /* container does not exist */ -#define DSVC_TABLE_EXISTS 25 /* container already exists */ - -#define DSVC_NERR (DSVC_TABLE_EXISTS + 1) - -/* - * Flags that can be passed to open_* - */ -#define DSVC_CREATE 0x01 /* create container; must not exist */ -#define DSVC_READ 0x02 /* open container for reading */ -#define DSVC_WRITE 0x04 /* open container for writing */ -#define DSVC_NONBLOCK 0x08 /* open container in nonblocking mode */ - -/* - * Query macros - used for initializing query flags to lookup_* - */ -#define DSVC_QINIT(q) ((q) = 0) -#define DSVC_QEQ(q, v) ((q) = ((q) | (v) | ((v) << 16))) -#define DSVC_QNEQ(q, v) ((q) = ((~((v) << 16)) & (q)) | (v)) -#define DSVC_QISEQ(q, v) (((q) & (v)) && ((q) & ((v) << 16))) -#define DSVC_QISNEQ(q, v) (((q) & (v)) && (!((q) & ((v) << 16)))) - -#define DSVC_MAX_MACSYM_LEN 128 /* max length of a macro or symbol */ - -/* - * DHCP Configuration Container (dhcptab(4)) - */ -#define DT_DHCPTAB "dhcptab" /* Default name of container */ -#define DT_SYMBOL 's' -#define DT_MACRO 'm' - -/* Query flags for lookup_dt */ -#define DT_QKEY 0x01 -#define DT_QTYPE 0x02 -#define DT_QALL (DT_QKEY|DT_QTYPE) - -/* - * Consumer's dhcptab record form. Dynamically allocated by underlying data - * store. dt_sig is set by underlying data store -- it's opaque to the - * DHCP service, and is used by the data store to detect update collisions. - * All fields must be fixed-width types and in host byte order. Note that - * SUNWbinfiles writes these records directly to disk, thus changing its - * definition may introduce binary compatibility problems. Note also that - * fields have been carefully ordered to avoid internal padding and the - * structure's size is 64-bit aligned to avoid capricious trailing padding. - */ -typedef struct { - uint64_t dt_sig; /* Opaque atomic cookie */ - char *dt_value; /* Value of type dt_type */ - char dt_key[DSVC_MAX_MACSYM_LEN + 1]; /* Macro/symbol name */ - char dt_type; /* Type of data */ - char dt_pad[2]; /* Pad to 64-bit boundary */ -} dt_rec_t; - -typedef struct dt_rec_list { - dt_rec_t *dtl_rec; - struct dt_rec_list *dtl_next; /* Next record in the list */ -} dt_rec_list_t; - -/* - * DHCP Network Container (dhcp_network(4)) - */ -#define DN_MAX_CID_LEN (DSVC_MAX_MACSYM_LEN / 2) -#define DN_MAX_COMMENT_LEN 48 - -/* Query flags for lookup_dn */ -#define DN_QCID 0x0001 -#define DN_QCIP 0x0002 -#define DN_QSIP 0x0004 -#define DN_QLEASE 0x0008 -#define DN_QMACRO 0x0010 -#define DN_QFDYNAMIC 0x0020 -#define DN_QFAUTOMATIC 0x0040 -#define DN_QFMANUAL 0x0080 -#define DN_QFUNUSABLE 0x0100 -#define DN_QFBOOTP_ONLY 0x0200 -#define DN_QALL (DN_QCID | DN_QCIP | DN_QSIP | DN_QLEASE |\ - DN_QMACRO | DN_QFDYNAMIC | DN_QFAUTOMATIC |\ - DN_QFMANUAL | DN_QFUNUSABLE |\ - DN_QFBOOTP_ONLY) - -/* dn_flags values */ -#define DN_FDYNAMIC 0x00 /* Non-permanent */ -#define DN_FAUTOMATIC 0x01 /* Lease is permanent */ -#define DN_FMANUAL 0x02 /* Manually allocated (sacred) */ -#define DN_FUNUSABLE 0x04 /* Address is unusable */ -#define DN_FBOOTP_ONLY 0x08 /* Address is reserved for BOOTP */ -#define DN_FALL (DN_FDYNAMIC | DN_FAUTOMATIC | DN_FMANUAL |\ - DN_FUNUSABLE | DN_FBOOTP_ONLY) - -/* - * Consumer's DHCP network container record form. Dynamically allocated by - * underlying data store. dn_sig is set by underlying data store -- it's - * opaque to the DHCP service, and is used by the data store to detect - * update collisions. All fields must be fixed-width types and in host - * byte order. Note that SUNWbinfiles writes these records directly to - * disk, thus changing its definition may introduce binary compatibility - * problems. Note also that fields have been carefully ordered to avoid - * internal padding and the structure's size is 64-bit aligned to avoid - * capricious trailing padding. - */ -typedef struct { - uint64_t dn_sig; /* Opaque atomic cookie */ - struct in_addr dn_cip; /* Client IP address */ - struct in_addr dn_sip; /* Server IP address */ - lease_t dn_lease; /* Abs lease expiration */ - char dn_macro[DSVC_MAX_MACSYM_LEN + 1]; - char dn_comment[DN_MAX_COMMENT_LEN + 1]; - uchar_t dn_cid[DN_MAX_CID_LEN]; /* Opaque client id */ - uchar_t dn_cid_len; /* Length of client id */ - uchar_t dn_flags; /* Flags */ -} dn_rec_t; - -typedef struct dn_rec_list { - dn_rec_t *dnl_rec; /* The record itself */ - struct dn_rec_list *dnl_next; /* Next entry in the list */ -} dn_rec_list_t; - -/* - * Synchronization Service Type and values. - */ -typedef uint32_t dsvc_synchtype_t; - -#define DSVC_SYNCH_NONE 0 /* no synch type */ -#define DSVC_SYNCH_DSVCD 1 /* dsvclockd(1M) synch type */ - -/* - * Generic API provided by SMI - */ -extern dt_rec_t *alloc_dtrec(const char *, char, const char *); -extern dn_rec_t *alloc_dnrec(const uchar_t *, uchar_t, uchar_t, struct in_addr, - struct in_addr, lease_t, const char *, const char *); -extern dt_rec_list_t *add_dtrec_to_list(dt_rec_t *, dt_rec_list_t *); -extern dn_rec_list_t *add_dnrec_to_list(dn_rec_t *, dn_rec_list_t *); -extern void free_dtrec(dt_rec_t *); -extern void free_dnrec(dn_rec_t *); -extern void free_dtrec_list(dt_rec_list_t *); -extern void free_dnrec_list(dn_rec_list_t *); -extern const char *dhcpsvc_errmsg(uint_t); - -/* - * The remaining functions are not directly callable by the libdhcpsvc - * implementation; don't expose them to it. - */ -#ifndef _DHCPSVC_IMPL - -/* - * Generic Service Provider Layer API provided by data store implementor - */ -extern int status(const char *); -extern int version(int *); -extern int configure(const char *); -extern int mklocation(const char *); - -/* - * dhcptab Service Provider Layer API - */ -extern int list_dt(const char *, char ***, uint_t *); -extern int open_dt(void **, const char *, uint_t); -extern int close_dt(void **); -extern int add_dt(void *, dt_rec_t *); -extern int remove_dt(const char *); -extern int modify_dt(void *, const dt_rec_t *, dt_rec_t *); -extern int delete_dt(void *, const dt_rec_t *); -extern int lookup_dt(void *, boolean_t, uint_t, int, - const dt_rec_t *, dt_rec_list_t **, uint_t *); -/* - * DHCP Network Service Provider Layer API - * IP address arguments are host order. - */ -extern int list_dn(const char *, char ***, uint_t *); -extern int open_dn(void **, const char *, uint_t, const struct in_addr *, - const struct in_addr *); -extern int close_dn(void **); -extern int add_dn(void *, dn_rec_t *); -extern int remove_dn(const char *, const struct in_addr *); -extern int modify_dn(void *, const dn_rec_t *, dn_rec_t *); -extern int delete_dn(void *, const dn_rec_t *); -extern int lookup_dn(void *, boolean_t, uint_t, int, - const dn_rec_t *, dn_rec_list_t **, uint_t *); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* !_DHCP_SVC_PUBLIC_H */ diff --git a/usr/src/lib/libdhcpsvc/modules/Makefile b/usr/src/lib/libdhcpsvc/modules/Makefile deleted file mode 100644 index 9e24b78a7a..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# -# lib/libdhcpsvc/modules/Makefile -# - -SUBDIRS = binfiles files files0 -include ../Makefile.subdirs - -.PARALLEL: $(SUBDIRS) diff --git a/usr/src/lib/libdhcpsvc/modules/Makefile.com b/usr/src/lib/libdhcpsvc/modules/Makefile.com deleted file mode 100644 index a1b00f4aa5..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/Makefile.com +++ /dev/null @@ -1,40 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include $(SRC)/lib/libdhcpsvc/Makefile.com - -# For all modules, we only want to build the shared objects. -LIBS = $(DYNLIB) - -# Override ROOTLIBDIR. -ROOTLIBDIR = $(ROOT)/usr/lib/inet/dhcp/svc - -# Make the utility routines available -UTILDIR = ../../../modules/util - -# Provide the current container version as DSVC_CONVER -CPPFLAGS += -DDSVC_CONVER=$(VERS:.%=%) diff --git a/usr/src/lib/libdhcpsvc/modules/Makefile.targ b/usr/src/lib/libdhcpsvc/modules/Makefile.targ deleted file mode 100644 index b82b03aeb0..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/Makefile.targ +++ /dev/null @@ -1,44 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2000 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/modules/Makefile.targ -# - -include $(SRC)/lib/libdhcpsvc/Makefile.targ - -# Since no one explicitly links against these modules, there is no -# point to building lint libraries. Instead, override the lint rule -# to lint the sources a la lintcheck. - -lint: lintcheck - -# -# Rule to build the utility functions -# -pics/%.o: $(UTILDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) diff --git a/usr/src/lib/libdhcpsvc/modules/binfiles/Makefile b/usr/src/lib/libdhcpsvc/modules/binfiles/Makefile deleted file mode 100644 index 2225b9c4c6..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/binfiles/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include $(SRC)/lib/Makefile.lib -SUBDIRS = $(MACH) -include ../../Makefile.subdirs diff --git a/usr/src/lib/libdhcpsvc/modules/binfiles/Makefile.com b/usr/src/lib/libdhcpsvc/modules/binfiles/Makefile.com deleted file mode 100644 index f2378492c4..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/binfiles/Makefile.com +++ /dev/null @@ -1,46 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -LIBRARY = ds_SUNWbinfiles.a -VERS = .1 -LOCOBJS = dhcptab.o dhcp_network.o general.o -OBJECTS = $(LOCOBJS) util.o - -# include library definitions -include $(SRC)/lib/libdhcpsvc/modules/Makefile.com - -SRCS = $(LOCOBJS:%.o=../%.c) $(UTILDIR)/util.c -LDLIBS += -lc -ldhcpsvc -lgen -CPPFLAGS += -D_FILE_OFFSET_BITS=64 -I$(UTILDIR) - -.KEEP_STATE: - -all: $(LIBS) - -# include library targets -include $(SRC)/lib/libdhcpsvc/modules/Makefile.targ diff --git a/usr/src/lib/libdhcpsvc/modules/binfiles/dhcp_network.c b/usr/src/lib/libdhcpsvc/modules/binfiles/dhcp_network.c deleted file mode 100644 index 195c42f56d..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/binfiles/dhcp_network.c +++ /dev/null @@ -1,1489 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This file contains public functions for managing DHCP network - * containers. For the semantics of these functions, please see the - * Enterprise DHCP Architecture Document. - * - * This module uses synchronization guarantees provided by dsvclockd(1M); - * please see $SRC/lib/libdhcpsvc/private/README.synch for details. - * - * Big Theory Statement for the SUNWbinfiles DHCP Network Module - * ============================================================= - * - * 1. On-disk Structure - * - * Each container consists of two basic pieces on-disk: a header and an - * array of records. In order to provide fast client IP lookup, the array - * of records is directly indexed by client IP address (using a simple - * mapping function). In order to provide fast client id lookup, each - * in-use record is also on exactly one doubly-linked client id hash chain; - * the hash chains heads are contained in the header). For all other - * lookups, we can restrict our search to only the in-use records by merely - * walking all of the hash chains. Here's a crude illustration of what - * this looks like on-disk (note that hash chains 2 and 3 are empty): - * - * _______________________________________________ - * | container info | hash chain heads (buckets) | - * header | | 1 | 2 | 3 | [ .... ] | N | - * | | | | | | | | | - * |__________________|_|________________________|_| - * | rec1 | rec2 | | rec3 | rec4 | | - * | | +---> | | | - * | unused | unused | hash1 | unused | | - * |___________|___________|________^|_|_________|_| - * | rec5 | rec6 | rec7 |v | rec8 | | - * | | | -> | | - * records | unused | hashN | hash1 <- hash1 | | - * |___________|________^|_|___________|_________|_| - * | : :: : : : | - * | : :: : [ more records... ] : | - * | : :: : : : | - * |___________:________::_:___________:_________:_| - * | recN-3 | recN-2 || | recN-1 | recN v | - * | | |+--> -> | - * | unused | unused +--- hashN <- hashN | - * |___________|___________|___________|___________| - * - * Note that the actual on-disk format is a bit more complicated than this - * due to robustness issues; see section 3 below for details. - * - * 2. Robustness Requirements - * - * This module has been designed to be as efficient as possible while still - * retaining the robustness minimally required for an enterprise-level - * environment. In particular, it is designed to handle the following - * failure situations: - * - * 1. An update operation (add, modify, delete) on a container is - * unable to complete due to an unexpected internal error at - * any point in the update code. - * - * 2. An update operation (add, modify, delete) on a container is - * unable to complete due to unexpected program termination while - * at any point in the update code. - * - * If either of these situations occur, the container in question must be - * left in a consistent (and viable) state. In addition, only the pending - * transaction (at most) may be lost. - * - * 3. Robustness Techniques - * - * This module uses a few different techniques to meet our robustness goals - * while maintaining high performance. The biggest problem we encounter - * when trying to achieve robustness is updating the client id hash chain. - * In particular, it is not possible to atomically add, move, or delete an - * item from a doubly linked list, thus creating a window where a crash - * could leave our hash chains in an inconsistent state. - * - * To address this problem, we actually maintain two images (copies) of all - * the hash chains in the container. At any point in time, exactly one of - * the two images is active (and thus considered authoritative), as - * indicated by a byte in the container header. When performing an update - * operation, all hash chain modifications are done on the *inactive* - * image, then, once the inactive image has completed the hash chain - * operations required by the update, the active and inactive images are - * atomically switched, making the formerly-inactive image authoritative. - * After the image switch, the update code then updates the formerly-active - * image's hash chains to match the active image's hash chains. - * - * This approach has the nice property that internal container consistency - * can always be restored after a crash by just resynchronizing the - * inactive image's hash chains with the active image's chains. Note that - * the atomic image switch serves as the "commit point" for the operation: - * if we crash before this point, we roll back the operation upon recovery - * and it appears as though the operation never happened; if we crash after - * this point, we roll forward the rest of the operation upon recovery as - * if the crash had not happened. - * - * This technique is enough to robustly implement our add and delete - * operations, but modify has an additional complication due to our direct - * mapping of client IP addresses to records. In particular, unless the - * record modification includes changing the client IP address, the - * modified record must be written at the same location as the original - * record -- however, if the modify operation fails part way through - * writing out the new client record, the record will be corrupt and we - * will have no way to return the record to a consistent state. To address - * this issue, we allocate a spare record in the container header called - * the "temporary" record. Upon a modification of this type, we first - * write the modified record to the temporary record and indicate that the - * temporary record is currently proxying for the actual record. We then - * copy the temporary record to the actual record and make the temporary - * record available again for future use. If a crash occurs before the - * copy to the temporary record is complete, then we just roll back as if - * the modify never happened (since we have not modified the actual - * record). If a crash occurs after copying the temporary record, we roll - * forward and complete the copy operation as if the crash never happened. - * Note that there are some additional subtle complications here; see the - * comments in the code for details. - */ - -#include <unistd.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/isa_defs.h> -#include <netinet/in.h> -#include <dhcp_svc_public.h> -#include <stdlib.h> -#include <dirent.h> -#include <string.h> -#include <libgen.h> -#include <errno.h> -#include <stddef.h> -#include <assert.h> - -#include "dhcp_network.h" -#include "util.h" - -static uint16_t cidhash(const uchar_t *, size_t); -static void net2path(char *, size_t, const char *, ipaddr_t); -static int check_dn(dn_handle_t *); -static int getabyte(int, off_t, uchar_t *); -static int setabyte(int, off_t, uchar_t); -static int read_rec(int, dn_filerec_t *, dn_recid_t); -static int write_rec(int, dn_filerec_t *, dn_recid_t); -static int read_header(int, dn_header_t *, boolean_t); -static int write_header(int, dn_header_t *); -static int read_hashhead(int, dn_recid_t *, uint16_t, uchar_t); -static int write_hashhead(int, dn_recid_t, uint16_t, uchar_t); -static boolean_t record_match(const dn_rec_t *, const dn_rec_t *, uint_t); - -int -open_dn(void **handlep, const char *dir, uint_t flags, - const struct in_addr *netp, const struct in_addr *maskp) -{ - dn_handle_t *dhp; - dn_header_t header = { 0 }; - char dnpath[MAXPATHLEN]; - int i, retval; - off_t filesz; - - dhp = malloc(sizeof (dn_handle_t)); - if (dhp == NULL) - return (DSVC_NO_MEMORY); - - /* - * As a safeguard, check that the size of a dn_header_t hasn't - * changed (since it contains a dn_rec_t, this will probably catch - * a change in that structure as well). If it has, bail rather - * than totally corrupting the container (by continuing). Note - * that this situation indicates an internal programming error, - * which is why we prefer assert() to just returning DSVC_INTERNAL. - */ - /* CONSTCOND */ - assert(sizeof (header) == 32768); - - net2path(dnpath, MAXPATHLEN, dir, netp->s_addr); - retval = open_file(dnpath, flags, &dhp->dh_fd); - if (retval != DSVC_SUCCESS) { - free(dhp); - return (retval); - } - - if (flags & DSVC_CREATE) { - /* - * We just created the per-network container; initialize - * the header and put it out on disk. Note that we leave - * `dnh_version' zero until the entire header has been - * written, so we can detect partial failure. - */ - header.dnh_version = 0; - header.dnh_network = netp->s_addr; - header.dnh_netmask = maskp->s_addr; - header.dnh_magic = DN_MAGIC; - header.dnh_tempimage = DN_NOIMAGE; - header.dnh_image = 0; - header.dnh_errors = 0; - header.dnh_checks = 0; - for (i = 0; i < DN_CIDHASHSZ; i++) { - header.dnh_cidhash[i][header.dnh_image] = DN_NOREC; - header.dnh_cidhash[i][!header.dnh_image] = DN_NOREC; - } - - if (write_header(dhp->dh_fd, &header) == -1) { - retval = syserr_to_dsvcerr(errno); - (void) remove_dn(dir, netp); - (void) close_dn((void **)&dhp); - return (retval); - } - - /* - * Virtually reserve all the space we're going to need for - * the dn_rec_t's ahead of time, so that we don't have to - * worry about "growing" the file later (though it may - * increase in size as we fill in holes). We're guaranteed - * that we'll read these holes as zeros, which we take - * advantage of since a dn_filerec_t with a rec_prev of - * DN_NOREC (which is 0) indicates that a record is unused. - */ - filesz = RECID2OFFSET(RECID(~0, header.dnh_netmask) + 1); - retval = setabyte(dhp->dh_fd, filesz - 1, 0); - if (retval != DSVC_SUCCESS) { - (void) remove_dn(dir, netp); - (void) close_dn((void **)&dhp); - return (retval); - } - - /* - * Set the version field on the container, effectively - * making it available for use. - */ - retval = setabyte(dhp->dh_fd, offsetof(dn_header_t, - dnh_version), DSVC_CONVER); - if (retval != DSVC_SUCCESS) { - (void) remove_dn(dir, netp); - (void) close_dn((void **)&dhp); - return (retval); - } - } else { - /* - * Container already exists; sanity check against the - * header that's on-disk. If we detect a problem then - * either someone scribbled on our container or we - * terminated abnormally when creating the container. - */ - if (read_header(dhp->dh_fd, &header, B_FALSE) == -1) { - retval = syserr_to_dsvcerr(errno); - (void) close_dn((void **)&dhp); - return (retval); - } - - if (header.dnh_network != netp->s_addr || - header.dnh_version != DSVC_CONVER || - header.dnh_magic != DN_MAGIC) { - (void) close_dn((void **)&dhp); - return (DSVC_INTERNAL); - } - } - - dhp->dh_netmask = header.dnh_netmask; - dhp->dh_oflags = flags; - - *handlep = dhp; - return (DSVC_SUCCESS); -} - -int -close_dn(void **handlep) -{ - dn_handle_t *dhp = (dn_handle_t *)*handlep; - - if (close(dhp->dh_fd) == -1) - return (DSVC_INTERNAL); - - free(dhp); - return (DSVC_SUCCESS); -} - -int -remove_dn(const char *dir, const struct in_addr *netp) -{ - char dnpath[MAXPATHLEN]; - - net2path(dnpath, MAXPATHLEN, dir, netp->s_addr); - if (unlink(dnpath) == -1) - return (syserr_to_dsvcerr(errno)); - - return (DSVC_SUCCESS); -} - -int -lookup_dn(void *handle, boolean_t partial, uint_t query, int count, - const dn_rec_t *targetp, dn_rec_list_t **recordsp, uint_t *nrecordsp) -{ - dn_handle_t *dhp = (dn_handle_t *)handle; - int retval = DSVC_SUCCESS; - uint_t nrecords, n; - uint16_t hash; - dn_rec_t *recordp; - dn_rec_list_t *records, *new_records; - dn_recid_t recid, temp_recid = DN_NOREC; - dn_filerec_t rec; - dn_header_t header; - uchar_t image; - int fd = dhp->dh_fd; - - if ((dhp->dh_oflags & DSVC_READ) == 0) - return (DSVC_ACCESS); - - if (read_header(fd, &header, B_FALSE) == -1) - return (syserr_to_dsvcerr(errno)); - - /* - * It's possible that a previous update to this container failed - * part-way through. In general, this is fine since we always keep - * our active image's hash chains correct and only swap to the - * alternate image when the other image is completely safe to use. - * However, for reasons explained in modify_dn(), it's possible - * that a record being modified was not completely updated before a - * failure occurred. In this case, the actual data for that record - * is contained in the temporary record in the header. We need to - * be careful to use that temporary record anywhere we'd otherwise - * refer to the partially updated record. Note that we do this - * rather than attempting to restore the consistency of the - * container because we're MT-hot here. - */ - if (header.dnh_dirty && header.dnh_tempimage == header.dnh_image) { - temp_recid = RECID(header.dnh_temp.rec_dn.dn_cip.s_addr, - header.dnh_netmask); - } - - image = header.dnh_image; - records = NULL; - for (n = 0, nrecords = 0; count < 0 || nrecords < count; n++) { - if (DSVC_QISEQ(query, DN_QCIP)) { - /* - * Lookup scenario 1: Caller has requested a QN_CIP - * query lookup; set `recid' to the only possible - * entry (which may not be in-use). - */ - if (n != 0) - break; - recid = RECID(targetp->dn_cip.s_addr, dhp->dh_netmask); - } else if (DSVC_QISEQ(query, DN_QCID)) { - /* - * Lookup scenario 2: Caller has requested a - * QN_CID-based lookup. Walk the `cidhash' chain - * (one call at a time) and set `recid' to hash - * bucket candidates. - * - * Note that it's possible for the client id value - * 00 to appear more than once, and it's not - * impossible for other duplicate client ids to - * occur, so continue until we reach `nrecords'. - */ - if (n == 0) { - hash = cidhash(targetp->dn_cid, - targetp->dn_cid_len); - if (read_hashhead(fd, &recid, hash, image) - == -1) - return (syserr_to_dsvcerr(errno)); - } else { - /* sanity check */ - if (recid == rec.rec_next[image]) - break; - recid = rec.rec_next[image]; - } - } else { - /* - * Lookup scenario 3: Caller has requested any - * other type of search. Walk the all the client - * id hashes. - */ - if (n == 0) { - hash = 0; - if (read_header(fd, &header, B_TRUE) == -1) - return (syserr_to_dsvcerr(errno)); - recid = header.dnh_cidhash[hash][image]; - } else { - /* sanity check */ - if (recid == rec.rec_next[image]) - break; - recid = rec.rec_next[image]; - } - - while (recid == DN_NOREC && ++hash < DN_CIDHASHSZ) - recid = header.dnh_cidhash[hash][image]; - } - - /* - * No more records; bail. - */ - if (recid == DN_NOREC) - break; - - if (recid == temp_recid) { - /* - * The temporary record is actually authoritative - * for this record's contents; use it instead. - */ - recid = DN_TEMPREC; - } - - if (read_rec(dhp->dh_fd, &rec, recid) == -1) { - retval = syserr_to_dsvcerr(errno); - break; - } - - /* - * If the record isn't in-use, then skip... - */ - if (rec.rec_prev[image] == DN_NOREC) - continue; - - /* - * See if we've got a match... - */ - if (!record_match(&rec.rec_dn, targetp, query)) - continue; - - /* - * Caller just wants a count of the number of matching - * records, not the records themselves; continue. - */ - if (recordsp == NULL) { - nrecords++; - continue; - } - - /* - * Allocate the record and fill it in. - */ - recordp = malloc(sizeof (dn_rec_t)); - if (recordp == NULL) { - if (!partial) - retval = DSVC_NO_MEMORY; - break; - } - *recordp = rec.rec_dn; - - /* - * Chuck the record on the list and up the counter. - */ - new_records = add_dnrec_to_list(recordp, records); - if (new_records == NULL) { - free(recordp); - if (!partial) - retval = DSVC_NO_MEMORY; - break; - } - - records = new_records; - nrecords++; - } - - if (retval == DSVC_SUCCESS) { - *nrecordsp = nrecords; - if (recordsp != NULL) - *recordsp = records; - return (DSVC_SUCCESS); - } - - if (records != NULL) - free_dnrec_list(records); - - return (retval); -} - -/* - * Compares `dnp' to the target `targetp', using `query' to decide what - * fields to compare. Returns B_TRUE if `dnp' matches `targetp', B_FALSE - * if not. - */ -static boolean_t -record_match(const dn_rec_t *dnp, const dn_rec_t *targetp, uint_t query) -{ - unsigned int qflags[] = { DN_QFDYNAMIC, DN_QFAUTOMATIC, DN_QFMANUAL, - DN_QFUNUSABLE, DN_QFBOOTP_ONLY }; - unsigned int flags[] = { DN_FDYNAMIC, DN_FAUTOMATIC, DN_FMANUAL, - DN_FUNUSABLE, DN_FBOOTP_ONLY }; - unsigned int i; - unsigned int query0; - - /* - * As an optimization, skip any checks if the query is empty. - */ - DSVC_QINIT(query0); - if (query == query0) - return (B_TRUE); - - if (DSVC_QISEQ(query, DN_QLEASE) && - targetp->dn_lease != dnp->dn_lease) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QLEASE) && - targetp->dn_lease == dnp->dn_lease) - return (B_FALSE); - - if (DSVC_QISEQ(query, DN_QCIP) && - dnp->dn_cip.s_addr != targetp->dn_cip.s_addr) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QCIP) && - dnp->dn_cip.s_addr == targetp->dn_cip.s_addr) - return (B_FALSE); - - if (DSVC_QISEQ(query, DN_QCID) && - (dnp->dn_cid_len != targetp->dn_cid_len || - (memcmp(dnp->dn_cid, targetp->dn_cid, dnp->dn_cid_len) != 0))) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QCID) && - (dnp->dn_cid_len == targetp->dn_cid_len && - (memcmp(dnp->dn_cid, targetp->dn_cid, dnp->dn_cid_len) == 0))) - return (B_FALSE); - - if (DSVC_QISEQ(query, DN_QSIP) && - dnp->dn_sip.s_addr != targetp->dn_sip.s_addr) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QSIP) && - dnp->dn_sip.s_addr == targetp->dn_sip.s_addr) - return (B_FALSE); - - if (DSVC_QISEQ(query, DN_QMACRO) && - strcmp(targetp->dn_macro, dnp->dn_macro) != 0) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QMACRO) && - strcmp(targetp->dn_macro, dnp->dn_macro) == 0) - return (B_FALSE); - - for (i = 0; i < sizeof (qflags) / sizeof (unsigned int); i++) { - if (DSVC_QISEQ(query, qflags[i]) && - (dnp->dn_flags & flags[i]) != - (targetp->dn_flags & flags[i])) - return (B_FALSE); - if (DSVC_QISNEQ(query, qflags[i]) && - (dnp->dn_flags & flags[i]) == - (targetp->dn_flags & flags[i])) - return (B_FALSE); - } - - return (B_TRUE); -} - -int -add_dn(void *handle, dn_rec_t *addp) -{ - dn_filerec_t rec, rec_next; - dn_recid_t recid, recid_head; - uint16_t hash; - uchar_t image; - int retval; - dn_handle_t *dhp = (dn_handle_t *)handle; - int fd = dhp->dh_fd; - - if ((dhp->dh_oflags & DSVC_WRITE) == 0) - return (DSVC_ACCESS); - - retval = check_dn(dhp); - if (retval != DSVC_SUCCESS) - return (retval); - - hash = cidhash(addp->dn_cid, addp->dn_cid_len); - - /* - * Get the active image. - */ - retval = getabyte(fd, offsetof(dn_header_t, dnh_image), &image); - if (retval != DSVC_SUCCESS) - return (retval); - - /* - * Doublecheck to make sure this entry doesn't exist already. - */ - recid = RECID(addp->dn_cip.s_addr, dhp->dh_netmask); - if (read_rec(fd, &rec, recid) == -1) - return (syserr_to_dsvcerr(errno)); - - if (rec.rec_prev[image] != DN_NOREC) - return (DSVC_EXISTS); - - /* - * We're going to insert `rec' at the head of the `hash' hash - * chain; get it ready-to-go. Note that we update the alternate - * image's hash record id pointers so that the record will - * atomically become in-use when we switch to the alternate image. - */ - if (read_hashhead(fd, &recid_head, hash, image) == -1) - return (syserr_to_dsvcerr(errno)); - - rec.rec_dn = *addp; - rec.rec_dn.dn_sig = gensig(); - rec.rec_prev[!image] = DN_HASHHEAD; - rec.rec_next[!image] = recid_head; - - /* - * If there's a record currently on the hash chain (i.e, we're - * not the first) then load the record. - */ - if (rec.rec_next[!image] != DN_NOREC) { - if (read_rec(fd, &rec_next, rec.rec_next[!image]) == -1) - return (syserr_to_dsvcerr(errno)); - } - - /* - * Before we update any information on disk, mark the container as - * dirty so that there's no chance the container is inconsistent - * without us knowing about it. - */ - retval = setabyte(fd, offsetof(dn_header_t, dnh_dirty), 1); - if (retval != DSVC_SUCCESS) - return (retval); - - /* - * Update the new record on-disk; note that it's not yet reachable - * via hash. - */ - if (write_rec(fd, &rec, recid) == -1) - return (syserr_to_dsvcerr(errno)); - - /* - * Update the alternate image's on-disk hash pointers. We need to - * do this before we switch to the alternate image so we cannot - * abort with an inconsistent active image. - */ - if (rec.rec_next[!image] != DN_NOREC) { - rec_next.rec_prev[!image] = recid; - if (write_rec(fd, &rec_next, rec.rec_next[!image]) == -1) - return (syserr_to_dsvcerr(errno)); - } - if (write_hashhead(fd, recid, hash, !image) == -1) - return (syserr_to_dsvcerr(errno)); - - /* - * Activate the alternate image. This is our commit point -- if we - * fail after this point, we will roll forward on recovery. - */ - image = !image; - retval = setabyte(fd, offsetof(dn_header_t, dnh_image), image); - if (retval != DSVC_SUCCESS) - return (retval); - - /* - * Update the old record id pointers to match - */ - rec.rec_prev[!image] = rec.rec_prev[image]; - rec.rec_next[!image] = rec.rec_next[image]; - if (write_rec(fd, &rec, recid) == -1) - return (syserr_to_dsvcerr(errno)); - - if (rec.rec_next[!image] != DN_NOREC) { - rec_next.rec_prev[!image] = recid; - if (write_rec(fd, &rec_next, rec.rec_next[!image]) == -1) - return (syserr_to_dsvcerr(errno)); - } - if (write_hashhead(fd, recid, hash, !image) == -1) - return (syserr_to_dsvcerr(errno)); - - /* - * Update the signature on the record handed back to the caller. - */ - addp->dn_sig = rec.rec_dn.dn_sig; - - /* - * Finally, mark the container as clean. - */ - return (setabyte(fd, offsetof(dn_header_t, dnh_dirty), 0)); -} - -int -delete_dn(void *handle, const dn_rec_t *delp) -{ - dn_filerec_t rec, rec_prev, rec_next; - dn_recid_t recid; - uint16_t hash; - uchar_t image; - int retval; - dn_handle_t *dhp = (dn_handle_t *)handle; - int fd = dhp->dh_fd; - - if ((dhp->dh_oflags & DSVC_WRITE) == 0) - return (DSVC_ACCESS); - - retval = check_dn(dhp); - if (retval != DSVC_SUCCESS) - return (retval); - - /* - * Get the active image. - */ - retval = getabyte(fd, offsetof(dn_header_t, dnh_image), &image); - if (retval != DSVC_SUCCESS) - return (retval); - - /* - * Find the original entry in the network table, make sure the - * record is in-use, and check the signature field (to guard - * against collisions). - */ - recid = RECID(delp->dn_cip.s_addr, dhp->dh_netmask); - if (read_rec(fd, &rec, recid) == -1) - return (syserr_to_dsvcerr(errno)); - - if (rec.rec_prev[image] == DN_NOREC) - return (DSVC_NOENT); - - hash = cidhash(rec.rec_dn.dn_cid, rec.rec_dn.dn_cid_len); - - /* - * The signatures must match to delete a record, *except* when - * delp->dn_sig == 0. This is so records can be deleted that - * weren't retrieved via lookup_dn() - */ - if (delp->dn_sig != 0 && rec.rec_dn.dn_sig != delp->dn_sig) - return (DSVC_COLLISION); - - /* - * Read our neighboring records. - */ - if (rec.rec_next[image] != DN_NOREC) { - if (read_rec(fd, &rec_next, rec.rec_next[image]) == -1) - return (syserr_to_dsvcerr(errno)); - } - - if (rec.rec_prev[image] != DN_HASHHEAD) { - if (read_rec(fd, &rec_prev, rec.rec_prev[image]) == -1) - return (syserr_to_dsvcerr(errno)); - } - - /* - * Before we update the alternate image's on-disk hash pointers, - * mark the container as dirty so that there's no chance the - * container is inconsistent without us knowing about it. - */ - retval = setabyte(fd, offsetof(dn_header_t, dnh_dirty), 1); - if (retval != DSVC_SUCCESS) - return (retval); - - /* - * Update the alternate image's on-disk hash pointers. We need to - * do this before we switch to the alternate image so we do not - * abort with an inconsistent active image. Also reset the - * record's alternate image record id pointers, so that the old - * record will not be in-use when we switch to the alternate image. - */ - if (rec.rec_next[image] != DN_NOREC) { - rec_next.rec_prev[!image] = rec.rec_prev[image]; - if (write_rec(fd, &rec_next, rec.rec_next[image]) == -1) - return (syserr_to_dsvcerr(errno)); - } - - if (rec.rec_prev[image] != DN_HASHHEAD) { - rec_prev.rec_next[!image] = rec.rec_next[image]; - if (write_rec(fd, &rec_prev, rec.rec_prev[image]) == -1) - return (syserr_to_dsvcerr(errno)); - } else { - if (write_hashhead(fd, rec.rec_next[image], hash, !image) == -1) - return (syserr_to_dsvcerr(errno)); - } - - rec.rec_next[!image] = DN_NOREC; - rec.rec_prev[!image] = DN_NOREC; - if (write_rec(fd, &rec, recid) == -1) - return (syserr_to_dsvcerr(errno)); - - /* - * Activate the alternate image. This is our commit point -- if we - * fail after this point, we will roll forward on recovery. - */ - image = !image; - retval = setabyte(fd, offsetof(dn_header_t, dnh_image), image); - if (retval != DSVC_SUCCESS) - return (retval); - - /* - * Update the old record id pointers to match. - */ - if (rec.rec_next[!image] != DN_NOREC) { - rec_next.rec_prev[!image] = rec.rec_prev[!image]; - if (write_rec(fd, &rec_next, rec.rec_next[!image]) == -1) - return (syserr_to_dsvcerr(errno)); - } - - if (rec.rec_prev[!image] != DN_HASHHEAD) { - rec_prev.rec_next[!image] = rec.rec_next[!image]; - if (write_rec(fd, &rec_prev, rec.rec_prev[!image]) == -1) - return (syserr_to_dsvcerr(errno)); - } else { - if (write_hashhead(fd, rec.rec_next[!image], hash, !image) - == -1) - return (syserr_to_dsvcerr(errno)); - } - - rec.rec_next[!image] = DN_NOREC; - rec.rec_prev[!image] = DN_NOREC; - if (write_rec(fd, &rec, recid) == -1) - return (syserr_to_dsvcerr(errno)); - - /* - * Finally, mark the container as clean. - */ - return (setabyte(fd, offsetof(dn_header_t, dnh_dirty), 0)); -} - -int -modify_dn(void *handle, const dn_rec_t *origp, dn_rec_t *newp) -{ - dn_filerec_t rec, new_rec, rec_head, rec_next, rec_prev; - dn_recid_t recid, new_recid, recid_head; - uint16_t hash, new_hash; - uchar_t image; - int retval; - dn_handle_t *dhp = (dn_handle_t *)handle; - int fd = dhp->dh_fd; - - if ((dhp->dh_oflags & DSVC_WRITE) == 0) - return (DSVC_ACCESS); - - retval = check_dn(dhp); - if (retval != DSVC_SUCCESS) - return (retval); - - /* - * Get the active image - */ - retval = getabyte(fd, offsetof(dn_header_t, dnh_image), &image); - if (retval != DSVC_SUCCESS) - return (retval); - - /* - * Find the original entry in the network table, make sure the - * entry is in-use, and check the signature field (to guard against - * collisions). - */ - recid = RECID(origp->dn_cip.s_addr, dhp->dh_netmask); - if (read_rec(fd, &rec, recid) == -1) - return (syserr_to_dsvcerr(errno)); - - if (rec.rec_prev[image] == DN_NOREC) - return (DSVC_NOENT); - - if (rec.rec_dn.dn_sig != origp->dn_sig) - return (DSVC_COLLISION); - - /* - * Check if the record id is changing (as a result of modifying the - * IP address). If it is, then make sure the new one is available - * (if not, fail with DSVC_EXISTS). - */ - new_recid = RECID(newp->dn_cip.s_addr, dhp->dh_netmask); - if (recid != new_recid) { - if (read_rec(fd, &new_rec, new_recid) == -1) - return (syserr_to_dsvcerr(errno)); - if (new_rec.rec_prev[image] != DN_NOREC) - return (DSVC_EXISTS); - } - - /* - * Update the record with the new information. - */ - new_rec.rec_dn = *newp; - new_rec.rec_dn.dn_sig = origp->dn_sig + 1; - - /* - * Find out if our hash chain is changing. If so, then update the - * new record's record id pointers to be on the new chain; - * otherwise just take the original record's pointers. Note that - * in either case, only update the alternate image pointers, so - * that the new record becomes in-use when we switch to the - * alternate image. - */ - hash = cidhash(rec.rec_dn.dn_cid, rec.rec_dn.dn_cid_len); - new_hash = cidhash(newp->dn_cid, newp->dn_cid_len); - - if (hash == new_hash) { - new_rec.rec_prev[!image] = rec.rec_prev[image]; - new_rec.rec_next[!image] = rec.rec_next[image]; - } else { - if (read_hashhead(fd, &recid_head, new_hash, image) == -1) - return (syserr_to_dsvcerr(errno)); - - new_rec.rec_prev[!image] = DN_HASHHEAD; - new_rec.rec_next[!image] = recid_head; - } - - /* - * Write the record out; if this means overwriting the old record, - * then write to a temporary record instead. - */ - if (write_rec(fd, &new_rec, new_recid == recid ? DN_TEMPREC : new_recid) - == -1) - return (syserr_to_dsvcerr(errno)); - - /* - * Mark the container as dirty so that there's no chance the - * container is inconsistent without us knowing about it. - */ - retval = setabyte(fd, offsetof(dn_header_t, dnh_dirty), 1); - if (retval != DSVC_SUCCESS) - return (retval); - - /* - * If we've changed either the hash chain or the record id, then - * update our neighboring records' record id pointers. If we're - * changing hash chains, then remove ourselves from the old - * hash chain and insert ourselves on the new one -- otherwise, if - * we're changing record id's, then update our neighbors with our - * new record id. Note that we only apply these changes to the - * alternate image for now so that we can recover upon failure. - */ - if (hash != new_hash || recid != new_recid) { - if (rec.rec_next[image] != DN_NOREC) { - if (read_rec(fd, &rec_next, rec.rec_next[image]) == -1) - return (syserr_to_dsvcerr(errno)); - } - if (rec.rec_prev[image] != DN_HASHHEAD) { - if (read_rec(fd, &rec_prev, rec.rec_prev[image]) == -1) - return (syserr_to_dsvcerr(errno)); - } - - if (hash != new_hash) { - rec_next.rec_prev[!image] = rec.rec_prev[!image]; - rec_prev.rec_next[!image] = rec.rec_next[!image]; - } else { - rec_next.rec_prev[!image] = new_recid; - rec_prev.rec_next[!image] = new_recid; - } - - if (rec.rec_next[image] != DN_NOREC) { - if (write_rec(fd, &rec_next, rec.rec_next[image]) == -1) - return (syserr_to_dsvcerr(errno)); - } - if (rec.rec_prev[image] != DN_HASHHEAD) { - if (write_rec(fd, &rec_prev, rec.rec_prev[image]) == -1) - return (syserr_to_dsvcerr(errno)); - } else { - if (write_hashhead(fd, rec_prev.rec_next[!image], hash, - !image) == -1) - return (syserr_to_dsvcerr(errno)); - } - - /* - * If our hash is changing, update the alternate image - * record id pointers to point to our moved record. - */ - if (hash != new_hash) { - if (recid_head != DN_NOREC) { - if (read_rec(fd, &rec_head, recid_head) == -1) - return (syserr_to_dsvcerr(errno)); - rec_head.rec_prev[!image] = new_recid; - if (write_rec(fd, &rec_head, recid_head) == -1) - return (syserr_to_dsvcerr(errno)); - } - if (write_hashhead(fd, new_recid, new_hash, !image) - == -1) - return (syserr_to_dsvcerr(errno)); - } - - /* - * If our record id is changing, reset the old record's - * alternate image record id pointers, so that the old - * record will not be in-use once we switch over to the - * alternate image. - */ - if (recid != new_recid) { - rec.rec_prev[!image] = DN_NOREC; - rec.rec_next[!image] = DN_NOREC; - if (write_rec(fd, &rec, recid) == -1) - return (syserr_to_dsvcerr(errno)); - } - } - - /* - * If we're using the temporary record, then set `dnh_tempimage' to - * the image that will be active when we're done. This piece of - * state is critical in the case of failure, since it indicates - * both that the temporary record is valid, and tells us whether we - * failed before or after activating the alternate image (below). - * If we failed before activating the alternate image, then the - * failure code can just reset `dnh_tempimage' to DN_NOIMAGE and - * resynchronize the pointers. Otherwise, we failed somewhere - * after making the alternate image active but before we completed - * copying the temporary record over to the actual record, which - * the recovery code will then complete on our behalf before - * resynchronizing the pointers. - */ - if (recid == new_recid) { - retval = setabyte(fd, offsetof(dn_header_t, dnh_tempimage), - !image); - if (retval != DSVC_SUCCESS) - return (retval); - } - - /* - * Activate the alternate image. This is our commit point -- if we - * fail after this point, we will roll forward on recovery. - */ - image = !image; - retval = setabyte(fd, offsetof(dn_header_t, dnh_image), image); - if (retval != DSVC_SUCCESS) - return (retval); - - /* - * If we used the temporary record, copy the data into the actual - * record. Once finished, reset `dnh_tempimage' to DN_NOIMAGE - * since the temporary record no longer needs to be used. - */ - if (recid == new_recid) { - if (write_rec(fd, &new_rec, new_recid) == -1) - return (syserr_to_dsvcerr(errno)); - - retval = setabyte(fd, offsetof(dn_header_t, dnh_tempimage), - DN_NOIMAGE); - if (retval != DSVC_SUCCESS) - return (retval); - } - - /* - * Update the old record id pointers to match. - */ - new_rec.rec_prev[!image] = new_rec.rec_prev[image]; - new_rec.rec_next[!image] = new_rec.rec_next[image]; - if (write_rec(fd, &new_rec, new_recid) == -1) - return (syserr_to_dsvcerr(errno)); - - if (hash != new_hash || recid != new_recid) { - if (rec.rec_next[image] != DN_NOREC) { - rec_next.rec_prev[!image] = rec.rec_prev[image]; - if (write_rec(fd, &rec_next, rec.rec_next[image]) == -1) - return (syserr_to_dsvcerr(errno)); - } - if (rec.rec_prev[image] != DN_HASHHEAD) { - rec_prev.rec_next[!image] = rec.rec_next[image]; - if (write_rec(fd, &rec_prev, rec.rec_prev[image]) == -1) - return (syserr_to_dsvcerr(errno)); - } else { - if (write_hashhead(fd, rec.rec_next[image], hash, - !image) == -1) - return (syserr_to_dsvcerr(errno)); - } - - /* - * If our hash changed, update the alternate image record - * id pointers to point to our moved record. - */ - if (hash != new_hash) { - if (recid_head != DN_NOREC) { - rec_head.rec_prev[!image] = - rec_head.rec_prev[image]; - if (write_rec(fd, &rec_head, recid_head) == -1) - return (syserr_to_dsvcerr(errno)); - } - if (write_hashhead(fd, new_recid, new_hash, !image) - == -1) - return (syserr_to_dsvcerr(errno)); - } - - /* - * If our record id changed, then finish marking the old - * record as "not in use". - */ - if (recid != new_recid) { - rec.rec_prev[!image] = DN_NOREC; - rec.rec_next[!image] = DN_NOREC; - if (write_rec(fd, &rec, recid) == -1) - return (syserr_to_dsvcerr(errno)); - } - } - - /* - * Update the signature on the new record handed back to the caller. - */ - newp->dn_sig = new_rec.rec_dn.dn_sig; - - /* - * Finally, mark the container as clean. - */ - return (setabyte(fd, offsetof(dn_header_t, dnh_dirty), 0)); -} - -int -list_dn(const char *location, char ***listppp, uint_t *countp) -{ - char ipaddr[INET_ADDRSTRLEN]; - struct dirent *result; - DIR *dirp; - unsigned int i, count = 0; - char *re, **new_listpp, **listpp = NULL; - char conver[4]; - int error; - - dirp = opendir(location); - if (dirp == NULL) { - switch (errno) { - case EACCES: - case EPERM: - return (DSVC_ACCESS); - case ENOENT: - return (DSVC_NO_LOCATION); - default: - break; - } - return (DSVC_INTERNAL); - } - - /* - * Compile a regular expression matching "SUNWbinfilesX_" (where X - * is a container version number) followed by an IP address - * (roughly speaking). Note that the $N constructions allow us to - * get the container version and IP address when calling regex(3C). - */ - re = regcmp("^SUNWbinfiles([0-9]{1,3})$0_" - "(([0-9]{1,3}_){3}[0-9]{1,3})$1$", (char *)0); - if (re == NULL) - return (DSVC_NO_MEMORY); - - while ((result = readdir(dirp)) != NULL) { - - if (regex(re, result->d_name, conver, ipaddr) != NULL) { - if (atoi(conver) != DSVC_CONVER) - continue; - - for (i = 0; ipaddr[i] != '\0'; i++) - if (ipaddr[i] == '_') - ipaddr[i] = '.'; - - new_listpp = realloc(listpp, - (sizeof (char **)) * (count + 1)); - if (new_listpp == NULL) { - error = DSVC_NO_MEMORY; - goto fail; - } - listpp = new_listpp; - listpp[count] = strdup(ipaddr); - if (listpp[count] == NULL) { - error = DSVC_NO_MEMORY; - goto fail; - } - count++; - } - } - free(re); - (void) closedir(dirp); - - *countp = count; - *listppp = listpp; - return (DSVC_SUCCESS); -fail: - free(re); - (void) closedir(dirp); - - for (i = 0; i < count; i++) - free(listpp[i]); - free(listpp); - return (error); -} - -/* - * Check (a la fsck) that a given DHCP network container is in a consistent - * state. If not, then attempt to restore internal consistency; this should - * always be possible unless the container has been externally corrupted. - */ -static int -check_dn(dn_handle_t *dhp) -{ - dn_header_t header; - uchar_t image, dirty; - uint16_t hash; - dn_filerec_t rec; - dn_recid_t recid, maxrecid; - int retval; - - /* - * Reading the whole header is a very expensive operation; only do - * it once we're sure the container is actually dirty. On an - * E4500, this optimization lowers the wall-clock cost of creating - * a 5000-record datastore by 20 percent. - */ - retval = getabyte(dhp->dh_fd, offsetof(dn_header_t, dnh_dirty), &dirty); - if (retval != DSVC_SUCCESS) - return (retval); - - if (dirty == 0) - return (DSVC_SUCCESS); - - if (read_header(dhp->dh_fd, &header, B_TRUE) == -1) - return (syserr_to_dsvcerr(errno)); - - /* - * If `dnh_tempimage' matches the current working image, then we - * crashed in the middle of a modify_dn() operation. Complete - * writing out the temporary record before restoring internal - * consistency. This is a bit of a kludge but there doesn't seem - * to be another way. - */ - if (header.dnh_tempimage == header.dnh_image) { - recid = RECID(header.dnh_temp.rec_dn.dn_cip.s_addr, - header.dnh_netmask); - if (write_rec(dhp->dh_fd, &header.dnh_temp, recid) == -1) - return (syserr_to_dsvcerr(errno)); - - header.dnh_tempimage = DN_NOIMAGE; - } - - /* - * Blindly update all the header hashhead pointers since we're - * going to have to re-write the header anyway. - */ - image = header.dnh_image; - for (hash = 0; hash < DN_CIDHASHSZ; hash++) { - header.dnh_cidhash[hash][!image] = - header.dnh_cidhash[hash][image]; - } - - /* - * Synchronize the record pointers of all in-use records. We do - * this instead of just walking the hashheads because not all dirty - * records are hashed (for instance, we may have failed part way - * through an add_dn()). - */ - maxrecid = RECID(~0, header.dnh_netmask); - for (recid = RECID(0, header.dnh_netmask); recid <= maxrecid; recid++) { - if (read_rec(dhp->dh_fd, &rec, recid) == -1) - return (syserr_to_dsvcerr(errno)); - - /* - * Verify the pointers match. If not, then correct - * the record and write it back to disk. - */ - if (rec.rec_next[image] != rec.rec_next[!image] || - rec.rec_prev[image] != rec.rec_prev[!image]) { - header.dnh_errors++; - - rec.rec_prev[!image] = rec.rec_prev[image]; - rec.rec_next[!image] = rec.rec_next[image]; - - if (write_rec(dhp->dh_fd, &rec, recid) == -1) - return (syserr_to_dsvcerr(errno)); - } - } - - header.dnh_checks++; - if (write_header(dhp->dh_fd, &header) == -1) - return (syserr_to_dsvcerr(errno)); - - /* - * Clear the dirty bit on the container. - */ - return (setabyte(dhp->dh_fd, offsetof(dn_header_t, dnh_dirty), 0)); -} - -/* - * Given a buffer `path' of `pathlen' bytes, fill it in with a path to the - * DHCP Network table for IP network `ip' located in directory `dir'. - */ -static void -net2path(char *path, size_t pathlen, const char *dir, ipaddr_t ip) -{ - (void) snprintf(path, pathlen, "%s/SUNWbinfiles%u_%d_%d_%d_%d", dir, - DSVC_CONVER, ip >> 24, (ip >> 16) & 0xff, (ip >> 8) & 0xff, - ip & 0xff); -} - -/* - * Given a `cid' that's `cidlen' bytes long, hash it to a value between 0 - * and DN_CIDHASHSZ - 1. We use CRC16 for our hash since it's known to be - * very evenly distributed. - */ -static uint16_t -cidhash(const uchar_t *cid, size_t cidlen) -{ - uchar_t bit; - uint16_t result = 0xffff; - const uint16_t crc16_poly = 0x8408; /* mutated CRC-CCITT polynomial */ - - while (cidlen-- != 0) { - result ^= *cid++; - for (bit = 0; bit < 8; bit++) { - if (result & 1) - result = (result >> 1) ^ crc16_poly; - else - result >>= 1; - } - } - return (result % DN_CIDHASHSZ); -} - -/* - * Convert the dn_filerec_t pointed to by `rec' from native (host) to - * network order or the other way. - */ -/* ARGSUSED */ -static void -nhconvert_rec(dn_filerec_t *rec) -{ -#ifdef _LITTLE_ENDIAN - dn_rec_t *dnp = &rec->rec_dn; - - nhconvert(&rec->rec_prev[0], &rec->rec_prev[0], sizeof (dn_recid_t)); - nhconvert(&rec->rec_prev[1], &rec->rec_prev[1], sizeof (dn_recid_t)); - nhconvert(&rec->rec_next[0], &rec->rec_next[0], sizeof (dn_recid_t)); - nhconvert(&rec->rec_next[1], &rec->rec_next[1], sizeof (dn_recid_t)); - - nhconvert(&dnp->dn_cip.s_addr, &dnp->dn_cip.s_addr, sizeof (ipaddr_t)); - nhconvert(&dnp->dn_sip.s_addr, &dnp->dn_sip.s_addr, sizeof (ipaddr_t)); - nhconvert(&dnp->dn_lease, &dnp->dn_lease, sizeof (lease_t)); - nhconvert(&dnp->dn_sig, &dnp->dn_sig, sizeof (uint64_t)); -#endif -} - -/* - * Convert the header pointed to by `hdrp' from native (host) to network - * order or the other way. If `hash' is false, then don't bother - * converting the hash chains. - */ -/* ARGSUSED */ -static void -nhconvert_header(dn_header_t *hdrp, boolean_t hash) -{ -#ifdef _LITTLE_ENDIAN - unsigned int i; - - nhconvert(&hdrp->dnh_network, &hdrp->dnh_network, sizeof (ipaddr_t)); - nhconvert(&hdrp->dnh_netmask, &hdrp->dnh_netmask, sizeof (ipaddr_t)); - nhconvert(&hdrp->dnh_magic, &hdrp->dnh_magic, sizeof (uint32_t)); - nhconvert_rec(&hdrp->dnh_temp); - - if (hash) { - for (i = 0; i < DN_CIDHASHSZ; i++) { - nhconvert(&hdrp->dnh_cidhash[i][0], - &hdrp->dnh_cidhash[i][0], sizeof (dn_recid_t)); - nhconvert(&hdrp->dnh_cidhash[i][1], - &hdrp->dnh_cidhash[i][1], sizeof (dn_recid_t)); - } - } -#endif -} - -/* - * Read the dn_filerec_t identified by `recid' from open container `fd' - * into `rec'. Returns 0 on success, -1 on failure (errno is set). - */ -static int -read_rec(int fd, dn_filerec_t *rec, dn_recid_t recid) -{ - if (pnread(fd, rec, sizeof (*rec), RECID2OFFSET(recid)) == -1) - return (-1); - - nhconvert_rec(rec); - return (0); -} - -/* - * Write the dn_filerec_t `rec' identified by `recid' into the open - * container `fd'. Returns 0 on success, -1 on failure (errno is set). - */ -static int -write_rec(int fd, dn_filerec_t *rec, dn_recid_t recid) -{ - int retval; - - nhconvert_rec(rec); - retval = pnwrite(fd, rec, sizeof (*rec), RECID2OFFSET(recid)); - nhconvert_rec(rec); - return (retval); -} - -/* - * Read the dn_header_t from the open container `fd' into the dn_header_t - * pointed to by `hdrp'; if `hash' is not set, then skip reading the - * dn_header_t hash chains. Returns 0 on success, -1 on failure (errno is - * set). - */ -static int -read_header(int fd, dn_header_t *hdrp, boolean_t hash) -{ - size_t size; - - size = hash ? sizeof (dn_header_t) : offsetof(dn_header_t, dnh_cidhash); - if (pnread(fd, hdrp, size, 0) == -1) - return (-1); - - nhconvert_header(hdrp, hash); - return (0); -} - -/* - * Write the dn_header_t pointed to by `hdrp' into open container `fd'. - * Returns 0 on success, -1 on failure (errno is set). - */ -static int -write_header(int fd, dn_header_t *hdrp) -{ - int retval; - - nhconvert_header(hdrp, B_TRUE); - retval = pnwrite(fd, hdrp, sizeof (dn_header_t), 0); - nhconvert_header(hdrp, B_TRUE); - return (retval); -} - -/* - * Read in the head of the `cidhash' hash chain from open container `fd' - * into `recid_headp', using image `image'. Returns 0 on success, -1 on - * failure (errno is set). - */ -static int -read_hashhead(int fd, dn_recid_t *recid_headp, uint16_t cidhash, uchar_t image) -{ - if (pnread(fd, recid_headp, sizeof (dn_recid_t), - offsetof(dn_header_t, dnh_cidhash[cidhash][image])) == -1) - return (-1); - - nhconvert(recid_headp, recid_headp, sizeof (dn_recid_t)); - return (0); -} - -/* - * Write out the head of the `cidhash' hash chain into open container `fd' - * from `recid_head', using image `image'. Returns 0 on success, -1 on - * failure (errno is set). - */ -static int -write_hashhead(int fd, dn_recid_t recid_head, uint16_t cidhash, uchar_t image) -{ - nhconvert(&recid_head, &recid_head, sizeof (dn_recid_t)); - return (pnwrite(fd, &recid_head, sizeof (dn_recid_t), - offsetof(dn_header_t, dnh_cidhash[cidhash][image]))); -} - -/* - * Get the byte `offset' bytes into open file `fd', and store in `bytep'. - * Returns a DSVC_* return code. - */ -static int -getabyte(int fd, off_t offset, uchar_t *bytep) -{ - switch (pread(fd, bytep, 1, offset)) { - case 1: - return (DSVC_SUCCESS); - case -1: - return (syserr_to_dsvcerr(errno)); - default: - break; - } - - return (DSVC_INTERNAL); -} - -/* - * Set the byte `offset' bytes into open file `fd' to `byte'. Returns a - * DSVC_* return code. - */ -static int -setabyte(int fd, off_t offset, uchar_t byte) -{ - switch (pwrite(fd, &byte, 1, offset)) { - case 1: - return (DSVC_SUCCESS); - case -1: - return (syserr_to_dsvcerr(errno)); - default: - break; - } - - return (DSVC_INTERNAL); -} diff --git a/usr/src/lib/libdhcpsvc/modules/binfiles/dhcp_network.h b/usr/src/lib/libdhcpsvc/modules/binfiles/dhcp_network.h deleted file mode 100644 index 80e80da731..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/binfiles/dhcp_network.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _DHCP_NETWORK_H -#define _DHCP_NETWORK_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Implementation-specific data structures and constants for the binary - * files dhcp_network container. These structures are subject to change at - * any time. - */ - -#include <sys/types.h> -#include <dhcp_svc_public.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * The client id hash size is based on the idea that, given a perfect hash, - * the hash chain length shouldn't be more than the number of buckets. - * Given a worst case network with 2^24 addresses, that means we should - * have 4096 buckets; we shrink this by a bit to make the dn_header_t size - * be a power of two (32768 bytes). Note that we assert that a header is - * this size in open_dn(). - */ -#define DN_CIDHASHSZ 4056 -#define DN_MAGIC 0x0d6c92e4 /* "dhcpnet" in hexadecimal world */ -#define DN_NOIMAGE 0x80 /* image field not in use */ -#define DN_NOREC 0x00000000 /* "no record" id value, must be zero */ -#define DN_TEMPREC 0xffffffff /* "temp record" id value */ -#define DN_HASHHEAD 0xfffffffe /* "hash chain head" id value */ - -typedef uint32_t dn_recid_t; /* record id type */ - -/* - * Macros to compute the record id for a record with address `addr' in a - * container with netmask `mask', and to convert a record id `recid' to its - * starting file offset within its container. Note that we reserve the - * record id value of 0 for DN_NOREC for reasons explained in open_dn(). - */ -#define RECID(addr, mask) ((dn_recid_t)(((addr) & ~(mask)) + 1)) -#define RECID2OFFSET(recid) \ - (((recid) == DN_TEMPREC) ? offsetof(dn_header_t, dnh_temp) : \ - (sizeof (dn_header_t) + ((off_t)sizeof (dn_filerec_t) * ((recid) - 1)))) - -/* - * What each dn_rec_t looks like on-disk -- contains the dn_rec_t, pointers - * to the previous and next dn_rec_t's on its client id hash. See the big - * theory statement in dhcp_network.c for a discussion on the redundant - * dn_recid_t's. - */ -typedef struct dn_filerec { - dn_recid_t rec_next[2]; /* id of next record in cidhash */ - dn_recid_t rec_prev[2]; /* id of prev record in cidhash */ - dn_rec_t rec_dn; /* actual dn_rec_t */ -} dn_filerec_t; - -/* - * Header atop each dhcp_network container -- contains some basic - * information about the container and an array of buckets to chain client - * id hashes from. See the big theory statement in dhcp_network.c for a - * discussion on the redundant dn_recid_t's and the concept of "images". - */ -typedef struct dn_header { - unsigned char dnh_version; /* container version */ - unsigned char dnh_dirty; /* container might be dirty */ - unsigned char dnh_image; /* container's active image */ - unsigned char dnh_tempimage; /* temporary record's image */ - uint32_t dnh_magic; /* container magic */ - ipaddr_t dnh_network; /* network number of table */ - ipaddr_t dnh_netmask; /* netmask of network number */ - dn_filerec_t dnh_temp; /* temporary record used in modify_dn */ - uint32_t dnh_checks; /* number of check_dn full runs */ - uint32_t dnh_errors; /* number of errors caught */ - uint32_t dnh_pad[4]; /* for future use */ - - /* - * Note: read_header() assumes that dnh_cidhash is the last member. - */ - dn_recid_t dnh_cidhash[DN_CIDHASHSZ][2]; /* cid hash buckets */ -} dn_header_t; - -/* - * Per-instance state for each handle returned from open_dn. - */ -typedef struct dn_handle { - int dh_fd; /* fd for open file pointer */ - unsigned int dh_oflags; /* flags passed into open_dn */ - ipaddr_t dh_netmask; /* cached netmask of container */ -} dn_handle_t; - -#ifdef __cplusplus -} -#endif - -#endif /* _DHCP_NETWORK_H */ diff --git a/usr/src/lib/libdhcpsvc/modules/binfiles/dhcptab.c b/usr/src/lib/libdhcpsvc/modules/binfiles/dhcptab.c deleted file mode 100644 index 9c9cf5fd02..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/binfiles/dhcptab.c +++ /dev/null @@ -1,779 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This file contains public functions for managing the dhcptab container. - * For the semantics of these functions, please see the Enterprise DHCP - * Architecture Document. - * - * This module uses synchronization guarantees provided by dsvclockd(1M); - * please see $SRC/lib/libdhcpsvc/private/README.synch for details. - * - * Big Theory Statement for the SUNWbinfiles DHCP Table Module - * =========================================================== - * - * Since the dhcptab container does not have any performance-critical - * consumers, this module focuses on being simple and robust rather than - * fast. The on-disk structure consists of a minimal header followed by a - * list of dt_filerec_t's in no particular order. Note that the dt_rec_t's - * dt_value can be arbitrarily large, which means each dt_filerec_t is also - * of arbitrary size; we deal with this by storing the on-disk size of each - * record in the record itself. - * - * To meet our robustness requirements (see the Big Theory Statement in - * dhcp_network.c), each update operation does its work on a copy of the - * dhcptab, which is then atomically renamed to the name of the actual - * dhcptab upon completion (yes, this is *very slow*). To speed this up a - * little, we use mmap(2) to generate the copy, which is about twice as - * fast as using read(2)/write(2). - */ - -#include <unistd.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <dhcp_svc_public.h> -#include <sys/stat.h> -#include <sys/isa_defs.h> -#include <fcntl.h> -#include <stdlib.h> -#include <stddef.h> -#include <string.h> -#include <errno.h> -#include <stdio.h> -#include <alloca.h> - -#include "dhcptab.h" -#include "util.h" - -/* - * We compute the RECSIZE using the offset of `rec_dtval' rather than the - * sizeof (dt_filerec_t) so that we don't include any trailing structure - * padding in the size calculation. - */ -#define RECSIZE(rec) (offsetof(dt_filerec_t, rec_dtval) + ((rec).rec_dtvalsize)) - -static int read_header(int, dt_header_t *); -static int write_header(int, dt_header_t *); -static int read_rec(int, dt_filerec_t *, off_t); -static int write_rec(int, dt_filerec_t *, off_t); -static void dt2path(char *, size_t, const char *, const char *); -static boolean_t record_match(const dt_rec_t *, const dt_rec_t *, uint_t); -static int find_dt(int, uint_t, uint_t, int, const dt_rec_t *, - dt_rec_list_t **, uint_t *); - -int -open_dt(void **handlep, const char *location, uint_t flags) -{ - dt_handle_t *dhp; - dt_header_t header = { 0 }; - char dtpath[MAXPATHLEN]; - int retval; - int fd; - - dhp = malloc(sizeof (dt_handle_t)); - if (dhp == NULL) - return (DSVC_NO_MEMORY); - - dhp->dh_oflags = flags; - (void) strlcpy(dhp->dh_location, location, MAXPATHLEN); - - dt2path(dtpath, MAXPATHLEN, location, ""); - retval = open_file(dtpath, flags, &fd); - if (retval != DSVC_SUCCESS) { - free(dhp); - return (retval); - } - - if (flags & DSVC_CREATE) { - /* - * We just created the per-network container; initialize - * the header and put it out on disk. - */ - header.dth_magic = DT_MAGIC; - header.dth_version = DSVC_CONVER; - - if (write_header(fd, &header) == -1) { - retval = syserr_to_dsvcerr(errno); - (void) close(fd); - (void) remove_dt(location); - (void) close_dt((void **)&dhp); - return (retval); - } - } else { - /* - * Container already exists; sanity check against the - * header that's on-disk. - */ - if (read_header(fd, &header) == -1) { - retval = syserr_to_dsvcerr(errno); - (void) close(fd); - (void) close_dt((void **)&dhp); - return (retval); - } - - if (header.dth_magic != DT_MAGIC || - header.dth_version != DSVC_CONVER) { - (void) close(fd); - (void) close_dt((void **)&dhp); - return (DSVC_INTERNAL); - } - } - - (void) close(fd); - *handlep = dhp; - return (DSVC_SUCCESS); -} - -int -close_dt(void **handlep) -{ - free(*handlep); - return (DSVC_SUCCESS); -} - -int -remove_dt(const char *location) -{ - char dtpath[MAXPATHLEN]; - - dt2path(dtpath, MAXPATHLEN, location, ""); - if (unlink(dtpath) == -1) - return (syserr_to_dsvcerr(errno)); - - return (DSVC_SUCCESS); -} - -int -lookup_dt(void *handle, boolean_t partial, uint_t query, int count, - const dt_rec_t *targetp, dt_rec_list_t **recordsp, uint_t *nrecordsp) -{ - int fd; - int retval; - char dtpath[MAXPATHLEN]; - dt_handle_t *dhp = (dt_handle_t *)handle; - - if ((dhp->dh_oflags & DSVC_READ) == 0) - return (DSVC_ACCESS); - - dt2path(dtpath, MAXPATHLEN, dhp->dh_location, ""); - fd = open(dtpath, O_RDONLY); - if (fd == -1) - return (syserr_to_dsvcerr(errno)); - - retval = find_dt(fd, partial ? FIND_PARTIAL : 0, query, count, targetp, - recordsp, nrecordsp); - - (void) close(fd); - return (retval); -} - -/* - * Internal version of lookup_dt() used by lookup_dt(), modify_dt(), - * add_dt(), and delete_dt(); same semantics as lookup_dt() except that the - * `partial' argument has been generalized into a `flags' field and the - * handle has been turned into a file descriptor. - */ -static int -find_dt(int fd, uint_t flags, uint_t query, int count, - const dt_rec_t *targetp, dt_rec_list_t **recordsp, uint_t *nrecordsp) -{ - int retval = DSVC_SUCCESS; - uint_t nrecords = 0, n = 0; - dt_rec_t *recordp; - dt_rec_list_t *records, *new_records; - dt_header_t header; - dt_filerec_t rec; - off_t recoff = sizeof (dt_header_t); - struct stat st; - - if (read_header(fd, &header) == -1) - return (syserr_to_dsvcerr(errno)); - - if (fstat(fd, &st) == -1) - return (DSVC_INTERNAL); - - records = NULL; - for (; (recoff < st.st_size) && (count < 0 || nrecords < count); - n++, recoff += RECSIZE(rec)) { - - if (read_rec(fd, &rec, recoff) == -1) { - retval = syserr_to_dsvcerr(errno); - break; - } - - /* - * See if we've got a match... - */ - if (!record_match(&rec.rec_dt, targetp, query)) - continue; - - /* - * Caller just wants a count of the number of matching - * records, not the records themselves; continue. - */ - if (recordsp == NULL) { - nrecords++; - continue; - } - - /* - * Allocate record; if FIND_POSITION flag is set, then - * we need to allocate an extended (dt_recpos_t) record. - */ - if (flags & FIND_POSITION) - recordp = malloc(sizeof (dt_recpos_t)); - else - recordp = malloc(sizeof (dt_rec_t)); - - if (recordp == NULL) { - if ((flags & FIND_PARTIAL) == 0) - retval = DSVC_NO_MEMORY; - break; - } - /* - * Fill in record; do a structure copy from our automatic - * record. If FIND_POSITION flag is on, pass back - * additional location information. - */ - *recordp = rec.rec_dt; - recordp->dt_value = malloc(rec.rec_dtvalsize); - if (recordp->dt_value == NULL) { - free_dtrec(recordp); - if ((flags & FIND_PARTIAL) == 0) - retval = DSVC_NO_MEMORY; - break; - } - if (pnread(fd, recordp->dt_value, rec.rec_dtvalsize, - recoff + offsetof(dt_filerec_t, rec_dtval)) == -1) { - if ((flags & FIND_PARTIAL) == 0) - retval = syserr_to_dsvcerr(errno); - free_dtrec(recordp); - break; - } - - if (flags & FIND_POSITION) { - ((dt_recpos_t *)recordp)->dtp_off = recoff; - ((dt_recpos_t *)recordp)->dtp_size = RECSIZE(rec); - } - - /* - * Chuck the record on the list and up the counter. - */ - new_records = add_dtrec_to_list(recordp, records); - if (new_records == NULL) { - free_dtrec(recordp); - if ((flags & FIND_PARTIAL) == 0) - retval = DSVC_NO_MEMORY; - break; - } - - records = new_records; - nrecords++; - } - - if (retval == DSVC_SUCCESS) { - *nrecordsp = nrecords; - if (recordsp != NULL) - *recordsp = records; - return (DSVC_SUCCESS); - } - - if (records != NULL) - free_dtrec_list(records); - - return (retval); -} - -/* - * Compares `dtp' to the target `targetp', using `query' to decide what - * fields to compare. Returns B_TRUE if `dtp' matches `targetp', B_FALSE - * if not. - */ -static boolean_t -record_match(const dt_rec_t *dtp, const dt_rec_t *targetp, uint_t query) -{ - if (DSVC_QISEQ(query, DT_QTYPE) && targetp->dt_type != dtp->dt_type) - return (B_FALSE); - if (DSVC_QISNEQ(query, DT_QTYPE) && targetp->dt_type == dtp->dt_type) - return (B_FALSE); - - if (DSVC_QISEQ(query, DT_QKEY) && - strcmp(targetp->dt_key, dtp->dt_key) != 0) - return (B_FALSE); - - if (DSVC_QISNEQ(query, DT_QKEY) && - strcmp(targetp->dt_key, dtp->dt_key) == 0) - return (B_FALSE); - - return (B_TRUE); -} - -int -add_dt(void *handle, dt_rec_t *addp) -{ - unsigned int found; - int query; - int fd, newfd; - int retval; - dt_filerec_t *rec; - struct stat st; - dt_handle_t *dhp = (dt_handle_t *)handle; - char newpath[MAXPATHLEN], dtpath[MAXPATHLEN]; - - if ((dhp->dh_oflags & DSVC_WRITE) == 0) - return (DSVC_ACCESS); - - dt2path(dtpath, MAXPATHLEN, dhp->dh_location, ""); - fd = open(dtpath, O_RDWR); - if (fd == -1) - return (syserr_to_dsvcerr(errno)); - - /* - * Make sure the record wasn't created when we weren't looking. - */ - DSVC_QINIT(query); - DSVC_QEQ(query, DT_QKEY|DT_QTYPE); - - retval = find_dt(fd, 0, query, 1, addp, NULL, &found); - if (retval != DSVC_SUCCESS) { - (void) close(fd); - return (retval); - } - if (found != 0) { - (void) close(fd); - return (DSVC_EXISTS); - } - - /* - * Make a new copy of the dhcptab with the new record appended. - * Once done, atomically rename the new dhcptab to the old name. - */ - if (fstat(fd, &st) == -1) { - (void) close(fd); - return (DSVC_INTERNAL); - } - - dt2path(newpath, MAXPATHLEN, dhp->dh_location, ".new"); - (void) unlink(newpath); - newfd = open(newpath, O_WRONLY|O_CREAT|O_EXCL, 0644); - if (newfd == -1) { - retval = syserr_to_dsvcerr(errno); - goto out; - } - - retval = copy_range(fd, 0, newfd, 0, st.st_size); - if (retval != DSVC_SUCCESS) - goto out; - - addp->dt_sig = gensig(); - rec = alloca(sizeof (dt_filerec_t) + strlen(addp->dt_value)); - rec->rec_dt = *addp; - rec->rec_dtvalsize = strlen(addp->dt_value) + 1; - (void) strcpy(rec->rec_dtval, addp->dt_value); - - if (write_rec(newfd, rec, st.st_size) == -1) { - retval = syserr_to_dsvcerr(errno); - goto out; - } - - /* - * Note: we close these descriptors before the rename(2) (rather - * than just having the `out:' label clean them up) to save NFS - * some work (otherwise, NFS has to save `dtpath' to an alternate - * name since its vnode would still be active). - */ - (void) close(fd); - (void) close(newfd); - - if (rename(newpath, dtpath) == -1) - retval = syserr_to_dsvcerr(errno); - - return (retval); -out: - (void) close(fd); - (void) close(newfd); - (void) unlink(newpath); - return (retval); -} - -int -modify_dt(void *handle, const dt_rec_t *origp, dt_rec_t *newp) -{ - unsigned int found; - int query; - int fd, newfd; - int retval; - dt_filerec_t *rec; - off_t recoff, recnext; - dt_rec_list_t *reclist; - struct stat st; - dt_handle_t *dhp = (dt_handle_t *)handle; - char newpath[MAXPATHLEN], dtpath[MAXPATHLEN]; - - if ((dhp->dh_oflags & DSVC_WRITE) == 0) - return (DSVC_ACCESS); - - dt2path(dtpath, MAXPATHLEN, dhp->dh_location, ""); - fd = open(dtpath, O_RDWR); - if (fd == -1) - return (syserr_to_dsvcerr(errno)); - - DSVC_QINIT(query); - DSVC_QEQ(query, DT_QKEY|DT_QTYPE); - - /* - * If we're changing the key for this record, make sure the key - * we're changing to doesn't already exist. - */ - if (origp->dt_type != newp->dt_type || - strcmp(origp->dt_key, newp->dt_key) != 0) { - retval = find_dt(fd, 0, query, 1, newp, NULL, &found); - if (retval != DSVC_SUCCESS) { - (void) close(fd); - return (retval); - } - if (found != 0) { - (void) close(fd); - return (DSVC_EXISTS); - } - } - - /* - * Fetch the original again to make sure it didn't go stale. - */ - retval = find_dt(fd, FIND_POSITION, query, 1, origp, &reclist, &found); - if (retval != DSVC_SUCCESS) { - (void) close(fd); - return (retval); - } - if (found == 0) { - (void) close(fd); - return (DSVC_NOENT); - } - - if (reclist->dtl_rec->dt_sig != origp->dt_sig) { - (void) close(fd); - free_dtrec_list(reclist); - return (DSVC_COLLISION); - } - - recoff = ((dt_recpos_t *)reclist->dtl_rec)->dtp_off; - recnext = recoff + ((dt_recpos_t *)reclist->dtl_rec)->dtp_size; - - free_dtrec_list(reclist); - - /* - * Make a new copy of the dhcptab, sans the record we're modifying, - * then append modified record at the end. Once done, atomically - * rename the new dhcptab to the old name. - */ - if (fstat(fd, &st) == -1) { - (void) close(fd); - return (DSVC_INTERNAL); - } - - dt2path(newpath, MAXPATHLEN, dhp->dh_location, ".new"); - (void) unlink(newpath); - newfd = open(newpath, O_WRONLY|O_CREAT|O_EXCL, 0644); - if (newfd == -1) { - retval = syserr_to_dsvcerr(errno); - goto out; - } - - retval = copy_range(fd, 0, newfd, 0, recoff); - if (retval != DSVC_SUCCESS) - goto out; - - retval = copy_range(fd, recnext, newfd, recoff, st.st_size - recnext); - if (retval != DSVC_SUCCESS) - goto out; - - newp->dt_sig = origp->dt_sig + 1; - rec = alloca(sizeof (dt_filerec_t) + strlen(newp->dt_value)); - rec->rec_dt = *newp; - rec->rec_dtvalsize = strlen(newp->dt_value) + 1; - (void) strcpy(rec->rec_dtval, newp->dt_value); - - if (write_rec(newfd, rec, st.st_size - (recnext - recoff)) == -1) { - retval = syserr_to_dsvcerr(errno); - goto out; - } - - /* - * See comment in add_dt() regarding the next two lines. - */ - (void) close(fd); - (void) close(newfd); - - if (rename(newpath, dtpath) == -1) - retval = syserr_to_dsvcerr(errno); - - return (retval); -out: - (void) close(fd); - (void) close(newfd); - (void) unlink(newpath); - return (retval); -} - -int -delete_dt(void *handle, const dt_rec_t *delp) -{ - unsigned int found; - int query; - int fd, newfd; - int retval; - off_t recoff, recnext; - dt_rec_list_t *reclist; - struct stat st; - dt_handle_t *dhp = (dt_handle_t *)handle; - char newpath[MAXPATHLEN], dtpath[MAXPATHLEN]; - - if ((dhp->dh_oflags & DSVC_WRITE) == 0) - return (DSVC_ACCESS); - - dt2path(dtpath, MAXPATHLEN, dhp->dh_location, ""); - fd = open(dtpath, O_RDWR); - if (fd == -1) - return (syserr_to_dsvcerr(errno)); - - /* - * Make sure the record exists and also that the signatures match; - * if `delp->dt_sig' is zero, then skip signature comparison (this - * is so one can delete records that were not looked up). - */ - DSVC_QINIT(query); - DSVC_QEQ(query, DT_QKEY|DT_QTYPE); - - retval = find_dt(fd, FIND_POSITION, query, 1, delp, &reclist, &found); - if (retval != DSVC_SUCCESS) { - (void) close(fd); - return (retval); - } - if (found == 0) { - (void) close(fd); - return (DSVC_NOENT); - } - - if (delp->dt_sig != 0 && reclist->dtl_rec->dt_sig != delp->dt_sig) { - (void) close(fd); - free_dtrec_list(reclist); - return (DSVC_COLLISION); - } - - recoff = ((dt_recpos_t *)reclist->dtl_rec)->dtp_off; - recnext = recoff + ((dt_recpos_t *)reclist->dtl_rec)->dtp_size; - - free_dtrec_list(reclist); - - /* - * Make a new copy of the dhcptab, sans the record we're deleting. - * Once done, atomically rename the new dhcptab to the old name. - */ - if (fstat(fd, &st) == -1) { - (void) close(fd); - return (DSVC_INTERNAL); - } - - dt2path(newpath, MAXPATHLEN, dhp->dh_location, ".new"); - (void) unlink(newpath); - newfd = open(newpath, O_WRONLY|O_CREAT|O_EXCL, 0644); - if (newfd == -1) { - retval = syserr_to_dsvcerr(errno); - goto out; - } - - retval = copy_range(fd, 0, newfd, 0, recoff); - if (retval != DSVC_SUCCESS) - goto out; - - retval = copy_range(fd, recnext, newfd, recoff, st.st_size - recnext); - if (retval != DSVC_SUCCESS) - goto out; - - /* - * See comment in add_dt() regarding the next two lines. - */ - (void) close(fd); - (void) close(newfd); - - if (rename(newpath, dtpath) == -1) - retval = syserr_to_dsvcerr(errno); - - return (retval); -out: - (void) close(fd); - (void) close(newfd); - (void) unlink(newpath); - return (retval); -} - -int -list_dt(const char *location, char ***listppp, uint_t *countp) -{ - char dtpath[MAXPATHLEN]; - char **listpp; - - if (access(location, F_OK|R_OK) == -1) { - switch (errno) { - case EACCES: - case EPERM: - return (DSVC_ACCESS); - case ENOENT: - return (DSVC_NO_LOCATION); - default: - break; - } - return (DSVC_INTERNAL); - } - - dt2path(dtpath, MAXPATHLEN, location, ""); - if (access(dtpath, F_OK|R_OK) == -1) { - *countp = 0; - *listppp = NULL; - return (DSVC_SUCCESS); - } - - listpp = malloc(sizeof (char **)); - if (listpp == NULL) - return (DSVC_NO_MEMORY); - listpp[0] = strdup(DT_DHCPTAB); - if (listpp[0] == NULL) { - free(listpp); - return (DSVC_NO_MEMORY); - } - - *listppp = listpp; - *countp = 1; - return (DSVC_SUCCESS); -} - -/* - * Given a buffer `path' of `pathlen' bytes, fill it in with a path to the - * dhcptab in directory `dir' with a suffix of `suffix'. - */ -static void -dt2path(char *path, size_t pathlen, const char *dir, const char *suffix) -{ - (void) snprintf(path, pathlen, "%s/SUNWbinfiles%u_%s%s", dir, - DSVC_CONVER, DT_DHCPTAB, suffix); -} - -/* - * Convert dt_header_t pointed to by `headerp' from native (host) to - * network order or the other way. - */ -/* ARGSUSED */ -static void -nhconvert_header(dt_header_t *headerp) -{ -#ifdef _LITTLE_ENDIAN - nhconvert(&headerp->dth_magic, &headerp->dth_magic, sizeof (uint32_t)); -#endif -} - -/* - * Convert dt_filerec_t pointed to by `rec' from native (host) to network - * order or the other way. - */ -/* ARGSUSED */ -static void -nhconvert_rec(dt_filerec_t *rec) -{ -#ifdef _LITTLE_ENDIAN - dt_rec_t *dtp = &rec->rec_dt; - - nhconvert(&rec->rec_dtvalsize, &rec->rec_dtvalsize, sizeof (uint32_t)); - nhconvert(&dtp->dt_sig, &dtp->dt_sig, sizeof (uint64_t)); -#endif -} - -/* - * Read the dt_header_t in the container at open file `fd' into the header - * pointed to by `headerp'. Returns 0 on success, -1 on failure (errno is - * set). - */ -static int -read_header(int fd, dt_header_t *headerp) -{ - if (pnread(fd, headerp, sizeof (dt_header_t), 0) == -1) - return (-1); - - nhconvert_header(headerp); - return (0); -} - -/* - * Write the dt_header_t pointed to by `headerp' to the container at open - * file `fd'. Returns 0 on success, -1 on failure (errno is set). - */ -static int -write_header(int fd, dt_header_t *headerp) -{ - int retval; - - nhconvert_header(headerp); - retval = pnwrite(fd, headerp, sizeof (dt_header_t), 0); - nhconvert_header(headerp); - return (retval); -} - - -/* - * Read the dt_filerec_t in the container from offset `recoff' in the - * container at open file `fd'. Note that this only returns the fixed - * sized part of the dt_filerec_t; the caller must retrieve `rev_dtval' on - * their own. Returns 0 on success, -1 on failure (errno is set). - */ -static int -read_rec(int fd, dt_filerec_t *rec, off_t recoff) -{ - if (pnread(fd, rec, sizeof (dt_filerec_t), recoff) == -1) - return (-1); - - nhconvert_rec(rec); - return (0); -} - -/* - * Write the dt_filerec_t pointed to be `rec' to offset `recoff' in the - * container at open file `fd'. Returns 0 on success, -1 on failure (errno - * is set). - */ -static int -write_rec(int fd, dt_filerec_t *rec, off_t recoff) -{ - int retval; - size_t recsize = RECSIZE(*rec); - - nhconvert_rec(rec); - retval = pnwrite(fd, rec, recsize, recoff); - nhconvert_rec(rec); - return (retval); -} diff --git a/usr/src/lib/libdhcpsvc/modules/binfiles/dhcptab.h b/usr/src/lib/libdhcpsvc/modules/binfiles/dhcptab.h deleted file mode 100644 index 887de8d440..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/binfiles/dhcptab.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _DHCPTAB_H -#define _DHCPTAB_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Implementation-specific data structures and constants for the binary - * dhcptab container. These structures are subject to change at any time. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/types.h> -#include <dhcp_svc_public.h> - -#define DT_NOREC 0 /* "no record" id value */ -#define DT_MAGIC 0x0d6c94ab /* "dhcptab" in a hexadecimal world */ - -/* - * Constants for use with find_dt - */ -#define FIND_PARTIAL 0x0001 /* allow partial success */ -#define FIND_POSITION 0x0002 /* return dt_recpos_t's */ - -/* - * Header atop the dhcptab container -- contains some basic information - * about the container for sanity-checking purposes. - */ -typedef struct dt_header { - unsigned char dth_version; /* container version */ - unsigned char dth_align[3]; /* ensure binary compatibility */ - uint32_t dth_magic; /* magic for sanity check */ - uint32_t dth_pad[4]; /* for future use */ -} dt_header_t; - -/* - * What each dt_rec_t looks like on-disk -- note that we cannot just write - * dt_rec_t's because the `dt_value' field can be arbitrarily large. - * Instead, write out the dt_rec_t structure followed by the variable-size - * `rec_dtval' array which will contain the current value of `dt_value'. - * Since `rec_dtval' is of variable size, we must explicitly keep track of - * its length via `rec_dtvalsize'. - */ -typedef struct dt_filerec { - dt_rec_t rec_dt; /* actual dt_rec_t */ - uint32_t rec_dtvalsize; /* total size of rec_dtval */ - char rec_dtval[1]; /* dt_value field from dt_rec_t */ -} dt_filerec_t; - -/* - * Per-record state describing the underlying record, including its - * position on-disk; these are returned instead of dt_rec_t's when find_dt - * is called with FIND_POSITION set. Note that for this to work, the - * dt_rec_t must be the first member. - */ -typedef struct dt_recpos { - dt_rec_t dtp_rec; /* traditional dt_rec_t */ - size_t dtp_size; /* its size in the file */ - off_t dtp_off; /* its starting offset in the file */ -} dt_recpos_t; - -/* - * Per-instance state for each handle returned from open_dt - */ -typedef struct dt_handle { - unsigned int dh_oflags; /* flags passed into open_dt */ - char dh_location[MAXPATHLEN]; /* location of container */ -} dt_handle_t; - -#ifdef __cplusplus -} -#endif - -#endif /* _DHCPTAB_H */ diff --git a/usr/src/lib/libdhcpsvc/modules/binfiles/general.c b/usr/src/lib/libdhcpsvc/modules/binfiles/general.c deleted file mode 100644 index 44702471b1..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/binfiles/general.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This file contains public API functions for module-level tasks. For the - * semantics of these functions, please see the Enterprise DHCP - * Architecture Document. - */ - -#include <assert.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <libgen.h> -#include <errno.h> -#include <dhcp_svc_public.h> - -#include "util.h" - -/* - * This symbol and its value tell the private layer that it must provide - * synchronization guarantees via dsvclockd(1M) before calling our *_dn() - * and *_dt() methods. Please see $SRC/lib/libdhcpsvc/private/README.synch - */ -int dsvc_synchtype = DSVC_SYNCH_DSVCD; - -int -status(const char *location) -{ - if (location != NULL) { - if (access(location, F_OK|R_OK) == -1) { - if (errno == ENOENT) - return (DSVC_NO_LOCATION); - return (syserr_to_dsvcerr(errno)); - } - } - return (DSVC_SUCCESS); -} - -int -version(int *vp) -{ - *vp = DSVC_PUBLIC_VERSION; - return (DSVC_SUCCESS); -} - -int -mklocation(const char *directory) -{ - if (mkdirp(directory, 0755) == -1) { - switch (errno) { - case ENAMETOOLONG: - case ENOTDIR: - return (DSVC_INVAL); - - case EEXIST: - return (DSVC_EXISTS); - - case EROFS: - case EPERM: - case EACCES: - return (DSVC_ACCESS); - - default: - return (DSVC_INTERNAL); - } - } - - return (DSVC_SUCCESS); -} - -int -mkloctoken(const char *location, char *token, size_t tokensize) -{ - assert(tokensize >= MAXPATHLEN); - if (realpath(location, token) == NULL) - return (syserr_to_dsvcerr(errno)); - - return (DSVC_SUCCESS); -} diff --git a/usr/src/lib/libdhcpsvc/modules/binfiles/i386/Makefile b/usr/src/lib/libdhcpsvc/modules/binfiles/i386/Makefile deleted file mode 100644 index 83743d4678..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/binfiles/i386/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2000 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/modules/binfiles/i386/Makefile - -include ../Makefile.com - -install: all $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/libdhcpsvc/modules/binfiles/mapfile-vers b/usr/src/lib/libdhcpsvc/modules/binfiles/mapfile-vers deleted file mode 100644 index b9a70e7675..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/binfiles/mapfile-vers +++ /dev/null @@ -1,65 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -$mapfile_version 2 - -SYMBOL_VERSION SUNWprivate_1.1 { - global: - add_dn; - add_dt; - close_dn; - close_dt; - delete_dn; - delete_dt; - dsvc_synchtype; - list_dn; - list_dt; - lookup_dn; - lookup_dt; - mklocation; - modify_dn; - modify_dt; - open_dn; - open_dt; - remove_dn; - remove_dt; - status; - version; - local: - *; -}; diff --git a/usr/src/lib/libdhcpsvc/modules/binfiles/sparc/Makefile b/usr/src/lib/libdhcpsvc/modules/binfiles/sparc/Makefile deleted file mode 100644 index d35f5d6de8..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/binfiles/sparc/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2000 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/modules/binfiles/sparc/Makefile - -include ../Makefile.com - -install: all $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/libdhcpsvc/modules/binfiles/tools/Makefile b/usr/src/lib/libdhcpsvc/modules/binfiles/tools/Makefile deleted file mode 100644 index 0e99ba7558..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/binfiles/tools/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2000 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/modules/binfiles/tools/Makefile -# - -PROG = printnet - -include $(SRC)/cmd/Makefile.cmd - -LDLIBS = -lnsl -CFLAGS += -D_FILE_OFFSET_BITS=64 - -.KEEP_STATE: - -all: $(PROG) - -clean: - -install: all - @$(ECHO) "Nothing installed" - -lint: lint_PROG - -include $(SRC)/cmd/Makefile.targ diff --git a/usr/src/lib/libdhcpsvc/modules/binfiles/tools/printnet.c b/usr/src/lib/libdhcpsvc/modules/binfiles/tools/printnet.c deleted file mode 100644 index 7d5687fd2c..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/binfiles/tools/printnet.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Print SUNWbinfiles DHCP network containers. - */ - -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <stdio.h> -#include <fcntl.h> -#include <errno.h> -#include <string.h> -#include <stddef.h> -#include <sys/socket.h> -#include "../dhcp_network.h" - -static void print_hashes(int, dn_header_t); - -int -main(int argc, char **argv) -{ - int confd; - dn_header_t header; - char netmask[INET_ADDRSTRLEN], network[INET_ADDRSTRLEN]; - struct in_addr in_addr; - unsigned int i; - - if (argc < 2) { - (void) fprintf(stderr, "usage: %s container [container ...]\n", - argv[0]); - return (EXIT_FAILURE); - } - - for (i = 1; argv[i] != NULL; i++) { - confd = open(argv[i], O_RDONLY); - if (confd == -1) { - (void) fprintf(stderr, "%s: cannot open container " - "`%s': %s\n", argv[0], argv[i], strerror(errno)); - continue; - } - - if (read(confd, &header, sizeof (header)) != sizeof (header) || - header.dnh_magic != DN_MAGIC) { - (void) fprintf(stderr, "%s: container `%s' is not a " - "binfiles network container\n", argv[0], argv[i]); - continue; - } - - (void) printf("binfiles network container `%s':\n", argv[i]); - - in_addr.s_addr = header.dnh_network; - (void) inet_ntop(AF_INET, &in_addr, network, INET_ADDRSTRLEN); - in_addr.s_addr = header.dnh_netmask; - (void) inet_ntop(AF_INET, &in_addr, netmask, INET_ADDRSTRLEN); - - (void) printf("%12s: %s\n", "network", network); - (void) printf("%12s: %s\n", "netmask", netmask); - (void) printf("%12s: %d\n", "dirtybit", header.dnh_dirty); - (void) printf("%12s: %d\n", "version", header.dnh_version); - (void) printf("%12s: %d\n", "active image", header.dnh_image); - (void) printf("%12s: %d\n", "temp image", header.dnh_tempimage); - (void) printf("%12s: %d\n", "checks", header.dnh_checks); - (void) printf("%12s: %d\n", "errors", header.dnh_errors); - print_hashes(confd, header); - (void) close(confd); - } - - return (EXIT_SUCCESS); -} - -static void -print_hashes(int confd, dn_header_t header) -{ - dn_filerec_t rec; - dn_recid_t recid; - unsigned int image, hash; - - for (hash = 0; hash < DN_CIDHASHSZ; hash++) { - for (image = 0; image < 2; image++) { - if (header.dnh_cidhash[hash][image] == DN_NOREC) - continue; - - (void) printf(" hash %4d/%d: ", hash, image); - recid = header.dnh_cidhash[hash][image]; - for (; recid != DN_NOREC; recid = rec.rec_next[image]) { - if (pread(confd, &rec, sizeof (dn_rec_t), - RECID2OFFSET(recid)) != sizeof (dn_rec_t)) { - (void) fprintf(stderr, "cannot read " - "recid %d: %s", recid, - strerror(errno)); - break; - } - (void) printf("%d<-[%d]->%d ", - rec.rec_prev[image], recid, - rec.rec_next[image]); - } - (void) printf("\n"); - } - } -} diff --git a/usr/src/lib/libdhcpsvc/modules/files/Makefile b/usr/src/lib/libdhcpsvc/modules/files/Makefile deleted file mode 100644 index 2225b9c4c6..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include $(SRC)/lib/Makefile.lib -SUBDIRS = $(MACH) -include ../../Makefile.subdirs diff --git a/usr/src/lib/libdhcpsvc/modules/files/Makefile.com b/usr/src/lib/libdhcpsvc/modules/files/Makefile.com deleted file mode 100644 index 51bc067f63..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files/Makefile.com +++ /dev/null @@ -1,47 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/modules/files/Makefile.com - -LIBRARY = ds_SUNWfiles.a -VERS = .1 -LOCOBJS = dhcptab.o dhcp_network.o general.o -OBJECTS = $(LOCOBJS) util.o - -# include library definitions -include $(SRC)/lib/libdhcpsvc/modules/Makefile.com - -SRCS = $(LOCOBJS:%.o=../%.c) $(UTILDIR)/util.c -LDLIBS += -lc -lnsl -linetutil -ldhcpsvc -lgen -CPPFLAGS += -D_FILE_OFFSET_BITS=64 -I$(UTILDIR) - -.KEEP_STATE: - -all: $(LIBS) - -# include library targets -include $(SRC)/lib/libdhcpsvc/modules/Makefile.targ diff --git a/usr/src/lib/libdhcpsvc/modules/files/dhcp_network.c b/usr/src/lib/libdhcpsvc/modules/files/dhcp_network.c deleted file mode 100644 index 898d2bf01b..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files/dhcp_network.c +++ /dev/null @@ -1,771 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This file contains public functions for managing DHCP network - * containers. For the semantics of these functions, please see the - * Enterprise DHCP Architecture Document. - */ - -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <stdlib.h> -#include <arpa/inet.h> -#include <sys/stat.h> -#include <string.h> -#include <errno.h> -#include <unistd.h> -#include <fcntl.h> -#include <alloca.h> -#include <dhcp_svc_public.h> -#include <dirent.h> -#include <libgen.h> -#include <libinetutil.h> -#include <sys/mman.h> - -#include "dhcp_network.h" -#include "util.h" - -static void net2path(char *, size_t, const char *, ipaddr_t, const char *); -static boolean_t record_match(char *[], dn_rec_t *, const dn_rec_t *, uint_t); -static int write_rec(int, dn_rec_t *, off_t); - -/* ARGSUSED */ -int -open_dn(void **handlep, const char *location, uint_t flags, - const struct in_addr *netp, const struct in_addr *maskp) -{ - char connet[INET_ADDRSTRLEN]; - char dnpath[MAXPATHLEN]; - unsigned int conver; - dn_handle_t *dhp; - FILE *fp; - int retval; - int i, nelems; - char nl; - struct in_addr net_nbo; - int fd; - - dhp = malloc(sizeof (dn_handle_t)); - if (dhp == NULL) - return (DSVC_NO_MEMORY); - - dhp->dh_net = netp->s_addr; - dhp->dh_oflags = flags; - (void) strlcpy(dhp->dh_location, location, MAXPATHLEN); - - net2path(dnpath, MAXPATHLEN, location, netp->s_addr, ""); - retval = open_file(dnpath, flags, &fd); - if (retval != DSVC_SUCCESS) { - free(dhp); - return (retval); - } - - fp = fdopen(fd, flags & DSVC_WRITE ? "r+" : "r"); - if (fp == NULL) { - (void) close(fd); - free(dhp); - return (DSVC_INTERNAL); - } - - if (flags & DSVC_CREATE) { - /* - * We just created the per-network container; put the - * header on for future use... - */ - net_nbo.s_addr = htonl(netp->s_addr); - (void) inet_ntop(AF_INET, &net_nbo, connet, INET_ADDRSTRLEN); - - for (i = 0; connet[i] != '\0'; i++) - if (connet[i] == '.') - connet[i] = '_'; - - retval = fprintf(fp, "# SUNWfiles%u_%s\n", DSVC_CONVER, connet); - if (retval < 0 || fflush(fp) == EOF) { - (void) fclose(fp); - (void) free(dhp); - return (DSVC_INTERNAL); - } - - (void) fprintf(fp, "#\n# Do NOT edit this file by hand -- use"); - (void) fprintf(fp, " pntadm(1M) or dhcpmgr(1M) instead\n#\n"); - } else { - /* - * Container already exists; sanity check against the - * header that's on-disk. - */ - nelems = fscanf(fp, "#%*1[ ]SUNWfiles%u_%15s%c", &conver, - connet, &nl); - - for (i = 0; connet[i] != '\0'; i++) - if (connet[i] == '_') - connet[i] = '.'; - - if (nelems != 3 || inet_addr(connet) != htonl(netp->s_addr) || - conver != DSVC_CONVER || nl != '\n') { - (void) fclose(fp); - (void) free(dhp); - return (DSVC_INTERNAL); - } - } - - (void) fclose(fp); - *handlep = dhp; - return (DSVC_SUCCESS); -} - -int -close_dn(void **handlep) -{ - free(*handlep); - return (DSVC_SUCCESS); -} - -int -remove_dn(const char *dir, const struct in_addr *netp) -{ - char dnpath[MAXPATHLEN]; - - net2path(dnpath, MAXPATHLEN, dir, netp->s_addr, ""); - if (unlink(dnpath) == -1) - return (syserr_to_dsvcerr(errno)); - - return (DSVC_SUCCESS); -} - -/* - * Internal version lookup routine used by both lookup_dn() and - * update_dn(); same semantics as lookup_dn() except that the `partial' - * argument has been generalized into a `flags' field. - */ -static int -find_dn(int fd, uint_t flags, uint_t query, int count, const dn_rec_t *targetp, - dn_rec_list_t **recordsp, uint_t *nrecordsp) -{ - int retval = DSVC_SUCCESS; - char *fields[DNF_FIELDS]; - uint_t nrecords; - dn_rec_t dn, *recordp; - dn_rec_list_t *records, *new_records; - unsigned int nfields; - struct stat st; - struct in_addr cip_nbo; - char *ent0, *ent, *entend; - char cip[INET_ADDRSTRLEN + 2]; - - /* - * Page the whole container into memory via mmap() so we can scan it - * quickly; map it MAP_PRIVATE so that we can change newlines to - * NULs without changing the actual container itself. - */ - if (fstat(fd, &st) == -1 || st.st_size < 1) - return (DSVC_INTERNAL); - - ent0 = mmap(0, st.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); - if (ent0 == MAP_FAILED) - return (DSVC_INTERNAL); - - /* - * NUL-terminate the last byte (which should be a newline) so that - * we can safely use string functions on the mapped container. - */ - ent0[st.st_size - 1] = '\0'; - - /* - * If we're searching by client IP address, then build a target - * string we can use to find it quickly. - */ - if (DSVC_QISEQ(query, DN_QCIP)) { - cip[0] = '\n'; - cip_nbo.s_addr = htonl(targetp->dn_cip.s_addr); - (void) inet_ntop(AF_INET, &cip_nbo, cip + 1, INET_ADDRSTRLEN); - (void) strlcat(cip, "|", sizeof (cip)); - } - - records = NULL; - ent = ent0; - for (nrecords = 0; count < 0 || nrecords < count; ent = entend + 1) { - /* - * Bail if we've reached the end of the container. - */ - if (ent - ent0 >= st.st_size) - break; - - /* - * If we're searching by client IP address, locate it - * quickly using strstr(3C); if we can't find it by this - * technique then it's not in the container. - */ - if (DSVC_QISEQ(query, DN_QCIP)) { - /* - * If we've already found the DN_QCIP record, bail. - */ - if (nrecords > 0) - break; - - ent = strstr(ent, cip); - if (ent == NULL) - break; - ent++; - } - - /* - * Find the end of the record and change it a NUL byte so - * that it is interpreted correctly with field_split() and - * record_match() below. If we can't find a trailing - * newline, then it must be the last record (whose newline - * we already changed to a NUL above). - */ - entend = strchr(ent, '\n'); - if (entend != NULL) - *entend = '\0'; - else - entend = &ent0[st.st_size - 1]; - - /* - * Skip pure comment lines; for now this just skips the - * header information at the top of the container. - */ - if (ent[0] == DNF_COMMENT_CHAR) - continue; - - /* - * Split the buffer up into DNF_FIELDS fields. - */ - nfields = field_split(ent, DNF_FIELDS, fields, "|"); - if (nfields < DNF_FIELDS) - continue; - - /* - * See if we've got a match, filling in dnf.dnf_rec as - * we go. If record_match() succeeds, dnf.dnf_rec will - * be completely filled in. - */ - if (!record_match(fields, &dn, targetp, query)) - continue; - - /* - * Caller just wants a count of the number of matching - * records, not the records themselves; continue. - */ - if (recordsp == NULL) { - nrecords++; - continue; - } - - /* - * Allocate record; if FIND_POSITION flag is set, then - * we need to allocate an extended (dn_recpos_t) record. - */ - if (flags & FIND_POSITION) - recordp = malloc(sizeof (dn_recpos_t)); - else - recordp = malloc(sizeof (dn_rec_t)); - - if (recordp == NULL) { - if ((flags & FIND_PARTIAL) == 0) - retval = DSVC_NO_MEMORY; - break; - } - - /* - * Fill in record; do a structure copy from our automatic - * dn. If FIND_POSITION flag is on, pass back additional - * position information. - */ - *recordp = dn; - if (flags & FIND_POSITION) { - ((dn_recpos_t *)recordp)->dnp_off = ent - ent0; - ((dn_recpos_t *)recordp)->dnp_size = entend - ent + 1; - } - - /* - * Chuck the record on the list; up the counter. - */ - new_records = add_dnrec_to_list(recordp, records); - if (new_records == NULL) { - free(recordp); - if ((flags & FIND_PARTIAL) == 0) - retval = DSVC_NO_MEMORY; - break; - } - - records = new_records; - nrecords++; - } - - (void) munmap(ent0, st.st_size); - - if (retval == DSVC_SUCCESS) { - *nrecordsp = nrecords; - if (recordsp != NULL) - *recordsp = records; - return (DSVC_SUCCESS); - } - - if (records != NULL) - free_dnrec_list(records); - - return (retval); -} - -int -lookup_dn(void *handle, boolean_t partial, uint_t query, int count, - const dn_rec_t *targetp, dn_rec_list_t **recordsp, uint_t *nrecordsp) -{ - int retval; - char dnpath[MAXPATHLEN]; - int fd; - dn_handle_t *dhp = (dn_handle_t *)handle; - - if ((dhp->dh_oflags & DSVC_READ) == 0) - return (DSVC_ACCESS); - - net2path(dnpath, MAXPATHLEN, dhp->dh_location, dhp->dh_net, ""); - fd = open(dnpath, O_RDONLY); - if (fd == -1) - return (syserr_to_dsvcerr(errno)); - - retval = find_dn(fd, partial ? FIND_PARTIAL : 0, query, count, targetp, - recordsp, nrecordsp); - - (void) close(fd); - return (retval); -} - -/* - * Compares the fields in fields[] agains the fields in target `targetp', - * using `query' to decide what fields to compare. Returns B_TRUE if `dnp' - * matches `targetp', B_FALSE if not. On success, `dnp' is completely - * filled in. - */ -static boolean_t -record_match(char *fields[], dn_rec_t *dnp, const dn_rec_t *targetp, - uint_t query) -{ - unsigned int qflags[] = { DN_QFDYNAMIC, DN_QFAUTOMATIC, DN_QFMANUAL, - DN_QFUNUSABLE, DN_QFBOOTP_ONLY }; - unsigned int flags[] = { DN_FDYNAMIC, DN_FAUTOMATIC, DN_FMANUAL, - DN_FUNUSABLE, DN_FBOOTP_ONLY }; - unsigned int i; - uint_t dn_cid_len; - - dnp->dn_cip.s_addr = ntohl(inet_addr(fields[DNF_CIP])); - if (DSVC_QISEQ(query, DN_QCIP) && - dnp->dn_cip.s_addr != targetp->dn_cip.s_addr) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QCIP) && - dnp->dn_cip.s_addr == targetp->dn_cip.s_addr) - return (B_FALSE); - - dnp->dn_lease = atoi(fields[DNF_LEASE]); - if (DSVC_QISEQ(query, DN_QLEASE) && targetp->dn_lease != dnp->dn_lease) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QLEASE) && targetp->dn_lease == dnp->dn_lease) - return (B_FALSE); - - /* - * We use dn_cid_len since dnp->dn_cid_len is of type uchar_t but - * hexascii_to_octet() expects an uint_t * - */ - dn_cid_len = DN_MAX_CID_LEN; - if (hexascii_to_octet(fields[DNF_CID], strlen(fields[DNF_CID]), - dnp->dn_cid, &dn_cid_len) != 0) - return (B_FALSE); - - dnp->dn_cid_len = dn_cid_len; - if (DSVC_QISEQ(query, DN_QCID) && - (dnp->dn_cid_len != targetp->dn_cid_len || - (memcmp(dnp->dn_cid, targetp->dn_cid, dnp->dn_cid_len) != 0))) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QCID) && - (dnp->dn_cid_len == targetp->dn_cid_len && - (memcmp(dnp->dn_cid, targetp->dn_cid, dnp->dn_cid_len) == 0))) - return (B_FALSE); - - dnp->dn_sip.s_addr = ntohl(inet_addr(fields[DNF_SIP])); - if (DSVC_QISEQ(query, DN_QSIP) && - dnp->dn_sip.s_addr != targetp->dn_sip.s_addr) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QSIP) && - dnp->dn_sip.s_addr == targetp->dn_sip.s_addr) - return (B_FALSE); - - unescape('|', fields[DNF_MACRO], dnp->dn_macro, sizeof (dnp->dn_macro)); - if (DSVC_QISEQ(query, DN_QMACRO) && - strcmp(targetp->dn_macro, dnp->dn_macro) != 0) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QMACRO) && - strcmp(targetp->dn_macro, dnp->dn_macro) == 0) - return (B_FALSE); - - dnp->dn_flags = atoi(fields[DNF_FLAGS]); - for (i = 0; i < sizeof (qflags) / sizeof (unsigned int); i++) { - if (DSVC_QISEQ(query, qflags[i]) && - (dnp->dn_flags & flags[i]) != - (targetp->dn_flags & flags[i])) - return (B_FALSE); - if (DSVC_QISNEQ(query, qflags[i]) && - (dnp->dn_flags & flags[i]) == - (targetp->dn_flags & flags[i])) - return (B_FALSE); - } - - dnp->dn_sig = atoll(fields[DNF_SIG]); - unescape('|', fields[DNF_COMMENT], dnp->dn_comment, - sizeof (dnp->dn_comment)); - - return (B_TRUE); -} - -/* - * Internal dhcp_network record update routine, used to factor out the - * common code between add_dn(), delete_dn(), and modify_dn(). If - * `origp' is NULL, then act like add_dn(); if `newp' is NULL, then - * act like delete_dn(); otherwise act like modify_dn(). - */ -static int -update_dn(const dn_handle_t *dhp, const dn_rec_t *origp, dn_rec_t *newp) -{ - char dnpath[MAXPATHLEN], newpath[MAXPATHLEN]; - int retval = DSVC_SUCCESS; - off_t recoff, recnext; - dn_rec_list_t *reclist; - int fd, newfd; - uint_t found; - int query; - struct stat st; - - - if ((dhp->dh_oflags & DSVC_WRITE) == 0) - return (DSVC_ACCESS); - - /* - * Open the container to update and a new container file which we - * will store the updated version of the container in. When the - * update is done, rename the new file to be the real container. - */ - net2path(dnpath, MAXPATHLEN, dhp->dh_location, dhp->dh_net, ""); - fd = open(dnpath, O_RDONLY); - if (fd == -1) - return (syserr_to_dsvcerr(errno)); - - net2path(newpath, MAXPATHLEN, dhp->dh_location, dhp->dh_net, ".new"); - newfd = open(newpath, O_CREAT|O_TRUNC|O_WRONLY, 0644); - if (newfd == -1) { - (void) close(fd); - return (syserr_to_dsvcerr(errno)); - } - - DSVC_QINIT(query); - DSVC_QEQ(query, DN_QCIP); - - /* - * If we're changing the key for this record, make sure the key - * we're changing to doesn't already exist. - */ - if (origp != NULL && newp != NULL) { - if (origp->dn_cip.s_addr != newp->dn_cip.s_addr) { - retval = find_dn(fd, 0, query, 1, newp, NULL, &found); - if (retval != DSVC_SUCCESS) - goto out; - if (found != 0) { - retval = DSVC_EXISTS; - goto out; - } - } - } - - /* - * If we're adding a new record, make sure the record doesn't - * already exist. - */ - if (newp != NULL && origp == NULL) { - retval = find_dn(fd, 0, query, 1, newp, NULL, &found); - if (retval != DSVC_SUCCESS) - goto out; - if (found != 0) { - retval = DSVC_EXISTS; - goto out; - } - } - - /* - * If we're deleting or modifying record, make sure the record - * still exists and that our copy isn't stale. Note that we don't - * check signatures if we're deleting the record and origp->dn_sig - * is zero, so that records that weren't looked up can be deleted. - */ - if (origp != NULL) { - retval = find_dn(fd, FIND_POSITION, query, 1, origp, &reclist, - &found); - if (retval != DSVC_SUCCESS) - goto out; - if (found == 0) { - retval = DSVC_NOENT; - goto out; - } - - if (reclist->dnl_rec->dn_sig != origp->dn_sig) { - if (newp != NULL || origp->dn_sig != 0) { - free_dnrec_list(reclist); - retval = DSVC_COLLISION; - goto out; - } - } - - /* - * Note the offset of the record we're modifying or deleting - * for use down below. - */ - recoff = ((dn_recpos_t *)reclist->dnl_rec)->dnp_off; - recnext = recoff + ((dn_recpos_t *)reclist->dnl_rec)->dnp_size; - - free_dnrec_list(reclist); - } else { - /* - * No record to modify or delete, so set `recoff' and - * `recnext' appropriately. - */ - recoff = 0; - recnext = 0; - } - - /* - * Make a new copy of the container. If we're deleting or - * modifying a record, don't copy that record to the new container. - */ - if (fstat(fd, &st) == -1) { - retval = DSVC_INTERNAL; - goto out; - } - - retval = copy_range(fd, 0, newfd, 0, recoff); - if (retval != DSVC_SUCCESS) - goto out; - - retval = copy_range(fd, recnext, newfd, recoff, st.st_size - recnext); - if (retval != DSVC_SUCCESS) - goto out; - - /* - * If there's a new/modified record, append it to the new container. - */ - if (newp != NULL) { - if (origp == NULL) - newp->dn_sig = gensig(); - else - newp->dn_sig = origp->dn_sig + 1; - - retval = write_rec(newfd, newp, recoff + st.st_size - recnext); - if (retval != DSVC_SUCCESS) - goto out; - } - - /* - * Note: we close these descriptors before the rename(2) (rather - * than just having the `out:' label clean them up) to save NFS - * some work (otherwise, NFS has to save `dnpath' to an alternate - * name since its vnode would still be active). - */ - (void) close(fd); - (void) close(newfd); - - if (rename(newpath, dnpath) == -1) - retval = syserr_to_dsvcerr(errno); - - return (retval); -out: - (void) close(fd); - (void) close(newfd); - (void) unlink(newpath); - return (retval); -} - -int -add_dn(void *handle, dn_rec_t *addp) -{ - return (update_dn((dn_handle_t *)handle, NULL, addp)); -} - -int -modify_dn(void *handle, const dn_rec_t *origp, dn_rec_t *newp) -{ - return (update_dn((dn_handle_t *)handle, origp, newp)); -} - -int -delete_dn(void *handle, const dn_rec_t *delp) -{ - return (update_dn((dn_handle_t *)handle, delp, NULL)); -} - -int -list_dn(const char *location, char ***listppp, uint_t *countp) -{ - char ipaddr[INET_ADDRSTRLEN]; - struct dirent *result; - DIR *dirp; - unsigned int i, count = 0; - char *re, **new_listpp, **listpp = NULL; - char conver[4]; - int error; - - dirp = opendir(location); - if (dirp == NULL) { - switch (errno) { - case EACCES: - case EPERM: - return (DSVC_ACCESS); - case ENOENT: - return (DSVC_NO_LOCATION); - default: - break; - } - return (DSVC_INTERNAL); - } - - /* - * Compile a regular expression matching "SUNWfilesX_" (where X is - * a container version number) followed by an IP address (roughly - * speaking). Note that the $N constructions allow us to get the - * container version and IP address when calling regex(3C). - */ - re = regcmp("^SUNWfiles([0-9]{1,3})$0_" - "(([0-9]{1,3}_){3}[0-9]{1,3})$1$", (char *)0); - if (re == NULL) - return (DSVC_NO_MEMORY); - - while ((result = readdir(dirp)) != NULL) { - if (regex(re, result->d_name, conver, ipaddr) != NULL) { - if (atoi(conver) != DSVC_CONVER) - continue; - - for (i = 0; ipaddr[i] != '\0'; i++) - if (ipaddr[i] == '_') - ipaddr[i] = '.'; - - new_listpp = realloc(listpp, - (sizeof (char **)) * (count + 1)); - if (new_listpp == NULL) { - error = DSVC_NO_MEMORY; - goto fail; - } - listpp = new_listpp; - listpp[count] = strdup(ipaddr); - if (listpp[count] == NULL) { - error = DSVC_NO_MEMORY; - goto fail; - } - count++; - } - } - free(re); - (void) closedir(dirp); - - *countp = count; - *listppp = listpp; - return (DSVC_SUCCESS); - -fail: - free(re); - (void) closedir(dirp); - - for (i = 0; i < count; i++) - free(listpp[i]); - free(listpp); - return (error); -} - -/* - * Given a buffer `path' of `pathlen' bytes, fill it in with a path to the - * DHCP Network table for IP network `ip' located in directory `dir' with a - * suffix of `suffix'. - */ -static void -net2path(char *path, size_t pathlen, const char *dir, ipaddr_t ip, - const char *suffix) -{ - (void) snprintf(path, pathlen, "%s/SUNWfiles%u_%d_%d_%d_%d%s", dir, - DSVC_CONVER, ip >> 24, (ip >> 16) & 0xff, (ip >> 8) & 0xff, - ip & 0xff, suffix); -} - -/* - * Write the dn_rec_t `recp' into the open container `fd' at offset - * `recoff'. Returns DSVC_* error code. - */ -static int -write_rec(int fd, dn_rec_t *recp, off_t recoff) -{ - char entbuf[1024], *ent = entbuf; - size_t entsize = sizeof (entbuf); - int entlen; - dn_filerec_t dnf; - struct in_addr nip; - unsigned int cid_len = sizeof (dnf.dnf_cid); - - /* - * Copy data into a dn_filerec_t, since that's what we can - * actually put on disk. - */ - if (octet_to_hexascii(recp->dn_cid, recp->dn_cid_len, dnf.dnf_cid, - &cid_len) != 0) - return (DSVC_INTERNAL); - - nip.s_addr = htonl(recp->dn_cip.s_addr); - (void) inet_ntop(AF_INET, &nip, dnf.dnf_cip, sizeof (dnf.dnf_cip)); - nip.s_addr = htonl(recp->dn_sip.s_addr); - (void) inet_ntop(AF_INET, &nip, dnf.dnf_sip, sizeof (dnf.dnf_cip)); - - dnf.dnf_sig = recp->dn_sig; - dnf.dnf_flags = recp->dn_flags; - dnf.dnf_lease = recp->dn_lease; - - escape('|', recp->dn_macro, dnf.dnf_macro, sizeof (dnf.dnf_macro)); - escape('|', recp->dn_comment, dnf.dnf_comment, - sizeof (dnf.dnf_comment)); -again: - entlen = snprintf(ent, entsize, "%s|%s|%02hu|%s|%u|%llu|%s|%s\n", - dnf.dnf_cip, dnf.dnf_cid, dnf.dnf_flags, dnf.dnf_sip, - dnf.dnf_lease, dnf.dnf_sig, dnf.dnf_macro, dnf.dnf_comment); - if (entlen == -1) - return (syserr_to_dsvcerr(errno)); - - if (entlen > entsize) { - entsize = entlen; - ent = alloca(entlen); - goto again; - } - - if (pnwrite(fd, ent, entlen, recoff) == -1) - return (syserr_to_dsvcerr(errno)); - - return (DSVC_SUCCESS); -} diff --git a/usr/src/lib/libdhcpsvc/modules/files/dhcp_network.h b/usr/src/lib/libdhcpsvc/modules/files/dhcp_network.h deleted file mode 100644 index 045faa46a5..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files/dhcp_network.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _DHCP_NETWORK_H -#define _DHCP_NETWORK_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/types.h> -#include <sys/param.h> -#include <netinet/in.h> -#include <dhcp_svc_public.h> - -/* - * Implementation-specific data structures for the files dhcp_network - * container. These structures are subject to change at any time. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Per-record state describing the underlying record, including its - * position on-disk. - */ -typedef struct dn_recpos { - dn_rec_t dnp_rec; /* traditional record */ - size_t dnp_size; /* its size in the file */ - off_t dnp_off; /* its starting offset in the file */ -} dn_recpos_t; - -/* - * Per-record state for the underlying on-disk record representation. Note - * that `dnf_cid' is twice its usual maximum length (plus room for a NUL - * byte) since it doubles in size when converted to ASCII; `dnf_macro' and - * `dnf_comment' are twice their usual maximum length in case we need to - * escape every character in them. - */ -typedef struct dn_filerec { - char dnf_cip[INET_ADDRSTRLEN]; - char dnf_cid[DN_MAX_CID_LEN * 2 + 1]; - uint16_t dnf_flags; - char dnf_sip[INET_ADDRSTRLEN]; - uint32_t dnf_lease; - uint64_t dnf_sig; - char dnf_macro[DSVC_MAX_MACSYM_LEN * 2 + 1]; - char dnf_comment[DN_MAX_COMMENT_LEN * 2 + 1]; -} dn_filerec_t; - -/* - * Per-instance state for each instance of an open_dn() - */ -typedef struct dn_handle { - unsigned int dh_oflags; /* flags passed into open_dn() */ - char dh_location[MAXPATHLEN]; - ipaddr_t dh_net; -} dn_handle_t; - -/* - * Order of the fields in the on-disk record. - */ -enum { DNF_CIP, DNF_CID, DNF_FLAGS, DNF_SIP, DNF_LEASE, DNF_SIG, DNF_MACRO, - DNF_COMMENT }; - -#define DNF_FIELDS 8 /* number of fields per record */ -#define DNF_COMMENT_CHAR '#' - -/* - * Constants for use with find_dn() - */ -#define FIND_PARTIAL 0x0001 /* allow partial success */ -#define FIND_POSITION 0x0002 /* return dn_recpos_t's */ - -#ifdef __cplusplus -} -#endif - -#endif /* _DHCP_NETWORK_H */ diff --git a/usr/src/lib/libdhcpsvc/modules/files/dhcptab.c b/usr/src/lib/libdhcpsvc/modules/files/dhcptab.c deleted file mode 100644 index 8a713e63a7..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files/dhcptab.c +++ /dev/null @@ -1,577 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This file contains public API functions for managing the dhcptab - * container. For the semantics of these functions, please see the - * Enterprise DHCP Architecture Document. - */ - -#include <sys/types.h> -#include <sys/socket.h> -#include <unistd.h> -#include <netinet/in.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <alloca.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include <dhcp_svc_public.h> - -#include "dhcptab.h" -#include "util.h" - -static void dt2path(char *, size_t, const char *, const char *); -static int write_rec(int, dt_rec_t *, off_t); - -int -open_dt(void **handlep, const char *location, uint_t flags) -{ - dt_handle_t *dhp; - unsigned int conver; - int nelems; - int retval; - char nl; - int fd; - char dtpath[MAXPATHLEN]; - FILE *fp; - - dhp = malloc(sizeof (dt_handle_t)); - if (dhp == NULL) - return (DSVC_NO_MEMORY); - - dhp->dh_oflags = flags; - (void) strlcpy(dhp->dh_location, location, MAXPATHLEN); - - dt2path(dtpath, MAXPATHLEN, location, ""); - retval = open_file(dtpath, flags, &fd); - if (retval != DSVC_SUCCESS) { - free(dhp); - return (retval); - } - - fp = fdopen(fd, flags & DSVC_WRITE ? "r+" : "r"); - if (fp == NULL) { - (void) close(fd); - free(dhp); - return (DSVC_INTERNAL); - } - - if (flags & DSVC_CREATE) { - /* - * We just created the per-network container; put the - * header on for future use... - */ - retval = fprintf(fp, "# SUNWfiles%u_dhcptab\n", DSVC_CONVER); - if (retval < 0 || fflush(fp) == EOF) { - (void) fclose(fp); - (void) free(dhp); - return (DSVC_INTERNAL); - } - - (void) fprintf(fp, "#\n# Do NOT edit this file by hand -- use"); - (void) fprintf(fp, " dhtadm(1M) or dhcpmgr(1M) instead\n#\n"); - } else { - /* - * Container already exists; sanity check against the - * header that's on-disk. - */ - nelems = fscanf(fp, "#%*1[ ]SUNWfiles%u_dhcptab%c", &conver, - &nl); - if (nelems != 2 || conver != DSVC_CONVER || nl != '\n') { - (void) fclose(fp); - free(dhp); - return (DSVC_INTERNAL); - } - } - - (void) fclose(fp); - *handlep = dhp; - return (DSVC_SUCCESS); -} - -int -close_dt(void **handlep) -{ - free(*handlep); - return (DSVC_SUCCESS); -} - -int -remove_dt(const char *location) -{ - char dtpath[MAXPATHLEN]; - - dt2path(dtpath, MAXPATHLEN, location, ""); - if (unlink(dtpath) == -1) - return (syserr_to_dsvcerr(errno)); - - return (DSVC_SUCCESS); -} - -/* - * Internal version of lookup_dt() used by both lookup_dt() and - * update_dt(); same semantics as lookup_dt() except that the `partial' - * argument has been generalized into a `flags' field and the handle has - * been turned into a FILE pointer. - */ -static int -find_dt(FILE *fp, uint_t flags, uint_t query, int count, - const dt_rec_t *targetp, dt_rec_list_t **recordsp, uint_t *nrecordsp) -{ - int retval = DSVC_SUCCESS; - char *buf = NULL, *fields[DTF_FIELDS]; - uint_t nrecords; - dt_rec_t dt, *recordp; - dt_rec_list_t *records, *new_records; - off_t recoff; - unsigned int nfields; - - if (fseek(fp, 0, SEEK_SET) == -1) - return (DSVC_INTERNAL); - - records = NULL; - for (nrecords = 0; count < 0 || nrecords < count; ) { - free(buf); - - if (flags & FIND_POSITION) - recoff = ftello(fp); - - buf = read_entry(fp); - if (buf == NULL) { - if (!feof(fp)) - retval = DSVC_NO_MEMORY; - break; - } - - /* - * Skip pure comment lines; for now this just skips the - * header information at the top of the container. - */ - if (buf[0] == DTF_COMMENT_CHAR) - continue; - - /* - * Split the buffer up into DTF_FIELDS fields. - */ - nfields = field_split(buf, DTF_FIELDS, fields, "|"); - if (nfields < DTF_FIELDS) - continue; - - /* - * See if we've got a match. If so, allocate the new - * record, fill it in, and continue. - */ - dt.dt_type = fields[DTF_TYPE][0]; - if (DSVC_QISEQ(query, DT_QTYPE) && - targetp->dt_type != dt.dt_type) - continue; - else if (DSVC_QISNEQ(query, DT_QTYPE) && - targetp->dt_type == dt.dt_type) - continue; - - unescape('|', fields[DTF_KEY], dt.dt_key, sizeof (dt.dt_key)); - if (DSVC_QISEQ(query, DT_QKEY) && - strcmp(targetp->dt_key, dt.dt_key) != 0) - continue; - else if (DSVC_QISNEQ(query, DT_QKEY) && - strcmp(targetp->dt_key, dt.dt_key) == 0) - continue; - - /* - * Caller just wants a count of the number of matching - * records, not the records themselves; continue. - */ - if (recordsp == NULL) { - nrecords++; - continue; - } - - dt.dt_sig = atoll(fields[DTF_SIG]); - dt.dt_value = strdup(fields[DTF_VALUE]); - if (dt.dt_value == NULL) { - if ((flags & FIND_PARTIAL) == 0) - retval = DSVC_NO_MEMORY; - break; - } - - /* - * Allocate record; if FIND_POSITION flag is set, then - * we need to allocate an extended (dt_recpos_t) record. - */ - if (flags & FIND_POSITION) - recordp = malloc(sizeof (dt_recpos_t)); - else - recordp = malloc(sizeof (dt_rec_t)); - - if (recordp == NULL) { - free(dt.dt_value); - if ((flags & FIND_PARTIAL) == 0) - retval = DSVC_NO_MEMORY; - break; - } - - /* - * Fill in record; do a structure copy from our automatic - * dt. If FIND_POSITION flag is on, pass back additional - * location information. - */ - *recordp = dt; - if (flags & FIND_POSITION) { - ((dt_recpos_t *)recordp)->dtp_off = recoff; - ((dt_recpos_t *)recordp)->dtp_size = ftello(fp) - - recoff; - } - - /* - * Chuck the record on the list; up the counter. - */ - new_records = add_dtrec_to_list(recordp, records); - if (new_records == NULL) { - free_dtrec(recordp); - if ((flags & FIND_PARTIAL) == 0) - retval = DSVC_NO_MEMORY; - break; - } - records = new_records; - nrecords++; - } - - free(buf); - - if (retval == DSVC_SUCCESS) { - *nrecordsp = nrecords; - if (recordsp != NULL) - *recordsp = records; - return (DSVC_SUCCESS); - } - - if (records != NULL) - free_dtrec_list(records); - - return (retval); -} - -int -lookup_dt(void *handle, boolean_t partial, uint_t query, int count, - const dt_rec_t *targetp, dt_rec_list_t **recordsp, uint_t *nrecordsp) -{ - int retval; - char dtpath[MAXPATHLEN]; - FILE *fp; - dt_handle_t *dhp = (dt_handle_t *)handle; - - if ((dhp->dh_oflags & DSVC_READ) == 0) - return (DSVC_ACCESS); - - dt2path(dtpath, MAXPATHLEN, dhp->dh_location, ""); - fp = fopen(dtpath, "r"); - if (fp == NULL) - return (syserr_to_dsvcerr(errno)); - - retval = find_dt(fp, partial ? FIND_PARTIAL : 0, query, count, targetp, - recordsp, nrecordsp); - - (void) fclose(fp); - return (retval); -} - -/* - * Internal dhcptab record update routine, used to factor out the - * common code between add_dt(), delete_dt(), and modify_dt(). If - * `origp' is NULL, then act like add_dt(); if `newp' is NULL, then - * act like delete_dt(); otherwise act like modify_dt(). - */ -static int -update_dt(const dt_handle_t *dhp, const dt_rec_t *origp, dt_rec_t *newp) -{ - char dtpath[MAXPATHLEN], newpath[MAXPATHLEN]; - int retval = DSVC_SUCCESS; - off_t recoff, recnext; - dt_rec_list_t *reclist; - FILE *fp; - int newfd; - uint_t found; - int query; - struct stat st; - - if ((dhp->dh_oflags & DSVC_WRITE) == 0) - return (DSVC_ACCESS); - - /* - * Open the container to update and a new container file which we - * will store the updated version of the container in. When the - * update is done, rename the new file to be the real container. - */ - dt2path(dtpath, MAXPATHLEN, dhp->dh_location, ""); - fp = fopen(dtpath, "r"); - if (fp == NULL) - return (syserr_to_dsvcerr(errno)); - - dt2path(newpath, MAXPATHLEN, dhp->dh_location, ".new"); - (void) unlink(newpath); - newfd = open(newpath, O_CREAT|O_EXCL|O_WRONLY, 0644); - if (newfd == -1) { - (void) fclose(fp); - return (syserr_to_dsvcerr(errno)); - } - - DSVC_QINIT(query); - DSVC_QEQ(query, DT_QKEY|DT_QTYPE); - - /* - * If we're changing the key for this record, make sure the key - * we're changing to doesn't already exist. - */ - if (origp != NULL && newp != NULL) { - if ((origp->dt_type != newp->dt_type || - strcmp(origp->dt_key, newp->dt_key) != 0)) { - retval = find_dt(fp, 0, query, 1, newp, NULL, &found); - if (retval != DSVC_SUCCESS) - goto out; - if (found != 0) { - retval = DSVC_EXISTS; - goto out; - } - } - } - - /* - * If we're adding a new record, make sure the record doesn't - * already exist. - */ - if (newp != NULL && origp == NULL) { - retval = find_dt(fp, 0, query, 1, newp, NULL, &found); - if (retval != DSVC_SUCCESS) - goto out; - if (found != 0) { - retval = DSVC_EXISTS; - goto out; - } - } - - /* - * If we're deleting or modifying record, make sure the record - * still exists and that our copy isn't stale. Note that we don't - * check signatures if we're deleting the record and origp->dt_sig - * is zero, so that records can be deleted that weren't looked up - * first. - */ - if (origp != NULL) { - retval = find_dt(fp, FIND_POSITION, query, 1, origp, &reclist, - &found); - if (retval != DSVC_SUCCESS) - goto out; - if (found == 0) { - retval = DSVC_NOENT; - goto out; - } - - if (reclist->dtl_rec->dt_sig != origp->dt_sig) { - if (newp != NULL || origp->dt_sig != 0) { - free_dtrec_list(reclist); - retval = DSVC_COLLISION; - goto out; - } - } - - /* - * Note the offset of the record we're modifying or deleting - * for use down below. - */ - recoff = ((dt_recpos_t *)reclist->dtl_rec)->dtp_off; - recnext = recoff + ((dt_recpos_t *)reclist->dtl_rec)->dtp_size; - - free_dtrec_list(reclist); - } else { - /* - * No record to modify or delete, so set `recoff' and - * `recnext' appropriately. - */ - recoff = 0; - recnext = 0; - } - - /* - * Make a new copy of the container. If we're deleting or - * modifying a record, don't copy that record to the new container. - */ - if (fstat(fileno(fp), &st) == -1) { - retval = DSVC_INTERNAL; - goto out; - } - - retval = copy_range(fileno(fp), 0, newfd, 0, recoff); - if (retval != DSVC_SUCCESS) - goto out; - - retval = copy_range(fileno(fp), recnext, newfd, recoff, - st.st_size - recnext); - if (retval != DSVC_SUCCESS) - goto out; - - /* - * If there's a new record, append it to the new container. - */ - if (newp != NULL) { - if (origp == NULL) - newp->dt_sig = gensig(); - else - newp->dt_sig = origp->dt_sig + 1; - - if (fstat(newfd, &st) == -1) { - retval = DSVC_INTERNAL; - goto out; - } - - retval = write_rec(newfd, newp, st.st_size); - if (retval != DSVC_SUCCESS) - goto out; - } - - /* - * Note: we close these descriptors before the rename(2) (rather - * than just having the `out:' label clean them up) to save NFS - * some work (otherwise, NFS has to save `dnpath' to an alternate - * name since its vnode would still be active). - */ - (void) fclose(fp); - (void) close(newfd); - - if (rename(newpath, dtpath) == -1) - retval = syserr_to_dsvcerr(errno); - - return (retval); -out: - (void) fclose(fp); - (void) close(newfd); - (void) unlink(newpath); - return (retval); -} - -int -delete_dt(void *handle, const dt_rec_t *delp) -{ - return (update_dt((dt_handle_t *)handle, delp, NULL)); -} - -int -add_dt(void *handle, dt_rec_t *addp) -{ - return (update_dt((dt_handle_t *)handle, NULL, addp)); -} - -int -modify_dt(void *handle, const dt_rec_t *origp, dt_rec_t *newp) -{ - return (update_dt((dt_handle_t *)handle, origp, newp)); -} - -int -list_dt(const char *location, char ***listppp, uint_t *countp) -{ - char dtpath[MAXPATHLEN]; - char **listpp; - - if (access(location, F_OK|R_OK) == -1) { - switch (errno) { - case EACCES: - case EPERM: - return (DSVC_ACCESS); - case ENOENT: - return (DSVC_NO_LOCATION); - default: - break; - } - return (DSVC_INTERNAL); - } - - dt2path(dtpath, MAXPATHLEN, location, ""); - if (access(dtpath, F_OK|R_OK) == -1) { - *countp = 0; - *listppp = NULL; - return (DSVC_SUCCESS); - } - - listpp = malloc(sizeof (char **)); - if (listpp == NULL) - return (DSVC_NO_MEMORY); - listpp[0] = strdup(DT_DHCPTAB); - if (listpp[0] == NULL) { - free(listpp); - return (DSVC_NO_MEMORY); - } - - *listppp = listpp; - *countp = 1; - return (DSVC_SUCCESS); -} - -/* - * Given a buffer `path' of `pathlen' bytes, fill it in with a path to the - * dhcptab in directory `dir' with a suffix of `suffix'. - */ -static void -dt2path(char *path, size_t pathlen, const char *dir, const char *suffix) -{ - (void) snprintf(path, pathlen, "%s/SUNWfiles%u_%s%s", dir, - DSVC_CONVER, DT_DHCPTAB, suffix); -} - -/* - * Write the dt_rec_t pointed to by `recp' into the open container `fd' at - * offset `recoff'. Returns DSVC_* error code. - */ -static int -write_rec(int fd, dt_rec_t *recp, off_t recoff) -{ - char escaped_key[DSVC_MAX_MACSYM_LEN * 2 + 1]; - char entbuf[1024], *ent = entbuf; - size_t entsize = sizeof (entbuf); - int entlen; - - escape('|', recp->dt_key, escaped_key, sizeof (escaped_key)); -again: - entlen = snprintf(ent, entsize, "%s|%c|%llu|%s\n", escaped_key, - recp->dt_type, recp->dt_sig, recp->dt_value); - if (entlen == -1) - return (syserr_to_dsvcerr(errno)); - - if (entlen > entsize) { - entsize = entlen; - ent = alloca(entlen); - goto again; - } - - if (pnwrite(fd, ent, entlen, recoff) == -1) - return (syserr_to_dsvcerr(errno)); - - return (DSVC_SUCCESS); -} diff --git a/usr/src/lib/libdhcpsvc/modules/files/dhcptab.h b/usr/src/lib/libdhcpsvc/modules/files/dhcptab.h deleted file mode 100644 index d5fad9449c..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files/dhcptab.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _DHCPTAB_H -#define _DHCPTAB_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/types.h> -#include <stdio.h> -#include <dhcp_svc_public.h> - -/* - * Implementation-specific data structures for the files dhcptab container. - * These structures are subject to change at any time. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Per-record state describing the underlying record, including its - * position on-disk. - */ -typedef struct dt_recpos { - dt_rec_t dtp_rec; /* traditional record */ - size_t dtp_size; /* its size in the file */ - off_t dtp_off; /* its starting offset in the file */ -} dt_recpos_t; - -/* - * Per-instance state for each instance of an open_dt() - */ -typedef struct dt_handle { - unsigned int dh_oflags; /* flags passed into open_dt() */ - char dh_location[MAXPATHLEN]; -} dt_handle_t; - -/* - * Order of the fields in the on-disk record. - */ -enum { DTF_KEY, DTF_TYPE, DTF_SIG, DTF_VALUE }; - -#define DTF_FIELDS 4 /* number of fields */ -#define DTF_COMMENT_CHAR '#' - -/* - * Constants for use with find_dt() - */ -#define FIND_PARTIAL 0x0001 /* allow partial success */ -#define FIND_POSITION 0x0002 /* return dt_recpos_t's */ - -#ifdef __cplusplus -} -#endif - -#endif /* _DHCPTAB_H */ diff --git a/usr/src/lib/libdhcpsvc/modules/files/general.c b/usr/src/lib/libdhcpsvc/modules/files/general.c deleted file mode 100644 index f1987b43ef..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files/general.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This file contains public API functions for module-level tasks. For the - * semantics of these functions, please see the Enterprise DHCP - * Architecture Document. - * - * WARNING: This file is also compiled into the files0 module; if you make - * changes to this file which are not appropriate for files0, you - * will need to provide files0 with its own implementation. - */ - -#include <assert.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <libgen.h> -#include <errno.h> -#include <dhcp_svc_public.h> -#include <dhcp_svc_private.h> /* DSVC_SYNCH_CROSSHOST */ - -#include "util.h" - -/* - * This symbol and its value tell the private layer that it must provide - * synchronization guarantees via dsvclockd(1M) before calling our *_dn() - * and *_dt() methods. Please see $SRC/lib/libdhcpsvc/private/README.synch - */ -int dsvc_synchtype = DSVC_SYNCH_DSVCD | DSVC_SYNCH_CROSSHOST; - -int -status(const char *location) -{ - if (location != NULL) { - if (access(location, F_OK|R_OK) == -1) { - if (errno == ENOENT) - return (DSVC_NO_LOCATION); - return (syserr_to_dsvcerr(errno)); - } - } - return (DSVC_SUCCESS); -} - -int -version(int *vp) -{ - *vp = DSVC_PUBLIC_VERSION; - return (DSVC_SUCCESS); -} - -int -mklocation(const char *location) -{ - if (mkdirp(location, 0755) == -1) { - switch (errno) { - case ENAMETOOLONG: - case ENOTDIR: - return (DSVC_INVAL); - - case EEXIST: - return (DSVC_EXISTS); - - case EROFS: - case EPERM: - case EACCES: - return (DSVC_ACCESS); - - default: - return (DSVC_INTERNAL); - } - } - - return (DSVC_SUCCESS); -} - -int -mkloctoken(const char *location, char *token, size_t tokensize) -{ - assert(tokensize >= MAXPATHLEN); - if (realpath(location, token) == NULL) - return (syserr_to_dsvcerr(errno)); - - return (DSVC_SUCCESS); -} diff --git a/usr/src/lib/libdhcpsvc/modules/files/i386/Makefile b/usr/src/lib/libdhcpsvc/modules/files/i386/Makefile deleted file mode 100644 index 58f853abfd..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files/i386/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2000 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/modules/files/i386/Makefile - -include ../Makefile.com - -install: all $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/libdhcpsvc/modules/files/mapfile-vers b/usr/src/lib/libdhcpsvc/modules/files/mapfile-vers deleted file mode 100644 index b9a70e7675..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files/mapfile-vers +++ /dev/null @@ -1,65 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -$mapfile_version 2 - -SYMBOL_VERSION SUNWprivate_1.1 { - global: - add_dn; - add_dt; - close_dn; - close_dt; - delete_dn; - delete_dt; - dsvc_synchtype; - list_dn; - list_dt; - lookup_dn; - lookup_dt; - mklocation; - modify_dn; - modify_dt; - open_dn; - open_dt; - remove_dn; - remove_dt; - status; - version; - local: - *; -}; diff --git a/usr/src/lib/libdhcpsvc/modules/files/sparc/Makefile b/usr/src/lib/libdhcpsvc/modules/files/sparc/Makefile deleted file mode 100644 index b58125edbc..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files/sparc/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2000 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/modules/files/sparc/Makefile - -include ../Makefile.com - -install: all $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/libdhcpsvc/modules/files0/Makefile b/usr/src/lib/libdhcpsvc/modules/files0/Makefile deleted file mode 100644 index 2225b9c4c6..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files0/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include $(SRC)/lib/Makefile.lib -SUBDIRS = $(MACH) -include ../../Makefile.subdirs diff --git a/usr/src/lib/libdhcpsvc/modules/files0/Makefile.com b/usr/src/lib/libdhcpsvc/modules/files0/Makefile.com deleted file mode 100644 index b1311870cb..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files0/Makefile.com +++ /dev/null @@ -1,51 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/modules/files0/Makefile.com - -LIBRARY = ds_SUNWfiles.a -VERS = .0 -LOCOBJS = dhcptab.o dhcp_network.o -OBJECTS = $(LOCOBJS) util.o general.o - -# include library definitions -include $(SRC)/lib/libdhcpsvc/modules/Makefile.com - -SRCS = $(LOCOBJS:%.o=../%.c) $(UTILDIR)/util.c ../../files/general.c -LDLIBS += -lc -lnsl -linetutil -ldhcpsvc -lgen -CPPFLAGS += -D_FILE_OFFSET_BITS=64 -I$(UTILDIR) - -.KEEP_STATE: - -all: $(LIBS) - -# include library targets -include $(SRC)/lib/libdhcpsvc/modules/Makefile.targ - -pics/general.o: ../../files/general.c - $(COMPILE.c) -o $@ ../../files/general.c - $(POST_PROCESS_O) diff --git a/usr/src/lib/libdhcpsvc/modules/files0/dhcp_network.c b/usr/src/lib/libdhcpsvc/modules/files0/dhcp_network.c deleted file mode 100644 index 9442c3df6c..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files0/dhcp_network.c +++ /dev/null @@ -1,668 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This file contains public functions for managing legacy DHCP network - * containers. For the semantics of these functions, please see the - * Enterprise DHCP Architecture Document. - */ - -#include <alloca.h> -#include <arpa/inet.h> -#include <ctype.h> -#include <dhcp_svc_public.h> -#include <dirent.h> -#include <errno.h> -#include <fcntl.h> -#include <libgen.h> -#include <libinetutil.h> -#include <netinet/in.h> -#include <stdlib.h> -#include <string.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include "dhcp_network.h" -#include "util.h" - -static void net2path(char *, size_t, const char *, ipaddr_t, const char *); -static boolean_t record_match(char *[], dn_rec_t *, const dn_rec_t *, uint_t); -static int write_rec(int, dn_rec_t *, off_t); - -/* ARGSUSED */ -int -open_dn(void **handlep, const char *location, uint_t flags, - const struct in_addr *netp, const struct in_addr *maskp) -{ - char dnpath[MAXPATHLEN]; - dn_handle_t *dhp; - int retval; - int fd; - - dhp = malloc(sizeof (dn_handle_t)); - if (dhp == NULL) - return (DSVC_NO_MEMORY); - - dhp->dh_net = netp->s_addr; - dhp->dh_oflags = flags; - (void) strlcpy(dhp->dh_location, location, MAXPATHLEN); - - /* - * This is a legacy format which has no header, so we neither write - * nor verify a header (we just create the file or make sure it - * exists, depending on the value of `flags'). - */ - net2path(dnpath, MAXPATHLEN, location, netp->s_addr, ""); - retval = open_file(dnpath, flags, &fd); - if (retval != DSVC_SUCCESS) { - free(dhp); - return (retval); - } - (void) close(fd); - - *handlep = dhp; - return (DSVC_SUCCESS); -} - -int -close_dn(void **handlep) -{ - free(*handlep); - return (DSVC_SUCCESS); -} - -int -remove_dn(const char *dir, const struct in_addr *netp) -{ - char dnpath[MAXPATHLEN]; - - net2path(dnpath, MAXPATHLEN, dir, netp->s_addr, ""); - if (unlink(dnpath) == -1) - return (syserr_to_dsvcerr(errno)); - - return (DSVC_SUCCESS); -} - -static int -find_dn(FILE *fp, uint_t flags, uint_t query, int count, - const dn_rec_t *targetp, dn_rec_list_t **recordsp, uint_t *nrecordsp) -{ - int retval = DSVC_SUCCESS; - char *commentp, *fields[DNF_MAX_FIELDS]; - char *buf = NULL; - uint_t nrecords; - dn_rec_t dn, *recordp; - dn_rec_list_t *records, *new_records; - unsigned int nfields; - off_t recoff; - - if (fseek(fp, 0, SEEK_SET) == -1) - return (DSVC_INTERNAL); - - records = NULL; - for (nrecords = 0; count < 0 || nrecords < count; ) { - free(buf); - - if (flags & FIND_POSITION) - recoff = ftello(fp); - - buf = read_entry(fp); - if (buf == NULL) { - if (!feof(fp)) - retval = DSVC_NO_MEMORY; - break; - } - - /* - * Skip pure comment lines; for now this just skips the - * header information at the top of the container. - */ - if (buf[0] == DNF_COMMENT_CHAR) - continue; - - /* - * Tell field_split() that there's one less field than - * there really is. We do this so that the comment and the - * macro field both end up in the DNF_MACRO field, since - * both fields are optional and it requires some fancy - * footwork (below) to tell which (if any) the record - * contains. - */ - nfields = field_split(buf, DNF_MAX_FIELDS - 1, fields, " \t"); - if (nfields < DNF_REQ_FIELDS) - continue; - - if (nfields == DNF_REQ_FIELDS) { - fields[DNF_MACRO] = ""; - fields[DNF_COMMENT] = ""; - } else { - /* - * Assume there is a comment; if we hit a comment - * delimiter char (DNF_COMMENT_CHAR), then simply - * change it to a NUL and advance commentp. If we - * hit whitespace, replace the first instance with - * NUL, and go searching for DNF_COMMENT_CHAR. - * This step is important since it efficiently - * handles the common case where a comment is - * preceded by a space. - */ - commentp = fields[DNF_MACRO]; - while (!isspace(*commentp) && - *commentp != DNF_COMMENT_CHAR && *commentp != '\0') - commentp++; - - if (isspace(*commentp)) { - *commentp++ = '\0'; - commentp = strchr(commentp, DNF_COMMENT_CHAR); - if (commentp == NULL) - commentp = ""; - } - - if (*commentp == DNF_COMMENT_CHAR) - *commentp++ = '\0'; - - fields[DNF_COMMENT] = commentp; - } - - /* - * See if we've got a match, filling in dnf.dnf_rec as - * we go. If record_match() succeeds, dnf.dnf_rec will - * be completely filled in. - */ - if (!record_match(fields, &dn, targetp, query)) - continue; - - /* - * Caller just wants a count of the number of matching - * records, not the records themselves; continue. - */ - if (recordsp == NULL) { - nrecords++; - continue; - } - - /* - * Allocate record; if FIND_POSITION flag is set, then - * we need to allocate an extended (dn_recpos_t) record. - */ - if (flags & FIND_POSITION) - recordp = malloc(sizeof (dn_recpos_t)); - else - recordp = malloc(sizeof (dn_rec_t)); - - if (recordp == NULL) { - if ((flags & FIND_PARTIAL) == 0) - retval = DSVC_NO_MEMORY; - break; - } - - /* - * Fill in record; do a structure copy from our automatic - * dn. If FIND_POSITION flag is on, pass back additional - * position information. - */ - *recordp = dn; - if (flags & FIND_POSITION) { - ((dn_recpos_t *)recordp)->dnp_off = recoff; - ((dn_recpos_t *)recordp)->dnp_size = ftello(fp) - - recoff; - } - - /* - * Chuck the record on the list and up the counter. - */ - new_records = add_dnrec_to_list(recordp, records); - if (new_records == NULL) { - free(recordp); - if ((flags & FIND_PARTIAL) == 0) - retval = DSVC_NO_MEMORY; - break; - } - - records = new_records; - nrecords++; - } - - free(buf); - - if (retval == DSVC_SUCCESS) { - *nrecordsp = nrecords; - if (recordsp != NULL) - *recordsp = records; - return (DSVC_SUCCESS); - } - - if (records != NULL) - free_dnrec_list(records); - - return (retval); -} - -int -lookup_dn(void *handle, boolean_t partial, uint_t query, int count, - const dn_rec_t *targetp, dn_rec_list_t **recordsp, uint_t *nrecordsp) -{ - int retval; - char dnpath[MAXPATHLEN]; - FILE *fp; - dn_handle_t *dhp = (dn_handle_t *)handle; - - if ((dhp->dh_oflags & DSVC_READ) == 0) - return (DSVC_ACCESS); - - net2path(dnpath, MAXPATHLEN, dhp->dh_location, dhp->dh_net, ""); - fp = fopen(dnpath, "r"); - if (fp == NULL) - return (syserr_to_dsvcerr(errno)); - - retval = find_dn(fp, partial ? FIND_PARTIAL : 0, query, count, targetp, - recordsp, nrecordsp); - - (void) fclose(fp); - return (retval); -} - -/* - * Compares the fields in fields[] agains the fields in target `targetp', - * using `query' to decide what fields to compare. Returns B_TRUE if `dnp' - * matches `targetp', B_FALSE if not. On success, `dnp' is completely - * filled in. - */ -static boolean_t -record_match(char *fields[], dn_rec_t *dnp, const dn_rec_t *targetp, - uint_t query) -{ - unsigned int qflags[] = { DN_QFDYNAMIC, DN_QFAUTOMATIC, DN_QFMANUAL, - DN_QFUNUSABLE, DN_QFBOOTP_ONLY }; - unsigned int flags[] = { DN_FDYNAMIC, DN_FAUTOMATIC, DN_FMANUAL, - DN_FUNUSABLE, DN_FBOOTP_ONLY }; - unsigned int i; - uint_t dn_cid_len; - - dnp->dn_cip.s_addr = ntohl(inet_addr(fields[DNF_CIP])); - if (DSVC_QISEQ(query, DN_QCIP) && - dnp->dn_cip.s_addr != targetp->dn_cip.s_addr) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QCIP) && - dnp->dn_cip.s_addr == targetp->dn_cip.s_addr) - return (B_FALSE); - - dnp->dn_lease = atoi(fields[DNF_LEASE]); - if (DSVC_QISEQ(query, DN_QLEASE) && targetp->dn_lease != dnp->dn_lease) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QLEASE) && targetp->dn_lease == dnp->dn_lease) - return (B_FALSE); - - /* - * We use dn_cid_len since dnp->dn_cid_len is of type uchar_t but - * hexascii_to_octet() expects a uint_t * - */ - dn_cid_len = DN_MAX_CID_LEN; - if (hexascii_to_octet(fields[DNF_CID], strlen(fields[DNF_CID]), - dnp->dn_cid, &dn_cid_len) != 0) - return (B_FALSE); - - dnp->dn_cid_len = dn_cid_len; - if (DSVC_QISEQ(query, DN_QCID) && - (dnp->dn_cid_len != targetp->dn_cid_len || - (memcmp(dnp->dn_cid, targetp->dn_cid, dnp->dn_cid_len) != 0))) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QCID) && - (dnp->dn_cid_len == targetp->dn_cid_len && - (memcmp(dnp->dn_cid, targetp->dn_cid, dnp->dn_cid_len) == 0))) - return (B_FALSE); - - dnp->dn_sip.s_addr = ntohl(inet_addr(fields[DNF_SIP])); - if (DSVC_QISEQ(query, DN_QSIP) && - dnp->dn_sip.s_addr != targetp->dn_sip.s_addr) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QSIP) && - dnp->dn_sip.s_addr == targetp->dn_sip.s_addr) - return (B_FALSE); - - (void) strlcpy(dnp->dn_macro, fields[DNF_MACRO], - sizeof (dnp->dn_macro)); - if (DSVC_QISEQ(query, DN_QMACRO) && - strcmp(targetp->dn_macro, dnp->dn_macro) != 0) - return (B_FALSE); - if (DSVC_QISNEQ(query, DN_QMACRO) && - strcmp(targetp->dn_macro, dnp->dn_macro) == 0) - return (B_FALSE); - - dnp->dn_flags = atoi(fields[DNF_FLAGS]); - for (i = 0; i < sizeof (qflags) / sizeof (unsigned int); i++) { - if (DSVC_QISEQ(query, qflags[i]) && - (dnp->dn_flags & flags[i]) != - (targetp->dn_flags & flags[i])) - return (B_FALSE); - if (DSVC_QISNEQ(query, qflags[i]) && - (dnp->dn_flags & flags[i]) == - (targetp->dn_flags & flags[i])) - return (B_FALSE); - } - (void) strlcpy(dnp->dn_comment, fields[DNF_COMMENT], - sizeof (dnp->dn_comment)); - - return (B_TRUE); -} - -/* - * Internal dhcp_network record update routine, used to factor out the - * common code between add_dn(), delete_dn(), and modify_dn(). If `origp' - * is NULL, then act like add_dn(); if `newp' is NULL, then act like - * delete_dn(); otherwise act like modify_dn(). - */ -static int -update_dn(const dn_handle_t *dhp, const dn_rec_t *origp, dn_rec_t *newp) -{ - char dnpath[MAXPATHLEN], newpath[MAXPATHLEN]; - int retval = DSVC_SUCCESS; - off_t recoff, recnext; - dn_rec_list_t *reclist; - FILE *fp; - int newfd; - uint_t found; - int query; - struct stat st; - - if ((dhp->dh_oflags & DSVC_WRITE) == 0) - return (DSVC_ACCESS); - - /* - * Open the container to update and a new container file which we - * will store the updated version of the container in. When the - * update is done, rename the new file to be the real container. - */ - net2path(dnpath, MAXPATHLEN, dhp->dh_location, dhp->dh_net, ""); - fp = fopen(dnpath, "r"); - if (fp == NULL) - return (syserr_to_dsvcerr(errno)); - - net2path(newpath, MAXPATHLEN, dhp->dh_location, dhp->dh_net, ".new"); - newfd = open(newpath, O_CREAT|O_TRUNC|O_WRONLY, 0644); - if (newfd == -1) { - (void) fclose(fp); - return (syserr_to_dsvcerr(errno)); - } - - DSVC_QINIT(query); - DSVC_QEQ(query, DN_QCIP); - - /* - * If we're adding a new record or changing a key for an existing - * record, bail if the record we want to add already exists. - */ - if (newp != NULL) { - if (origp == NULL || - origp->dn_cip.s_addr != newp->dn_cip.s_addr) { - retval = find_dn(fp, 0, query, 1, newp, NULL, &found); - if (retval != DSVC_SUCCESS) - goto out; - if (found != 0) { - retval = DSVC_EXISTS; - goto out; - } - } - } - - /* - * If we're deleting or modifying record, make sure the record - * still exists. Note that we don't check signatures because this - * is a legacy format that has no signatures. - */ - if (origp != NULL) { - retval = find_dn(fp, FIND_POSITION, query, 1, origp, &reclist, - &found); - if (retval != DSVC_SUCCESS) - goto out; - if (found == 0) { - retval = DSVC_NOENT; - goto out; - } - - /* - * Note the offset of the record we're modifying or deleting - * for use down below. - */ - recoff = ((dn_recpos_t *)reclist->dnl_rec)->dnp_off; - recnext = recoff + ((dn_recpos_t *)reclist->dnl_rec)->dnp_size; - - free_dnrec_list(reclist); - } else { - /* - * No record to modify or delete, so set `recoff' and - * `recnext' appropriately. - */ - recoff = 0; - recnext = 0; - } - - /* - * Make a new copy of the container. If we're deleting or - * modifying a record, don't copy that record to the new container. - */ - if (fstat(fileno(fp), &st) == -1) { - retval = DSVC_INTERNAL; - goto out; - } - - retval = copy_range(fileno(fp), 0, newfd, 0, recoff); - if (retval != DSVC_SUCCESS) - goto out; - - retval = copy_range(fileno(fp), recnext, newfd, recoff, - st.st_size - recnext); - if (retval != DSVC_SUCCESS) - goto out; - - /* - * If there's a new/modified record, append it to the new container. - */ - if (newp != NULL) { - retval = write_rec(newfd, newp, recoff + st.st_size - recnext); - if (retval != DSVC_SUCCESS) - goto out; - } - - /* - * Note: we close these descriptors before the rename(2) (rather - * than just having the `out:' label clean them up) to save NFS - * some work (otherwise, NFS has to save `dnpath' to an alternate - * name since its vnode would still be active). - */ - (void) fclose(fp); - (void) close(newfd); - - if (rename(newpath, dnpath) == -1) - retval = syserr_to_dsvcerr(errno); - - return (retval); -out: - (void) fclose(fp); - (void) close(newfd); - (void) unlink(newpath); - return (retval); -} - -int -add_dn(void *handle, dn_rec_t *addp) -{ - return (update_dn((dn_handle_t *)handle, NULL, addp)); -} - -int -modify_dn(void *handle, const dn_rec_t *origp, dn_rec_t *newp) -{ - return (update_dn((dn_handle_t *)handle, origp, newp)); -} - -int -delete_dn(void *handle, const dn_rec_t *delp) -{ - return (update_dn((dn_handle_t *)handle, delp, NULL)); -} - -int -list_dn(const char *location, char ***listppp, uint_t *countp) -{ - char ipaddr[INET_ADDRSTRLEN]; - struct dirent *result; - DIR *dirp; - unsigned int i, count = 0; - char *re, **new_listpp, **listpp = NULL; - int error; - - dirp = opendir(location); - if (dirp == NULL) { - switch (errno) { - case EACCES: - case EPERM: - return (DSVC_ACCESS); - case ENOENT: - return (DSVC_NO_LOCATION); - default: - break; - } - return (DSVC_INTERNAL); - } - - /* - * Compile a regular expression matching an IP address delimited by - * underscores. Note that the `$0' at the end allows us to save the - * IP address in ipaddr when calling regex(3C). - */ - re = regcmp("^(([0-9]{1,3}\\_){3}[0-9]{1,3})$0$", (char *)0); - if (re == NULL) - return (DSVC_NO_MEMORY); - - while ((result = readdir(dirp)) != NULL) { - if (regex(re, result->d_name, ipaddr) != NULL) { - new_listpp = realloc(listpp, - (sizeof (char **)) * (count + 1)); - if (new_listpp == NULL) { - error = DSVC_NO_MEMORY; - goto fail; - } - listpp = new_listpp; - listpp[count] = strdup(ipaddr); - if (listpp[count] == NULL) { - error = DSVC_NO_MEMORY; - goto fail; - } - - /* - * Change all underscores to dots. - */ - for (i = 0; listpp[count][i] != '\0'; i++) { - if (listpp[count][i] == '_') - listpp[count][i] = '.'; - } - - count++; - } - } - free(re); - (void) closedir(dirp); - - *countp = count; - *listppp = listpp; - return (DSVC_SUCCESS); - -fail: - free(re); - (void) closedir(dirp); - - for (i = 0; i < count; i++) - free(listpp[i]); - free(listpp); - return (error); -} - -/* - * Given a buffer `path' of `pathlen' bytes, fill it in with a path to the - * DHCP Network table for IP network `ip' located in directory `dir' with a - * suffix of `suffix'. - */ -static void -net2path(char *path, size_t pathlen, const char *dir, ipaddr_t ip, - const char *suffix) -{ - (void) snprintf(path, pathlen, "%s/%d_%d_%d_%d%s", dir, ip >> 24, - (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff, suffix); -} - -/* - * Write the dn_rec_t `recp' into the open container `fd' at offset - * `recoff'. Returns DSVC_* error code. - */ -static int -write_rec(int fd, dn_rec_t *recp, off_t recoff) -{ - char entbuf[1024], *ent = entbuf; - size_t entsize = sizeof (entbuf); - int entlen; - char dn_cip[INET_ADDRSTRLEN], dn_sip[INET_ADDRSTRLEN]; - char dn_cid[DN_MAX_CID_LEN * 2 + 1]; - unsigned int dn_cid_len = sizeof (dn_cid); - struct in_addr nip; - - if (octet_to_hexascii(recp->dn_cid, recp->dn_cid_len, dn_cid, - &dn_cid_len) != 0) - return (DSVC_INTERNAL); - - nip.s_addr = htonl(recp->dn_cip.s_addr); - (void) inet_ntop(AF_INET, &nip, dn_cip, sizeof (dn_cip)); - nip.s_addr = htonl(recp->dn_sip.s_addr); - (void) inet_ntop(AF_INET, &nip, dn_sip, sizeof (dn_sip)); -again: - if (recp->dn_comment[0] != '\0') { - entlen = snprintf(ent, entsize, "%s %02hu %s %s %u %s %c%s\n", - dn_cid, recp->dn_flags, dn_cip, dn_sip, recp->dn_lease, - recp->dn_macro, DNF_COMMENT_CHAR, recp->dn_comment); - } else { - entlen = snprintf(ent, entsize, "%s %02hu %s %s %u %s\n", - dn_cid, recp->dn_flags, dn_cip, dn_sip, recp->dn_lease, - recp->dn_macro); - } - - if (entlen == -1) - return (syserr_to_dsvcerr(errno)); - - if (entlen > entsize) { - entsize = entlen; - ent = alloca(entlen); - goto again; - } - - if (pnwrite(fd, ent, entlen, recoff) == -1) - return (syserr_to_dsvcerr(errno)); - - return (DSVC_SUCCESS); -} diff --git a/usr/src/lib/libdhcpsvc/modules/files0/dhcp_network.h b/usr/src/lib/libdhcpsvc/modules/files0/dhcp_network.h deleted file mode 100644 index 65f4c6874b..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files0/dhcp_network.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _DHCP_NETWORK_H -#define _DHCP_NETWORK_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/param.h> - -/* - * Implementation-specific data structures and constants for the files0 - * dhcp_network container. These are subject to change at any time. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Per-record state describing the underlying record, including its - * position on-disk. - */ -typedef struct dn_recpos { - dn_rec_t dnp_rec; /* traditional record */ - size_t dnp_size; /* its size in the file */ - off_t dnp_off; /* its starting offset in the file */ -} dn_recpos_t; - -/* - * Per-instance state for each instance of an open_dn(). - */ -typedef struct dn_handle { - unsigned int dh_oflags; /* flags passed into open_dn() */ - char dh_location[MAXPATHLEN]; - ipaddr_t dh_net; -} dn_handle_t; - -/* - * Order of the fields in the on-disk record. - */ -enum { DNF_CID, DNF_FLAGS, DNF_CIP, DNF_SIP, DNF_LEASE, DNF_MACRO, - DNF_COMMENT }; - -#define DNF_MAX_FIELDS 7 /* maximum number of fields */ -#define DNF_REQ_FIELDS 5 /* number of required fields */ -#define DNF_COMMENT_CHAR '#' - -/* - * Constants for use with find_dn(). - */ -#define FIND_PARTIAL 0x0001 /* allow partial success */ -#define FIND_POSITION 0x0002 /* return dn_recpos_t's */ - -#ifdef __cplusplus -} -#endif - -#endif /* _DHCP_NETWORK_H */ diff --git a/usr/src/lib/libdhcpsvc/modules/files0/dhcptab.c b/usr/src/lib/libdhcpsvc/modules/files0/dhcptab.c deleted file mode 100644 index d00b0e1c8b..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files0/dhcptab.c +++ /dev/null @@ -1,505 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This file contains public API functions for managing the legacy dhcptab - * container format. For the semantics of these functions, please see the - * Enterprise DHCP Architecture Document. - */ - -#include <alloca.h> -#include <dhcp_svc_public.h> -#include <errno.h> -#include <fcntl.h> -#include <netinet/in.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include "dhcptab.h" -#include "util.h" - -static void dt2path(char *, size_t, const char *, const char *); -static int write_rec(int, dt_rec_t *, off_t); - -int -open_dt(void **handlep, const char *location, uint_t flags) -{ - dt_handle_t *dhp; - int retval; - int fd; - char dtpath[MAXPATHLEN]; - - dhp = malloc(sizeof (dt_handle_t)); - if (dhp == NULL) - return (DSVC_NO_MEMORY); - - dhp->dh_oflags = flags; - (void) strlcpy(dhp->dh_location, location, MAXPATHLEN); - - /* - * This is a legacy format which has no header, so we neither write - * nor verify a header (we just create the file or make sure it - * exists, depending on the value of `flags'). - */ - dt2path(dtpath, MAXPATHLEN, dhp->dh_location, ""); - retval = open_file(dtpath, flags, &fd); - if (retval != DSVC_SUCCESS) { - free(dhp); - return (retval); - } - (void) close(fd); - - *handlep = dhp; - return (DSVC_SUCCESS); -} - -int -close_dt(void **handlep) -{ - free(*handlep); - return (DSVC_SUCCESS); -} - -int -remove_dt(const char *location) -{ - char dtpath[MAXPATHLEN]; - - dt2path(dtpath, MAXPATHLEN, location, ""); - if (unlink(dtpath) == -1) - return (syserr_to_dsvcerr(errno)); - - return (DSVC_SUCCESS); -} - -/* - * Internal version of lookup_dt() used by both lookup_dt() and - * update_dt(); same semantics as lookup_dt() except that the `partial' - * argument has been generalized into a `flags' field and the handle has - * been turned into a FILE pointer. - */ -static int -find_dt(FILE *fp, uint_t flags, uint_t query, int count, - const dt_rec_t *targetp, dt_rec_list_t **recordsp, uint_t *nrecordsp) -{ - int retval = DSVC_SUCCESS; - char *buf = NULL, *fields[DTF_MAX_FIELDS]; - uint_t nrecords; - dt_rec_t *recordp; - dt_rec_list_t *records, *new_records; - unsigned int nfields; - off_t recoff; - - if (fseek(fp, 0, SEEK_SET) == -1) - return (DSVC_INTERNAL); - - records = NULL; - for (nrecords = 0; count < 0 || nrecords < count; ) { - free(buf); - - if (flags & FIND_POSITION) - recoff = ftello(fp); - - buf = read_entry(fp); - if (buf == NULL) { - if (!feof(fp)) - retval = DSVC_NO_MEMORY; - break; - } - - /* - * Skip pure comment lines; for now this just skips the - * header information at the top of the container. - */ - if (buf[0] == DTF_COMMENT_CHAR) - continue; - - /* - * Parse out the entry into the dt_rec_t - */ - nfields = field_split(buf, DTF_MAX_FIELDS, fields, " \t"); - if (nfields < DTF_MAX_FIELDS) - continue; - - /* - * See if we've got a match. If so, allocate the new - * record, fill it in, and continue. - */ - if (DSVC_QISEQ(query, DT_QTYPE) && - targetp->dt_type != fields[DTF_TYPE][0]) - continue; - else if (DSVC_QISNEQ(query, DT_QTYPE) && - targetp->dt_type == fields[DTF_TYPE][0]) - continue; - - if (DSVC_QISEQ(query, DT_QKEY) && - strcmp(targetp->dt_key, fields[DTF_KEY]) != 0) - continue; - else if (DSVC_QISNEQ(query, DT_QKEY) && - strcmp(targetp->dt_key, fields[DTF_KEY]) == 0) - continue; - - /* - * Caller just wants a count of the number of matching - * records, not the records themselves; continue. - */ - if (recordsp == NULL) { - nrecords++; - continue; - } - - /* - * Allocate record; if FIND_POSITION flag is set, then we - * need to allocate an extended (dt_recpos_t) record. - */ - if (flags & FIND_POSITION) - recordp = malloc(sizeof (dt_recpos_t)); - else - recordp = malloc(sizeof (dt_rec_t)); - - if (recordp == NULL) { - if ((flags & FIND_PARTIAL) == 0) - retval = DSVC_NO_MEMORY; - break; - } - - /* - * Fill in record; if FIND_POSITION flag is set, then pass - * back additional location information. - */ - (void) strlcpy(recordp->dt_key, fields[DTF_KEY], - sizeof (recordp->dt_key)); - recordp->dt_sig = 1; - recordp->dt_type = fields[DTF_TYPE][0]; - recordp->dt_value = strdup(fields[DTF_VALUE]); - if (recordp->dt_value == NULL) { - free(recordp); - if ((flags & FIND_PARTIAL) == 0) - retval = DSVC_NO_MEMORY; - break; - } - - if (flags & FIND_POSITION) { - ((dt_recpos_t *)recordp)->dtp_off = recoff; - ((dt_recpos_t *)recordp)->dtp_size = ftello(fp) - - recoff; - } - - /* - * Chuck the record on the list; up the counter. - */ - new_records = add_dtrec_to_list(recordp, records); - if (new_records == NULL) { - free_dtrec(recordp); - if ((flags & FIND_PARTIAL) == 0) - retval = DSVC_NO_MEMORY; - break; - } - records = new_records; - nrecords++; - } - - free(buf); - - if (retval == DSVC_SUCCESS) { - *nrecordsp = nrecords; - if (recordsp != NULL) - *recordsp = records; - return (DSVC_SUCCESS); - } - - if (records != NULL) - free_dtrec_list(records); - - return (retval); -} - -int -lookup_dt(void *handle, boolean_t partial, uint_t query, int count, - const dt_rec_t *targetp, dt_rec_list_t **recordsp, uint_t *nrecordsp) -{ - int retval; - char dtpath[MAXPATHLEN]; - FILE *fp; - dt_handle_t *dhp = (dt_handle_t *)handle; - - if ((dhp->dh_oflags & DSVC_READ) == 0) - return (DSVC_ACCESS); - - dt2path(dtpath, MAXPATHLEN, dhp->dh_location, ""); - fp = fopen(dtpath, "r"); - if (fp == NULL) - return (syserr_to_dsvcerr(errno)); - - retval = find_dt(fp, partial ? FIND_PARTIAL : 0, query, count, targetp, - recordsp, nrecordsp); - - (void) fclose(fp); - return (retval); -} - -/* - * Internal dhcptab record update routine, used to factor out the - * common code between add_dt(), delete_dt(), and modify_dt(). If - * `origp' is NULL, then act like add_dt(); if `newp' is NULL, then - * act like delete_dt(); otherwise act like modify_dt(). - */ -static int -update_dt(const dt_handle_t *dhp, const dt_rec_t *origp, dt_rec_t *newp) -{ - char dtpath[MAXPATHLEN], newpath[MAXPATHLEN]; - int retval = DSVC_SUCCESS; - off_t recoff, recnext; - dt_rec_list_t *reclist; - FILE *fp; - int newfd; - uint_t found; - int query; - struct stat st; - - if ((dhp->dh_oflags & DSVC_WRITE) == 0) - return (DSVC_ACCESS); - - /* - * Open the container to update and a new container file which we - * will store the updated version of the container in. When the - * update is done, rename the new file to be the real container. - */ - dt2path(dtpath, MAXPATHLEN, dhp->dh_location, ""); - fp = fopen(dtpath, "r"); - if (fp == NULL) - return (syserr_to_dsvcerr(errno)); - - dt2path(newpath, MAXPATHLEN, dhp->dh_location, ".new"); - (void) unlink(newpath); - newfd = open(newpath, O_CREAT|O_EXCL|O_WRONLY, 0644); - if (newfd == -1) { - (void) fclose(fp); - return (syserr_to_dsvcerr(errno)); - } - - DSVC_QINIT(query); - DSVC_QEQ(query, DT_QKEY|DT_QTYPE); - - /* - * If we're adding a new record or changing a key for an existing - * record, bail if the record we want to add already exists. - */ - if (newp != NULL) { - if (origp == NULL || origp->dt_type != newp->dt_type || - strcmp(origp->dt_key, newp->dt_key) != 0) { - retval = find_dt(fp, 0, query, 1, newp, NULL, &found); - if (retval != DSVC_SUCCESS) - goto out; - if (found != 0) { - retval = DSVC_EXISTS; - goto out; - } - } - } - - /* - * If we're deleting or modifying record, make sure the record - * still exists. Note that we don't check signatures because this - * is a legacy format that has no signatures. - */ - if (origp != NULL) { - retval = find_dt(fp, FIND_POSITION, query, 1, origp, &reclist, - &found); - if (retval != DSVC_SUCCESS) - goto out; - if (found == 0) { - retval = DSVC_NOENT; - goto out; - } - - /* - * Note the offset of the record we're modifying or deleting - * for use down below. - */ - recoff = ((dt_recpos_t *)reclist->dtl_rec)->dtp_off; - recnext = recoff + ((dt_recpos_t *)reclist->dtl_rec)->dtp_size; - - free_dtrec_list(reclist); - } else { - /* - * No record to modify or delete, so set `recoff' and - * `recnext' appropriately. - */ - recoff = 0; - recnext = 0; - } - - /* - * Make a new copy of the container. If we're deleting or - * modifying a record, don't copy that record to the new container. - */ - if (fstat(fileno(fp), &st) == -1) { - retval = DSVC_INTERNAL; - goto out; - } - - retval = copy_range(fileno(fp), 0, newfd, 0, recoff); - if (retval != DSVC_SUCCESS) - goto out; - - retval = copy_range(fileno(fp), recnext, newfd, recoff, - st.st_size - recnext); - if (retval != DSVC_SUCCESS) - goto out; - - /* - * If there's a new record, append it to the new container. - */ - if (newp != NULL) { - retval = write_rec(newfd, newp, recoff + st.st_size - recnext); - if (retval != DSVC_SUCCESS) - goto out; - } - - /* - * Note: we close these descriptors before the rename(2) (rather - * than just having the `out:' label clean them up) to save NFS - * some work (otherwise, NFS has to save `dtpath' to an alternate - * name since its vnode would still be active). - */ - (void) fclose(fp); - (void) close(newfd); - - if (rename(newpath, dtpath) == -1) - retval = syserr_to_dsvcerr(errno); - - return (retval); -out: - (void) fclose(fp); - (void) close(newfd); - (void) unlink(newpath); - return (retval); -} - -int -delete_dt(void *handle, const dt_rec_t *delp) -{ - return (update_dt((dt_handle_t *)handle, delp, NULL)); -} - -int -add_dt(void *handle, dt_rec_t *addp) -{ - return (update_dt((dt_handle_t *)handle, NULL, addp)); -} - -int -modify_dt(void *handle, const dt_rec_t *origp, dt_rec_t *newp) -{ - return (update_dt((dt_handle_t *)handle, origp, newp)); -} - -int -list_dt(const char *location, char ***listppp, uint_t *countp) -{ - char dtpath[MAXPATHLEN]; - char **listpp; - - if (access(location, F_OK|R_OK) == -1) { - switch (errno) { - case EACCES: - case EPERM: - return (DSVC_ACCESS); - case ENOENT: - return (DSVC_NO_LOCATION); - default: - break; - } - return (DSVC_INTERNAL); - } - - dt2path(dtpath, MAXPATHLEN, location, ""); - if (access(dtpath, F_OK|R_OK) == -1) { - *countp = 0; - *listppp = NULL; - return (DSVC_SUCCESS); - } - - listpp = malloc(sizeof (char **)); - if (listpp == NULL) - return (DSVC_NO_MEMORY); - listpp[0] = strdup(DT_DHCPTAB); - if (listpp[0] == NULL) { - free(listpp); - return (DSVC_NO_MEMORY); - } - - *listppp = listpp; - *countp = 1; - return (DSVC_SUCCESS); -} - -/* - * Given a buffer `path' of `pathlen' bytes, fill it in with a path to - * the dhcptab in directory `dir' with a suffix of `suffix'. - */ -static void -dt2path(char *path, size_t pathlen, const char *dir, const char *suffix) -{ - (void) snprintf(path, pathlen, "%s/%s%s", dir, DT_DHCPTAB, suffix); -} - -/* - * Write the dt_rec_t pointed to by `recp' into the open container `fd' at - * offset `recoff'. Returns DSVC_* error code. - */ -static int -write_rec(int fd, dt_rec_t *recp, off_t recoff) -{ - char entbuf[1024], *ent = entbuf; - size_t entsize = sizeof (entbuf); - int entlen; - -again: - entlen = snprintf(ent, entsize, "%s\t%c\t%s\n", recp->dt_key, - recp->dt_type, recp->dt_value); - if (entlen == -1) - return (syserr_to_dsvcerr(errno)); - - if (entlen > entsize) { - entsize = entlen; - ent = alloca(entlen); - goto again; - } - - if (pnwrite(fd, ent, entlen, recoff) == -1) - return (syserr_to_dsvcerr(errno)); - - return (DSVC_SUCCESS); -} diff --git a/usr/src/lib/libdhcpsvc/modules/files0/dhcptab.h b/usr/src/lib/libdhcpsvc/modules/files0/dhcptab.h deleted file mode 100644 index 4c3dcd83ae..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files0/dhcptab.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _DHCPTAB_H -#define _DHCPTAB_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/param.h> - -/* - * Implementation-specific data structures and constants for the files0 - * dhcptab container. These are subject to change at any time. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Per-record state describing the underlying record, including its - * position on-disk. - */ -typedef struct dt_recpos { - dt_rec_t dtp_rec; /* traditional record */ - size_t dtp_size; /* its size in the file */ - off_t dtp_off; /* its starting offset in the file */ -} dt_recpos_t; - -/* - * Per-instance state for each instance of an open_dt(). - */ -typedef struct dt_handle { - unsigned int dh_oflags; /* flags passed into open_dt() */ - char dh_location[MAXPATHLEN]; -} dt_handle_t; - -/* - * Order of the fields in the on-disk record. - */ -enum { DTF_KEY, DTF_TYPE, DTF_VALUE }; - -#define DTF_MAX_FIELDS 3 /* maximum number of fields */ -#define DTF_COMMENT_CHAR '#' - -/* - * Constants for use with find_dt(). - */ -#define FIND_PARTIAL 0x0001 /* allow partial success */ -#define FIND_POSITION 0x0002 /* return dt_recpos_t's */ - -#ifdef __cplusplus -} -#endif - -#endif /* _DHCPTAB_H */ diff --git a/usr/src/lib/libdhcpsvc/modules/files0/i386/Makefile b/usr/src/lib/libdhcpsvc/modules/files0/i386/Makefile deleted file mode 100644 index b98c3b5b37..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files0/i386/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2000 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/modules/files0/i386/Makefile - -include ../Makefile.com - -# This version of SUNWfiles isn't the default; don't install $(ROOTLINKS) -install: all $(ROOTLIBS) diff --git a/usr/src/lib/libdhcpsvc/modules/files0/mapfile-vers b/usr/src/lib/libdhcpsvc/modules/files0/mapfile-vers deleted file mode 100644 index c6c5a8bbac..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files0/mapfile-vers +++ /dev/null @@ -1,64 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -$mapfile_version 2 - -SYMBOL_VERSION SUNWprivate_1.1 { - global: - add_dn; - add_dt; - close_dn; - close_dt; - delete_dn; - delete_dt; - list_dn; - list_dt; - lookup_dn; - lookup_dt; - mklocation; - modify_dn; - modify_dt; - open_dn; - open_dt; - remove_dn; - remove_dt; - status; - version; - local: - *; -}; diff --git a/usr/src/lib/libdhcpsvc/modules/files0/sparc/Makefile b/usr/src/lib/libdhcpsvc/modules/files0/sparc/Makefile deleted file mode 100644 index 8e97f4fd23..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/files0/sparc/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2000 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/modules/files0/sparc/Makefile - -include ../Makefile.com - -# This version of SUNWfiles isn't the default; don't install $(ROOTLINKS) -install: all $(ROOTLIBS) diff --git a/usr/src/lib/libdhcpsvc/modules/templates/Makefile b/usr/src/lib/libdhcpsvc/modules/templates/Makefile deleted file mode 100644 index 2225b9c4c6..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/templates/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include $(SRC)/lib/Makefile.lib -SUBDIRS = $(MACH) -include ../../Makefile.subdirs diff --git a/usr/src/lib/libdhcpsvc/modules/templates/Makefile.com b/usr/src/lib/libdhcpsvc/modules/templates/Makefile.com deleted file mode 100644 index fcd070bad4..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/templates/Makefile.com +++ /dev/null @@ -1,44 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/modules/RESOURCE/Makefile.com - -LIBRARY = ds_RESOURCE.a -VERS = .1 -OBJECTS = dhcptab.o dhcp_network.o general.o - -# include library definitions -include $(SRC)/lib/libdhcpsvc/modules/Makefile.com - -LDLIBS += -lc - -.KEEP_STATE: - -all: $(LIBS) - -# include library targets -include $(SRC)/lib/libdhcpsvc/modules/Makefile.targ diff --git a/usr/src/lib/libdhcpsvc/modules/templates/dhcp_network.c b/usr/src/lib/libdhcpsvc/modules/templates/dhcp_network.c deleted file mode 100644 index 5c5cf4ef33..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/templates/dhcp_network.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This module contains public API functions for managing dhcp network - * containers. - */ - -#include <dhcp_svc_public.h> - -/* - * Creates or opens the dhcp network container ``netp'' (host order) in - * ``location'' and initializes ``handlep'' to point to the instance handle. - * Performs any initialization needed by data store. New containers are - * created with the identity of the caller. - */ -int -open_dn(void **handlep, const char *location, uint_t flags, - const struct in_addr *netp, const struct in_addr *maskp) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * Frees instance handle, cleans up per instance state. - */ -int -close_dn(void **handlep) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * Remove DHCP network container ``netp'' (host order) in location. - * This function will block if the underlying data service is busy or - * otherwise unavailable. - */ -int -remove_dn(const char *location, const struct in_addr *netp) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * Searches DHCP network container for instances that match the query - * described by the combination of query and targetp. If the partial - * argument is true, then lookup operations that are unable to - * complete entirely are allowed (and considered successful). The - * query argument consists of 2 fields, each 16 bits long. The lower - * 16 bits selects which fields {client_id, flags, client_ip, - * server_ip, expiration, macro, or comment} of targetp are to be - * considered in the query. The upper 16 bits identifies whether a - * particular field value must match (bit set) or not match (bit - * clear). Bits 7-15 in both 16 bit fields are currently unused, and - * must be set to 0. The count field specifies the maximum number of - * matching records to return, or -1 if any number of records may be - * returned. The recordsp argument is set to point to the resulting - * list of records; if recordsp is passed in as NULL then no records - * are actually returned. Note that these records are dynamically - * allocated, thus the caller is responsible for freeing them. The - * number of records found is returned in nrecordsp; a value of 0 means - * that no records matched the query. - */ -int -lookup_dn(void *handle, boolean_t partial, uint_t query, int count, - const dn_rec_t *targetp, dn_rec_list_t **recordsp, uint_t *nrecordsp) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * Add the record pointed to by ``addp'' to from the dhcp network container - * referred to by the handle. The underlying public module will set ``addp's'' - * signature as part of the data store operation. - */ -int -add_dn(void *handle, dn_rec_t *addp) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * Atomically modify the record ``origp'' with the record ``newp'' in the dhcp - * network container referred to by the handle. ``newp's'' signature will - * be set by the underlying public module. If an update collision - * occurs, either because ``origp's'' signature in the data store has changed - * or ``newp'' would overwrite an preexisting record, DSVC_COLLISION is - * returned and no update of the data store occurs. - */ -int -modify_dn(void *handle, const dn_rec_t *origp, dn_rec_t *newp) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * Delete the record pointed to by ``pnp'' from the dhcp network container - * referred to by the handle. If ``pnp's'' signature is zero, the caller - * is not interested in checking for collisions, and the record should simply - * be deleted if it exists. If the signature is non-zero, and the signature of - * the data store version of this record do not match, an update collision - * occurs, no deletion of any record is done, and DSVC_COLLISION is returned. - */ -int -delete_dn(void *handle, const dn_rec_t *pnp) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * List the current number of dhcp network container objects located at - * ``location'' in ``listppp''. Return number of list elements in ``count''. - * If no objects exist, then ``count'' is set to 0 and DSVC_SUCCESS is returned. - * - * This function will block if the underlying data service is busy or is - * otherwise unvailable. - */ -int -list_dn(const char *location, char ***listppp, uint_t *count) -{ - return (DSVC_UNSUPPORTED); -} diff --git a/usr/src/lib/libdhcpsvc/modules/templates/dhcptab.c b/usr/src/lib/libdhcpsvc/modules/templates/dhcptab.c deleted file mode 100644 index 6702cb9286..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/templates/dhcptab.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This module contains the public API functions for managing the dhcptab - * container. - */ - -#include <dhcp_svc_public.h> - -/* - * Creates or opens the dhcptab container in ``location'' and initializes - * ``handlep'' to point to the instance handle. When creating a new dhcptab, the - * caller's identity is used for owner/permissions. Performs any initialization - * needed by data store. - */ -int -open_dt(void **handlep, const char *location, uint_t flags) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * Frees instance handle, cleans up per instance state. - */ -int -close_dt(void **handlep) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * Remove dhcptab container in ``location'' from data store. If the underlying - * data store is busy, this function will block. - */ -int -remove_dt(const char *location) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * Searches the dhcptab container for instances that match the query - * described by the combination of query and targetp. If the partial - * argument is true, then lookup operations that are unable to - * complete entirely are allowed (and considered successful). The - * query argument consists of 2 fields, each 16 bits long. The lower - * 16 bits selects which fields {key, flags} of targetp are to be - * considered in the query. The upper 16 bits identifies whether a - * particular field value must match (bit set) or not match (bit - * clear). Bits 2-15 in both 16 bit fields are currently unused, and - * must be set to 0. The count field specifies the maximum number of - * matching records to return, or -1 if any number of records may be - * returned. The recordsp argument is set to point to the resulting - * list of records; if recordsp is passed in as NULL then no records - * are actually returned. Note that these records are dynamically - * allocated, thus the caller is responsible for freeing them. The - * number of records found is returned in nrecordsp; a value of 0 - * means that no records matched the query. - */ -int -lookup_dt(void *handle, boolean_t partial, uint_t query, int count, - const dt_rec_t *targetp, dt_rec_list_t **recordsp, uint_t *nrecordsp) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * Add the record pointed to by ``addp'' to from the dhcptab container referred - * to by the handle. The underlying public module will set ``addp's'' signature - * as part of the data store operation. - */ -int -add_dt(void *handle, dt_rec_t *addp) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * Atomically modify the record ``origp'' with the record ``newp'' in the - * dhcptab container referred to by the handle. ``newp's'' signature will - * be set by the underlying public module. If an update collision - * occurs, either because ``origp's'' signature in the data store has changed - * or ``newp'' would overwrite an existing record, DSVC_COLLISION is - * returned and no update of the data store occurs. - */ -int -modify_dt(void *handle, const dt_rec_t *origp, dt_rec_t *newp) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * Delete the record referred to by dtp from the dhcptab container - * referred to by the handle. If ``dtp's'' signature is zero, the - * caller is not interested in checking for collisions, and the record - * should simply be deleted if it exists. If the signature is non-zero, - * and the signature of the data store version of this record do not match, - * an update collision occurs, no deletion of matching record in data store - * is done, and DSVC_COLLISION is returned. - */ -int -delete_dt(void *handle, const dt_rec_t *dtp) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * List the current number of dhcptab container objects located at - * ``location'' in ``listppp''. Return number of list elements in ``count''. - * If no objects exist, then ``count'' is set to 0 and DSVC_SUCCESS is returned. - * - * This function will block waiting for a result, if the underlying data store - * is busy. - */ -int -list_dt(const char *location, char ***listppp, uint_t *count) -{ - return (DSVC_UNSUPPORTED); -} diff --git a/usr/src/lib/libdhcpsvc/modules/templates/general.c b/usr/src/lib/libdhcpsvc/modules/templates/general.c deleted file mode 100644 index f09d941d1c..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/templates/general.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This module contains the public APIs for status, version, and mklocation. - */ - -#include <dhcp_svc_public.h> - -/* - * This API function instructs the underlying datastore to return its general - * status. If the ``location'' argument is non-NULL, the function validates - * the location for the data store containers (is it formed correctly - * for the data store, and does it exist). - */ -int -status(const char *location) -{ - return (DSVC_UNSUPPORTED); -} - -/* - * Return the data store API version supported by this module. This version - * was implemented to support version 1 of the API. - */ -int -version(int *vp) -{ - *vp = DSVC_PUBLIC_VERSION; - return (DSVC_SUCCESS); -} - -/* - * Create the datastore-specific "location" if it doesn't already exist. - * Containers will ultimately be created there. - */ -int -mklocation(const char *location) -{ - return (DSVC_UNSUPPORTED); -} diff --git a/usr/src/lib/libdhcpsvc/modules/templates/i386/Makefile b/usr/src/lib/libdhcpsvc/modules/templates/i386/Makefile deleted file mode 100644 index 4ab8ac5973..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/templates/i386/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/modules/RESOURCE/i386/Makefile - -include ../Makefile.com - -install: all $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/libdhcpsvc/modules/templates/sparc/Makefile b/usr/src/lib/libdhcpsvc/modules/templates/sparc/Makefile deleted file mode 100644 index 4cadce2c0f..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/templates/sparc/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/modules/RESOURCE/sparc/Makefile - -include ../Makefile.com - -install: all $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/libdhcpsvc/modules/util/util.c b/usr/src/lib/libdhcpsvc/modules/util/util.c deleted file mode 100644 index 4b50304f42..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/util/util.c +++ /dev/null @@ -1,451 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000-2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Internal libdhcpsvc public module utility functions: a collection of - * general-purpose routines that are used by assorted public modules. - * Someday we should integrate this into the build process a bit more - * intelligently. - */ - -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/isa_defs.h> -#include <dhcp_svc_public.h> -#include <assert.h> -#include <stdlib.h> -#include <fcntl.h> -#include <errno.h> -#include <string.h> -#include <sys/sysmacros.h> -#include <unistd.h> -#include <ctype.h> - -#include "util.h" - -/* - * Open a file at path `pathname'; depending on the flags passed in through - * `dsvc_flags', this file may be optionally created or opened read-only. - * On success, DSVC_SUCCESS is returned and `fdp' points to the opened file - * descriptor. On failure, a DSVC_* error code is returned. - */ -int -open_file(const char *pathname, unsigned int dsvc_flags, int *fdp) -{ - int open_flags; - - /* - * Note that we always open with read access, independent of - * dsvc_flags, because an update operation (add, delete, modify) - * needs to lookup records to detect collisions. - */ - open_flags = O_RDONLY; - if (dsvc_flags & DSVC_WRITE) - open_flags = O_RDWR; - if (dsvc_flags & DSVC_CREATE) - open_flags |= O_CREAT|O_EXCL; - - *fdp = open(pathname, open_flags, 0644); - if (*fdp == -1) - return (syserr_to_dsvcerr(errno)); - - return (DSVC_SUCCESS); -} - -/* - * Read input a chunk at a time, avoiding as much copying as possible. To - * this end, we don't read into a temporary buffer, but rather read - * directly into dynamically reallocated storage (on the assumption that - * most of the time we will have to return something). Returns NULL either - * on failure or EOF; use feof(3C) on `fp' to determine which condition - * occurred. - */ -char * -read_entry(FILE *fp) -{ - char *newline, *new_result, *result = NULL; - unsigned int len = 0, size = 0, chunksize = BUFSIZ; - - for (;;) { - /* - * See if we need to grow the buffer; we always try to read - * `chunksize' bytes, so we need at least `chunksize' around; - * grab a little more just to avoid constant realloc'ing - */ - if (len + chunksize > size) { - size = len + (chunksize * 2); - new_result = realloc(result, size); - if (new_result == NULL) { - free(result); - return (NULL); - } - } - - if (fgets(&new_result[len], chunksize, fp) == NULL) { - /* - * Hit EOF; if we never read any data, then free - * `new_result' and return NULL. If we are - * returning data, it's in `new_result', not - * `result'. - */ - if (result == NULL) - free(new_result); - else - result = new_result; - break; - } - result = new_result; - - /* - * If we read a newline, then see if the preceding - * character was an escape. If so, remove the escape and - * continue; otherwise we're done. Note that we need to - * do the strrchr() on `&result[len]' so that NUL's that - * may be lurking elsewhere on the line don't confuse us. - */ - newline = strrchr(&result[len], '\n'); - if (newline != NULL) { - len = newline - result; - if (newline == result || newline[-1] != '\\') { - newline[0] = '\0'; - break; - } - newline[-1] = '\0'; - len -= 2; - } else { - /* - * We either `chunksize' worth of data or we hit a - * NUL somewhere in the data stream. If we hit a - * NUL, then we can't "see" beyond the NUL; just - * advance to the NUL itself and continue. - */ - len += strlen(&result[len]); - } - } - return (result); -} - -/* - * Given a buffer `buf' of words separated by one or more of the characters - * in `seps', split it into at most `nfields' fields, by changing the - * separator character following a field to a NUL character. Set - * `fields[i]' to point to the beginning of field i in `buf'. Return the - * number of fields set in `fields[]'. This routine is quite similar to - * bufsplit(3G), but less general, faster, and also handles multiple - * multiple whitespace separator characters differently. - */ -unsigned int -field_split(char *buf, unsigned int nfields, char *fields[], const char *seps) -{ - unsigned int i = 0; - char *ch; - - for (;;) { - fields[i] = buf; - - /* - * Look for the field separator, byte-at-a-time; ignore - * separators that have been escaped. Believe it or not, - * strchr(3C) will match `seps' if `*buf' is the NUL byte - * (which indicates we're done). - */ - for (;;) { - ch = strchr(seps, *buf); - if (ch != NULL && *ch == '\0') - return (i + 1); - if (ch != NULL && (buf == fields[i] || buf[-1] != '\\')) - break; - buf++; - } - - /* - * If this is the last field, then consider any remaining - * text on the line part of the last field. This is - * similar to how `read' in sh(1) works. - */ - if (++i == nfields) - return (i); - - if (*buf == '\0') - return (i); - - *buf = '\0'; - - /* - * If separator is whitespace, then skip all consecutive - * pieces of whitespace. - */ - while (ch != NULL && isspace(*ch)) { - ch = strchr(seps, buf[1]); - if (ch != NULL && isspace(*ch)) - buf++; - } - buf++; - } -} - -/* - * Map a standard errno into a corresponding DSVC_* code. If there - * is no translation, default to DSVC_INTERNAL. - */ -int -syserr_to_dsvcerr(int error) -{ - switch (error) { - - case EEXIST: - return (DSVC_TABLE_EXISTS); - - case ENOMEM: - return (DSVC_NO_MEMORY); - - case ENOSPC: - return (DSVC_NO_RESOURCES); - - case EROFS: - case EPERM: - case EACCES: - return (DSVC_ACCESS); - - case ENOENT: - return (DSVC_NO_TABLE); - - default: - break; - } - - return (DSVC_INTERNAL); -} - -/* - * Convert an object of `len' bytes pointed to by `srcraw' between - * network-order and host-order and store in `dstraw'. The length `len' - * must be the actual length of the objects pointed to by `srcraw' and - * `dstraw' (or zero) or the results are undefined. Note that `srcraw' and - * `dstraw' may be the same, in which case the object is converted - * in-place. This routine will convert from host-order to network-order or - * network-order to host-order, since the conversion is the same. - */ -void -nhconvert(void *dstraw, const void *srcraw, size_t len) -{ -#ifdef _LITTLE_ENDIAN - uint8_t b1, b2; - uint8_t *dst, *src; - size_t i; - - /* - * If both `srcraw' and `dstraw' are 32-bit aligned and `len' is 4, - * then use ntohl() to do the byteswap, since it's hand-tuned. - */ - if (IS_P2ALIGNED(dstraw, 4) && IS_P2ALIGNED(srcraw, 4) && len == 4) { - *(uint32_t *)dstraw = ntohl(*(uint32_t *)srcraw); - return; - } - - dst = (uint8_t *)dstraw; - src = (uint8_t *)srcraw; - - for (i = 0; i < len / 2; i++) { - b1 = src[i]; - b2 = src[len - i - 1]; - dst[i] = b2; - dst[len - i - 1] = b1; - } -#else - if (srcraw != dstraw) - (void) memmove(dstraw, srcraw, len); -#endif -} - -/* - * Positioned n-byte read: read `buflen' bytes at offset `off' at open file - * `fd' into `buffer', or "read" none at all. Returns -1 if all `buflen' - * bytes cannot be read; otherwise, returns 0. - */ -int -pnread(int fd, void *buffer, size_t buflen, off_t off) -{ - size_t nread; - ssize_t nbytes; - char *buf = buffer; - - for (nread = 0; nread < buflen; nread += nbytes) { - nbytes = pread(fd, &buf[nread], buflen - nread, off + nread); - if (nbytes == -1) - return (-1); - if (nbytes == 0) { - errno = EIO; - return (-1); - } - } - - assert(nread == buflen); - return (0); -} - -/* - * Positioned n-byte write: write `buflen' bytes from `buffer' to offset - * `off' in open file `fd'. Tries to write all `buflen' bytes, but does - * not attempt to "undo" what it has done in the case of failure. Returns - * -1 if all `buflen' bytes cannot be written, otherwise returns 0. - */ -int -pnwrite(int fd, const void *buffer, size_t buflen, off_t off) -{ - size_t nwritten; - ssize_t nbytes; - const char *buf = buffer; - - for (nwritten = 0; nwritten < buflen; nwritten += nbytes) { - nbytes = pwrite(fd, &buf[nwritten], buflen - nwritten, - off + nwritten); - if (nbytes == -1) - return (-1); - if (nbytes == 0) { - errno = EIO; - return (-1); - } - } - - assert(nwritten == buflen); - return (0); -} - -/* - * Copy `nbytes' efficiently from offset `srcoff' in `srcfd' to offset - * `dstoff' in `dstfd'; returns a DSVC_* return code. Note that we make - * `nbytes' a uint64_t (rather than a size_t) so that we can copy 2^64 - * bits even when compiled ILP32. - */ -int -copy_range(int srcfd, off_t srcoff, int dstfd, off_t dstoff, uint64_t nbytes) -{ - const size_t chunksize = 16 * PAGESIZE; - size_t validsize; - size_t skip; - uint64_t nwritten = 0; - int mflags = MAP_PRIVATE; - char *buf = NULL; - int error; - - /* - * Handle trivial copy specially so we don't call munmap() below. - */ - if (nbytes == 0) - return (DSVC_SUCCESS); - - /* - * The `off' argument to mmap(2) must be page-aligned, so align it; - * compute how many bytes we need to skip over in the mmap()'d - * buffer as a result. - */ - skip = srcoff % PAGESIZE; - srcoff -= skip; - - while (nwritten < nbytes) { - buf = mmap(buf, chunksize, PROT_READ, mflags, srcfd, srcoff); - if (buf == MAP_FAILED) - return (DSVC_INTERNAL); - mflags |= MAP_FIXED; - - validsize = MIN(chunksize, nbytes - nwritten + skip); - if (pnwrite(dstfd, &buf[skip], validsize - skip, dstoff) - == -1) { - error = errno; - (void) munmap(buf, chunksize); - return (syserr_to_dsvcerr(error)); - } - - nwritten += validsize - skip; - dstoff += validsize - skip; - srcoff += validsize; - skip = 0; - } - (void) munmap(buf, chunksize); - - return (DSVC_SUCCESS); -} - -/* - * Unescape all instances of `delimiter' in `buffer' and store result in - * `unescaped', which is `size' bytes. To guarantee that all data is - * copied, `unescaped' should be at least as long as `buffer'. - */ -void -unescape(char delimiter, const char *buffer, char *unescaped, size_t size) -{ - int i, j; - - size--; - for (i = 0, j = 0; buffer[i] != '\0' && j < size; i++, j++) { - if (buffer[i] == '\\' && buffer[i + 1] == delimiter) - i++; - unescaped[j] = buffer[i]; - } - unescaped[j] = '\0'; -} - -/* - * Escape all instances of `delimiter' in `buffer' and store result in - * `escaped', which is `size' bytes. To guarantee that all data is - * copied, `escaped' should be at least twice as long as `buffer'. - */ -void -escape(char delimiter, const char *buffer, char *escaped, size_t size) -{ - int i, j; - - size--; - for (i = 0, j = 0; buffer[i] != '\0' && j < size; i++, j++) { - if (buffer[i] == delimiter) - escaped[j++] = '\\'; - escaped[j] = buffer[i]; - } - escaped[j] = '\0'; -} - -/* - * Generate a signature for a new record. The signature is conceptually - * divided into two pieces: a random 16-bit "generation number" and a - * 48-bit monotonically increasing integer. The generation number protects - * against stale updates to records that have been deleted and since - * recreated. - */ -uint64_t -gensig(void) -{ - static int seeded = 0; - - if (seeded == 0) { - srand48((long)gethrtime()); - seeded++; - } - - return ((uint64_t)lrand48() << 48 | 1); -} diff --git a/usr/src/lib/libdhcpsvc/modules/util/util.h b/usr/src/lib/libdhcpsvc/modules/util/util.h deleted file mode 100644 index ad6abfff84..0000000000 --- a/usr/src/lib/libdhcpsvc/modules/util/util.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2000 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _UTIL_H -#define _UTIL_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Interfaces for libdhcpsvc public module utility functions; these are for - * internal use only. See util.c for information about how to use the - * exported functions. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/types.h> -#include <stdio.h> - -extern int copy_range(int, off_t, int, off_t, uint64_t); -extern unsigned int field_split(char *, uint_t, char **, const char *); -extern void nhconvert(void *, const void *, size_t); -extern int open_file(const char *, unsigned int, int *); -extern char *read_entry(FILE *); -extern int syserr_to_dsvcerr(int); -extern int pnread(int, void *, size_t, off_t); -extern int pnwrite(int, const void *, size_t, off_t); -extern void escape(char, const char *, char *, size_t); -extern void unescape(char, const char *, char *, size_t); -extern uint64_t gensig(void); - -#ifdef __cplusplus -} -#endif - -#endif /* _UTIL_H */ diff --git a/usr/src/lib/libdhcpsvc/private/Makefile b/usr/src/lib/libdhcpsvc/private/Makefile deleted file mode 100644 index 8be228255c..0000000000 --- a/usr/src/lib/libdhcpsvc/private/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include ../Makefile.com -SUBDIRS = $(MACH) -include ../Makefile.subdirs - -XGETFLAGS += -a -POFILE = errmsgs.po - -_msg: $(MSGDOMAINPOFILE) - -include $(SRC)/Makefile.msg.targ -include $(SRC)/lib/Makefile.targ diff --git a/usr/src/lib/libdhcpsvc/private/Makefile.com b/usr/src/lib/libdhcpsvc/private/Makefile.com deleted file mode 100644 index 6d5d7a397a..0000000000 --- a/usr/src/lib/libdhcpsvc/private/Makefile.com +++ /dev/null @@ -1,48 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -LIBRARY = libdhcpsvc.a -VERS = .1 -OBJECTS = confopt.o errmsgs.o private.o public.o dsvcd_synch.o - -# include library definitions -include $(SRC)/lib/libdhcpsvc/Makefile.com - -LIBS = $(DYNLIB) $(LINTLIB) -$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC) - -LDLIBS += -lnsl -linetutil -lelf -lc -CPPFLAGS += -D_DHCPSVC_IMPL -I$(SRC)/cmd/cmd-inet/usr.lib/dsvclockd $(DEBUG) - -.KEEP_STATE: - -all: $(LIBS) - -lint: lintcheck - -# include library targets -include $(SRC)/lib/libdhcpsvc/Makefile.targ diff --git a/usr/src/lib/libdhcpsvc/private/README.synch b/usr/src/lib/libdhcpsvc/private/README.synch deleted file mode 100644 index 255d3834e5..0000000000 --- a/usr/src/lib/libdhcpsvc/private/README.synch +++ /dev/null @@ -1,176 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -DHCP Service Library Synchronization -Peter Memishian, Solaris Software, meem@east.sun.com - -#ident "%Z%%M% %I% %E% SMI" - -Introduction -============ - -When writing DHCP service libraries (i.e., public modules) that provide -access to locally-backed datastores (i.e., have their backing datastore on -the same machine that the module is running on), it can be difficult for -the module author to synchronize access to the underlying datastore between -multiple processes, multiple threads within a single process, multiple -threads within multiple processes, and multiple threads within multiple -processes on multiple machines. - -The goal of DHCP Service Library Synchronization is to simplify the design -of modules using locally-backed datastores by pushing these issues up into -the DHCP service library framework: by designing your module to use this -framework, your code becomes simpler and your design cleaner. - -What does DHCP Service Library Synchronization do for me? -========================================================= - -It synchronizes access to several of the DHCP Service Library public-layer -functions; the particular synchronization guarantees vary depending on the -underlying function being called: - - add_d?() per-container exclusive-perimeter - delete_d?() per-container exclusive-perimeter - modify_d?() per-container exclusive-perimeter - lookup_d?() per-container shared-perimeter - all others no synchronization provided - -The term `per-container exclusive perimeter' access means that only one -thread may be inside the per-container "perimeter" at a time; that means -that if one thread is inside add_dn() for a given container, no other thread -may be inside add_dn() (or delete_dn(), modify_dn(), and lookup_dn() for -that same container). However, other threads may be within routines that -provide no synchronization guarantees such as close_dn(). - -The term `per-container shared perimeter' access means that multiple threads -may be inside the perimeter, as long as they are all in routines which have -either no synchronization guarantees or also have `per-container shared -perimeter' access. For instance, multiple threads may be within lookup_dt() -concurrently, but another thread may not be in add_dt() at the same time. - -Note that the preceding discussion assumes that all the threads being -serialized are all running on the same machine. However, there's also an -optional facility which provides synchronization across multiple threads on -multiple machines as well; see the discussion on cross-host synchronization -below. - -How do I write my module to use DHCP Service Library Synchronization? -===================================================================== - -Write your module just as you normally would. Of course, when writing your -code, you get to take advantage of the synchronization guarantees this -architecture makes for you. - -When you're done writing your module, then add the following to one of your -C source files: - - /* - * This symbol and its value tell the private layer that it must provide - * synchronization guarantees via dsvclockd(1M) before calling our *_dn() - * and *_dt() methods. Please see $SRC/lib/libdhcpsvc/private/README.synch - */ - int dsvc_synchtype = DSVC_SYNCH_DSVCD; - -Next, note that if you want to use cross-host synchronization, you'll need -to bitwise-or in the DSVC_SYNCH_CROSSHOST flag as well -- however, please -read the discussion below regarding cross-host synchronization first! - -The private layer synchronizes access to similarly named containers; that -is, all requests for a given (location, container_name, container_version, -datastore) tuple are synchronized with respect to one another. One -implication of this approach is that there must not be two tuples which -identify the same container -- for instance, (/var/dhcp, dhcptab, 1, -SUNWfiles) and (/var/dhcp/, dhcptab, 1, SUNWfiles) name the same container -but are distinct tuples and thus would not be synchronized with respect to -one another! - -To address this issue, the `location' field given in the above tuple is -required to have the property that no two location names map to the same -location. Public modules whose `location' field does not meet this -constraint must implement a mkloctoken() method, prototyped below, which -maps a location into a token which does meet the constraints. In the above -scenario, mkloctoken() would use realpath(3C) to perform the mapping. - - int mkloctoken(const char *location, char *token, size_t tokensize); - -The location to map is passed in as `location', which must be mapped into an -ASCII `token' of `tokensize' bytes or less. The function should return -DSVC_SUCCESS or a DSVC_* error code describing the problem on failure. Note -that modules which do not use synchronization or already have location names -which meet the constraints need not provide mkloctoken(). - -Cross-host Synchronization -========================== - -Datastores wishing to make use of cross-host synchronization have an -additional constraint: the `location' must be the name of a directory which -is shared and accessible by all hosts which are accessing the datastore. -This constraint is because the code is uses NFS-based file locking to -perform the synchronization. While this is a severe limitation, only -SUNWfiles currently uses this feature, and even that is only for backward -compatibility. We discourage use of this feature in future datastore -implementations. - -How does it work? -================= - -It is helpful but not necessary to understand how this architecture works. -Furthermore, the internal details are still evolving; if you rely on any -details here, the only guarantee is that your code will break someday. - -The easiest way to explain the architecture is by example; thus, assume you -have a module `mymod' that you want to use with DHCP Service Library -Synchronization. Then, for each method specified in the DHCP Server -Performance Project specification, the following happens: - - 1. The private layer is called with the specified method - (as specified in the DHCP Server Performance Project spec) - - 2. The private layer locates the underlying public module - to invoke, given the settings in /etc/inet/dhcpsvc.conf. - (as specified in the DHCP Server Performance Project spec) - - 3. The private layer detects that this module is one that - requires use of DHCP Service Library Synchronization (by - checking the value of the module's dsvc_synchtype symbol). - - 4. If this method is one for which synchronization guarantees - are provided, the private layer sends a "lock" request - across a door to the DHCP service door server daemon (also - known as the lock manager), dsvclockd. - - 5. The dsvclockd daemon receives the lock request and attempts - to lock a given container for either exclusive or shared - access (depending on the request). If the lock request was - "nonblocking" and the lock cannot be immediately acquired, - a DSVC_BUSY error is returned. Otherwise, the daemon waits - until it acquires the lock and sends a DSVC_SUCCESS reply - back. - - 6. Assuming the lock could be obtained (if it was necessary; - see step 4), the private layer locates the appropriate - method in `ds_mymod.so' module, and calls it. - - 7. Once the method has completed (successfully or otherwise), - if this was a method which required a "lock" request, the - private layer sends an "unlock" request to the dsvclockd. - - 8. The private layer returns the reply to the caller. diff --git a/usr/src/lib/libdhcpsvc/private/confopt.c b/usr/src/lib/libdhcpsvc/private/confopt.c deleted file mode 100644 index 05fb4fe758..0000000000 --- a/usr/src/lib/libdhcpsvc/private/confopt.c +++ /dev/null @@ -1,415 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This module contains the functions implementing the interface to the - * /etc/inet/dhcpsvc.conf DHCP service configuration file. - */ - -#include <thread.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <alloca.h> -#include <string.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <errno.h> -#include <dhcp_svc_confkey.h> -#include <dhcp_svc_confopt.h> -#include <dhcp_svc_private.h> - -/* - * Finds the parameter called key, and returns a reference to it. Returns - * NULL if not found or an error occurred. - */ -static dhcp_confopt_t * -find_dhcp_confopt(dhcp_confopt_t *ddp, const char *key) -{ - unsigned int i; - - if (ddp == NULL || key == NULL) - return (NULL); - - for (i = 0; ddp[i].co_type != DHCP_END; i++) { - if (ddp[i].co_type == DHCP_KEY && - strcasecmp(ddp[i].co_key, key) == 0) - return (&ddp[i]); - } - return (NULL); -} - -/* - * Adds a dhcp_confopt_t to the ddpp table. If the table is NULL, one is - * created. The table is terminated by a NULL entry. The key and value - * arguments are copied, not referenced directly. No check is done to see - * if the parameter already exists. Returns 0 for success, nonzero - * otherwise. - */ -int -add_dsvc_conf(dhcp_confopt_t **ddpp, const char *key, const char *value) -{ - dhcp_confopt_t *ndp, tdp; - unsigned int i; - - if (ddpp == NULL || key == NULL || value == NULL) { - errno = EINVAL; - return (-1); - } - - tdp.co_key = strdup(key); - tdp.co_type = DHCP_KEY; - tdp.co_value = strdup(value); - if (tdp.co_key == NULL || tdp.co_value == NULL) { - free(tdp.co_key); - free(tdp.co_value); - errno = ENOMEM; - return (-1); - } - - for (i = 0; *ddpp && (*ddpp)[i].co_key != NULL; i++) - ; - - ndp = realloc(*ddpp, (i + 2) * sizeof (dhcp_confopt_t)); - if (ndp == NULL) { - free(tdp.co_key); - free(tdp.co_value); - errno = ENOMEM; - return (-1); - } - - ndp[i] = tdp; - (void) memset(&ndp[i + 1], 0, sizeof (dhcp_confopt_t)); - *ddpp = ndp; - - return (0); -} - -/* - * Reads the contents of the configuration file into a dynamically - * allocated array of dhcp_confopt_t records. A zeroed element marks the - * end of the array. Blank lines are ignored. Caller is responsible for - * freeing ddp. - */ -int -read_dsvc_conf(dhcp_confopt_t **ddpp) -{ - struct stat sb; - int dd; - int error; - unsigned int entry; - char *cp, *dp, *eol, *value; - dhcp_confopt_t confopt, *tdp, *ddp = NULL; - char conf[MAXPATHLEN]; - - if (ddpp == NULL) { - errno = EINVAL; - return (-1); - } - - (void) snprintf(conf, sizeof (conf), "%s" DHCP_CONFOPT_FILE, - DHCP_CONFOPT_ROOT); - - if ((dd = open(conf, O_RDONLY)) == -1) - return (-1); - if (fstat(dd, &sb) == -1) { - error = errno; - (void) close(dd); - errno = error; - return (-1); - } - - dp = alloca(sb.st_size); - if (read(dd, dp, sb.st_size) != sb.st_size) { - error = errno; - (void) close(dd); - errno = error; - return (-1); - } - (void) close(dd); - - for (entry = 0, cp = dp; cp < &dp[sb.st_size]; cp = eol + 1) { - eol = strchr(cp, '\n'); - if (eol == NULL) /* done parsing file */ - break; - if (eol == cp) /* blank line -- skip */ - continue; - *eol = '\0'; - - if (*cp == '#') { - confopt.co_type = DHCP_COMMENT; - confopt.co_comment = strdup(cp + 1); - if (confopt.co_comment == NULL) - goto nomem; - } else { - value = strchr(cp, '='); - if (value == NULL) - continue; - *value = '\0'; - - confopt.co_type = DHCP_KEY; - confopt.co_key = strdup(cp); - if (confopt.co_key == NULL) - goto nomem; - - confopt.co_value = strdup(value + 1); - if (confopt.co_value == NULL) { - free(confopt.co_key); - goto nomem; - } - } - - /* always allocate a spare slot for the zeroed entry */ - tdp = realloc(ddp, (entry + 2) * sizeof (dhcp_confopt_t)); - if (tdp == NULL) - goto nomem; - - tdp[entry] = confopt; - (void) memset(&tdp[entry + 1], 0, sizeof (dhcp_confopt_t)); - ddp = tdp; - entry++; - } - - if (ddp == NULL) - return (-1); - - *ddpp = ddp; - return (0); - -nomem: - if (ddp != NULL) - free_dsvc_conf(ddp); - - errno = ENOMEM; - return (-1); -} - -/* - * If the requested parameter exists, replace its value with the new - * value. If it doesn't exist, then add the parameter with the new value. - * Returns 0 for success, -1 otherwise (errno is set). - */ -int -replace_dsvc_conf(dhcp_confopt_t **ddpp, const char *key, const char *value) -{ - dhcp_confopt_t *tdp; - int err; - - if (ddpp == NULL || key == NULL || value == NULL) { - errno = EINVAL; - return (-1); - } - if ((tdp = find_dhcp_confopt(*ddpp, key)) != NULL) { - char *valp; - - if ((valp = strdup(value)) == NULL) - return (-1); /* NOMEM */ - - if (tdp->co_value != NULL) - free(tdp->co_value); - - tdp->co_value = valp; - - errno = 0; - err = 0; - } else - err = (add_dsvc_conf(ddpp, key, value) == 0) ? 0 : -1; - - return (err); -} - -/* - * Writes ddp array to the configuration file. If the configuration file - * already exists, its contents are replaced with the contents of the ddp - * array. If the configuration file does not exist, it is created using - * the identity of the caller (euid/egid) with the permission bits - * specified by the mode argument (and modified by the umask). Caller is - * responsible for freeing the array. - */ -int -write_dsvc_conf(dhcp_confopt_t *ddp, mode_t mode) -{ - int tdd; - ssize_t bytes; - size_t i, size; - char *tmpbuf; - char tmpconf[MAXPATHLEN], conf[MAXPATHLEN]; - - if (ddp == NULL) { - errno = EINVAL; - return (-1); - } - - /* guess at final file size */ - for (i = 0, size = 0; ddp[i].co_type != DHCP_END; i++) { - if (ddp[i].co_type == DHCP_KEY) { - size += strlen(ddp[i].co_key) + 1; /* include = */ - size += strlen(ddp[i].co_value) + 1; /* include \n */ - } else - size += strlen(ddp[i].co_comment) + 2; /* inc # + \n */ - } - - if (size == 0) { - errno = EINVAL; - return (-1); - } - - (void) snprintf(conf, sizeof (conf), "%s" DHCP_CONFOPT_FILE, - DHCP_CONFOPT_ROOT); - (void) snprintf(tmpconf, sizeof (tmpconf), - "%s" DHCP_CONFOPT_FILE ".%ld.%u", DHCP_CONFOPT_ROOT, getpid(), - thr_self()); - - if ((tdd = open(tmpconf, O_CREAT | O_EXCL | O_WRONLY, mode)) < 0) - return (-1); - - tmpbuf = alloca(size); - for (i = 0; ddp[i].co_type != DHCP_END; i++) { - if (ddp[i].co_type == DHCP_KEY) - (void) snprintf(tmpbuf, size, "%s=%s\n", ddp[i].co_key, - ddp[i].co_value); - else - (void) snprintf(tmpbuf, size, "#%s\n", - ddp[i].co_comment); - - bytes = write(tdd, tmpbuf, strlen(tmpbuf)); - - /* Nuke the file if we can't successfully update it */ - if (bytes != strlen(tmpbuf)) { - (void) close(tdd); - (void) unlink(tmpconf); - return (-1); - } - } - (void) close(tdd); - - /* Move new file into place */ - if (rename(tmpconf, conf) < 0) { - (void) unlink(tmpconf); - return (-1); - } - - return (0); -} - -/* - * Frees the memory associated with the ddp array. - */ -void -free_dsvc_conf(dhcp_confopt_t *ddp) -{ - unsigned int i; - - if (ddp == NULL) - return; - - for (i = 0; ddp[i].co_type != DHCP_END; i++) { - if (ddp[i].co_type == DHCP_KEY) { - free(ddp[i].co_key); - free(ddp[i].co_value); - } else - free(ddp[i].co_comment); - } - free(ddp); -} - -/* - * Deletes the configuration file. - */ -int -delete_dsvc_conf(void) -{ - char confpath[MAXPATHLEN]; - - (void) snprintf(confpath, sizeof (confpath), "%s" DHCP_CONFOPT_FILE, - DHCP_CONFOPT_ROOT); - return (unlink(confpath)); -} - -/* - * Return a copy of the value portion of the named key. Caller is - * responsible for freeing value when they're finished using it. Returns 0 - * for success, -1 otherwise (errno is set). - */ -int -query_dsvc_conf(dhcp_confopt_t *ddp, const char *key, char **value) -{ - dhcp_confopt_t *tdp; - - if (key == NULL || value == NULL) { - errno = EINVAL; - return (-1); - } - if ((tdp = find_dhcp_confopt(ddp, key)) != NULL) { - *value = strdup(tdp->co_value); - if (*value == NULL) { - errno = ENOMEM; - return (-1); - } - errno = 0; - return (0); - } - errno = ENOENT; - *value = NULL; - return (-1); -} - -/* - * Given a dhcp_confopt_t structure, fill in a dsvc_datastore_t. - * Data is copied from dhcp_confopt_t structure. - */ -int -confopt_to_datastore(dhcp_confopt_t *ddp, dsvc_datastore_t *dsp) -{ - dhcp_confopt_t *tdp; - - if (ddp == NULL || dsp == NULL) - return (DSVC_INVAL); - - tdp = find_dhcp_confopt(ddp, DSVC_CK_CONVER); - if (tdp == NULL || tdp->co_value == NULL) - return (DSVC_BAD_CONVER); - dsp->d_conver = atoi(tdp->co_value); - - if (query_dsvc_conf(ddp, DSVC_CK_RESOURCE, &dsp->d_resource) == -1) - return (DSVC_BAD_RESOURCE); - - if (query_dsvc_conf(ddp, DSVC_CK_PATH, &dsp->d_location) == -1) { - free(dsp->d_resource); - return (DSVC_BAD_PATH); - } - - /* - * RESOURCE_CONFIG is optional - underlying service will complain - * if it isn't right. - */ - (void) query_dsvc_conf(ddp, DSVC_CK_RESOURCE_CONFIG, &dsp->d_config); - - return (DSVC_SUCCESS); -} diff --git a/usr/src/lib/libdhcpsvc/private/dsvcd_synch.c b/usr/src/lib/libdhcpsvc/private/dsvcd_synch.c deleted file mode 100644 index 7e1fd26073..0000000000 --- a/usr/src/lib/libdhcpsvc/private/dsvcd_synch.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Doors-daemon (dsvclockd) synchronization strategy: contacts a standalone - * daemon to coordinate access to the shared resource across multiple - * processes and multiple threads within a process. Performance is slow - * (about 1200 locks and unlocks per second on a Ultra 170E/167 MHz) but it - * provides robust locks and scales well as the number of CPUs increase. - */ - -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/wait.h> -#include <fcntl.h> -#include <unistd.h> -#include <dsvclockd.h> -#include <door.h> -#include <stdlib.h> -#include <errno.h> -#include <string.h> -#include <stdio.h> -#include <dhcp_svc_private.h> - -static int dsvcd_lock(dsvc_synch_t *, dsvcd_locktype_t, void **); - -/* - * Our synchronization-private data which hangs off of sp->s_data; This - * data is thus per-open-container-instance and (of course) per-process. - */ -typedef struct { - int s_lockfd; /* door lock request fd */ - boolean_t s_crosshost; /* request crosshost synch */ -} dsvcd_synch_t; - -/* - * Initialize the dsvclockd synchronization strategy for an open container, - * whose synchronization information ("synchronization instance") is - * pointed to by `sp', by opening the door to the dsvclockd. On success, - * hang our synchronization-private data off of `sp->s_data'. Returns a - * DSVC_* code. - */ -static int -dsvcd_init(dsvc_synch_t *sp, unsigned int synchflags) -{ - dsvcd_synch_t *dsp; - char doorpath[MAXPATHLEN]; - door_info_t info; - unsigned int tries; - pid_t dsvclockd_pid; - int fd; - - if (geteuid() != 0) - return (DSVC_ACCESS); - - dsp = malloc(sizeof (dsvcd_synch_t)); - sp->s_data = dsp; - if (dsp == NULL) - return (DSVC_NO_MEMORY); - - (void) snprintf(doorpath, MAXPATHLEN, DSVCD_DOOR_FMT, - sp->s_datastore->d_resource); - - dsp->s_lockfd = -1; - dsp->s_crosshost = (synchflags & DSVC_SYNCH_CROSSHOST) != 0; - - fd = open(doorpath, O_RDONLY); - if (fd == -1) { - if (errno == EACCES) { - free(dsp); - sp->s_data = NULL; - return (DSVC_ACCESS); - } - } else { - if (door_info(fd, &info) == 0 && info.di_target != -1) { - dsp->s_lockfd = fd; - return (DSVC_SUCCESS); - } - (void) close(fd); - } - - switch (dsvclockd_pid = fork()) { - case -1: - break; - case 0: - /* - * Close all descriptors so messages don't leak through. - */ - (void) closefrom(0); - - /* - * It's okay if the exec fails; the `default' case below - * will give up and return DSVC_NO_LOCKMGR. - */ - (void) execl(DSVCD_PATH, DSVCD_PATH, (char *)0); - _exit(EXIT_FAILURE); - default: - /* - * Make five attempts to open the dsvclockd door, each - * spaced a half second apart. - */ - for (tries = 0; tries < 5; tries++) { - fd = open(doorpath, O_RDONLY); - if (fd != -1) { - if (door_info(fd, &info) == 0 && - info.di_target != -1) { - (void) waitpid(dsvclockd_pid, NULL, 0); - dsp->s_lockfd = fd; - return (DSVC_SUCCESS); - } - (void) close(fd); - } - (void) poll(NULL, 0, 500); - } - (void) waitpid(dsvclockd_pid, NULL, 0); - break; - } - - free(dsp); - sp->s_data = NULL; - return (DSVC_NO_LOCKMGR); -} - -/* - * Finish using the dsvclockd synchronization strategy on synchronization - * instance `sp'. - */ -static void -dsvcd_fini(dsvc_synch_t *sp) -{ - dsvcd_synch_t *dsp = sp->s_data; - - sp->s_data = NULL; - (void) close(dsp->s_lockfd); - free(dsp); -} - -/* - * Obtain a shared lock on synchronization instance `sp'. Upon success, - * `unlock_cookiep' is set to a token to pass to `dsvcd_unlock' to unlock - * the lock. Returns a DSVC_* code. - */ -static int -dsvcd_rdlock(dsvc_synch_t *sp, void **unlock_cookiep) -{ - return (dsvcd_lock(sp, DSVCD_RDLOCK, unlock_cookiep)); -} - -/* - * Obtain an exclusive lock on synchronization instance `sp'. Upon - * success, `unlock_cookiep' is set to a token to pass to `dsvcd_unlock' to - * unlock the lock. Returns a DSVC_* code. - */ -static int -dsvcd_wrlock(dsvc_synch_t *sp, void **unlock_cookiep) -{ - return (dsvcd_lock(sp, DSVCD_WRLOCK, unlock_cookiep)); -} - -/* - * Lock the synchronization instance `sp' with a lock of type `locktype'. - * Upon success, `unlock_cookiep' is set to point to a door descriptor - * which is used to unlock the lock and to detect if the caller dies - * holding the lock. Returns a DSVC_* code. - */ -static int -dsvcd_lock(dsvc_synch_t *sp, dsvcd_locktype_t locktype, void **unlock_cookiep) -{ - door_arg_t args; - dsvcd_lock_request_t request; - dsvcd_reply_t reply; - door_desc_t *descp; - int unlockfd; - int i; - dsvcd_synch_t *dsp = sp->s_data; - - if (dsp->s_lockfd == -1) - return (DSVC_NO_LOCKMGR); - - request.lrq_request.rq_version = DSVCD_DOOR_VERSION; - request.lrq_request.rq_reqtype = DSVCD_LOCK; - request.lrq_locktype = locktype; - request.lrq_nonblock = sp->s_nonblock; - request.lrq_crosshost = dsp->s_crosshost; - request.lrq_conver = sp->s_datastore->d_conver; - - (void) strlcpy(request.lrq_loctoken, sp->s_loctoken, - sizeof (request.lrq_loctoken)); - (void) strlcpy(request.lrq_conname, sp->s_conname, - sizeof (request.lrq_conname)); - - args.data_ptr = (char *)&request; - args.data_size = sizeof (dsvcd_lock_request_t); - args.desc_ptr = NULL; - args.desc_num = 0; - args.rbuf = (char *)&reply; - args.rsize = sizeof (dsvcd_reply_t); - - if (door_call(dsp->s_lockfd, &args) == -1) { - /* - * If the lock manager went away, we'll get back EBADF. - */ - return (errno == EBADF ? DSVC_NO_LOCKMGR : DSVC_SYNCH_ERR); - } - - descp = args.desc_ptr; - if (args.desc_num == 0) - unlockfd = -1; - else { - unlockfd = descp->d_data.d_desc.d_descriptor; - - /* - * There shouldn't be more than one descriptor, but close - * any extras to ease future compatibility. - */ - for (i = 1; i < args.desc_num; i++) - (void) close(descp[i].d_data.d_desc.d_descriptor); - } - - if (args.rbuf != (char *)&reply) { - (void) memcpy(&reply, args.rbuf, sizeof (reply)); - (void) munmap(args.rbuf, args.rsize); - } - - if (args.data_size != sizeof (dsvcd_reply_t) || - reply.rp_version != DSVCD_DOOR_VERSION) { - (void) close(unlockfd); - return (DSVC_SYNCH_ERR); - } - - if (reply.rp_retval == DSVC_SUCCESS && unlockfd == -1) - return (DSVC_SYNCH_ERR); - - *unlock_cookiep = (void *)unlockfd; - return (reply.rp_retval); -} - -/* - * Unlock the synchronization instance `sp' using the unlock token - * `unlock_cookiep'. Returns a DSVC_* code. - */ -/* ARGSUSED */ -static int -dsvcd_unlock(dsvc_synch_t *sp, void *unlock_cookie) -{ - door_arg_t args; - dsvcd_unlock_request_t request; - dsvcd_reply_t reply; - int unlockfd = (int)unlock_cookie; - int i; - - request.urq_request.rq_version = DSVCD_DOOR_VERSION; - request.urq_request.rq_reqtype = DSVCD_UNLOCK; - - args.data_ptr = (char *)&request; - args.data_size = sizeof (dsvcd_unlock_request_t); - args.desc_ptr = NULL; - args.desc_num = 0; - args.rbuf = (char *)&reply; - args.rsize = sizeof (dsvcd_reply_t); - - if (door_call(unlockfd, &args) == -1) { - /* - * If the lock manager went away while we had a lock - * checked out, regard that as a synchronization error -- - * it should never happen under correct operation. - */ - return (DSVC_SYNCH_ERR); - } - - /* - * There shouldn't be any descriptors returned from the server - * here, but this may change in the future -- close any to ease - * future compatibility. - */ - for (i = 0; i < args.desc_num; i++) - (void) close(args.desc_ptr[i].d_data.d_desc.d_descriptor); - - /* - * Close the unlock door even if the door_call() fails; this is so - * the container gets unlocked even if there's some screwup in the - * graceful unlocking protocol (in that case, this will generate - * a DOOR_UNREF_DATA call). - */ - (void) close(unlockfd); - - if (args.rbuf != (char *)&reply) { - (void) memcpy(&reply, args.rbuf, sizeof (reply)); - (void) munmap(args.rbuf, args.rsize); - } - - if (args.data_size != sizeof (dsvcd_reply_t) || - reply.rp_version != DSVCD_DOOR_VERSION) - return (DSVC_SYNCH_ERR); - - return (reply.rp_retval); -} - -dsvc_synch_ops_t dsvcd_synch_ops = { - dsvcd_init, dsvcd_fini, dsvcd_rdlock, dsvcd_wrlock, dsvcd_unlock -}; diff --git a/usr/src/lib/libdhcpsvc/private/errmsgs.c b/usr/src/lib/libdhcpsvc/private/errmsgs.c deleted file mode 100644 index 6f794e5fd1..0000000000 --- a/usr/src/lib/libdhcpsvc/private/errmsgs.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This file contains the message strings for the data store error - * return codes. - */ - -#include <dhcp_svc_public.h> -#include <locale.h> - -/* - * Note: must be kept in sync with error codes in <dhcp_svc_public.h> - */ -static char *errmsgs[DSVC_NERR] = { -/* 0 DSVC_SUCCESS */ "Success", -/* 1 DSVC_EXISTS */ "Already exists", -/* 2 DSVC_ACCESS */ "Access denied", -/* 3 DSVC_NO_CRED */ "No underlying service credential", -/* 4 DSVC_NOENT */ "Entry does not exist", -/* 5 DSVC_BUSY */ "Busy", -/* 6 DSVC_INVAL */ "Invalid arguments", -/* 7 DSVC_INTERNAL */ "Internal error", -/* 8 DSVC_UNAVAILABLE */ "Underlying service required by " - "public module is unavailable", -/* 9 DSVC_COLLISION */ "Update collision", -/* 10 DSVC_UNSUPPORTED */ "Operation unsupported", -/* 11 DSVC_NO_MEMORY */ "Virtual memory exhausted", -/* 12 DSVC_NO_RESOURCES */ "Non-memory resources unavailable", -/* 13 DSVC_BAD_RESOURCE */ "Malformed/missing RESOURCE setting", -/* 14 DSVC_BAD_PATH */ "Malformed/missing PATH setting", -/* 15 DSVC_MODULE_VERSION */ "Public module version mismatch", -/* 16 DSVC_MODULE_ERR */ "Error in public module", -/* 17 DSVC_MODULE_LOAD_ERR */ "Error loading public module", -/* 18 DSVC_MODULE_UNLOAD_ERR */ "Error unloading public module", -/* 19 DSVC_MODULE_CFG_ERR */ "Module-specific configuration failed", -/* 20 DSVC_SYNCH_ERR */ "Error in synchronization protocol", -/* 21 DSVC_NO_LOCKMGR */ "Cannot contact lock manager", -/* 22 DSVC_NO_LOCATION */ "Location does not exist", -/* 23 DSVC_BAD_CONVER */ "Malformed/missing CONVER setting", -/* 24 DSVC_NO_TABLE */ "Table does not exist", -/* 25 DSVC_TABLE_EXISTS */ "Table already exists" -}; - -/* - * Return the appropriate error message for a given DSVC error. - */ -const char * -dhcpsvc_errmsg(unsigned int index) -{ - if (index >= DSVC_NERR) - return (dgettext(TEXT_DOMAIN, "<unknown error>")); - - return (dgettext(TEXT_DOMAIN, errmsgs[index])); -} diff --git a/usr/src/lib/libdhcpsvc/private/i386/Makefile b/usr/src/lib/libdhcpsvc/private/i386/Makefile deleted file mode 100644 index bfd483ea38..0000000000 --- a/usr/src/lib/libdhcpsvc/private/i386/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/private/i386/Makefile - -include ../Makefile.com - -install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/lib/libdhcpsvc/private/inc.flg b/usr/src/lib/libdhcpsvc/private/inc.flg deleted file mode 100644 index a02f632171..0000000000 --- a/usr/src/lib/libdhcpsvc/private/inc.flg +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# - -echo_file usr/src/cmd/cmd-inet/usr.lib/dsvclockd/dsvclockd.h diff --git a/usr/src/lib/libdhcpsvc/private/llib-ldhcpsvc b/usr/src/lib/libdhcpsvc/private/llib-ldhcpsvc deleted file mode 100644 index df45ce8f3b..0000000000 --- a/usr/src/lib/libdhcpsvc/private/llib-ldhcpsvc +++ /dev/null @@ -1,34 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* LINTLIBRARY */ -/* PROTOLIB1 */ - -#include <dhcp_svc_public.h> -#include <dhcp_svc_private.h> -#include <dhcp_svc_confopt.h> diff --git a/usr/src/lib/libdhcpsvc/private/mapfile-vers b/usr/src/lib/libdhcpsvc/private/mapfile-vers deleted file mode 100644 index b8969b71fe..0000000000 --- a/usr/src/lib/libdhcpsvc/private/mapfile-vers +++ /dev/null @@ -1,76 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -$mapfile_version 2 - -SYMBOL_VERSION SUNWprivate_1.1 { - global: - add_dd_entry; - add_dnrec_to_list; - add_dsvc_conf; - add_dtrec_to_list; - alloc_dnrec; - alloc_dtrec; - close_dd; - confopt_to_datastore; - delete_dd_entry; - delete_dsvc_conf; - dhcpsvc_errmsg; - enumerate_dd; - free_dd; - free_dd_list; - free_dnrec; - free_dnrec_list; - free_dsvc_conf; - free_dtrec; - free_dtrec_list; - list_dd; - lookup_dd; - mklocation_dd; - modify_dd_entry; - module_synchtype; - open_dd; - query_dsvc_conf; - read_dsvc_conf; - remove_dd; - replace_dsvc_conf; - status_dd; - write_dsvc_conf; - local: - *; -}; diff --git a/usr/src/lib/libdhcpsvc/private/private.c b/usr/src/lib/libdhcpsvc/private/private.c deleted file mode 100644 index 1045df04fe..0000000000 --- a/usr/src/lib/libdhcpsvc/private/private.c +++ /dev/null @@ -1,871 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This module contains the private layer API. - */ - -#include <stdio.h> -#include <assert.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <sys/param.h> -#include <libelf.h> -#include <gelf.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <dlfcn.h> -#include <glob.h> -#include <fcntl.h> -#include <libinetutil.h> -#include <dhcp_svc_public.h> -#include <dhcp_svc_private.h> - -/* - * Threading notes for private layer consumers: - * - * The handles returned from open_dd() may be shared across multiple - * threads with no adverse side effects. However, it's up to that consumer - * to ensure that all threads have finished using an instance before - * closing the instance or removing the container it's referencing. - * Phrased differently: - * - * * Consumers must ensure all threads sharing a handle are - * finished before calling close_dd(). - * - * * Consumers must ensure all threads referencing a container are - * closed before calling remove_dd(). - */ - -static boolean_t validate_dd_entry(dsvc_handle_t, const void *, boolean_t); -static int synch_init(dsvc_handle_t, const char *, uint_t); -static void synch_fini(dsvc_handle_t); - -/* - * Order here should match the function array in <dhcp_svc_private.h> - */ -static char *funcnames[] = { - "status", "version", "mklocation", - "list_dt", "open_dt", "close_dt", "remove_dt", - "lookup_dt", "add_dt", "modify_dt", "delete_dt", - "list_dn", "open_dn", "close_dn", "remove_dn", - "lookup_dn", "add_dn", "modify_dn", "delete_dn" -}; - -extern dsvc_synch_ops_t dsvcd_synch_ops; - -/* - * Retrieve the current version associated with the datastore named by - * `resource' and store in `converp'. One might think we could do this via - * a simple readlink(2), but on internal release builds $(ROOTLINKS) - * installs using hardlinks, not symlinks. For this reason and to make it - * harder for us to be fooled, we'll dredge up the actual soname through - * ELF. Close your eyes, it's gonna get ugly. - */ -static int -get_conver(const char *resource, int *converp) -{ - int elf_fd; - int i; - GElf_Shdr gelf_shdr; - GElf_Dyn gelf_dyn; - Elf_Scn *elf_scn = NULL; - Elf *elf_file; - Elf_Data *elf_data; - char *soname = NULL; - char path[MAXPATHLEN]; - - (void) snprintf(path, sizeof (path), "%s%s/%s_%s.so", DHCP_CONFOPT_ROOT, - DSVC_MODULE_DIR, DSVC_PUBLIC_PREFIX, resource); - - elf_fd = open(path, O_RDONLY); - if (elf_fd == -1) - return (DSVC_MODULE_ERR); - - if (elf_version(EV_CURRENT) == EV_NONE) { - (void) close(elf_fd); - return (DSVC_INTERNAL); - } - - elf_file = elf_begin(elf_fd, ELF_C_READ, NULL); - if (elf_file == NULL || elf_kind(elf_file) != ELF_K_ELF) { - (void) close(elf_fd); - return (DSVC_INTERNAL); - } - - while ((elf_scn = elf_nextscn(elf_file, elf_scn)) != NULL) { - if (gelf_getshdr(elf_scn, &gelf_shdr) == 0) - continue; - - if (gelf_shdr.sh_type != SHT_DYNAMIC) - continue; - - elf_data = elf_getdata(elf_scn, NULL); - if (elf_data == NULL) - continue; - - i = 0; - do { - (void) gelf_getdyn(elf_data, i++, &gelf_dyn); - if (gelf_dyn.d_tag == DT_SONAME) - soname = elf_strptr(elf_file, gelf_shdr.sh_link, - gelf_dyn.d_un.d_ptr); - } while (gelf_dyn.d_tag != DT_NULL && soname == NULL); - } - if (soname == NULL || sscanf(soname, "%*[^.].so.%d", converp) != 1) { - (void) elf_end(elf_file); - (void) close(elf_fd); - return (DSVC_MODULE_ERR); - } - (void) elf_end(elf_file); - (void) close(elf_fd); - - return (DSVC_SUCCESS); -} - -/* - * Unload a public datastore module. - */ -static int -unload_public_module(void **instance, dsvc_splapi_t *api) -{ - static dsvc_splapi_t null_api; - - if (dlclose(*instance) != 0) - return (DSVC_MODULE_UNLOAD_ERR); - - *instance = NULL; - *api = null_api; - - return (DSVC_SUCCESS); -} - -/* - * Load public datastore module. Validates version of module. Returns - * instance of opened module, and populates the api argument with the - * function addresses exporting the API. - */ -static int -load_public_module(dsvc_datastore_t *ddp, void **instance, dsvc_splapi_t *api) -{ - int i, v; - dsvc_splfuncp_t configure; - char path[MAXPATHLEN]; - - (void) snprintf(path, sizeof (path), "%s%s/%s_%s.so", DHCP_CONFOPT_ROOT, - DSVC_MODULE_DIR, DSVC_PUBLIC_PREFIX, ddp->d_resource); - - if (ddp->d_conver != DSVC_CUR_CONVER) - (void) snprintf(path, sizeof (path), "%s.%d", path, - ddp->d_conver); - - *instance = dlopen(path, RTLD_LAZY|RTLD_GROUP|RTLD_WORLD); - if (*instance == NULL) - return (DSVC_MODULE_LOAD_ERR); - - /* - * No requirement to duplicate the names - we can always reference - * the same set. - */ - api->version = (dsvc_splfuncp_t)dlsym(*instance, "version"); - if (api->version == NULL || api->version(&v) != DSVC_SUCCESS || - v != DSVC_PUBLIC_VERSION) { - (void) unload_public_module(instance, api); - return (DSVC_MODULE_VERSION); - } - - configure = (dsvc_splfuncp_t)dlsym(*instance, "configure"); - if (configure != NULL) { - if (configure(ddp->d_config) != DSVC_SUCCESS) { - (void) unload_public_module(instance, api); - return (DSVC_MODULE_CFG_ERR); - } - } - - for (i = 0; i < DSVC_NSPLFUNCS; i++) { - if ((((dsvc_splfuncp_t *)api)[i] = - (dsvc_splfuncp_t)dlsym(*instance, funcnames[i])) == NULL) { - (void) unload_public_module(instance, api); - return (DSVC_MODULE_ERR); - } - } - - /* - * Caller requested the current version; fill in what that current - * version is. - */ - if (ddp->d_conver == DSVC_CUR_CONVER) { - int error; - error = get_conver(ddp->d_resource, &ddp->d_conver); - if (error != DSVC_SUCCESS) { - (void) unload_public_module(instance, api); - return (error); - } - } - - return (DSVC_SUCCESS); -} - -/* - * Return a dynamically-allocated null-terminated list of the available - * modules stored in the module directory. A count of the available - * modules is stored in the num argument. Caller is responsible for - * freeing the list. - */ -int -enumerate_dd(char ***modules, int *nump) -{ - int i, retval; - char *ptr; - glob_t globbuf; - char globpat[MAXPATHLEN]; - - if (modules == NULL || nump == NULL) - return (DSVC_INVAL); - - (void) snprintf(globpat, sizeof (globpat), "%s%s/%s_*\\.so", - DHCP_CONFOPT_ROOT, DSVC_MODULE_DIR, DSVC_PUBLIC_PREFIX); - - retval = glob(globpat, GLOB_NOSORT, NULL, &globbuf); - if (retval != 0) { - globfree(&globbuf); - switch (retval) { - case GLOB_NOMATCH: - *nump = 0; - *modules = NULL; - return (DSVC_SUCCESS); - case GLOB_NOSPACE: - return (DSVC_NO_MEMORY); - default: - return (DSVC_INTERNAL); - } - } - - *modules = calloc(globbuf.gl_pathc, sizeof (char **)); - if (*modules == NULL) { - globfree(&globbuf); - return (DSVC_NO_MEMORY); - } - - for (i = 0; i < globbuf.gl_pathc; i++) { - ptr = strrchr(globbuf.gl_pathv[i], '/'); - if (ptr == NULL) - ptr = globbuf.gl_pathv[i]; - else - ptr++; - (*modules)[i] = malloc(strlen(ptr) + 1); - if ((*modules)[i] == NULL) { - while (i--) - free((*modules)[i]); - free(modules); - globfree(&globbuf); - return (DSVC_NO_MEMORY); - } - - (void) sscanf(ptr, "%*[^_]_%[^.]", (*modules)[i]); - } - - globfree(&globbuf); - *nump = i; - return (DSVC_SUCCESS); -} - -/* - * Check the status of the underlying service supporting the data store. - * Caller is responsible for freeing any dynamically allocated arguments. - */ -int -status_dd(dsvc_datastore_t *ddp) -{ - void *instance; - dsvc_splapi_t api; - int error; - - error = load_public_module(ddp, &instance, &api); - if (error != DSVC_SUCCESS) - return (error); - - error = api.status(ddp->d_location); - - (void) unload_public_module(&instance, &api); - - return (error); -} - -/* - * Create within the data store the "location" where containers will be - * stored. - */ -int -mklocation_dd(dsvc_datastore_t *ddp) -{ - void *instance; - dsvc_splapi_t api; - int error; - - error = load_public_module(ddp, &instance, &api); - if (error != DSVC_SUCCESS) - return (error); - - error = api.mklocation(ddp->d_location); - - (void) unload_public_module(&instance, &api); - - return (error); -} - -/* - * Return a list of the current container objects of type 'type' located at - * 'location' in listppp. Return the number of list elements in 'count'. - */ -int -list_dd(dsvc_datastore_t *ddp, dsvc_contype_t type, char ***listppp, - uint_t *count) -{ - void *instance; - dsvc_splapi_t api; - int error; - - error = load_public_module(ddp, &instance, &api); - if (error != DSVC_SUCCESS) - return (error); - - if (type == DSVC_DHCPTAB) - error = api.list_dt(ddp->d_location, listppp, count); - else - error = api.list_dn(ddp->d_location, listppp, count); - - (void) unload_public_module(&instance, &api); - - return (error); -} - -/* - * Creates or opens the DHCP container of type called name within the - * specific datastore referenced by ddp, and returns a handle to this - * container in the handp argument. New containers are created with - * the identity of the caller. Caller is responsible for freeing any - * dynamically allocated arguments. The returned handle instance must - * be released by calling close_dd(). - */ -int -open_dd(dsvc_handle_t *handp, dsvc_datastore_t *ddp, dsvc_contype_t type, - const char *name, uint_t flags) -{ - int error; - dsvc_handle_t hp; - - *handp = NULL; - - if (type == DSVC_DHCPNETWORK && name == NULL) - return (DSVC_INVAL); - - if (flags & DSVC_CREATE && (flags & DSVC_WRITE) == 0) - return (DSVC_INVAL); - - if ((hp = calloc(1, sizeof (struct dsvc_handle))) == NULL) - return (DSVC_NO_MEMORY); - - if (type == DSVC_DHCPNETWORK) { - hp->d_conid.c_net.s_addr = ntohl(inet_addr(name)); - if (hp->d_conid.c_net.s_addr == INADDR_BROADCAST) { - free(hp); - return (DSVC_INVAL); - } - get_netmask4(&hp->d_conid.c_net, &hp->d_conid.c_mask); - } - - error = load_public_module(ddp, &hp->d_instance, &hp->d_api); - if (error != DSVC_SUCCESS) { - free(hp); - return (error); - } - - hp->d_type = type; - hp->d_desc.d_conver = ddp->d_conver; - hp->d_desc.d_resource = strdup(ddp->d_resource); - hp->d_desc.d_location = strdup(ddp->d_location); - if (hp->d_desc.d_resource == NULL || hp->d_desc.d_location == NULL) { - error = DSVC_NO_MEMORY; - goto error; - } - - /* - * Initialize the synchronization strategy (may not be any). - */ - error = synch_init(hp, name, flags); - if (error != DSVC_SUCCESS) - goto error; - - if (type == DSVC_DHCPTAB) - error = hp->d_api.open_dt(&hp->d_hand, ddp->d_location, flags); - else - error = hp->d_api.open_dn(&hp->d_hand, ddp->d_location, flags, - &hp->d_conid.c_net, &hp->d_conid.c_mask); - - if (error != DSVC_SUCCESS) { - if (hp->d_synch != NULL) - synch_fini(hp); - goto error; - } - - *handp = hp; - return (DSVC_SUCCESS); -error: - (void) unload_public_module(&hp->d_instance, &hp->d_api); - free(hp->d_desc.d_resource); - free(hp->d_desc.d_location); - free(hp); - return (error); -} - -/* - * Remove DHCP container called name of type within the specific datastore - * referenced by ddp. Caller is responsible for freeing any dynamically - * allocated arguments. - */ -int -remove_dd(dsvc_datastore_t *ddp, dsvc_contype_t type, const char *name) -{ - void *instance; - int error; - dsvc_splapi_t api; - struct in_addr ip, mask; - - if (type != DSVC_DHCPTAB) { - if ((ip.s_addr = inet_addr(name)) == INADDR_BROADCAST) - return (DSVC_INVAL); - ip.s_addr = ntohl(ip.s_addr); - get_netmask4(&ip, &mask); - } - - error = load_public_module(ddp, &instance, &api); - if (error != DSVC_SUCCESS) - return (error); - - /* remove the DHCP container */ - if (type == DSVC_DHCPTAB) - error = api.remove_dt(ddp->d_location); - else - error = api.remove_dn(ddp->d_location, &ip, &mask); - - (void) unload_public_module(&instance, &api); - - return (error); -} - -/* - * Delete the handle instance referenced by hand. Frees hand if the close - * operation was successful. NOTE: Caller is responsible for synchronizing - * multiple threads such that close_dd() is called when all consuming - * threads have exited. - */ -int -close_dd(dsvc_handle_t *handp) -{ - int error; - - if (handp == NULL || DSVC_HANDLE_INVAL(*handp)) - return (DSVC_INVAL); - - if ((*handp)->d_type == DSVC_DHCPTAB) - error = (*handp)->d_api.close_dt(&((*handp)->d_hand)); - else - error = (*handp)->d_api.close_dn(&((*handp)->d_hand)); - - if (error == DSVC_SUCCESS) { - error = unload_public_module(&(*handp)->d_instance, - &(*handp)->d_api); - if ((*handp)->d_synch != NULL) - synch_fini(*handp); - free((*handp)->d_desc.d_resource); - free((*handp)->d_desc.d_location); - free(*handp); - *handp = NULL; - } - - return (error); -} - -/* - * Searches hand container for records that match the query described by - * the combination of query and targetp. If the partial field is true, then - * lookup operations that have located some records but are unable to - * complete entirely are allowed. The query argument consists of 2 fields, - * each 16 bits long. The lower 16 bits selects which fields in the targetp - * record are to be considered in the query. The upper 16 bits identifies - * whether a particular field value must match (bit set) or not match (bit - * clear). Unused bits in both 16 bit fields must be 0. The count argument - * specifies the maximum number of matching records to return. A count - * value of -1 requests that all matching records be returned. recordsp is - * set to point to the resulting list of records; if recordsp is NULL then - * no records are actually returned. Note that these records are - * dynamically allocated, thus the caller is responsible for freeing them. - * The number of records found is returned in nrecordsp; a value of 0 means - * that no records matched the query. - */ -int -lookup_dd(dsvc_handle_t hand, boolean_t partial, uint_t query, - int count, const void *targetp, void **recordsp, uint_t *nrecordsp) -{ - uint_t mask = 0; - int error; - void *unlock_cookie; - int (*lookup)(); - - if (targetp == NULL || nrecordsp == NULL || DSVC_HANDLE_INVAL(hand)) - return (DSVC_INVAL); - - if (hand->d_type == DSVC_DHCPTAB) { - mask = (uint_t)~DT_QALL; - lookup = hand->d_api.lookup_dt; - } else { - mask = (uint_t)~DN_QALL; - lookup = hand->d_api.lookup_dn; - } - - /* validate query */ - if (((query & 0xffff) & mask) || ((query >> 16) & mask)) - return (DSVC_INVAL); - - /* - * XXX: need to validate the `targetp' -- what a mess cuz only the - * fields lit in `query' need to be valid. - */ - - if (hand->d_synch != NULL) { - error = DSVC_SYNCH_RDLOCK(hand->d_synch, &unlock_cookie); - if (error != DSVC_SUCCESS) - return (error); - } - - error = lookup(hand->d_hand, partial, query, count, targetp, recordsp, - nrecordsp); - - if (hand->d_synch != NULL) - (void) DSVC_SYNCH_UNLOCK(hand->d_synch, unlock_cookie); - - return (error); -} - -/* - * Frees the record pointed to by entryp. - */ -void -free_dd(dsvc_handle_t hand, void *entryp) -{ - if (DSVC_HANDLE_INVAL(hand) || entryp == NULL) - return; - - if (hand->d_type == DSVC_DHCPTAB) - free_dtrec((dt_rec_t *)entryp); - else - free_dnrec((dn_rec_t *)entryp); -} - -/* - * Frees the list of records pointed to by listp. - */ -void -free_dd_list(dsvc_handle_t hand, void *listp) -{ - if (DSVC_HANDLE_INVAL(hand) || listp == NULL) - return; - - if (hand->d_type == DSVC_DHCPTAB) - free_dtrec_list((dt_rec_list_t *)listp); - else - free_dnrec_list((dn_rec_list_t *)listp); -} - -/* - * Add the record newp to the DHCP container hand. newp's update signature - * will be updated by the public layer module doing the update. Caller is - * responsible for freeing newp if it was dynamically allocated. - */ -int -add_dd_entry(dsvc_handle_t hand, void *newp) -{ - int error; - void *unlock_cookie; - - if (DSVC_HANDLE_INVAL(hand)) - return (DSVC_INVAL); - - if (!validate_dd_entry(hand, newp, B_FALSE)) - return (DSVC_INVAL); - - if (hand->d_synch != NULL) { - error = DSVC_SYNCH_WRLOCK(hand->d_synch, &unlock_cookie); - if (error != DSVC_SUCCESS) - return (error); - } - - if (hand->d_type == DSVC_DHCPTAB) - error = hand->d_api.add_dt(hand->d_hand, newp); - else - error = hand->d_api.add_dn(hand->d_hand, newp); - - if (hand->d_synch != NULL) - (void) DSVC_SYNCH_UNLOCK(hand->d_synch, unlock_cookie); - - return (error); -} - -/* - * Modify the record origp with the record newp in the DHCP container hand. - * newp's update signature will be updated by the public layer module doing - * the update. Caller is responsible for freeing origp and/or newp if they - * were dynamically allocated. - */ -int -modify_dd_entry(dsvc_handle_t hand, const void *origp, void *newp) -{ - int error; - void *unlock_cookie; - - if (DSVC_HANDLE_INVAL(hand)) - return (DSVC_INVAL); - - if (!validate_dd_entry(hand, origp, B_TRUE)) - return (DSVC_INVAL); - - if (!validate_dd_entry(hand, newp, B_FALSE)) - return (DSVC_INVAL); - - if (hand->d_synch != NULL) { - error = DSVC_SYNCH_WRLOCK(hand->d_synch, &unlock_cookie); - if (error != DSVC_SUCCESS) - return (error); - } - - if (hand->d_type == DSVC_DHCPTAB) - error = hand->d_api.modify_dt(hand->d_hand, origp, newp); - else - error = hand->d_api.modify_dn(hand->d_hand, origp, newp); - - if (hand->d_synch != NULL) - (void) DSVC_SYNCH_UNLOCK(hand->d_synch, unlock_cookie); - - return (error); -} - -/* - * Deletes the record referred to by entryp from the DHCP container hand. - * Caller is responsible for freeing entryp if it was dynamically - * allocated. - */ -int -delete_dd_entry(dsvc_handle_t hand, void *entryp) -{ - int error; - void *unlock_cookie; - - if (DSVC_HANDLE_INVAL(hand)) - return (DSVC_INVAL); - - if (!validate_dd_entry(hand, entryp, B_TRUE)) - return (DSVC_INVAL); - - if (hand->d_synch != NULL) { - error = DSVC_SYNCH_WRLOCK(hand->d_synch, &unlock_cookie); - if (error != DSVC_SUCCESS) - return (error); - } - - if (hand->d_type == DSVC_DHCPTAB) - error = hand->d_api.delete_dt(hand->d_hand, entryp); - else - error = hand->d_api.delete_dn(hand->d_hand, entryp); - - if (hand->d_synch != NULL) - (void) DSVC_SYNCH_UNLOCK(hand->d_synch, unlock_cookie); - - return (error); -} - -/* - * Validate that the DHCP network record `dn' is correctly formed; returns - * B_TRUE if it is, B_FALSE if it's not. If `justkey' is set, then only - * validate the key. - */ -static boolean_t -validate_dnrec(dsvc_handle_t hand, const dn_rec_t *dn, boolean_t justkey) -{ - /* CIP must be on container's network */ - if (hand->d_conid.c_net.s_addr != - (dn->dn_cip.s_addr & hand->d_conid.c_mask.s_addr)) - return (B_FALSE); - - if (justkey) - return (B_TRUE); - - if (dn->dn_cid_len < 1 || dn->dn_cid_len > DN_MAX_CID_LEN) - return (B_FALSE); - - if ((dn->dn_flags & ~DN_FALL) != 0) - return (B_FALSE); - - return (B_TRUE); -} - -/* - * Validate that the dhcptab record `dt' is correctly formed; returns - * B_TRUE if it is, B_FALSE if it's not. If `justkey' is set, then only - * validate the key. - */ -/* ARGSUSED */ -static boolean_t -validate_dtrec(dsvc_handle_t hand, const dt_rec_t *dt, boolean_t justkey) -{ - return (dt->dt_type == DT_SYMBOL || dt->dt_type == DT_MACRO); -} - -/* - * Validate that a DHCP record of type `hand->d_type' is correctly formed; - * returns B_TRUE if it is, B_FALSE if it's not. If `justkey' is set, then - * only validate the key. - */ -static boolean_t -validate_dd_entry(dsvc_handle_t hand, const void *entryp, boolean_t justkey) -{ - if (entryp == NULL) - return (B_FALSE); - - if (hand->d_type == DSVC_DHCPTAB) - return (validate_dtrec(hand, (dt_rec_t *)entryp, justkey)); - else if (hand->d_type == DSVC_DHCPNETWORK) - return (validate_dnrec(hand, (dn_rec_t *)entryp, justkey)); - - return (B_FALSE); -} - -/* - * Get the type of synchronization needed for this module and store in - * `synchtypep'. Returns a DSVC_* code. This function is exported so that - * dsvclockd(1M) can use it. - */ -int -module_synchtype(dsvc_datastore_t *ddp, dsvc_synchtype_t *synchtypep) -{ - void *instance; - dsvc_splapi_t api; - dsvc_synchtype_t *dsvc_synchtypep; - - if (load_public_module(ddp, &instance, &api) != DSVC_SUCCESS) - return (DSVC_INTERNAL); - - dsvc_synchtypep = dlsym(instance, "dsvc_synchtype"); - if (dsvc_synchtypep != NULL) - *synchtypep = *dsvc_synchtypep; - else - *synchtypep = DSVC_SYNCH_NONE; - - (void) unload_public_module(&instance, &api); - - return (DSVC_SUCCESS); -} - -/* - * Initialize private-layer synchronization on handle `hand' for container - * `conname'; `flags' is the same flags passed into open_dd(). If there's - * no synchronization needed, always succeeds. Returns a DSVC_* code. - */ -int -synch_init(dsvc_handle_t hand, const char *conname, uint_t flags) -{ - dsvc_synchtype_t synchtype; - dsvc_synch_t *sp; - int error; - int (*mkloctoken)(const char *, char *, size_t); - - error = module_synchtype(&hand->d_desc, &synchtype); - if (error != DSVC_SUCCESS) - return (error); - - if (synchtype == DSVC_SYNCH_NONE) - return (DSVC_SUCCESS); - - sp = malloc(sizeof (dsvc_synch_t)); - if (sp == NULL) - return (DSVC_NO_MEMORY); - - sp->s_conname = strdup(conname); - if (sp->s_conname == NULL) { - free(sp); - return (DSVC_NO_MEMORY); - } - sp->s_nonblock = flags & DSVC_NONBLOCK; - sp->s_datastore = &hand->d_desc; - - mkloctoken = (int (*)())dlsym(hand->d_instance, "mkloctoken"); - if (mkloctoken == NULL) { - (void) strlcpy(sp->s_loctoken, sp->s_datastore->d_location, - sizeof (sp->s_loctoken)); - } else { - error = mkloctoken(sp->s_datastore->d_location, sp->s_loctoken, - sizeof (sp->s_loctoken)); - if (error != DSVC_SUCCESS) { - free(sp->s_conname); - free(sp); - return (error); - } - } - - /* - * The only synchtype supported is DSVC_SYNCH_DSVCD; if this - * changes, we'll need to enhance this. - */ - assert((synchtype & DSVC_SYNCH_STRATMASK) == DSVC_SYNCH_DSVCD); - sp->s_ops = &dsvcd_synch_ops; - - error = DSVC_SYNCH_INIT(sp, synchtype & DSVC_SYNCH_FLAGMASK); - if (error != DSVC_SUCCESS) { - free(sp->s_conname); - free(sp); - return (error); - } - - hand->d_synch = sp; - return (DSVC_SUCCESS); -} - -/* - * Finish using private-layer synchronization on handle `hand'. - */ -void -synch_fini(dsvc_handle_t hand) -{ - DSVC_SYNCH_FINI(hand->d_synch); - free(hand->d_synch->s_conname); - free(hand->d_synch); - hand->d_synch = NULL; -} diff --git a/usr/src/lib/libdhcpsvc/private/public.c b/usr/src/lib/libdhcpsvc/private/public.c deleted file mode 100644 index cd4f19b74d..0000000000 --- a/usr/src/lib/libdhcpsvc/private/public.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * This module contains the glue functions necessary for gluing in - * the selected public module API into the private API. - */ - -#include <stdlib.h> -#include <string.h> -#include <dhcp_svc_public.h> - -/* - * Allocate a dt_rec_t structure. Argument values are copied and set - * to the respective fields within the allocated dt_rec_t structure. - * Caller is should free structure using free_dtrec(). - */ -dt_rec_t * -alloc_dtrec(const char *key, char type, const char *value) -{ - dt_rec_t *retval = malloc(sizeof (dt_rec_t)); - - if (key == NULL || value == NULL || retval == NULL) { - free(retval); - return (NULL); - } - - (void) strlcpy(retval->dt_key, key, sizeof (retval->dt_key)); - retval->dt_sig = 0; - retval->dt_type = type; - retval->dt_value = strdup(value); - if (retval->dt_value == NULL) { - free(retval); - return (NULL); - } - return (retval); -} - -/* - * Allocate a dn_rec_t structure. Argument values are copied and set - * to the respective fields within the allocated dn_rec_t structure. - */ -dn_rec_t * -alloc_dnrec(const uchar_t *cid, uchar_t cid_len, uchar_t flags, - struct in_addr cip, struct in_addr sip, lease_t lease, const char *macro, - const char *comment) -{ - dn_rec_t *retval = malloc(sizeof (dn_rec_t)); - - if (cid == NULL || retval == NULL) { - free(retval); - return (NULL); - } - - retval->dn_cid_len = cid_len; - retval->dn_flags = flags; - retval->dn_cip = cip; - retval->dn_sip = sip; - retval->dn_lease = lease; - retval->dn_macro[0] = '\0'; - retval->dn_comment[0] = '\0'; - retval->dn_sig = 0; - (void) memcpy(retval->dn_cid, cid, cid_len); - - if (macro != NULL) - (void) strlcpy(retval->dn_macro, macro, - sizeof (retval->dn_macro)); - - if (comment != NULL) - (void) strlcpy(retval->dn_comment, comment, - sizeof (retval->dn_comment)); - - return (retval); -} - -/* - * Prepend a dt_rec_t to a dt_rec_list_t; if `listp' is NULL, then - * the list is created. - */ -dt_rec_list_t * -add_dtrec_to_list(dt_rec_t *entryp, dt_rec_list_t *listp) -{ - dt_rec_list_t *retval = malloc(sizeof (dt_rec_list_t)); - - if (entryp == NULL || retval == NULL) { - free(retval); - return (NULL); - } - - retval->dtl_next = listp; - retval->dtl_rec = entryp; - return (retval); -} - -/* - * Prepend a dn_rec_t to a dn_rec_list_t; if `listp' is NULL, then - * the list is created. - */ -dn_rec_list_t * -add_dnrec_to_list(dn_rec_t *entryp, dn_rec_list_t *listp) -{ - dn_rec_list_t *retval = malloc(sizeof (dn_rec_list_t)); - - if (entryp == NULL || retval == NULL) { - free(retval); - return (NULL); - } - - retval->dnl_next = listp; - retval->dnl_rec = entryp; - return (retval); -} - -/* - * Free all elements of dtp, as well as the dt_rec_t structure itself. - */ -void -free_dtrec(dt_rec_t *dtp) -{ - if (dtp != NULL) { - free(dtp->dt_value); - free(dtp); - } -} - -/* - * Free a list of dt_rec_t's - */ -void -free_dtrec_list(dt_rec_list_t *dtlp) -{ - dt_rec_list_t *next; - - for (; dtlp != NULL; dtlp = next) { - free_dtrec(dtlp->dtl_rec); - next = dtlp->dtl_next; - free(dtlp); - } -} - -/* - * Free the dn_rec_t structure. - */ -void -free_dnrec(dn_rec_t *dnp) -{ - free(dnp); -} - -/* - * Free a list of dn_rec_t's - */ -void -free_dnrec_list(dn_rec_list_t *dnlp) -{ - dn_rec_list_t *next; - - for (; dnlp != NULL; dnlp = next) { - free_dnrec(dnlp->dnl_rec); - next = dnlp->dnl_next; - free(dnlp); - } -} diff --git a/usr/src/lib/libdhcpsvc/private/sparc/Makefile b/usr/src/lib/libdhcpsvc/private/sparc/Makefile deleted file mode 100644 index c73f19bee9..0000000000 --- a/usr/src/lib/libdhcpsvc/private/sparc/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/private/sparc/Makefile - -include ../Makefile.com - -install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/lib/libdhcpsvc/tests/Makefile b/usr/src/lib/libdhcpsvc/tests/Makefile deleted file mode 100644 index 3296d39e87..0000000000 --- a/usr/src/lib/libdhcpsvc/tests/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# -#ident "%Z%%M% %I% %E% SMI" -# -# lib/libdhcpsvc/tests/Makefile -# - -PROG = test_confopt test_private - -include $(SRC)/cmd/Makefile.cmd - -LDLIBS += -ldhcpsvc -lnsl -linetutil -COPTFLAG = -g -CPPFLAGS += -D_REENTRANT - -.KEEP_STATE: -.PARALLEL: $(PROG) - -all: $(PROG) - -clean: - -install: all - @$(ECHO) "Nothing installed" - -lint: - $(LINT.c) test_confopt.c $(LDLIBS) - $(LINT.c) test_private.c $(LDLIBS) - -include $(SRC)/cmd/Makefile.targ diff --git a/usr/src/lib/libdhcpsvc/tests/specs/applications.txt b/usr/src/lib/libdhcpsvc/tests/specs/applications.txt deleted file mode 100644 index 3ed09019fb..0000000000 --- a/usr/src/lib/libdhcpsvc/tests/specs/applications.txt +++ /dev/null @@ -1,75 +0,0 @@ -#ident "%Z%%M% %I% %E% SMI" mwc - -CDDL HEADER START - -The contents of this file are subject to the terms of the -Common Development and Distribution License, Version 1.0 only -(the "License"). You may not use this file except in compliance -with the License. - -You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -or http://www.opensolaris.org/os/licensing. -See the License for the specific language governing permissions -and limitations under the License. - -When distributing Covered Code, include this CDDL HEADER in each -file and include the License file at usr/src/OPENSOLARIS.LICENSE. -If applicable, add the following below this CDDL HEADER, with the -fields enclosed by brackets "[]" replaced with your own identifying -information: Portions Copyright [yyyy] [name of copyright owner] - -CDDL HEADER END - - Enterprise: Application Layer Test Specification - ================================================ - -ABSTRACT - - This document describes a series of test specifications intended -to be used in the development of test suite(s) to validate the -application/service layer functionality described in Section 2.0 of the -Enterprise DHCP Service Architecture Specification (ARCH) [1]. There is -one test specification for each of the following application/service -layer components: - - * in.dhcpd - DHCP Service daemon - - * dhcpmgr - DHCP Manager GUI - - * dhcpconfig - CLI DHCP service bootstrap program - - * dhtadm - CLI dhcptab table management utility - - * pntadm - CLI dhcp network table(s) management - utility - -TEST APPLICATION - - Test suites(s) written to these specifications should be run -on the reference platform of each of the supported architectures -(sparcv8, sparcv9, IA32, IA64) for each build of the ON consolidation. -See "Enterprise Reference platforms" [1]. - -1.0 in.dhcpd Test Specification - - <link to in.dhcpd.txt> - -2.0 dhcpmgr Test Specification - - <link to dhcpmgr.txt> - -3.0 dhcpconfig Test Specification - - <link to dhcpconfig.txt> - -4.0 dhtadm Test Specification - - <link to dhtadm.txt> - -5.0 pntadm Test Specification - - <link to pntadm.txt> - -REFERENCES - - [1] "Enterprise Reference Hardware Platforms", mwc, 10/23/1999. diff --git a/usr/src/lib/libdhcpsvc/tests/specs/private.txt b/usr/src/lib/libdhcpsvc/tests/specs/private.txt deleted file mode 100644 index d1e9685231..0000000000 --- a/usr/src/lib/libdhcpsvc/tests/specs/private.txt +++ /dev/null @@ -1,1060 +0,0 @@ -#ident "%Z%%M% %I% %E% SMI" mwc - -CDDL HEADER START - -The contents of this file are subject to the terms of the -Common Development and Distribution License, Version 1.0 only -(the "License"). You may not use this file except in compliance -with the License. - -You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -or http://www.opensolaris.org/os/licensing. -See the License for the specific language governing permissions -and limitations under the License. - -When distributing Covered Code, include this CDDL HEADER in each -file and include the License file at usr/src/OPENSOLARIS.LICENSE. -If applicable, add the following below this CDDL HEADER, with the -fields enclosed by brackets "[]" replaced with your own identifying -information: Portions Copyright [yyyy] [name of copyright owner] - -CDDL HEADER END - - Enterprise: Private Layer Test Specification - ============================================ - -ABSTRACT - - This document describes two test specifications intended to be -used in the development of test suite(s) designed to validate the private -layer API described in Section 2.1 of the Enterprise DHCP Service -Architecture Specification (ARCH) [1]. The first specification outlines -testing requirements for the DHCP default file API (ARCH, section 2.1.1) -[1]. The second specification outlines the testing requirements for the -dhcptab and dhcp network container API (ARCH, section 2.1.2) [1]. Each -specification contains a basic sanity test specification, designed to -verify that the API works as designed when fed data in the correct form. -Each specification also contains a full test specification, which -compliments the basic sanity test by providing cases which test the -stability and MT-safeness of the API. - -TEST APPLICATION - - Test suite(s) written to these specifications should be run on -an instance of each reference platform on each build of the ON -consolidation. See "Enterprise Reference Platforms" [2] for more -information. - -1.0 DHCP default file API Test Specification - -1.1 ABSTRACT - - This test specification is divided into two subspecifications -outlining the testing requirements for validating the default file API -described in Section 2.1.1 of ARCH [1]. The first specification describes -a basic sanity test, which describes the testing requirements to verify -that the API works as designed when fed data in the correct form. The -second specification describes a full test, which complements the basic -sanity test by defining test requirements which test the error checking -behavior and MT-safeness of the API. - -1.2 TEST APPLICATION - - Test suite(s) written to this specification should be run on the -reference platform of each of the supported architectures (sparcv8, -sparcv9, IA32, IA64) for each build of the ON consolidation. See -"Enterprise Reference Platforms" [2]. - -1.3 TEST PREPARATION - - Prior to running a test suite, install SUNWdhcsr and SUNWdhcsu -on the testing platform. No external setup is required for this test -suite. Remove any existing default file, /etc/default/dhcp. - -1.4 BASIC SANITY TEST - - Description - - This test validates the basic operation of the default - file API function calls when presented with valid input. - - Test Data - - RESOURCE=files - PATH=/var/dhcp_test - RUN_MODE=server - VERBOSE=TRUE - RELAY_HOPS=8 - INTERFACES=hme0,le0,qfe3 - ETHERS_COMPAT=FALSE - ICMP_VERIFY=TRUE - OFFER_CACHE_TIMEOUT=11 - RESCAN_INTERVAL=61 - LOGGING_FACILITY=6 - BOOTP_COMPAT=FALSE - - Case #1 write_dhcp_defaults: - - Use function to write the test data, using file mode of - 0646. Confirm that data written matches test data. Confirm that - default file created has 0646 file mode and the function - returns 0. - - Case #2 read_dhcp_defaults: - - Create default file containing test data. Read data - using the function. Confirm data contained with dhcp_defaults_t - matches test data and the function returns 0. - - Case #3 delete_dhcp_defaults: - - Remove the default file using the function. Confirm - that default file has been removed and the function returns 0. - - Case #4 query_dhcp_defaults: - - Call function, cycling through each test data key. - Confirm that key is found, and that data returned is correct - and the function returns 0. - - Case #5: free_dhcp_defaults: - - Using the dhcp_defaults_t built containing the test - data, confirm that the function returns 0. - -1.5 FULL TEST - - Description - - This test verifies that the default file API function - calls respond correctly when presented with incorrect data. It - also validates the MT-safeness of the API. - - Test Data - - RESOURCE=files - PATH=/var/dhcp_test - RUN_MODE=server - VERBOSE=TRUE - RELAY_HOPS=8 - INTERFACES=hme0,le0,qfe3 - ETHERS_COMPAT=FALSE - ICMP_VERIFY=TRUE - OFFER_CACHE_TIMEOUT=11 - RESCAN_INTERVAL=61 - LOGGING_FACILITY=6 - BOOTP_COMPAT=FALSE - - Case #1 all API function calls: - - Call each of the API functions with invalid argument(s). - For functions that take more than one argument, call those - functions once for each argument, providing invalid data for - each argument in turn. Confirm that functions return -1 and set - errno to EINVAL. - - Case #2 existing lock file: - - Create /etc/default/.dhcp_defaults_lock. Confirm that - read_dhcp_defaults and write_dhcp_defaults return -1 and set - errno to EAGAIN. - - Case #2 read_dhcp_defaults: - - Condition Expected Result - ========= =============== - - No default file. Confirm that the function - returns -1 and sets errno - to ENOENT. - - Default file w/ Confirm that the function - mode set to 000. returns -1 and sets errno - to EACCESS. - - Case #3 delete_dhcp_defaults: - - Condition Expected Result - ========= =============== - - No default file. Confirm that the function - returns -1 and sets errno - to ENOENT. - - Default file w/ Confirm that the function - mode set to 000. returns -1 and sets errno - to EACCESS. - - Case #3 write_dhcp_defaults: - - Condition Expected Result - ========= =============== - - Default file w/ Confirm that the function - mode set to 000. returns -1 and sets errno - to EACCESS. - - Case #4 Multi-access stress: - - Preparation: - - Generate TUNABLE versions of the default file - containing unique combinations of defaults (no - line within the TUNABLE files are the same). The - default file will be written/accessed using UFS. - - Tunable default values: - - TUNABLE value: 5 - INTERATE value: 100 - - A single multi-threaded test program can be - written which can be used in the following 3 cases. - It will write/read a unique version of the default - file. It will retry a default file operation if EAGAIN - is returned. - - 4.1. Multiple processes - - Run TUNABLE instances of the test program which - writes / reads a different version of the TUNABLE - default file possibilities for a tunable (INTERATE) - number of iterations at once. Once the instances of - the test program have completed their interations, - verify that the file consists of exactly one of the - TUNABLE possible versions of the default file. - - 4.2. Multiple threads, single process - - Run a single instance of the test program which - creates a tunable number of threads (TUNABLE) each of - which will write and read one of the unique default file - combinations for a tunable (INTERATE) number of - interations. Verify that after the program completes, - exactly one of the TUNABLE possible versions of the - default files exists. - - 4.3. Multiple threads, multiple processes, NFS in use - - Run multiple versions of the test program, each - using multiple threads, some versions of the test - program accessing the default directory using NFS, - others using UFS. Verify after the test programs - complete that exactly one of the TUNABLE possible - versions of the default file exists. - - Caution: ensure that the number of threads * - number of processes does not exceed the number of unique - possible default files. - - 4.4. Variation of 4.1-4.3: - - Generate another process which periodically - snags the default file lock file, and verifies that the - current version of the default file matches one of the - unique default file versions. - -2.0 dhcptab and dhcp network container API Test Specification - -2.1 ABSTRACT - - This test specification is divided into two subspecifications -outlining the testing requirements for validating the dhcptab and dhcp -network container API described in Section 2.1.2 of ARCH [1]. The first -specification describes a basic sanity test, which describes the testing -requirements to verify that the API works as designed when fed data in -the correct form with the correct preconditions present. The second -specification describes a full test, which complements the basic sanity -test by defining test requirements which test the error checking -behavior and MT-safeness of the API. - -2.2 TEST APPLICATION - - Test suite(s) written to this specification should be run on the -reference platform of each of the supported architectures (sparcv8, -sparcv9, IA32, IA64) for each build of the ON consolidation. See -"Enterprise Reference Platforms" [2]. - -2.3 TEST PREPARATION - - Prior to running a test suite, install SUNWdhcsr and SUNWdhcsu -on the testing platform. Select a public module SUNWdhc{df,db,dn} and -install it. Configure any data service providing service to the public -module. Set the RESOURCE and PATH default file parameters as required by -the public module. Note that if the underlying public module's -environment is appropriately configured, the results of testing the API -should be the same for any other appropriately configured public module. -The public module status can be verified by running the basic sanity -test for the specific public module. The tester should record the -public module environment used during the test. - -2.4 BASIC SANITY TEST - - Description - - This test validates the basic operation of the dhcptab - and dhcp network container API function calls when presented with - valid input. - - Test Data - - Item Description Application - ==== =========== =========== - <network address> IP address of *_dn - network. Ensure - that appropriate - subnet mask is - available in - netmasks(4). - Candidate networks - have to have at - least 3000 hosts. - - dt records As follows: *_dt - - SrootOpt s Vendor=SUNW.Ultra-1 SUNW.i86pc,1,ASCII,1,0 - SrootIP4 s Vendor=SUNW.Ultra-1 SUNW.i86pc,2,IP,1,1 - SrootNM s Vendor=SUNW.Ultra-1 SUNW.i86pc,3,ASCII,1,0 - SrootPTH s Vendor=SUNW.Ultra-1 SUNW.i86pc,4,ASCII,1,0 - SswapIP4 s Vendor=SUNW.Ultra-1 SUNW.i86pc,5,IP,1,1 - SswapPTH s Vendor=SUNW.Ultra-1 SUNW.i86pc,6,ASCII,1,0 - SbootFIL s Vendor=SUNW.Ultra-1 SUNW.i86pc,7,ASCII,1,0 - Stz s Vendor=SUNW.Ultra-1 SUNW.i86pc,8,ASCII,1,0 - SbootRS s Vendor=SUNW.Ultra-1 SUNW.i86pc,9,NUMBER,2,1 - SinstIP4 s Vendor=SUNW.Ultra-1 SUNW.i86pc,10,IP,1,1 - SinstNM s Vendor=SUNW.Ultra-1 SUNW.i86pc,11,ASCII,1,0 - SinstPTH s Vendor=SUNW.Ultra-1 SUNW.i86pc,12,ASCII,1,0 - SsysidCF s Vendor=SUNW.Ultra-1 SUNW.i86pc,13,ASCII,1,0 - SjumpsCF s Vendor=SUNW.Ultra-1 SUNW.i86pc,14,ASCII,1,0 - Sterm s Vendor=SUNW.Ultra-1 SUNW.i86pc,15,ASCII,1,0 - Locale m :UTCoffst=-18000: - Solaris m :SrootIP4=129.148.174.27:SrootNM="atlantic": \ - :SinstIP4=129.148.174.27:SinstNM="atlantic": \ - :Sterm="xterm":BootSrvA=129.148.174.27: - sparc m \ -:SrootPTH="/export/s28/solaris1of2.s28s_wos/latest/Solaris_8/Tools/Boot": \ - :SinstPTH="/export/s28/solaris1of2.s28s_wos/latest": - sun4u m :Include=Solaris:Include=sparc: - i86pc m :Include=Solaris:SbootFIL="/platform/i86pc/kernel/unix": \ - :SinstPTH="/export/s28/solaris1of2.s28x_wos/latest": \ -:SrootPTH="/export/s28/solaris1of2.s28x_wos/latest/Solaris_8/Tools/Boot": - SUNW.i86pc m :Include=i86pc: - SUNW.Ultra-1 m :SbootFIL="/platform/sun4u/kernel/sparcv9/unix": \ - :Include=sun4u: - <network address> m :Subnet=255.255.0.0:Router=172.21.0.2: \ - :Broadcst=172.21.255.255: - atlantic m :Include=Locale:Timeserv=129.148.174.27:LeaseTim=3600: \ - :LeaseNeg:Hostname:DNSdmain="snt.east.sun.com": \ - :DNSserv=172.21.0.1: - 010800207E8A02 m :Impress=172.22.255.27: - - - <network address> Dhcp network container. *_dn - - dn records ~3000, as follows: *_dn - - 00 00 <network address>+6 172.21.0.2 0 atlantic - . - . - . - 00 00 <network address>+3006 172.21.0.2 0 atlantic - - - - Case #1 dhcpsvc_errmsg: - - Use function in a loop to display all messages - associated with the error codes in Figure 2 of ARCH [1]. Verify - that messages are displayed correctly. - - Case #2 enumerate_dd: - - Verify that this function properly enumerates the public - modules present on the machine under test in - /usr/lib/inet/dhcp/svc. Free memory (count entries in modules). - - Case #3 status_dd: - - Verify that the selected data store service is correctly - configured. - - Case #4 capability_dd: - - Verify that this function returns the correct - capabilities for the public module currently configured for use. - Note: Some public modules may not support this function, which - will cause this function to return DSVC_UNSUPPORTED. - - Case #5 open_dd: - - Using DSVC_CREATE | DSVC_READ | DSVC_WRITE, create a - dhcptab container and a dhcp network container (called - <network address>). Preserve the handles returned for later - use in the following test cases. - - Case #6 list_dd: - - Verify that this function properly returns the currently - available DHCP containers (Case #5) in the data service hosting - the public module. Only those containers created in Case #5 - should exist. Free memory (count entries in listppp). - - Case #7 add_dd_entry: - - Using the handles returned in Case #5, add the test - data records to the dhcptab and dhcp network containers. - - Case #8 lookup_dd: - - 8.1. Verify case #7. - - Using a "count" of -1 and a "query" value set - using DSVC_QINIT (Figure 5 of ARCH[1]), verify that the - contents of the dhcptab container and <network address> - container match the test data. "records" should equal - the number of records for each container. Note that the - order of the records returned may not be the same as - the order in which they were added in case #7. - - 8.2 Verify dhcptab container type. - - 8.2.1. Look for all records with a DT_QTYPE - value of "s". Verify that only the "s" type - records are returned. - - 8.2.2. Look for all records with DT_QTYPE value - of "m". Verify that only the "m" type records - are returned. - - 8.2.3. Look for DT_QKEY of "atlantic". Verify - that only the macro "atlantic" is returned. - - 8.2.4. Look for DT_QKEY of i86pc and not a - DT_QTYPE of "m". Verify that only the macro - "i86pc" is returned. - - 8.3 Verify dhcp network container type. - - 8.2.1. Look for all records with a DN_QCIP - of <network address>+100. Verify that only - one record (with a cip of - <network address>+100) is returned. - - 8.2.2. Look for all records with DN_QMACRO - value of "atlantic". Verify that all records - are returned ("records" == 3000). Note that - records returned may be in a different order - than they were added as part of case #7. - - Case #9 modify_dd_entry: - - 9.1 Modify dhcptab container records - - 9.1.1 Using lookup_dd to find the record with a - DT_QKEY of "Sterm", change the name of the - record from "Sterm" to "sTERM". Use lookup_dd to - verify that the original record has been - renamed. - - 9.1.2 Using lookup_dd to find the record with a - DT_QKEY of "Solaris", change the value portion - of the record to be: - - :SrootIP4=129.148.174.27:SrootNM="atlantic": \ - :SinstIP4=129.148.174.27:SinstNM="atlantic": \ - :sTERM="sun-cmd":BootSrvA=129.148.174.27: - - Using lookup_dd, reexecute the lookup and verify - that the value portion of the record has been - modified correctly. - - 9.2 Modify dhcp network container records - - 9.2.1 Using lookup_dd to find the record with a - DN_QCIP of <network address>+10, change the - lease field to 1/1/2000 and the flags field to - MANUAL. Use lookup_dd to verify that the - original record has been changed. - - 9.2.2 Using lookup_dd to find the record with a - DN_QFLAGS of MANUAL. Change the dn_cid field - to 01080020FFFFFF, dn_flags field to - MANUAL+AUTOMATIC, dn_sip field to 172.23.0.77, - dn_lease field to -1, dn_macro field to "happy", - and the dn_comment field to "This is a test". - Use lookup_dd to verify that the original record - has been changed. - - - Case #10 delete_dd_entry: - - 10.1 Delete dhcptab container record - - Using lookup_dd to find the record with a - DT_QKEY of SUNW.Ultra-1, delete this record. Verify - using lookup_dd that this record can no longer be found. - - 10.2 Delete dhcp network container record - - Using lookup_dd to find the record with a - DN_QCIP of <network address>+101, delete this record. - Verify using lookup_dd that this record can no longer be - found. - - Case #11 close_dd: - - 11.1 Close the open instance of the dhcptab container. - Verify that close_dd returns DSVC_SUCCESS. - - 11.2 Close the open instance of the dhcp network - container <network address>. Verify that close_dd - returns DSVC_SUCCESS. - - Case #12 remove_dd: - - 12.1 Remove the dhcptab container. Verify that it no - longer exists using list_dd. - - 12.2 Remove the dhcp network container <network - address>. Verify that it no longer exists using list_dd. - -2.5 FULL TEST - - Description - - This test verifies that the dhcptab and dhcp network - container API function calls respond correctly when presented with - incorrect data. It also validates the MT-safeness of the API. - The test suite should allow any number of concurrent threads or - test suite processes to be invoked. - - Test Data - - Item Description Application - ==== =========== =========== - <network address> IP address of *_dn - network. Ensure - that appropriate - subnet mask is - available in - netmasks(4). - Candidate networks - have to have at - least 3000 hosts. - - dt records As follows: *_dt - - SrootOpt s Vendor=SUNW.Ultra-1 SUNW.i86pc,1,ASCII,1,0 - SrootIP4 s Vendor=SUNW.Ultra-1 SUNW.i86pc,2,IP,1,1 - SrootNM s Vendor=SUNW.Ultra-1 SUNW.i86pc,3,ASCII,1,0 - SrootPTH s Vendor=SUNW.Ultra-1 SUNW.i86pc,4,ASCII,1,0 - SswapIP4 s Vendor=SUNW.Ultra-1 SUNW.i86pc,5,IP,1,1 - SswapPTH s Vendor=SUNW.Ultra-1 SUNW.i86pc,6,ASCII,1,0 - SbootFIL s Vendor=SUNW.Ultra-1 SUNW.i86pc,7,ASCII,1,0 - Stz s Vendor=SUNW.Ultra-1 SUNW.i86pc,8,ASCII,1,0 - SbootRS s Vendor=SUNW.Ultra-1 SUNW.i86pc,9,NUMBER,2,1 - SinstIP4 s Vendor=SUNW.Ultra-1 SUNW.i86pc,10,IP,1,1 - SinstNM s Vendor=SUNW.Ultra-1 SUNW.i86pc,11,ASCII,1,0 - SinstPTH s Vendor=SUNW.Ultra-1 SUNW.i86pc,12,ASCII,1,0 - SsysidCF s Vendor=SUNW.Ultra-1 SUNW.i86pc,13,ASCII,1,0 - SjumpsCF s Vendor=SUNW.Ultra-1 SUNW.i86pc,14,ASCII,1,0 - Sterm s Vendor=SUNW.Ultra-1 SUNW.i86pc,15,ASCII,1,0 - Locale m :UTCoffst=-18000: - Solaris m :SrootIP4=129.148.174.27:SrootNM="atlantic": \ - :SinstIP4=129.148.174.27:SinstNM="atlantic": \ - :Sterm="xterm":BootSrvA=129.148.174.27: - sparc m \ -:SrootPTH="/export/s28/solaris1of2.s28s_wos/latest/Solaris_8/Tools/Boot": \ - :SinstPTH="/export/s28/solaris1of2.s28s_wos/latest": - sun4u m :Include=Solaris:Include=sparc: - i86pc m :Include=Solaris:SbootFIL="/platform/i86pc/kernel/unix": \ - :SinstPTH="/export/s28/solaris1of2.s28x_wos/latest": \ -:SrootPTH="/export/s28/solaris1of2.s28x_wos/latest/Solaris_8/Tools/Boot": - SUNW.i86pc m :Include=i86pc: - SUNW.Ultra-1 m :SbootFIL="/platform/sun4u/kernel/sparcv9/unix": \ - :Include=sun4u: - <network address> m :Subnet=255.255.0.0:Router=172.21.0.2: \ - :Broadcst=172.21.255.255: - atlantic m :Include=Locale:Timeserv=129.148.174.27:LeaseTim=3600: \ - :LeaseNeg:Hostname:DNSdmain="snt.east.sun.com": \ - :DNSserv=172.21.0.1: - 010800207E8A02 m :Impress=172.22.255.27: - - - <network address> Dhcp network container. *_dn - - dn records ~3000, as follows: *_dn - - 00 00 <network address>+6 172.21.0.2 0 atlantic - . - . - . - 00 00 <network address>+3006 172.21.0.2 0 atlantic - - - - Case #1 all API function calls: - - 1.1 Invalid arguments - - Call each of the API functions with invalid - argument(s). For functions that take more than one - argument, call those functions once for each argument, - providing invalid data for each argument in turn. - Confirm that functions return DSVC_INVAL for all cases - but dhcpsvc_errmsg. This function should return a - string of "unknown". - - 1.2 No public modules (N/A for dhcpsvc_errmsg) - - Call each of the API functions. Verify that - DSVC_ENOENT is returned. - - 1.3 Permission (N/A for dhcpsvc_errmsg) - - Change the permission of the public module to be - unreadable by any user (000). Verify that DSVC_ACCESS - is returned. Restore permission of public module. - - Case #2 status_dd: - - 2.1 Supporting data service not configured. - - Verify that DSVC_SUCCESS is *not* returned. - Some public modules may not return the same error message - in this case. All should fail. - - 2.2 Configured data service, but unavailable. - - Using a data service-specific method of making - the data service temporarily unavailable, call the - function. DSVC_BUSY or DSVC_INTERNAL (different depending - on implementation) is returned. - - 2.3 Configured data service, available. - - Verify that DSVC_SUCCESS is returned. - - Case #3 open_dd: - - Perform the following subcases once each for the dhcptab - container and dhcp network container described in the test - data. - - 3.1 No container - - Call function with DSVC_READ | DSVC_WRITE. - Verify that DSVC_NOENT is returned. - - 3.2 Basic - - Using DSVC_CREATE | DSVC_READ | DSVC_WRITE, - create a dhcptab container and a dhcp network container - (called <network address>). - - 3.3 NON_BLOCK - - Call function with DSVC_READ | DSVC_WRITE | - DSVC_NONBLOCK. Depending on whether the public module - supports it (see module doc), the function should return - either DSVC_SUCCESS or DSVC_UNSUPPORTED. - - 3.4 Container exists - - Using DSVC_CREATE | DSVC_READ | DSVC_WRITE, - verify that the function returns DSVC_EXISTS. - - Cleanup: Remove the containers using remove_dd. - - Case #4 list_dd: - - 4.1 No containers - - Verify that list_dd returns DSVC_NOENT. - - Case #5 add_dd_entry: - - Create and load containers as per Case #5 and Case - #7 of the Basic Sanity Test. - - 5.1 Record exists - - Attempt to add a test data record for the - dhcptab container and dhcp network container - respectively. Verify that DSVC_EXISTS is returned. - - 5.2 Busy - - Close containers with close_dd. Reopen with - DSVC_NONBLOCK specified. If success is returned, using a - data service specific technique for making the service - busy, attempt to add an additional record to each of the - two containers. Verify that DSVC_BUSY is returned. - Remove the busy condition, and reattempt the add. Verify - that DSVC_SUCCESS is returned. close_dd the containers. - - 5.3 Read only - - Reopen the containers with DSVC_READ access - only. If success is returned, attempt to add a new - record to each container. Verify that DSVC_ACCESS is - returned. close_dd the containers. - - Cleanup: Remove the containers using remove_dd. - - Case #5 lookup_dd: - - Create and load containers as per Case #5 and Case #7 of - the Basic Sanity Test. - - 5.1. Record does not exist. - - Produce dhcptab container and dhcp network - container queries that would not be satisfied by the - test data. Verify that DSVC_SUCCESS is returned, and - "records" is 0. - - 5.2 Busy - - Close containers with close_dd. Reopen with - DSVC_NONBLOCK specified. If DSVC_SUCCESS is returned, - using a data service specific technique for making - the service busy, attempt to perform a valid lookup of - records in each of the two containers. Verify that DSVC_BUSY - is returned. Remove the busy condition, and reattempt - the lookups. Verify that DSVC_SUCCESS is returned, and - that data returned is valid. close_dd the containers. - - 5.3 Write only - - Reopen the containers with DSVC_WRITE access - only. If success is returned, attempt to perform - lookup_dd's using any syntactically legal query for each - container type. Verify that DSVC_ACCESS is returned. - close_dd the containers. - - Cleanup: Remove the containers using remove_dd. - - Case #6 modify_dd_entry: - - Create and load containers as per Case #5 and Case #7 of - the Basic Sanity Test. - - 6.1 Unknown record - - Fabricate dn_rec_t / dt_rec_t instances known not - to exist in the respective containers. Attempt to modify - the records. Verify that DSVC_NOENT is returned. - - 6.2 Update Collision #1 - - Use lookup_dd to find valid dhcptab and dhcp - network container records (one each). Change the - signature on the resultant dt_rec_t / dn_rec_t. Attempt - to modify records. Verify that DSVC_COLLISION is returned. - - 6.3 Update Collision #2 - - Use lookup_dd to find valid dhcptab and dhcp - network container records (one each). Attempt to rename - the records to names which already exist (dt_key + - dt_type, dn_cip). Verify that DSVC_EXISTS is returned. - - 6.4 Busy - - Close containers with close_dd. Reopen with - DSVC_NONBLOCK specified. If DSVC_SUCCESS is returned, - acquire valid dhcptab and dhcp network container - records using lookup_dd. Using a data service specific - technique for making the service busy, attempt to - modify the value (non-key fields) of the records. Verify - that DSVC_BUSY is returned. Remove the busy condition, - and reattempt the modifies. Verify that DSVC_SUCCESS - is returned. Reacquire the records. Verify that the - contents have been suitably updated. close_dd the - containers. - - 6.5 Read only - - Reopen the containers with DSVC_READ access - only. If success is returned, locate valid container - records using the appropriate queries to lookup_dd. - Modify the contents of a copy of the dt_rec_t / - dn_rec_t. Attempt to modify the record in the containers. - Verify that DSVC_ACCESS is returned. close_dd the - containers. - - Cleanup: Remove the containers using remove_dd. - - Case #7 free_dd: - - This function should be used to release the results of - lookup_dd calls. Its operation must be validated by running this - test suite under bcheck with -memuse, and ensuring that no free - blocks remain after exit. Note that the test suite must be - written with care to make this case useful (free any allocated - memory before exit). - - Case #8 delete_dd_entry: - - Create and load containers as per Case #5 and Case #7 of - the Basic Sanity Test. - - 8.1 Unknown record - - Fabricate dn_rec_t / dt_rec_t instances known not - to exist in the respective containers. Attempt to delete - the records. Verify that DSVC_NOENT is returned. - - 8.2 Busy - - Close containers with close_dd. Reopen with - DSVC_NONBLOCK specified. If DSVC_SUCCESS is returned, - acquire valid dhcptab and dhcp network container - records using lookup_dd. Using a data service specific - technique for making the service busy, attempt to - delete the records. Verify that DSVC_BUSY is returned. - Remove the busy condition, and reattempt the deletes. - Verify that DSVC_SUCCESS is returned. Attempt to - reacquire the records. Verify that the records have been - deleted. close_dd the containers. - - 8.3 Read only - - Reopen the containers with DSVC_READ access - only. If success is returned, locate valid container - records using the appropriate queries to lookup_dd. - Attempt to delete the records in the containers. - Verify that DSVC_ACCESS is returned. close_dd the - containers. - - Cleanup: Remove the containers using remove_dd. - - Case #9 close_dd: - - 9.1 Busy - - Create containers as per Case #5 of the Basic - Sanity Test, with the exception that DSVC_NONBLOCK is - specified. If DSVC_SUCCESS is returned, using a data - service specific technique for making the service busy, - attempt to close the containers using the handles - returned by open_dd. Verify that DSVC_BUSY is returned. - Remove the busy condition, and reattempt the close_dd. - Verify that DSVC_SUCCESS is returned. - - Cleanup: Remove the containers using remove_dd. - - Case #10 remove_dd: - - Create containers as per Case #5 of the Basic Sanity Test. - - 10.1 Unknown container - - Attempt to remove a non-existent dhcp network - container. Verify that DSVC_NOENT is returned. - - 10.2 Busy - - Close containers with close_dd. Reopen with - DSVC_NONBLOCK specified. If DSVC_SUCCESS is returned, - using a data service specific technique for making the - service busy, attempt to remove the containers. Verify - that DSVC_BUSY is returned. Remove the busy condition, - close_dd the containers, and reattempt the removes. - Verify that DSVC_SUCCESS is returned. Verify using - list_dd that the containers have been removed. - - Case #11 Multi-access stress - - The service provider layer modules underneath - the private layer are not required to manage reference - counts for open instances. So while individual private - layer handles are considered to be MT-safe (and parallel - access to data containers is suitably protected), an - application using the private layer API must synchronize - close and/or container remove operations among threads - such that no threads hold handles to a container after - the handle has been closed or the container has been - removed. - - This case assumes a test which is - multi-threaded, and can run the following test using - from 1 to THREADS threads. The test can also be run in - multiple concurrent processes. - - The goal of this test is to ensure that the API - is MT-safe with respect to the containers and the - records contained within those containers. This goal is - accomplished by verifying that the end result of the - test is consistent. - - Tunable default values: - - PROCESSES: 20 - THREADS: 20 - - 11.1 The dhcptab container test - - 11.1.1 open_dd - - Create a dhcptab using DSVC_CREATE | - DSVC_READ | DSVC_WRITE. If DSVC_EXISTS is - returned, retry the open attempt w/o the - DSVC_CREATE flag. Log that this event occurred. - Handle will be used for balance of test. If any - other error occurs, terminate the test as - failed. - - 11.1.2 add_dd_entry - - Add the test data records to the dhcptab - container. If DSVC_EXISTS is returned, skip that - record, and continue attempting to add the other - records. Log that this event occurred. If any - other error occurs, terminate the test as - failed. - - 11.1.3 lookup_dd - - Using DT_QKEY of "atlantic" and DT_QTYPE - of "m", find the atlantic record. Compare its - value against the test data. If it has - changed, then output a message to this affect. - If any error occurs, terminate the test as failed. - - 11.1.4 modify_dd_entry - - Using the results of 11.1.3, change the - record as follows. If it is no different from - the test data, change the value to: - - :Timeserv=129.148.174.28:LeaseTim=86400: \ - :Hostname:DNSdmain="east.sun.com":DNSserv=172.23.3.3: - - If it doesn't match the test data - value, change the LeaseTim by incrementing it by - one. Attempt to update the record. If it fails - with DSVC_COLLISION, retry 11.1.3 and 11.1.4 for - three attempts. Log message if modify was - unsuccessful. If any other error occurs, - terminate the test as failed. - - 11.1.5 delete_dd_entry - - Use lookup_dd to find a DT_QKEY of - "SjumpsCF" and a DT_QTYPE of "s". If it does - not exist, log a message. If it does exist, - attempt to delete it. If DSVC_NOENT is returned, - log a message. - - 11.1.6 close_dd - - Use close_dd to close the open handle. - If DSVC_NOENT is returned, log a message. - - 11.1.7 epilogue - - Compare the resultant dhcptab container - to the test data. The only differences should be - a changed value of the atlantic macro as - expected from 11.1.4 and the SjumpsCF symbol - should be removed. Any other inconsistency means - the test has failed. - - Clean up: Remove the dhcptab container. - - 11.2 The dhcp network container test - - 11.2.1 open_dd - - Create a <network address> dhcp network - container using DSVC_CREATE | DSVC_READ | DSVC_WRITE. - If DSVC_EXISTS is returned, retry the open - attempt w/o the DSVC_CREATE flag. Log that this - event occurred. Handle will be used for balance - of test. If any other error occurs, terminate - the test as failed. - - 11.2.2 add_dd_entry - - Add the test data records to the dhcp - network container. If DSVC_EXISTS is - returned, skip that record, and continue - attempting to add the other records. Log that - this event occurred. If any other error occurs, - terminate the test as failed. - - 11.2.3 lookup_dd - - Find the DN_QCIP of <network address>+102 - record. Compare its value against the test data. - If it has changed, then output a message to this - affect. If any error occurs, terminate the test - as failed. - - 11.2.4 modify_dd_entry - - Using the results of 11.2.3, change the - record as follows. If it is no different from - the test data, change the value to: - -01DEADBEEF 03 <network address>+102 172.23.3.3 941619403 Solaris - - If it doesn't match the test data - value, change dn_lease by incrementing it by - one. Attempt to update the record. If it fails - with DSVC_COLLISION, retry 11.2.3 and 11.2.4 for - three attempts. Log message if modify was - unsuccessful. If any other error occurs, - terminate the test as failed. - - 11.2.5 delete_dd_entry - - Use lookup_dd to find a DN_QCIP of - <network address>+1001. If it does not exist, - log a message. If it does exist, attempt to - delete it. If DSVC_NOENT is returned, log a - message. - - 11.2.6 close_dd - - Use close_dd to close the open handle. - If DSVC_NOENT is returned, log a message. - - 11.2.7 epilogue - - The <network address> dhcp network - container should be consistent at the end of - a test run. The only differences should be a - changed value of the <network address>+102 - record with the value as per 11.2.4 and the - lease time potentially incremented, as well as - the <network address>+1001 record missing. - Any other inconsistency means the test has - failed. - - Cleanup: remove <network address> dhcp network - container. - - 11.3 Multi-process run - - Run 11.1 and 11.2 in PROCESSES separate - processes. - - 11.4 Multi-threaded run, single process - - Run 11.1 and 11.2 in THREADS separate threads - within a single process. - - 11.5 Multi-process, Multi-threaded run - - Run 11.1 and 11.2 in PROCESSES separate - processes each spawning THREADS separate threads. - -REFERENCES - - [1] "Enterprise DHCP Service Architecture Specification", mwc, - 6/25/1999. - - [2] "Enterprise Reference Hardware Platforms", mwc, 10/23/1999. diff --git a/usr/src/lib/libdhcpsvc/tests/specs/public.txt b/usr/src/lib/libdhcpsvc/tests/specs/public.txt deleted file mode 100644 index 610dd5ba16..0000000000 --- a/usr/src/lib/libdhcpsvc/tests/specs/public.txt +++ /dev/null @@ -1,1201 +0,0 @@ -#ident "%Z%%M% %I% %E% SMI" mwc - -CDDL HEADER START - -The contents of this file are subject to the terms of the -Common Development and Distribution License, Version 1.0 only -(the "License"). You may not use this file except in compliance -with the License. - -You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -or http://www.opensolaris.org/os/licensing. -See the License for the specific language governing permissions -and limitations under the License. - -When distributing Covered Code, include this CDDL HEADER in each -file and include the License file at usr/src/OPENSOLARIS.LICENSE. -If applicable, add the following below this CDDL HEADER, with the -fields enclosed by brackets "[]" replaced with your own identifying -information: Portions Copyright [yyyy] [name of copyright owner] - -CDDL HEADER END - - Enterprise: Public Layer Test Specification - =========================================== - -ABSTRACT - - This document describes a test specification intended to be used -in the development of tests designed to validate the service provider -layer API described in Section 2.2 of the Enterprise DHCP Service -Architecture Specification (ARCH) [1]. The first test is a basic sanity -test, designed to verify that the API works as designed when fed data -in the correct form. The second test is a full test, which compliments -the basic sanity test by providing cases which test the stability and -MT-safeness of the API. - -TEST APPLICATION - - Test suite(s) written to this specification should be run on -every available public module on the reference platform of each of the -supported architectures (sparcv8, sparcv9, IA32, IA64) for each build -of the ON consolidation. See "Enterprise Reference platforms" [2] for -more information. - -TEST PREPARATION - - The packages SUNWdhc{df,db,dn} containing the public module(s) -under test need to be installed in /usr/lib/inet/dhcp/svc on the machine -under test. The data service(s) (if necessary) which hosts the data -store must be configured and running. A data store container directory -(location) within the data service must exist and be empty. The machine -under test must have the appropriate authorization (root user) for -accessing the hosting data service. Note that it is important to note -whether the data service is hosted on the test machine, or whether the -data service is hosted on a different machine and the machine under -test is a client of that data service. Where the data service is hosted -will have an affect on the test results, particularly performance. - -BASIC SANITY TEST - - Description - - This test validates the basic operation of service - provider layer API function calls when presented with valid - arguments in a valid run environment. It is implemented as a - multithreaded program running a single thread to exercise the API - referenced in Section 2.2 of ARCH [1]. This program should create - dhcptab and dhcp network containers within the data store, and - exercise the *_dt and *_dn calls to add, modify, and delete - multiple records. The result of the add, modify, and delete - operations must be validated between each operation. The program - should be written such that the initial condition described under - TEST PREPARATION is restored. Operations are PASS/FAIL, and must - be compared against a human-verified expect file. - - Test Data - - Item Description Application - ==== =========== =========== - <location> Public module specific status, list, - path name to container open_dt, - directory (e.g. /var/dhcp remove_dt, - for 'files' data store). open_dn, - remove_dn - - <Server IP> System under test's IP N/A - address. - - dt records As follows: *_dt - - SrootOpt s Vendor=SUNW.Ultra-1 SUNW.i86pc,1,ASCII,1,0 - SrootIP4 s Vendor=SUNW.Ultra-1 SUNW.i86pc,2,IP,1,1 - SrootNM s Vendor=SUNW.Ultra-1 SUNW.i86pc,3,ASCII,1,0 - SrootPTH s Vendor=SUNW.Ultra-1 SUNW.i86pc,4,ASCII,1,0 - SswapIP4 s Vendor=SUNW.Ultra-1 SUNW.i86pc,5,IP,1,1 - SswapPTH s Vendor=SUNW.Ultra-1 SUNW.i86pc,6,ASCII,1,0 - SbootFIL s Vendor=SUNW.Ultra-1 SUNW.i86pc,7,ASCII,1,0 - Stz s Vendor=SUNW.Ultra-1 SUNW.i86pc,8,ASCII,1,0 - SbootRS s Vendor=SUNW.Ultra-1 SUNW.i86pc,9,NUMBER,2,1 - SinstIP4 s Vendor=SUNW.Ultra-1 SUNW.i86pc,10,IP,1,1 - SinstNM s Vendor=SUNW.Ultra-1 SUNW.i86pc,11,ASCII,1,0 - SinstPTH s Vendor=SUNW.Ultra-1 SUNW.i86pc,12,ASCII,1,0 - SsysidCF s Vendor=SUNW.Ultra-1 SUNW.i86pc,13,ASCII,1,0 - SjumpsCF s Vendor=SUNW.Ultra-1 SUNW.i86pc,14,ASCII,1,0 - Sterm s Vendor=SUNW.Ultra-1 SUNW.i86pc,15,ASCII,1,0 - Locale m :UTCoffst=-18000: - Solaris m :SrootIP4=129.148.174.27:SrootNM="atlantic": \ - :SinstIP4=129.148.174.27:SinstNM="atlantic": \ - :Sterm="xterm":BootSrvA=129.148.174.27: - sparc m \ -:SrootPTH="/export/s28/solaris1of2.s28s_wos/latest/Solaris_8/Tools/Boot": \ - :SinstPTH="/export/s28/solaris1of2.s28s_wos/latest": - sun4u m :Include=Solaris:Include=sparc: - i86pc m :Include=Solaris:SbootFIL="/platform/i86pc/kernel/unix": \ - :SinstPTH="/export/s28/solaris1of2.s28x_wos/latest": \ -:SrootPTH="/export/s28/solaris1of2.s28x_wos/latest/Solaris_8/Tools/Boot": - SUNW.i86pc m :Include=i86pc: - SUNW.Ultra-1 m :SbootFIL="/platform/sun4u/kernel/sparcv9/unix": \ - :Include=sun4u: - 172.21.0.0 m :Subnet=255.255.0.0:Router=172.21.0.2: \ - :Broadcst=172.21.255.255: - atlantic m :Include=Locale:Timeserv=129.148.174.27:LeaseTim=3600: \ - :LeaseNeg:Hostname:DNSdmain="snt.east.sun.com": \ - :DNSserv=172.21.0.1: - 010800207E8A02 m :Impress=172.22.255.27: - - - 172.21.0.0 Dhcp network container. *_dn - - dn records ~3000, as follows: *_dn - - 00 00 172.21.0.6 <Server IP> 0 atlantic - . - . - . - 00 00 172.21.12.6 <Server IP> 0 atlantic - - Generic Data Store Status - ========================= - - Case #1 status: - - Call function with <location>. PASS if DSVC_SUCCESS is - returned, FAIL otherwise. If this case fails, abort the test. - - Case #2 version: - - Call function. Version value returned must be one (1) - for PASS. If this case fails, abort the test. - - Case #3 capability: - - Call function. Compare returned capability against - confirmed capability known for the public module under test. - Match is PASS. - - Case #4 list: - - Call function with <location>. PASS if DSVC_NOENT is - returned, listppp is NULL, and count is set to 0. As part of - Test preparation, there should be *no* containers of any kind in - the underlying data service of the public module. If this case - fails, abort the test. - - dhcptab Container API - ===================== - - Case #5 alloc_dtrec: - - Call function, verify that a non-NULL dt_rec_t pointer - is returned. Free result with free_dtrec. - - Case #6 open_dt: - - Create a dhcptab at <location> specifying DSVC_CREATE | - DSVC_READ | DSVC_WRITE. Preserve handpp for use in the following - cases. PASS if DSVC_SUCCESS is returned, abort the test - otherwise. - - Case #7 add_dt: - - 7.1. Initialize container. - - Using the handle returned in case #6, add the - dhcptab test records to the dhcptab. Verify that the - dhcptab exists by calling list. - - 7.2. Attempt to add duplicate record. - - Attempt to add the SbootRS symbol definition and - 172.21.0.0 macro definition to the dhcptab container. - PASS if DSVC_EXISTS is returned in both cases. - - Case #8 lookup_dt: - - 8.1. Verify case #7. - - Using a count value of -1 and a "query" value - initialized by DSVC_QINIT (Figure 5 of ARCH[1]), verify - that the contents of the dhcptab container match the - test data. Note that the order of the records returned - may not be the same as the order in which they were - added in case #7. - - 8.2 Verify dhcptab container type. - - 8.2.1. Look for all records with a DT_QTYPE - value of "s". Verify that only the "s" type - records are returned. - - 8.2.2. Look for all records with a DT_QTYPE - value of "m". Verify that only the "m" type - records are returned. - - 8.2.3. Look for DT_QKEY of "atlantic". Verify - that only the macro "atlantic" is returned, and - the value is correct. - - 8.2.4. Look for DTQKEY of i86pc and not a - DT_QTYPE of "m". Verify that only the macro - "i86pc" is returned. - - Case #9 modify_dt: - - 9.1 Modify dhcptab container records - - 9.1.1. Using lookup_dt to find the record with a - DT_QKEY of "Sterm", change the name of the - record from "Sterm" to "sTERM". Use lookup_dt to - verify that the original record has been - renamed. - - 9.1.2. Using lookup_dt to find the record with a - DT_QKEY of "Solaris", change the value portion - of the record to be: - - :SrootIP4=129.148.174.27:SrootNM="atlantic": \ - :SinstIP4=129.148.174.27:SinstNM="atlantic": \ - :sTERM="sun-cmd":BootSrvA=129.148.174.27: - - Using lookup_dt, reexecute the lookup and verify - that the value portion of the record has been - modified correctly. - - Case #10 delete_dt: - - Using lookup_dt to find the record with a DT_QKEY of - "SUNW.Ultra-1", delete this record. Verify using lookup_dt that - this record can no longer be found (DSVC_NOENT). - - Case #11 close_dt: - - Close the open instance of the dhcptab container. Verify - that close_dt returns DSVC_SUCCESS. - - Case #12 remove_dt: - - Remove the dhcptab container. Verify that it no longer - exists using list. - - dhcp network Container API - ========================== - - Case #13 open_dn: - - Using DSVC_CREATE | DSVC_READ | DSVC_WRITE, create a - dhcp network container (called <network address>). Preserve the - handle returned for later use in the following test cases. PASS - if DSVC_SUCCESS is returned, terminate the test otherwise. - Verify that the dhcp network container exists using list. - - Case #14 add_dn: - - 14.1. Initialize container. - - Using the handle returned in case #13, add the - dhcp network test records to the dhcp network container. - Verify that the dhcp network container exists by - calling list. - - 14.2. Attempt to add duplicate record. - - Attempt to add the 172.21.0.254 client record - to the <network address> dhcp network container. PASS - if DSVC_EXISTS is returned. - - Case #15 lookup_dn: - - 15.1. Verify case #14. - - Using a "count" of -1 and a "query" value - initialized using DSVC_QINIT (Figure 5 of ARCH[1]), - verify that the contents of the <network address> - container match the test data. "records" should equal - the number of records added in case #14. Note that the - order of the records returned may not be the same as the - order in which they were added in case #14. - - 15.2. Verify <network address> dhcp network container - type. - - 15.2.1. Look for all records with a DN_QCIP of - <network address>+100. Verify that only one - record (with a cip of <network address>+100 is - returned. - - 15.2.2. Look for all records with a DN_QMACRO - value of "atlantic". Verify that all records - are returned ("records" == 3000). Note that the - records returned may not be in the same order in - which they were added as part of case #14. - - Case #16 modify_dn: - - 16.1. Using lookup_dn to find the record with a DN_QCIP - of <network address>+10, change the lease field to - 1/1/2000 and the flags field to MANUAL. Use lookup_dn to - verify that the original record has been changed. - - 16.2. Using lookup_dn to find the record with a - DN_QFLAGS of MANUAL. Change the dn_cid field to - 01080020FFFFFF, dn_flags field to MANUAL+AUTOMATIC, - dn_sip field to 172.23.0.77, dn_lease field to -1, - dn_macro field to "happy", and the dn_comment field to - "This is a test". Use lookup_dn to verify that the - original record has been changed correctly. - - Case #17 delete_dn: - - Using lookup_dn to find the record with a DN_QCIP of - <network address>+101, delete this record. Verify using - lookup_dn that this record can no longer be found. - - Case #18 close_dn: - - Close the open instance of the dhcp network container - <network address>. Verify that close_dn returns DSVC_SUCCESS. - - Case #19 remove_dn: - - Remove the dhcp network container <network address>. - Verify that the container is in fact gone using list. - -FULL TEST - - Description - - This suite verifies that the dhcptab and dhcp network - table API function calls respond correctly when presented with - incorrect data. It also validates the MT-safeness of the API. - The test suite should allow any number of concurrent threads or - test suite processes to be invoked. The data must remain - consistent as measured at certain points during the test in - order for the test to be considered to have passed successfully. - - Test Data - - Item Description Application - ==== =========== =========== - <location> Public module specific status, list, - path name to container open_dt, - directory (e.g. /var/dhcp remove_dt, - for 'files' data store). open_dn, - remove_dn - - <Server IP> System under test's IP N/A - address. - - dt records As follows: *_dt - - SrootOpt s Vendor=SUNW.Ultra-1 SUNW.i86pc,1,ASCII,1,0 - SrootIP4 s Vendor=SUNW.Ultra-1 SUNW.i86pc,2,IP,1,1 - SrootNM s Vendor=SUNW.Ultra-1 SUNW.i86pc,3,ASCII,1,0 - SrootPTH s Vendor=SUNW.Ultra-1 SUNW.i86pc,4,ASCII,1,0 - SswapIP4 s Vendor=SUNW.Ultra-1 SUNW.i86pc,5,IP,1,1 - SswapPTH s Vendor=SUNW.Ultra-1 SUNW.i86pc,6,ASCII,1,0 - SbootFIL s Vendor=SUNW.Ultra-1 SUNW.i86pc,7,ASCII,1,0 - Stz s Vendor=SUNW.Ultra-1 SUNW.i86pc,8,ASCII,1,0 - SbootRS s Vendor=SUNW.Ultra-1 SUNW.i86pc,9,NUMBER,2,1 - SinstIP4 s Vendor=SUNW.Ultra-1 SUNW.i86pc,10,IP,1,1 - SinstNM s Vendor=SUNW.Ultra-1 SUNW.i86pc,11,ASCII,1,0 - SinstPTH s Vendor=SUNW.Ultra-1 SUNW.i86pc,12,ASCII,1,0 - SsysidCF s Vendor=SUNW.Ultra-1 SUNW.i86pc,13,ASCII,1,0 - SjumpsCF s Vendor=SUNW.Ultra-1 SUNW.i86pc,14,ASCII,1,0 - Sterm s Vendor=SUNW.Ultra-1 SUNW.i86pc,15,ASCII,1,0 - Locale m :UTCoffst=-18000: - Solaris m :SrootIP4=129.148.174.27:SrootNM="atlantic": \ - :SinstIP4=129.148.174.27:SinstNM="atlantic": \ - :Sterm="xterm":BootSrvA=129.148.174.27: - sparc m \ -:SrootPTH="/export/s28/solaris1of2.s28s_wos/latest/Solaris_8/Tools/Boot": \ - :SinstPTH="/export/s28/solaris1of2.s28s_wos/latest": - sun4u m :Include=Solaris:Include=sparc: - i86pc m :Include=Solaris:SbootFIL="/platform/i86pc/kernel/unix": \ - :SinstPTH="/export/s28/solaris1of2.s28x_wos/latest": \ -:SrootPTH="/export/s28/solaris1of2.s28x_wos/latest/Solaris_8/Tools/Boot": - SUNW.i86pc m :Include=i86pc: - SUNW.Ultra-1 m :SbootFIL="/platform/sun4u/kernel/sparcv9/unix": \ - :Include=sun4u: - 172.21.0.0 m :Subnet=255.255.0.0:Router=172.21.0.2: \ - :Broadcst=172.21.255.255: - atlantic m :Include=Locale:Timeserv=129.148.174.27:LeaseTim=3600: \ - :LeaseNeg:Hostname:DNSdmain="snt.east.sun.com": \ - :DNSserv=172.21.0.1: - 010800207E8A02 m :Impress=172.22.255.27: - - - 172.21.0.0 Dhcp network container. *_dn - - dn records ~3000, as follows: *_dn - - 00 00 172.21.0.6 <Server IP> 0 atlantic - . - . - . - 00 00 172.21.12.6 <Server IP> 0 atlantic - - Case #1: - Disable the underlying data service. How this is done - is data service-dependent. Call each of status, version, - capability, list, open_dt, remove_dt, open_dn, and remove_dn. - PASS if the function returns DSVC_INTERNAL or - DSVC_MODULE_ERROR. What is returned is data service-specific. If - this test FAILs (e.g. a function returns DSVC_SUCCESS, terminate - the test run. - - Cleanup: Reenable the underlying data service. - - dhcptab Container API - ===================== - - Case #2 list_dt: - - 2.1. Invalid Location - - Call function with an invalid <location>. PASS - if DSVC_INVAL is returned. If this case fails, abort - the test. - - 2.2. No container - - Verify that list returns DSVC_NOENT. - - Case #3 open_dt: - - 3.1. No container - - Call function with DSVC_READ | DSVC_WRITE. - Verify that DSVC_NOENT is returned. - - 3.2. NON_BLOCK - - Using DSVC_CREATE | DSVC_READ | DSVC_WRITE, - call open_dt to create a dhcptab container. Call - close_dt to close the handle. Call open_dt with - DSVC_READ | DSVC_WRITE | DSVC_NONBLOCK. Depending on - whether the public module supports it (see module doc), - the function should return either DSVC_SUCCESS or - DSVC_UNSUPPORTED. If NON_BLOCK access is supported, - endeavor to make the underlying service temporarily - unavailable (e.g: NIS+: checkpoint the database). Call - open_dt again with the same flags (read, write, - nonblock). open_dt must fail and return DSVC_BUSY. - - Cleanup: re-enable underlying service, close the open - handle. - - 3.3. Container exists - - Call function with DSVC_CREATE | DSVC_READ | - DSVC_WRITE. Verify that the function returns - DSVC_EXISTS. - - Cleanup: remove the dhcptab container using remove_dt. - - Case #4 add_dt: - - Create and load the dhcptab as per Case #6 and Case #7.1 - of the Basic Sanity Test. - - 4.1. Record exists - - Attempt to add a test dhcptab record to the - dhcptab. Verify that DSVC_EXISTS is returned. - - 4.2. Busy - - Close open handle with close_dt. Reopen with - DSVC_NONBLOCK specified. If nonblocking semantics are - supported, then make the data service busy through the - use of a data service-specific technique and attempt to - add an additional dhcptab record. Verify that DSVC_BUSY - is returned. Remove the data service busy condition and - reattempt the add operation. Verify that DSVC_SUCCESS is - returned. close_dt the container. - - 4.3. Read only - - Close any open handles. Reopen the dhcptab with - DSVC_READ access only. If success is returned, attempt - to add a new record to the dhcptab. Verify that - DSVC_ACCESS is returned. close_dt the handle. Note that - some data store modules may return DSVC_UNSUPPORTED for - read-only access. - - Cleanup: Close open handles, remove the dhcptab using - remove_dt. - - Case #5 lookup_dt: - - Create and load the dhcptab as per Case #6 and Case #7.1 - of the Basic Sanity Test. - - 5.1. Record does not exist. - - Produce a dhcptab container query that would not - be satisfied by the test data. Verify that DSVC_SUCCESS - is returned, and "records" is 0. - - 5.2. Busy - - Close dhcptab handle with close_dt. Reopen with - DSVC_NONBLOCK specified. IF DSVC_SUCCESS is returned - (Nonblocking access is supported), using a data - service-specific technique for making the service busy, - attempt to perform a valid lookup of a dhcptab record. - Verify that DSVC_BUSY is returned. Remove the busy - condition, and reattempt the lookup. Verify that - DSVC_SUCCESS is returned, and that the data returned is - valid. close_dt the handle. - - 5.3. Write only - - Reopen the dhcptab container with DSVC_WRITE - access only. If success is returned, attempt to perform - lookup_dt's using any syntactically legal query for the - dhcptab. Verify that DSVC_ACCESS is returned. close_dt - the handle. - - 5.4. Multiple matching records - - Reopen the dhcptab container as per case - #6 and case #7.1 of the Basic Sanity Test. Using - modify_dt, change the dt_key for the SrootOpt symbol - such that the key value is now sun4u. Form a query which - simply specifies a DT_QKEY value of "sun4u". Verify that - exactly two records are returned, and that there values - are what is expected (one a macro, the other a symbol, - with the appropriate values). - - Cleanup: Remove the dhcptab container using remove_dt. - - Case #6 modify_dt: - - Create and load the dhcptab container as per Case #6 - and Case #7.1 of the Basic Sanity Test. - - 6.1. Unknown record - - Fabricate dt_rec_t elements initialized with - data known not to exist in the dhcptab. Attempt to - modify these elements. Verify that DSVC_NOENT is - returned. - - 6.2. Update Collision #1 - - Use lookup_dt to find a valid dhcptab record. - Change the signature on the resultant dt_rec_t. Attempt - to modify the record. Verify that DSVC_COLLISION is - returned. - - 6.3. Update Collision #2 - - Use lookup_dt to find a valid dhcptab record. - Attempt to rename the record to one that already exists - (dt_key + dt_type). Verify that DSVC_EXISTS is returned. - - 6.4. Busy - - Close the dhcptab with close_dt. Reopen with - DSVC_NONBLOCK specified. If DSVC_SUCCESS is returned (it - is supported), acquire a valid dhcptab record using - lookup_dt. Using a data service specific technique for - making the service busy, attempt to modify the value - (non-key fields) of the record. Verify that DSVC_BUSY is - returned. Remove the busy condition, and reattempt the - modify. Verify that DSVC_SUCCESS is returned. - Reacquire the record. Verify that the contents have been - suitably updated. close_dt the container. - - 6.5. Read only - - Reopen the dhcptab with DSVC_READ access only. - If success is returned, locate a valid container record - using the appropriate query to lookup_dt. Modify the - contents of the record. Attempt to commit the modify to - the dhcptab. Verify that DSVC_ACCESS is returned. - close_dt the dhcptab handle. - - Cleanup: Remove the dhcptab using remove_dt. - - Case #7 free_dtrec_list: - - This function should be used to release the results of - lookup_dt calls. Its operation must be validated by running this - test under bcheck with -memuse, and ensuring that no free blocks - remain after exit. Note that the test must be written with care - to make this case useful (free any allocated memory when it is - no longer needed). - - Case #8 delete_dt: - - Create and load the dhcptab container as per Case #6 and - Case #7.1 of the Basic Sanity Test. - - 8.1 Unknown record - - Fabricate dt_rec_t containing a record known - not to exist in the dhcptab. Attempt to delete the - record. Verify that DSVC_NOENT is returned. - - 8.2 Busy - - Close the dhcptab with close_dt. Reopen with - DSVC_NONBLOCK specified. If DSVC_SUCCESS is returned, - acquire a valid dhcptab container record using - lookup_dt. Using a data service specific technique for - making the service busy, attempt to delete the record. - Verify that DSVC_BUSY is returned. Remove the busy - condition, and reattempt the delete. Verify that - DSVC_SUCCESS is returned. Attempt to reacquire the - record. Verify that the record has in fact been deleted. - Close the dhcptab using close_dt. - - 8.3 Read only - - Reopen the dhcptab container with DSVC_READ - access only. If success is returned, locate a valid - dhcptab record using an appropriate query to lookup_dt. - Attempt to delete the record. Verify that DSVC_ACCESS is - returned. Close the dhcptab using close_dt. - - Cleanup: Remove the dhcptab using remove_dt. - - Case #9 close_dt: - - Verify that this function handles nonblocking semantics - correctly. Create a dhcptab as per case #6 of the Basic Sanity - Test, with the exception that DSVC_NONBLOCK is specified. If - nonblocking mode is supported, then using a data service - specific technique for making the service busy, attempt to close - the dhcptab handle returned by open_dt. Verify that DSVC_BUSY - is returned. Remove the busy condition, and reattempt the - close_dt. Verify that DSVC_SUCCESS is returned. - - Cleanup: Remove the dhcptab container using remove_dt. - - Case #10 remove_dt: - - Verify that this function handles nonblocking semantics - correctly. Create a dhcptab container as per Case #6 of the Basic - Sanity Test. Close open handle using close_dt. Reopen with - DSVC_NONBLOCK specified. If nonblocking mode is supported, using - a data service specific technique for making the service busy, - attempt to remove the dhcptab container. Verify that DSVC_BUSY is - returned. Remove the busy condition, and reattempt the remove. - Verify that the dhcptab container is removed using list and that - the function returns DSVC_SUCCESS. - - Cleanup: Close the open handle using close_dt (ignore result). - - dhcp network Container API - ========================== - - Case #11 list_dn: - - 11.1. Invalid Location - - Call function with an invalid <location>. PASS - if DSVC_INVAL is returned. If this case fails, abort - the test. - - 11.2. No container - - Verify that list returns DSVC_NOENT. - - Case #12 open_dn: - - 12.1. No container - - Call function with DSVC_READ | DSVC_WRITE and - <network address>. Verify that DSVC_NOENT is returned. - - 12.2. NON_BLOCK - - Using the flag values of DSVC_CREATE | - DSVC_READ | DSVC_WRITE | DSVC_NONBLOCK, the function - to create a dhcp network container called <network - address>. Depending on whether the public module - supports nonblocking semantics (see module doc), - the function should return either DSVC_SUCCESS or - DSVC_UNSUPPORTED. If NON_BLOCK access is supported, - endeavor to make the underlying service temporarily - unavailable (e.g: NIS+: checkpoint the database). Call - open_dn again with the same flags (read, write, - nonblock). open_dn must fail and return DSVC_BUSY. - - Cleanup: re-enable underlying service, close the open - handle. - - 12.3. Container exists. - - Using the flag values DSVC_CREATE | DSVC_READ | - DSVC_WRITE, attempt to open <network address>. Verify - that the function returns DSVC_EXISTS. - - Cleanup: Remove the <network address> dhcp network - container using remove_dn. - - Case #13 add_dn: - - Create and load the <network address> dhcp network - container as per Case #13 and Case #14.1 of the Basic Sanity - Test. - - 13.1. Record exists - - Attempt to add a test dhcp network record to - the <network address> dhcp network container. Verify - that DSVC_EXISTS is returned. - - 13.2. Busy - - Close open handle with close_dn. Reopen with - DSVC_NONBLOCK specified. If nonblocking semantics are - supported, then make the data service busy through the - use of a data service-specific technique and attempt to - add an additional dhcp network record. Verify that - DSVC_BUSY is returned. Remove the data service busy - condition and reattempt the add operation. Verify that - DSVC_SUCCESS is returned. close_dn the container. - - 13.3. Read only - - Close any open handles. Reopen the <network - address> dhcp network container with DSVC_READ access - only. If success is returned, attempt to add a new - record to the dhcp network container. Verify that - DSVC_ACCESS is returned. close_dn the handle. Note that - some data store modules may return DSVC_UNSUPPORTED for - read-only access. - - Cleanup: Close open handles, remove the <network - address> dhcp network container using remove_dn. - - Case #14 lookup_dn: - - Create and load the <network address> dhcp network - container as per Case #13 and Case #14.1 of the Basic Sanity - Test. - - 14.1. Record does not exist. - - Produce a dhcp network container query that - would not be satisfied by the test data. Verify that - DSVC_SUCCESS is returned, and "records" is 0. - - 14.2. Busy - - Close the <network address> dhcp network handle - with close_dn. Reopen with DSVC_NONBLOCK specified. If - DSVC_SUCCESS is returned (Nonblocking access is - supported), using a data service-specific technique for - making the service busy, attempt to perform a valid - lookup of a dhcp network record. Verify that DSVC_BUSY - is returned. Remove the busy condition, and reattempt - the lookup. Verify that DSVC_SUCCESS is returned, and - that the data returned is valid. close_dn the handle. - - 14.3. Write only - - Reopen the dhcp network container with DSVC_WRITE - access only. If success is returned, attempt to perform - lookup_dn's using any syntactically legal query for the - <network address> dhcp network container. Verify that - DSVC_ACCESS is returned. close_dn the handle. - - 14.4. Multiple matching records - - Reopen the dhcp network container as per case - #13 and case #14.1 of the Basic Sanity Test. Using - modify_dn, change the dn_cid fields for records <network - address>+1 through <network address>+217 to 01BADDCAFE. - Form a query which simply specifies a DN_QCID of - 01BADDCAFE. Confirm that exactly 216 records are - returned, and that their CIP range is correct. - - Cleanup: Remove the <network address> dhcp network - container using remove_dn. - - Case #15 modify_dn: - - Create and load the <network address> dhcp network - container as per Case #13 and Case #14.1 of the Basic Sanity - Test. - - 15.1. Unknown record - - Fabricate dn_rec_t elements initialized with - data known not to exist in the dhcp network container. - Attempt to modify these elements. Verify that DSVC_NOENT - is returned. - - 15.2. Update Collision #1 - - Use lookup_dn to find a valid dhcp network record. - Change the signature on the resultant dn_rec_t. Attempt - to modify the record. Verify that DSVC_COLLISION is - returned. - - 15.3. Update Collision #2 - - Use lookup_dn to find a valid dhcp network record. - Attempt to rename the record to one that already exists - (dn_cid, dn_flags, dn_cip, dn_sip, dn_lease, dn_macro). - Verify that DSVC_EXISTS is returned. - - 15.4. Busy - - Close the dhcp network container with close_dn. - Reopen with DSVC_NONBLOCK specified. If DSVC_SUCCESS is - returned (nonblocking semantics are supported), acquire - a valid dhcp network record using lookup_dn. Using a - data service specific technique for making the service - busy, attempt to modify the value (non-key fields) of - the record. Verify that DSVC_BUSY is returned. Remove - the busy condition, and reattempt the modify. Verify - that DSVC_SUCCESS is returned. Reacquire the record. - Verify that the contents have been suitably updated. - close_dn the container. - - 15.5. Read only - - Reopen the dhcp network container with DSVC_READ - access only. If success is returned, locate a valid - container record using the appropriate query to - lookup_dn. Modify the contents of the record. Attempt - to commit the modify to the dhcp network container. - Verify that DSVC_ACCESS is returned. close_dn the - dhcp network container handle. - - Cleanup: Remove the dhcp network container using - remove_dn. - - Case #16 free_dnrec_list: - - This function should be used to release the results of - lookup_dn calls. Its operation must be validated by running this - test under bcheck with -memuse, and ensuring that no free blocks - remain after exit. Note that the test must be written with care - to make this case useful (free any allocated memory when it is - no longer needed). - - Case #17 delete_dn: - - Create and load the <network address> dhcp network - container as per Case #13 and Case #14.1 of the Basic Sanity - Test. - - 17.1 Unknown record - - Fabricate dn_rec_t containing a record known - not to exist in the dhcp network container. Attempt - to delete the record. Verify that DSVC_NOENT is returned. - - 17.2 Busy - - Close the dhcp network container with close_dn. - Reopen with DSVC_NONBLOCK specified. If DSVC_SUCCESS is - returned, acquire a valid dhcp network container record - using lookup_dn. Using a data service specific technique - for making the service busy, attempt to delete the record. - Verify that DSVC_BUSY is returned. Remove the busy - condition, and reattempt the delete. Verify that - DSVC_SUCCESS is returned. Attempt to reacquire the - record. Verify that the record has in fact been deleted. - Close the dhcp network container using close_dn. - - 17.3 Read only - - Reopen the dhcp network container with DSVC_READ - access only. If success is returned, locate a valid - dhcp network record using an appropriate query to - lookup_dn. Attempt to delete the record. Verify that - DSVC_ACCESS is returned. Close the dhcp network - container using close_dn. - - Cleanup: Remove the dhcp network container using - remove_dn. - - Case #18 close_dn: - - Verify that this function handles nonblocking semantics - correctly. Create the <network address> dhcp network container - as per case #13 of the Basic Sanity Test, with the exception - that DSVC_NONBLOCK is specified. If nonblocking mode is - supported, then using a data service specific technique for - making the service busy, attempt to close the dhcp network - handle returned by open_dn. Verify that DSVC_BUSY is returned. - Remove the busy condition, and reattempt the close_dn. Verify - that DSVC_SUCCESS is returned. - - Cleanup: Remove the dhcp network container using remove_dn. - - Case #19 remove_dn: - - Verify that this function handles nonblocking semantics - correctly. Create the <network address> dhcp network container - as per Case #13 of the Basic Sanity Test, with the exception - that DSVC_NONBLOCK is specified. If nonblocking mode is - supported, using a data service specific technique for making - the service busy, attempt to remove the dhcp network container. - Verify that DSVC_BUSY is returned. Remove the busy condition, - and reattempt the remove. Verify that the <network address> dhcp - network container is removed using list and that the function - returns DSVC_SUCCESS. - - Cleanup: Close the open handle using close_dn (ignore result). - - Case #20 Multi-access stress - - Public layer modules are not required to manage reference - counts for open instances. So while individual handles are - considered to be MT-safe (and parallel access to containers is - suitably protected), an application using the service provider - layer API must synchronize close and/or container remove - operations among threads such that no threads hold handles to a - container after the handle has been closed or the container has - been removed. - - This case assumes a test which is multi-threaded, and - can run the following test using from 1 to THREADS threads. The - test can also be run in multiple concurrent processes. - - The goal of this test is to ensure that the API is - MT-safe with respect to the containers and the records contained - within those containers. This goal is accomplished by verifying - that the end result of the test is consistent. - - Tunable default values: - - PROCESSES: 20 - THREADS: 20 - - 20.1 The dhcptab container test - - 20.1.1 open_dt - - Create a dhcptab using DSVC_CREATE | - DSVC_READ | DSVC_WRITE. If DSVC_EXISTS is - returned, retry the open attempt w/o the - DSVC_CREATE flag. Log that this event occurred. - Handle will be used for balance of test. If any - other error occurs, terminate the test as - failed. - - 20.1.2 add_dt - - Add the test data records to the dhcptab - container. If DSVC_EXISTS is returned, skip that - record, and continue attempting to add the other - records. Log that this event occurred. If any - other error occurs, terminate the test as - failed. - - 20.1.3 lookup_dt - - Using DT_QKEY of "atlantic" and DT_QTYPE - of "m", find the atlantic record. Compare its - value against the test data. If it has - changed, then output a message to this affect. - If any error occurs, terminate the test as failed. - - 20.1.4 modify_dt - - Using the results of 20.1.3, change the - record as follows. If it is no different from - the test data, change the value to: - - :Timeserv=129.148.174.28:LeaseTim=86400: \ - :Hostname:DNSdmain="east.sun.com":DNSserv=172.23.3.3: - - If it doesn't match the test data - value, change the LeaseTim by incrementing it by - one. Attempt to update the record. If it fails - with DSVC_COLLISION, retry 20.1.3 and 20.1.4 for - three attempts. Log message if modify was - unsuccessful. If any other error occurs, - terminate the test as failed. - - 20.1.5 delete_dt - - Use lookup_dt to find a DT_QKEY of - "SjumpsCF" and a DT_QTYPE of "s". If it does - not exist, log a message. If it does exist, - attempt to delete it. If DSVC_NOENT is returned, - log a message. - - 20.1.6 close_dt - - Use close_dt to close the open handle. - If DSVC_NOENT is returned, log a message. - - 20.1.7 epilogue - - Compare the resultant dhcptab container - to the test data. The only differences should be - a changed value of the atlantic macro as - expected from 20.1.4 and the SjumpsCF symbol - should be removed. Any other inconsistency means - the test has failed. - - Clean up: Remove the dhcptab container. - - 20.2 The dhcp network table container test - - 20.2.1 open_dn - - Create a <network address> dhcp network - table using DSVC_CREATE | DSVC_READ | DSVC_WRITE. - If DSVC_EXISTS is returned, retry the open - attempt w/o the DSVC_CREATE flag. Log that this - event occurred. Handle will be used for balance - of test. If any other error occurs, terminate - the test as failed. - - 20.2.2 add_dn - - Add the test data records to the dhcp - network table container. If DSVC_EXISTS is - returned, skip that record, and continue - attempting to add the other records. Log that - this event occurred. If any other error occurs, - terminate the test as failed. - - 20.2.3 lookup_dn - - Find the DN_QCIP of <network address>+102 - record. Compare its value against the test data. - If it has changed, then output a message to this - affect. If any error occurs, terminate the test - as failed. - - 20.2.4 modify_dn - - Using the results of 20.2.3, change the - record as follows. If it is no different from - the test data, change the value to: - -01DEADBEEF 03 <network address>+102 172.23.3.3 941619403 Solaris - - If it doesn't match the test data - value, change dn_lease by incrementing it by - one. Attempt to update the record. If it fails - with DSVC_COLLISION, retry 20.2.3 and 20.2.4 for - three attempts. Log message if modify was - unsuccessful. If any other error occurs, - terminate the test as failed. - - 20.2.5 delete_dn - - Use lookup_dn to find a DN_QCIP of - <network address>+1001. If it does not exist, - log a message. If it does exist, attempt to - delete it. If DSVC_NOENT is returned, log a - message. - - 20.2.6 close_dn - - Use close_dn to close the open handle. - If DSVC_NOENT is returned, log a message. - - 20.2.7 epilogue - - The <network address> dhcp network - container should be consistent at the end of - a test run. The only differences should be a - changed value of the <network address>+102 - record with the value as per 20.2.4 and the - lease time potentially incremented, as well as - the <network address>+1001 record missing. - Any other inconsistency means the test has - failed. - - Cleanup: remove <network address> dhcp network - container. - - 20.3 Multi-process run - - Run 20.1 and 20.2 in PROCESSES separate - processes. - - 20.4 Multi-threaded run, single process - - Run 20.1 and 20.2 in THREADS separate threads - within a single process. - - 20.5 Multi-process, Multi-threaded run - - Run 20.1 and 20.2 in PROCESSES separate - processes each spawning THREADS separate threads. - - Case #21 Capacity - - This test case endeavors to probe the stability and the - performance of the public module implementation when: - - a) The data storage containers are filled to capacity. - - b) The data storage containers are overfilled. - - Note that while the number of records within a dhcptab - container could be infinite, the number of records within a dhcp - network container is bounded by the number of possible IP - addresses within the network represented by the container. If a - class A network is represented, there can be up to 16,777,215 - possible records. The total number of records supported by a - public module (with some overhead for container information) is - the upper bound. That total number could be influenced by - settings in the underlying hosting data service, or by the - available memory or disk resources of the machine under test. - Since record sizes for dhcptab and dhcp network containers - differ, discovering the maximum number of possible records - requires some dynamic experimentation by the test itself. - - 21.1 Initialization - - Call capability. The max number of possible - records for the environment under test will be contained - within the returned structure as will some estimate of - the operations per second claimed by the public module - in the run environment. A dhcptab will be created with - contains 1/3 of the maximum number of records. One or - more dhcp network containers will be created to contain - the balance of the records. A multithreaded program can - create the containers and load them with single threads, - one for each container. A consistent series of records - must be added to the dhcptab (monotonically increasing - symbol / macro records created, each with unique value - portions which could be calculated by the key fields of - the record). dhcp network container records simply contain - records unique by client IP address. - - Initialization will stop when no more records can be - added to the system (XXX - what sort of error code would - be returned? DSVC_INTERNAL?). Operations per second - must be measured during the initialization process to - determine whether it is close to the advertised number - (XXX - how could this be verified?). - - 21.2 Modify - - For every existing dhcp network record, modify - the lease time such that it is set to the number of - modify operations done during this subcase (first one == - 1, last 1+N). Measure operations per second during this - process. - - 21.3 Add - - Attempt to add a new dhcptab and a new dhcp - network container(s) record. This operation should fail - (XXX expected results?). - - 21.4 Lookup - - Form a configured number of legal queries (TBD - tunable) for the dhcptab and dhcp network container(s). - Validate that the data returned is what is expected - based upon knowledge of relationship between the record - being searched for and the expected value based upon the - search parameters. PASS if queries are successful. - Measure operations per second during this process for - comparison against advertised number. - - 21.5 Delete - - Using lookup and delete, find and delete every - single record added by the test. Confirm that the - containers contain no records. Measure operations per - second during this process for comparison against the - advertised number. - - Cleanup: Remove the containers. - -REFERENCES - - [1] "Enterprise DHCP Service Architecture Specification", mwc, - 6/25/1999. - - [2] "Enterprise Reference Hardware Platforms", mwc, 10/23/1999. diff --git a/usr/src/lib/libdhcpsvc/tests/specs/refplat.txt b/usr/src/lib/libdhcpsvc/tests/specs/refplat.txt deleted file mode 100644 index 6af6a9d0af..0000000000 --- a/usr/src/lib/libdhcpsvc/tests/specs/refplat.txt +++ /dev/null @@ -1,52 +0,0 @@ -#ident "%Z%%M% %I% %E% SMI" - -CDDL HEADER START - -The contents of this file are subject to the terms of the -Common Development and Distribution License, Version 1.0 only -(the "License"). You may not use this file except in compliance -with the License. - -You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -or http://www.opensolaris.org/os/licensing. -See the License for the specific language governing permissions -and limitations under the License. - -When distributing Covered Code, include this CDDL HEADER in each -file and include the License file at usr/src/OPENSOLARIS.LICENSE. -If applicable, add the following below this CDDL HEADER, with the -fields enclosed by brackets "[]" replaced with your own identifying -information: Portions Copyright [yyyy] [name of copyright owner] - -CDDL HEADER END - - Enterprise Reference Hardware Platforms - ======================================= - -ABSTRACT - - This document describes the hardware platforms for use in testing -the Enterprise DHCP Service Project [0]. - - While the Enterprise DHCP Server Project (Enterprise) describes -a 32bit application, 64bit platforms are included to verify behavior of -Enterprise in 64bit environments. - -HARDWARE PLATFORMS - - Server: - - 1) sparcv9: E450, 1GB memory, 4x400MHZ Ultrasparc-II. This machine - is located in the burlington lab (blue-nc1701), annex port 31. - - 2) sparcv8: SPARCstation-10, 96MB of memory, 4x33MHZ. This machine - is located in the burlington lab (yellow-ss10x4), annex port 6. - - 3) IA32: Dell 410 MT, 128MB of memory, 2x350MHZ. This machine is - located in the burlington lab (blue-dell410mt), annex port 47, - ss-snt-pcu outlet 3. - -REFERENCES - - [0] "Enterprise DHCP service", PSARC/1998/177, - /shared/sac/PSARC/1998/177. diff --git a/usr/src/lib/libdhcpsvc/tests/test_confopt.c b/usr/src/lib/libdhcpsvc/tests/test_confopt.c deleted file mode 100644 index dd7fc2bc32..0000000000 --- a/usr/src/lib/libdhcpsvc/tests/test_confopt.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <stdlib.h> -#include <alloca.h> -#include <string.h> -#include <errno.h> -#include <dhcp_svc_confopt.h> - -int -main(void) -{ - int i; - dhcp_confopt_t *dsp; - - if (read_dsvc_conf(&dsp) < 0) { - if (errno != ENOENT) { - perror("Read failed"); - return (1); - } else { - (void) fprintf(stderr, - "Read failed because file does not exist\n"); - /* - * Make one. - */ - dsp = alloca(4 * sizeof (dhcp_confopt_t)); - dsp[0].co_type = DHCP_COMMENT; - dsp[0].co_comment = " Generated by test_confopt"; - dsp[1].co_type = DHCP_KEY; - dsp[1].co_key = "RESOURCE"; - dsp[1].co_value = "files"; - dsp[2].co_type = DHCP_KEY; - dsp[2].co_key = "PATH"; - dsp[2].co_value = "/var/dhcp"; - dsp[3].co_type = DHCP_END; - } - } else { - (void) printf("Read worked\n"); - - for (i = 0; dsp[i].co_type != DHCP_END; i++) { - if (dsp[i].co_type == DHCP_KEY) { - (void) printf("Key: %s, Value: %s\n", - dsp[i].co_key, dsp[i].co_value); - if (strcmp(dsp[i].co_key, "RESOURCE") == 0) { - free(dsp[i].co_value); - dsp[i].co_value = strdup("nisplus"); - } - } else { - (void) printf("Comment: %s\n", - dsp[i].co_comment); - } - } - } - - if (write_dsvc_conf(dsp, 0644) < 0) { - perror("Write failed"); - return (1); - } else - (void) printf("Write worked\n"); - - free_dsvc_conf(dsp); - return (0); -} diff --git a/usr/src/lib/libdhcpsvc/tests/test_private.c b/usr/src/lib/libdhcpsvc/tests/test_private.c deleted file mode 100644 index c96adaef43..0000000000 --- a/usr/src/lib/libdhcpsvc/tests/test_private.c +++ /dev/null @@ -1,539 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <stdlib.h> -#include <alloca.h> -#include <strings.h> -#include <sys/types.h> -#include <arpa/inet.h> -#include <sys/socket.h> -#include <fcntl.h> -#include <errno.h> -#include <dhcp_svc_confopt.h> -#include <dhcp_svc_private.h> -#include <dhcp_svc_public.h> -#include <libinetutil.h> - -/* - * Argument: resource, and path in that resource. - */ -int -main(int argc, char *argv[]) -{ - int nmods, i, error; - boolean_t dsp_valid = B_FALSE; - char **mods, **listpp; - uint32_t count; - dsvc_datastore_t dsp; - dsvc_handle_t handle; - char cid[DN_MAX_CID_LEN * 2 + 1]; - uint_t cidlen; - char cip[INET_ADDRSTRLEN], sip[INET_ADDRSTRLEN]; - uint32_t query; - dt_rec_t dt, *dtp, *ntp; - dt_rec_list_t *resdtp, *wtp; - dn_rec_t dn, *dnp; - dn_rec_list_t *resdnp, *wnp; - - if (argc != 3) { - (void) fprintf(stderr, "Usage: %s <resource> <path>\n", - argv[0]); - return (1); - } - - /* enumerate_dd() */ - (void) printf("enumerate_dd: ... "); - error = enumerate_dd(&mods, &nmods); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - - if (error != DSVC_SUCCESS) - return (1); - - (void) printf("enumerate_dd: count of modules: %d\n", nmods); - for (i = 0; i < nmods; i++) { - (void) printf(" %d is: %s\n", i, mods[i]); - if (strcmp(argv[1], mods[i]) == 0) { - dsp.d_location = argv[2]; - dsp.d_resource = strdup(mods[i]); - dsp.d_conver = DSVC_CUR_CONVER; - dsp_valid = B_TRUE; - } - free(mods[i]); - } - free(mods); - - if (!dsp_valid) { - (void) printf("%s: no module for resource `%s'\n", argv[0], - argv[1]); - return (1); - } - - (void) printf("\nstarting testing on %s, tables @ %s\n", - argv[1], argv[2]); - - /* - * Using the datastore struct we built from arguments, begin poking - * at the user selected public module. - */ - - /* status_dd */ - (void) printf("status_dd: ... "); - error = status_dd(&dsp); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - - (void) printf("Datastore version is %d\n", dsp.d_conver); - - /* mklocation_dd */ - (void) printf("mklocation_dd of %s: ... ", dsp.d_location); - error = mklocation_dd(&dsp); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - - /* list_dd - dhcptab */ - (void) printf("\nlist_dd of dhcptab containers: ... "); - error = list_dd(&dsp, DSVC_DHCPTAB, &listpp, &count); - (void) printf(" %s\n", dhcpsvc_errmsg(error)); - if (error == DSVC_SUCCESS) { - (void) printf(" %d dhcptab container(s): ", count); - for (i = 0; i < count; i++) { - (void) printf("%s ", listpp[i] != NULL ? - listpp[i] : "NULL"); - free(listpp[i]); - } - (void) printf("\n"); - free(listpp); - } else { - (void) printf("list_dd: listpp: 0x%p, count: %d\n", - (void *)listpp, count); - } - - /* open_dd - dhcptab (create) */ - (void) printf("open_dd: dhcptab: ... "); - error = open_dd(&handle, &dsp, DSVC_DHCPTAB, "dhcptab", - DSVC_CREATE | DSVC_READ | DSVC_WRITE); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - if (error != DSVC_SUCCESS) - return (1); - - /* add_dd_entry - dhcptab */ - { - dt_rec_t recs[5]; - - (void) strcpy(recs[0].dt_key, "172.21.0.0"); - recs[0].dt_type = DT_MACRO; - recs[0].dt_value = ":Router=172.21.0.1:Subnet=255.255.0.0:"; - - (void) strcpy(recs[1].dt_key, "172.20.64.0"); - recs[1].dt_type = DT_MACRO; - recs[1].dt_value = - ":Router=172.20.64.2:Subnet=255.255.255.192:"; - - (void) strcpy(recs[2].dt_key, "172.20.64.64"); - recs[2].dt_type = DT_MACRO; - recs[2].dt_value = - ":Router=172.20.64.65:Subnet=255.255.255.192:"; - - (void) strcpy(recs[3].dt_key, "172.20.64.128"); - recs[3].dt_type = DT_MACRO; - recs[3].dt_value = - ":Router=172.20.64.129:Subnet=255.255.255.128:"; - - (void) strcpy(recs[4].dt_key, "172.22.0.0"); - recs[4].dt_type = DT_MACRO; - recs[4].dt_value = - ":Router=172.22.0.1:Subnet=255.255.0.0:MTU=4532:"; - - (void) printf("add_dd_entry: ... key type value\n"); - for (i = 0; i < sizeof (recs) / sizeof (dt_rec_t); i++) { - (void) printf(" %s %c %s ... ", - recs[i].dt_key, recs[i].dt_type, recs[i].dt_value); - error = add_dd_entry(handle, &recs[i]); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - if (error != DSVC_SUCCESS) - break; - } - } - - /* lookup_dd - dhcptab - macro called '172.20.64.128', then delete it */ - - DSVC_QINIT(query); - DSVC_QEQ(query, DT_QKEY); - DSVC_QEQ(query, DT_QTYPE); - - (void) memset(&dt, 0, sizeof (dt)); - (void) strcpy(dt.dt_key, "172.20.64.128"); - dt.dt_type = 'm'; - - (void) printf("lookup_dd: macro %s ... ", dt.dt_key); - error = lookup_dd(handle, B_FALSE, query, -1, &dt, (void **)&resdtp, - &count); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - - if (error == DSVC_SUCCESS) { - if (count != 1) { - (void) printf("lookup_dd: expected 1 record, got %d\n", - count); - } - - for (i = 0, wtp = resdtp; i < count && wtp != NULL; i++) { - dtp = wtp->dtl_rec; - (void) printf(" %s %c %s\n", - dtp->dt_key, dtp->dt_type, dtp->dt_value); - wtp = wtp->dtl_next; - } - free_dd_list(handle, resdtp); - } - - /* Delete it */ - (void) printf("delete_dd_entry: %s ... ", dt.dt_key); - error = delete_dd_entry(handle, &dt); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - - - /* - * lookup_dd - dhcptab - macro called '172.21.0.0', and modify its - * definition and replace the value. - */ - - DSVC_QINIT(query); - DSVC_QEQ(query, DT_QKEY); - - (void) memset(&dt, 0, sizeof (dt)); - (void) strcpy(dt.dt_key, "172.21.0.0"); - - (void) printf("lookup_dd: macro %s ... ", dt.dt_key); - error = lookup_dd(handle, B_FALSE, query, 1, &dt, (void **)&resdtp, - &count); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - - if (error == DSVC_SUCCESS) { - if (count != 1) { - (void) printf("lookup_dd: expected 1 record, " - "got %d\n", count); - } else { - dtp = resdtp->dtl_rec; - (void) printf(" %s %c %s\n", dtp->dt_key, - dtp->dt_type, dtp->dt_value); - - ntp = alloc_dtrec(dtp->dt_key, dtp->dt_type, - ":Subnet=255.255.0.0:Router=172.21.0.1 " - "172.21.0.2:MTU=1500:"); - if (ntp != NULL) { - ntp->dt_sig = dtp->dt_sig; - - /* Modify it */ - (void) printf("modify_dd_entry: macro %s ... ", - dt.dt_key); - error = modify_dd_entry(handle, dtp, ntp); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - free_dd(handle, ntp); - } - } - free_dd_list(handle, resdtp); - } - - /* lookup_dd - all records */ - - DSVC_QINIT(query); - - (void) printf("lookup_dd: all records ... "); - error = lookup_dd(handle, B_FALSE, query, -1, &dt, (void **)&resdtp, - &count); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - if (error == DSVC_SUCCESS) { - for (i = 0, wtp = resdtp; i < count && wtp != NULL; i++) { - dtp = wtp->dtl_rec; - (void) printf(" %s %c %s\n", dtp->dt_key, - dtp->dt_type, dtp->dt_value); - wtp = wtp->dtl_next; - } - free_dd_list(handle, resdtp); - } - - /* close_dd - dhcptab */ - (void) printf("close_dd: dhcptab ... "); - error = close_dd(&handle); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - - /* list_dd - dhcp network containers */ - (void) printf("list_dd: dhcptab ... "); - error = list_dd(&dsp, DSVC_DHCPTAB, &listpp, &count); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - if (error == DSVC_SUCCESS) { - (void) printf(" %d dhcp network container(s): ", count); - for (i = 0; i < count; i++) { - (void) printf("%s ", listpp[i] != NULL ? - listpp[i] : "NULL"); - free(listpp[i]); - } - free(listpp); - (void) printf("\n"); - } else { - (void) printf("list_dd: listpp: 0x%p, count: %d\n", - (void *)listpp, count); - } - - /* remove_dd - dhcptab */ - (void) printf("remove_dd: dhcptab ... "); - error = remove_dd(&dsp, DSVC_DHCPTAB, NULL); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - - /* open_dd - 129.148.5.0 create */ - (void) printf("\nopen_dd: 129.148.5.0: ... "); - error = open_dd(&handle, &dsp, DSVC_DHCPNETWORK, "129.148.5.0", - DSVC_CREATE | DSVC_READ | DSVC_WRITE); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - if (error != DSVC_SUCCESS) - return (1); - - /* add_dd_entry - 129.148.5.0 */ - { - uchar_t cid0[7] = { 0x01, 0x08, 0x00, 0x20, 0x00, 0x00, 0x01 }; - dn_rec_t recs[5] = { 0 }; - - recs[0].dn_cid_len = sizeof (cid0); - recs[0].dn_flags = 2; - recs[0].dn_cip.s_addr = 0x81940502; - recs[0].dn_sip.s_addr = 0x81940501; - (void) memcpy(recs[0].dn_cid, cid0, sizeof (cid0)); - (void) strlcpy(recs[0].dn_macro, "myserv", DSVC_MAX_MACSYM_LEN); - (void) strlcpy(recs[0].dn_comment, "dave", DN_MAX_COMMENT_LEN); - - recs[1].dn_cid_len = 1; - recs[1].dn_flags = 1; - recs[1].dn_cip.s_addr = 0x81940503; - recs[1].dn_sip.s_addr = 0x81940501; - (void) strlcpy(recs[1].dn_macro, "myserv", DSVC_MAX_MACSYM_LEN); - (void) strlcpy(recs[1].dn_comment, "meem", DN_MAX_COMMENT_LEN); - - recs[2].dn_cid_len = 1; - recs[2].dn_cip.s_addr = 0x81940504; - recs[2].dn_sip.s_addr = 0x81940501; - (void) strlcpy(recs[2].dn_macro, "myserv", DSVC_MAX_MACSYM_LEN); - (void) strlcpy(recs[2].dn_comment, "cpj", DN_MAX_COMMENT_LEN); - - recs[3].dn_cid_len = 1; - recs[3].dn_cip.s_addr = 0x81940505; - recs[3].dn_sip.s_addr = 0x81940501; - (void) strlcpy(recs[3].dn_macro, "myserv", DSVC_MAX_MACSYM_LEN); - (void) strlcpy(recs[3].dn_comment, "mwc", DN_MAX_COMMENT_LEN); - - recs[4].dn_cid_len = 1; - recs[4].dn_cip.s_addr = 0x81940506; - recs[4].dn_sip.s_addr = 0x81940501; - (void) strlcpy(recs[4].dn_macro, "myserv", DSVC_MAX_MACSYM_LEN); - (void) strlcpy(recs[4].dn_comment, "markh", DN_MAX_COMMENT_LEN); - - (void) printf("add_dd_entry: ... cid flag cip sip lease " - "macro comment\n"); - for (i = 0; i < sizeof (recs) / sizeof (dn_rec_t); i++) { - cidlen = sizeof (cid); - (void) octet_to_hexascii(recs[i].dn_cid, - recs[i].dn_cid_len, cid, &cidlen); - (void) printf(" %s %d %s %s %u %s %s ... ", - cid, recs[i].dn_flags, - inet_ntop(AF_INET, &recs[i].dn_cip, cip, - INET_ADDRSTRLEN), - inet_ntop(AF_INET, &recs[i].dn_sip, sip, - INET_ADDRSTRLEN), - recs[i].dn_lease, recs[i].dn_macro, - recs[i].dn_comment); - - error = add_dd_entry(handle, &recs[i]); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - if (error != DSVC_SUCCESS) - break; - } - } - - /* lookup_dd - lookup all records. */ - DSVC_QINIT(query); - - (void) printf("lookup_dd: 129.148.5.0 ... "); - error = lookup_dd(handle, B_FALSE, query, -1, &dn, (void **)&resdnp, - &count); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - if (error == DSVC_SUCCESS) { - for (i = 0, wnp = resdnp; i < count && wnp != NULL; i++) { - dnp = wnp->dnl_rec; - cidlen = sizeof (cid); - (void) octet_to_hexascii(dnp->dn_cid, - dnp->dn_cid_len, cid, &cidlen); - (void) inet_ntop(AF_INET, &dnp->dn_cip, - cip, INET_ADDRSTRLEN); - (void) inet_ntop(AF_INET, &dnp->dn_sip, - sip, INET_ADDRSTRLEN); - (void) printf(" %s %02u %s %s %u '%s' #%s\n", - cid, dnp->dn_flags, cip, sip, dnp->dn_lease, - dnp->dn_macro, dnp->dn_comment); - wnp = wnp->dnl_next; - } - free_dd_list(handle, resdnp); - } - - /* delete_dd_entry - 129.148.5.3 */ - dn.dn_sig = 0; - dn.dn_cip.s_addr = ntohl(inet_addr("129.148.5.3")); - (void) printf("delete_dd_entry: 129.148.5.3 ... "); - error = delete_dd_entry(handle, &dn); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - - /* - * lookup_dd - 129.148.5.0 - record with cid of 01080020000001, modify - * flags to MANUAL+BOOTP, lease to -1, macro to foobar, and server to - * 129.148.174.27. - */ - DSVC_QINIT(query); - DSVC_QEQ(query, DN_QCID); - - (void) memset(&dn, 0, sizeof (dn)); - dn.dn_cid[0] = 0x1; - dn.dn_cid[1] = 0x8; - dn.dn_cid[2] = 0x0; - dn.dn_cid[3] = 0x20; - dn.dn_cid[4] = 0x0; - dn.dn_cid[5] = 0x0; - dn.dn_cid[6] = 0x1; - dn.dn_cid_len = 7; - - (void) printf("lookup_dd: 01080020000001 ... "); - error = lookup_dd(handle, B_FALSE, query, 1, &dn, (void **)&resdnp, - &count); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - - if (error == DSVC_SUCCESS) { - if (count != 1) { - (void) printf("lookup_dd: expected 1 record, got %d\n", - count); - } else { - dnp = resdnp->dnl_rec; - dn = *dnp; /* struct copy */ - - dn.dn_flags = DN_FMANUAL | DN_FBOOTP_ONLY; - dn.dn_lease = DHCP_PERM; - (void) strcpy(dn.dn_macro, "foobar"); - dn.dn_sip.s_addr = ntohl(inet_addr("129.148.174.27")); - - /* Modify it */ - (void) printf("modify_dd_entry: 01080020000001 ... "); - error = modify_dd_entry(handle, dnp, &dn); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - } - free_dd_list(handle, resdnp); - } - - /* lookup_dd - lookup all fields with DN_FMANUAL set */ - - DSVC_QINIT(query); - DSVC_QEQ(query, DN_QFMANUAL); - - (void) memset(&dn, 0, sizeof (dn)); - dn.dn_flags = DN_FMANUAL; - - (void) printf("lookup_dd: F_MANUAL ... "); - error = lookup_dd(handle, B_FALSE, query, 1, &dn, (void **)&resdnp, - &count); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - - if (error == DSVC_SUCCESS) { - if (count != 1) { - (void) printf("lookup_dd: expected 1 record, " - "got %d\n", count); - } else { - dnp = resdnp->dnl_rec; - cidlen = sizeof (cid); - (void) octet_to_hexascii(dnp->dn_cid, - dnp->dn_cid_len, cid, &cidlen); - (void) inet_ntop(AF_INET, &dnp->dn_cip, - cip, INET_ADDRSTRLEN); - (void) inet_ntop(AF_INET, &dnp->dn_sip, - sip, INET_ADDRSTRLEN); - (void) printf(" %s %02u %s %s %u '%s' #%s\n", - cid, dnp->dn_flags, cip, sip, dnp->dn_lease, - dnp->dn_macro, dnp->dn_comment); - } - free_dd_list(handle, resdnp); - } - - /* lookup_dd - lookup all records. */ - - DSVC_QINIT(query); - - (void) printf("lookup_dd: 129.148.5.0 ..."); - error = lookup_dd(handle, B_FALSE, query, -1, &dn, (void **)&resdnp, - &count); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - - if (error == DSVC_SUCCESS) { - for (i = 0, wnp = resdnp; i < count && wnp != NULL; i++) { - cidlen = sizeof (cid); - dnp = wnp->dnl_rec; - (void) octet_to_hexascii(dnp->dn_cid, - dnp->dn_cid_len, cid, &cidlen); - (void) inet_ntop(AF_INET, &dnp->dn_cip, - cip, INET_ADDRSTRLEN); - (void) inet_ntop(AF_INET, &dnp->dn_sip, - sip, INET_ADDRSTRLEN); - (void) printf(" %s %02u %s %s %u '%s' #%s\n", - cid, dnp->dn_flags, cip, sip, dnp->dn_lease, - dnp->dn_macro, dnp->dn_comment); - wnp = wnp->dnl_next; - } - free_dd_list(handle, resdnp); - } - - /* close_dd - 129.148.5.0 */ - (void) printf("close_dd: 129.148.5.0 ... "); - error = close_dd(&handle); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - - /* list_dd - dhcp network containers */ - (void) printf("list_dd: ... "); - error = list_dd(&dsp, DSVC_DHCPNETWORK, &listpp, &count); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - if (error == DSVC_SUCCESS) { - (void) printf(" %d dhcp network container(s): ", count); - for (i = 0; i < count; i++) { - (void) printf("%s ", listpp[i] != NULL ? - listpp[i] : "NULL"); - free(listpp[i]); - } - free(listpp); - (void) printf("\n"); - } else { - (void) printf("list_dd: listpp: 0x%p, count: %d\n", - (void *)listpp, count); - } - - /* remove_dd - 129.148.5.0 */ - (void) printf("remove_dd_entry: 129.148.5.0 ... "); - error = remove_dd(&dsp, DSVC_DHCPNETWORK, "129.148.5.0"); - (void) printf("%s\n", dhcpsvc_errmsg(error)); - - return (0); -} diff --git a/usr/src/lib/libdhcputil/common/dhcp_symbol.h b/usr/src/lib/libdhcputil/common/dhcp_symbol.h index 0e153457e4..c8749b1424 100644 --- a/usr/src/lib/libdhcputil/common/dhcp_symbol.h +++ b/usr/src/lib/libdhcputil/common/dhcp_symbol.h @@ -19,6 +19,8 @@ * CDDL HEADER END */ /* + * Copyright 2014 Garrett D'Amore <garrett@damore.org> + * * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -26,8 +28,6 @@ #ifndef _DHCP_SYMBOL_H #define _DHCP_SYMBOL_H -#pragma ident "%Z%%M% %I% %E% SMI" - /* * This file, along with <dhcp_symbol_common.h>, contains the DHCP symbol * constants and the definitions for the external interfaces to the parsing @@ -36,7 +36,6 @@ */ #include <sys/types.h> -#include <dhcp_svc_private.h> #include <dhcp_symbol_common.h> #ifdef __cplusplus @@ -46,13 +45,13 @@ extern "C" { /* * Vendor class length (and implicitly, the number of classes) */ -#define DSYM_CLASS_SIZE DSVC_MAX_MACSYM_LEN /* Single class max */ +#define DSYM_CLASS_SIZE 128 /* Single class max */ #define DSYM_MAX_CLASS_SIZE (DSYM_CLASS_SIZE * 10) /* At least 10 */ /* - * Maximum symbol length is defined by the libdhcpsvc. + * Maximum symbol length */ -#define DSYM_MAX_SYM_LEN DSVC_MAX_MACSYM_LEN +#define DSYM_MAX_SYM_LEN 128 /* * symbol parsing error codes diff --git a/usr/src/man/man1m/Makefile b/usr/src/man/man1m/Makefile index dc69b7fae0..a95323906e 100644 --- a/usr/src/man/man1m/Makefile +++ b/usr/src/man/man1m/Makefile @@ -105,9 +105,6 @@ _MANFILES= 6to4relay.1m \ dfshares.1m \ dfshares_nfs.1m \ dhcpagent.1m \ - dhcpconfig.1m \ - dhcpmgr.1m \ - dhtadm.1m \ disks.1m \ diskscan.1m \ dispadmin.1m \ @@ -123,7 +120,6 @@ _MANFILES= 6to4relay.1m \ dscfgadm.1m \ dscfglockd.1m \ dsstat.1m \ - dsvclockd.1m \ dtrace.1m \ dumpadm.1m \ editmap.1m \ @@ -197,7 +193,6 @@ _MANFILES= 6to4relay.1m \ in.chargend.1m \ in.comsat.1m \ in.daytimed.1m \ - in.dhcpd.1m \ in.discardd.1m \ in.echod.1m \ in.fingerd.1m \ @@ -378,7 +373,6 @@ _MANFILES= 6to4relay.1m \ plockstat.1m \ pmadm.1m \ pmconfig.1m \ - pntadm.1m \ polkit-is-privileged.1m \ pooladm.1m \ poolbind.1m \ diff --git a/usr/src/man/man1m/dhcpconfig.1m b/usr/src/man/man1m/dhcpconfig.1m deleted file mode 100644 index ccb4eb6bed..0000000000 --- a/usr/src/man/man1m/dhcpconfig.1m +++ /dev/null @@ -1,792 +0,0 @@ -'\" te -.\" Copyright (c) 2002 by Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH DHCPCONFIG 1M "Jun 16, 2004" -.SH NAME -dhcpconfig \- DHCP service configuration utility -.SH SYNOPSIS -.LP -.nf -\fBdhcpconfig\fR \fB-D\fR \fB-r\fR \fIresource\fR \fB-p\fR \fIpath\fR [\fB-u\fR \fIuninterpreted\fR] - [\fB-l\fR \fIlease_length\fR] [\fB-n\fR ] [\fB-d\fR \fIDNS_domain\fR] - [\fB-a\fR \fIDNS_server_addresses\fR] [\fB-h\fR \fIhosts_resource\fR] - [\fB-y\fR \fIhosts_domain\fR] -.fi - -.LP -.nf -\fBdhcpconfig\fR \fB-R\fR \fIserver_addresses\fR -.fi - -.LP -.nf -\fBdhcpconfig\fR \fB-U\fR [\fB-f\fR] [\fB-x\fR] [\fB-h\fR] -.fi - -.LP -.nf -\fBdhcpconfig\fR \fB-N\fR \fInetwork_address\fR [\fB-m\fR \fIsubnet_mask\fR] [\fB-b\fR ] - [\fB-t\fR \fIrouter_addresses\fR] [\fB-y\fR \fINIS-domain\fR] - [\fB-a\fR \fINIS_server_addresses\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhcpconfig\fR \fB-C\fR \fB-r\fR \fIresource\fR \fB-p\fR \fIpath\fR [\fB-f\fR] [\fB-k\fR] - [\fB-u\fR \fIuninterpreted\fR] -.fi - -.LP -.nf -\fBdhcpconfig\fR \fB-X\fR \fIfilename\fR [\fB-m\fR \fImacro_list\fR] [\fB-o\fR \fIoption_list\fR] - [\fB-a\fR \fInetwork_addresses\fR] [\fB-f\fR] [\fB-x\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhcpconfig\fR \fB-I\fR \fIfilename\fR [\fB-f\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhcpconfig\fR \fB-P\fR [\fIparameter\fR[=\fIvalue\fR],]... -.fi - -.LP -.nf -\fBdhcpconfig\fR \fB-S\fR [\fB-f\fR] [\fB-e\fR | \fB-d\fR | \fB-r\fR | \fB-q\fR] -.fi - -.SH DESCRIPTION -.sp -.LP -The \fBdhcpconfig\fR command is used to configure and manage the Dynamic Host -Configuration Protocol (DHCP) service or BOOTP relay services. It is intended -for use by experienced Solaris system administrators and is designed for ease -of use in scripts. The \fBdhcpmgr\fR utility is recommended for less -experienced administrators or those preferring a graphical utility to configure -and manage the DHCP service or BOOTP relay service. -.sp -.LP -The \fBdhcpconfig\fR command can be run by root, or by other users assigned to -the DHCP Management profile. See \fBrbac\fR(5) and \fBuser_attr\fR(4). -.sp -.LP -\fBdhcpconfig\fR requires one of the following function flags: \fB-D\fR, -\fB-R\fR, \fB-U\fR, \fB-N\fR, \fB-C\fR, \fB-X\fR, \fB-I\fR, \fB-P\fR or -\fB-S\fR. -.sp -.LP -The \fBdhcpconfig\fR menu driven mode is supported in Solaris 8 and previous -versions of Solaris. -.SS "Where dhcpconfig Obtains Configuration Information" -.sp -.LP -\fBdhcpconfig\fR scans various configuration files on your Solaris machine for -information it can use to assign values to options contained in macros it adds -to the \fBdhcptab\fR configuration table. The following table lists information -\fBdhcpconfig\fR needs, the source used, and how the information is used: -.sp - -.sp -.TS -box; -l | l | l -l | l | l . -\fIInformation\fR \fISource\fR \fIWhere Used\fR -_ -Timezone System date, timezone settings \fBLocale\fR macro -DNS parameters \fBnsswitch.conf\fR, \fB/etc/resolv.conf\fR Server macro -NIS parameters System domainname, \fBnsswitch.conf\fR, NIS Network macros -Subnetmask T{ -Network interface, \fBnetmasks\fR table in nameservice -T} Network macros -.TE - -.sp -.LP -If you have not set these parameters on your server machine, you should do so -before configuring the DHCP server with \fBdhcpconfig\fR. Note that if you -specify options with the \fBdhcpconfig \fR\fB-D\fR command line, the values you -supply override the values obtained from the system files. -.SH OPTIONS -.sp -.LP -The following options are supported: -.sp -.ne 2 -.na -\fB\fB-C\fR\fR -.ad -.RS 23n -Convert to using a new data store, recreating the DHCP data tables in a format -appropriate to the new data store, and setting up the DHCP server to use the -new data store. -.sp -The following sub-options are required: -.sp -.ne 2 -.na -\fB\fB-p\fR \fIpath_to_data\fR\fR -.ad -.RS 20n -The paths for \fBSUNWfiles\fR and \fBSUNWbinfiles\fR must be absolute -\fBUNIX\fR pathnames. The path for \fBSUNWnisplus\fR must be a fully specified -\fBNIS+\fR directory (including the tailing period.) See \fBdhcp_modules\fR(5). -.RE - -.sp -.ne 2 -.na -\fB\fB-r\fR \fIdata_resource\fR\fR -.ad -.RS 20n -New data store resource. One of the following must be specified: -\fBSUNWfiles\fR, \fBSUNWbinfiles\fR, or \fBSUNWnisplus\fR. See -\fBdhcp_modules\fR(5). -.RE - -The following sub-options are optional: -.sp -.ne 2 -.na -\fB\fB-f\fR\fR -.ad -.RS 20n -Do not prompt for confirmation. If \fB-f\fR is not used, a warning and -confirmation prompt are issued before the conversion starts. -.RE - -.sp -.ne 2 -.na -\fB\fB-k\fR\fR -.ad -.RS 20n -Keep the old DHCP data tables after successful conversion. If any problem -occurs during conversion, tables are not deleted even if \fB-k\fR sub-option is -not specified. -.RE - -.sp -.ne 2 -.na -\fB\fB-u\fR \fIuninterpreted\fR\fR -.ad -.RS 20n -Data which is ignored by \fBdhcpconfig\fR, but passed on to the datastore for -interpretation. The private layer provides for module-specific configuration -information through the use of the \fBRESOURCE_CONFIG \fR keyword. -Uninterpreted data is stored within \fBRESOURCE_CONFIG\fR keyword of -\fBdhcpsvc.conf\fR(4). The \fB-u\fR sub-option is not used with the -\fBSUNWfiles\fR, \fBSUNWbinfiles\fR, and \fBSUNWnisplus\fR data stores. See -\fBdhcp_modules\fR(5). -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-D\fR\fR -.ad -.RS 23n -Configure the \fBDHCP\fR service. -.sp -The following sub-options are required: -.sp -.ne 2 -.na -\fB\fB-r\fR \fIdata_resource\fR\fR -.ad -.RS 20n -One of the following must be specified: \fBSUNWfiles\fR, \fBSUNWbinfiles\fR, or -\fBSUNWnisplus\fR. Other data stores may be available.See -\fBdhcp_modules\fR(5). -.RE - -.sp -.ne 2 -.na -\fB\fB-p\fR \fIpath\fR\fR -.ad -.RS 20n -The paths for \fBSUNWfiles\fR and \fBSUNWbinfiles\fR must be absolute -\fBUNIX\fR pathnames. The path for \fBSUNWnisplus\fR must be a fully specified -\fBNIS+\fR directory (including the tailing period.) . See -\fBdhcp_modules\fR(5). -.RE - -The following sub-options are optional: -.sp -.ne 2 -.na -\fB\fB-a\fR \fIDNS_servers\fR\fR -.ad -.RS 21n -IP addresses of DNS servers, separated with commas. -.RE - -.sp -.ne 2 -.na -\fB\fB-d\fR \fIDNS_domain\fR\fR -.ad -.RS 21n -DNS domain name. -.RE - -.sp -.ne 2 -.na -\fB\fB-h\fR \fIhosts_resource\fR\fR -.ad -.RS 21n -Resource in which to place hosts data. Usually, the name service in use on the -server. Valid values are \fBnisplus\fR, \fBfiles\fR, or \fBdns\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-l\fR \fIseconds\fR\fR -.ad -.RS 21n -Lease length used for addresses not having a specified lease length, in -seconds. -.RE - -.sp -.ne 2 -.na -\fB\fB-n\fR\fR -.ad -.RS 21n -Non-negotiable leases -.RE - -.sp -.ne 2 -.na -\fB\fB-y\fR \fIhosts_domain\fR\fR -.ad -.RS 21n -DNS or NIS+ domain name to be used for hosts data. Valid only if \fBdns\fR or -\fBnisplus\fR is specified for \fB-h\fR sub-option. -.RE - -.sp -.ne 2 -.na -\fB\fB-u\fR \fIuninterpreted\fR\fR -.ad -.RS 21n -Data which is ignored by \fBdhcpconfig\fR, but passed on to the datastore for -interpretation. The private layer provides for module-specific configuration -information through the use of the \fBRESOURCE_CONFIG \fR keyword. -Uninterpreted data is stored within \fBRESOURCE_CONFIG\fR keyword of -\fBdhcpsvc.conf\fR(4). The \fB-u\fR sub-option is not used with the -\fBSUNWfiles\fR, \fBSUNWbinfiles\fR, and \fBSUNWnisplus\fR data stores. See -\fBdhcp_modules\fR(5). -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-I\fR \fIfilename\fR\fR -.ad -.RS 23n -Import data from \fIfilename\fR, containing data previously exported from a -Solaris DHCP server. Note that after importing, you may have to edit macros to -specify the correct domain names, and edit network tables to change the owning -server of addresses in imported networks. Use \fBdhtadm\fR and \fBpntadm\fR to -do this. -.sp -The following sub-options are supported: -.sp -.ne 2 -.na -\fB\fB-f\fR\fR -.ad -.RS 6n -Replace any conflicting data with the data being imported. -.RE - -.sp -.ne 2 -.na -\fB\fB-g\fR\fR -.ad -.RS 6n -Signal the daemon to reload the \fBdhcptab\fR once the import has been -completed. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-N\fR \fInet_address\fR\fR -.ad -.RS 23n -Configure an additional network for DHCP service. -.sp -The following sub-options are supported: -.sp -.ne 2 -.na -\fB\fB-a\fR \fINIS_server_addresses\fR\fR -.ad -.RS 27n -List of IP addresses of NIS servers. -.RE - -.sp -.ne 2 -.na -\fB\fB-b\fR\fR -.ad -.RS 27n -Network is a point-to-point (PPP) network, therefore no broadcast address -should be configured. If \fB-\fRb is not used, the network is assumed to be a -LAN, and the broadcast address is determined using the network address and -subnet mask. -.RE - -.sp -.ne 2 -.na -\fB\fB-g\fR\fR -.ad -.RS 27n -Signal the daemon to reload the \fBdhcptab\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-m\fR \fIxxx.xxx.xxx.xxx\fR\fR -.ad -.RS 27n -Subnet mask for the network; if \fB-m\fR is not used, subnet mask is obtained -from netmasks. -.RE - -.sp -.ne 2 -.na -\fB\fB-t\fR \fIrouter_addresses\fR\fR -.ad -.RS 27n -List of router IP addresses; if not specified, router discovery flag is set. -.RE - -.sp -.ne 2 -.na -\fB\fB-y\fR \fINIS_domain_name\fR\fR -.ad -.RS 27n -If NIS is used on this network, specify the NIS domain name. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-P\fR\fR -.ad -.RS 23n -Configure the DHCP service parameters. Each parameter and value are specified -by the following pattern: -.sp -.in +2 -.nf -\fIparameter\fR[=\fIvalue\fR],\&.\|.\|. -.fi -.in -2 -.sp - -Where parameter and value are: -.sp -.ne 2 -.na -\fB\fIparameter\fR\fR -.ad -.RS 13n -One of the DHCP service parameters listed in \fBdhcpsvc.conf\fR(4). If the -corresponding \fIvalue\fR is not specified, the current parameter value is -displayed. If \fIparameter\fR is not specified, all parameters and current -values are displayed. -.RE - -.sp -.ne 2 -.na -\fB\fIvalue\fR\fR -.ad -.RS 13n -Optional string to set the servers parameter to if the value is acceptable. If -the value is missing or is empty (\fB""\fR), the parameter and its current -value are deleted. -.RE - -After a parameter has changed the DHCP server requires re-starting before you -can use new parameter values. -.RE - -.sp -.ne 2 -.na -\fB\fB-R\fR \fIserver_addresses\fR\fR -.ad -.RS 23n -Configure the BOOTP relay service. BOOTP or DHCP requests are forwarded to the -list of servers specified. -.sp -\fIserver_addresses\fR is a comma separated list of hostnames and/or IP -addresses. -.RE - -.sp -.ne 2 -.na -\fB\fB-S\fR\fR -.ad -.RS 23n -Control the DHCP service. -.sp -The following sub-options are supported: -.sp -.ne 2 -.na -\fB\fB-d\fR\fR -.ad -.RS 6n - Disable and stop the DHCP service. -.RE - -.sp -.ne 2 -.na -\fB\fB-e\fR\fR -.ad -.RS 6n -Enable and start the DHCP service. -.RE - -.sp -.ne 2 -.na -\fB\fB-q\fR\fR -.ad -.RS 6n -Display the state of the DHCP service. The state is encoded into the exit -status. -.sp -.in +2 -.nf -0 DHCP service disabled and stopped -1 DHCP service enabled and stopped -2 DHCP service disabled and running -3 DHCP service enabled and running -.fi -.in -2 -.sp - -.RE - -.sp -.ne 2 -.na -\fB\fB-r\fR\fR -.ad -.RS 6n -Enable and restart the DHCP service. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-U\fR\fR -.ad -.RS 23n -Unconfigure the DHCP service or BOOTP relay service. -.sp -The following sub-options are supported: -.sp -.ne 2 -.na -\fB\fB-f\fR\fR -.ad -.RS 6n -Do not prompt for confirmation. If \fB-f\fR is not used, a warning and -confirmation prompt is issued. -.RE - -.sp -.ne 2 -.na -\fB\fB-h\fR\fR -.ad -.RS 6n -Delete hosts entries from name service. -.RE - -.sp -.ne 2 -.na -\fB\fB-x\fR\fR -.ad -.RS 6n -Delete the \fBdhcptab\fR and network tables. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-X\fR \fIfilename\fR\fR -.ad -.RS 23n -Export data from the DHCP data tables, saving to \fIfilename\fR, to move the -data to another Solaris DHCP server. -.sp -The following sub-options are optional: -.sp -.ne 2 -.na -\fB\fB-a\fR \fInetworks_to_export\fR\fR -.ad -.RS 25n -List of networks whose addresses should be exported, or the keyword ALL to -specify all networks. If \fB-a\fR is not specified, no networks are exported. -.RE - -.sp -.ne 2 -.na -\fB\fB-g\fR \fR -.ad -.RS 25n -Signal the daemon to reload the \fBdhcptab\fR after the export has been -completed. -.RE - -.sp -.ne 2 -.na -\fB\fB-m\fR \fImacros_to_export\fR\fR -.ad -.RS 25n -List of macros to export, or the keyword \fBALL\fR to specify all macros. If -\fB-m\fR is not specified, no macros are exported. -.RE - -.sp -.ne 2 -.na -\fB\fB-o\fR \fIoptions_to_export\fR\fR -.ad -.RS 25n -List of options to export, or the keyword \fBALL\fR to specify all options. If -\fB-o\fR is not specified, no options are exported. -.RE - -.sp -.ne 2 -.na -\fB\fB-x\fR\fR -.ad -.RS 25n -Delete the data from this server after it is exported. If \fB-x\fR is not -specified you are in effect copying the data. -.RE - -.RE - -.SH EXAMPLES -.LP -\fBExample 1 \fRConfiguring DHCP Service with Binary Files Data Store -.sp -.LP -The following command configures DHCP service, using the binary files data -store, in the DNS domain \fBacme.eng\fR, with a lease time of 28800 seconds (8 -hours), - -.sp -.in +2 -.nf -example# dhcpconfig -D -r SUNWbinfiles -p /var/dhcp -l 28800\e - -d acme.eng -a 120.30.33.4 -h dns -y acme.eng -.fi -.in -2 -.sp - -.LP -\fBExample 2 \fRConfiguring BOOTP Relay Agent -.sp -.LP -The following command configures the DHCP daemon as a BOOTP relay agent, which -forwards BOOTP and DHCP requests to the servers having the IP addresses -120.30.33.7 and 120.30.42.132: - -.sp -.in +2 -.nf -example# dhcpconfig -R 120.30.33.7,120.30.42.132 -.fi -.in -2 -.sp - -.LP -\fBExample 3 \fRUnconfiguring DHCP Service -.sp -.LP -The following command unconfigures the DHCP service, with confirmation, and -deletes the DHCP data tables and host table entries: - -.sp -.in +2 -.nf -example# dhcpconfig -U -x -h -.fi -.in -2 -.sp - -.LP -\fBExample 4 \fRConfiguring a Network for DHCP Service -.sp -.LP -The following command configures an additional LAN network for DHCP service, -specifying that clients should use router discovery and providing the NIS -domain name and NIS server address: - -.sp -.in +2 -.nf -example# dhcpconfig -N 120.30.171.0 -y east.acme.eng.com\e - -a 120.30.33.4 -.fi -.in -2 -.sp - -.LP -\fBExample 5 \fRConverting to SUNWnisplus Data Store -.sp -.LP -The following command converts a DHCP server from using a text or binary files -data store to a NIS+ data store, deleting the old data store's DHCP tables: - -.sp -.in +2 -.nf -example# dhcpconfig -C -r SUNWnisplus -p whatever.com. -.fi -.in -2 -.sp - -.LP -\fBExample 6 \fRExporting a Network, Macros, and Options from a DHCP Server -.sp -.LP -The following command exports one network (\fB120.30.171.0\fR) and its -addresses, the macro \fB120.30.171.0\fR, and the options \fBmotd\fR and -\fBPSptr\fRfrom a DHCP server, saves the exported data in file -\fB/export/var/120301710_data\fR, and deletes the exported data from the -server. - -.sp -.in +2 -.nf -example# dhcpconfig -X /var/dhcp/120301710_export - -a 120.30.171.0 -m 120.30.171.0 -o motd,PSptr -.fi -.in -2 -.sp - -.LP -\fBExample 7 \fRImporting Data on a DHCP Server -.sp -.LP -The following command imports DHCP data from a file, -\fB/net/golduck/export/var/120301710_data\fR, containing data previously -exported from a Solaris DHCP server, overwrites any conflicting data on the -importing server, and signals the daemon to reload the \fBdhcptab\fR once the -import is completed: - -.sp -.in +2 -.nf -example# dhcpconfig -I /net/golduck/export/var/120301710_data -f -g -.fi -.in -2 -.sp - -.LP -\fBExample 8 \fRSetting DHCP Server Parameters -.sp -.LP - The following command sets the number of minutes that the DHCP server waits -before timing out when updating DNS information on DHCP clients to five -minutes. - -.sp -.in +2 -.nf -example# example# dhcpconfig -P UPDATE_TIMEOUT=5 -.fi -.in -2 -.sp - -.LP -\fBExample 9 \fRRe-starting the DHCP server -.sp -.LP -The following command stops and re-starts the DHCP server. - -.sp -.in +2 -.nf -example# example# dhcpconfig -S -r -DHCP server stopped -DHCP server started -.fi -.in -2 -.sp - -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability Evolving -.TE - -.SH SEE ALSO -.sp -.LP -\fBdhcpmgr\fR(1M), \fBdhtadm\fR(1M), \fBin.dhcpd\fR(1M), \fBpntadm\fR(1M), -\fBdhcp_network\fR(4), \fBdhcptab\fR(4), \fBdhcpsvc.conf\fR(4), -\fBnsswitch.conf\fR(4), \fBresolv.conf\fR(4), \fBuser_attr\fR(4), -\fBattributes\fR(5), \fBdhcp\fR(5), \fBdhcp_modules\fR(5), \fBrbac\fR(5) -.sp -.LP -\fI\fR diff --git a/usr/src/man/man1m/dhcpmgr.1m b/usr/src/man/man1m/dhcpmgr.1m deleted file mode 100644 index f90906b7b6..0000000000 --- a/usr/src/man/man1m/dhcpmgr.1m +++ /dev/null @@ -1,164 +0,0 @@ -'\" te -.\" Copyright (c) 2001 Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH DHCPMGR 1M "Mar 13, 2001" -.SH NAME -dhcpmgr \- graphical interface for managing DHCP service -.SH SYNOPSIS -.LP -.nf -\fB/usr/sadm/admin/bin/dhcpmgr\fR -.fi - -.SH DESCRIPTION -.sp -.LP -\fBdhcpmgr\fR is a graphical user interface which enables you to manage the -Dynamic Host Configuration Protocol (\fBDHCP\fR) service on the local system. -It performs the functions of the \fBdhcpconfig\fR, \fBdhtadm\fR, and -\fBpntadm\fR command line utilities. You must be \fBroot\fR to use -\fBdhcpmgr\fR. The \fBdhcpmgr\fR Help, available from the \fBHelp\fR menu, -contains detailed information about using the tool. -.SH USAGE -.sp -.LP -You can perform the following tasks using \fBdhcpmgr\fR: -.sp -.ne 2 -.na -\fBConfigure DHCP service\fR -.ad -.sp .6 -.RS 4n -Use \fBdhcpmgr\fR to configure the DHCP daemon as a \fBDHCP\fR server, and -select the data store to use for storing network configuration tables.. -.RE - -.sp -.ne 2 -.na -\fBConfigure BOOTP relay service\fR -.ad -.sp .6 -.RS 4n -Use \fBdhcpmgr\fR to configure the DHCP daemon as a \fBBOOTP\fR relay. -.RE - -.sp -.ne 2 -.na -\fBManage DHCP or BOOTP relay service\fR -.ad -.sp .6 -.RS 4n -Use \fBdhcpmgr\fR to start, stop, enable, disable or unconfigure the \fBDHCP\fR -service or \fBBOOTP\fR relay service, or change DHCP server parameters. -.RE - -.sp -.ne 2 -.na -\fBManage DHCP addresses\fR -.ad -.sp .6 -.RS 4n -Use \fBdhcpmgr\fR to add, modify, or delete \fBIP\fR addresses leased by the -\fBDHCP\fR service. -.RE - -.sp -.ne 2 -.na -\fBManage DHCP macros\fR -.ad -.sp .6 -.RS 4n -Use \fBdhcpmgr\fR to add, modify or delete macros used to supply configuration -parameters to \fBDHCP\fR clients. -.RE - -.sp -.ne 2 -.na -\fBManage DHCP options\fR -.ad -.sp .6 -.RS 4n -Use \fBdhcpmgr\fR to add, modify or delete options used to define parameters -deliverable through \fBDHCP\fR. -.RE - -.sp -.ne 2 -.na -\fBConvert to a new DHCP data store\fR -.ad -.sp .6 -.RS 4n -Use \fBdhcpmgr\fR to configure the DHCP server to use a different data store, -and convert the DHCP data to the format used by the new data store. -.RE - -.sp -.ne 2 -.na -\fBMove DHCP data to another server\fR -.ad -.sp .6 -.RS 4n -Use \fBdhcpmgr\fR to export data from one Solaris DHCP server and import data -onto another Solaris DHCP server. -.RE - -.SH EXIT STATUS -.sp -.LP -The following exit values are returned: -.sp -.ne 2 -.na -\fB\fB0\fR \fR -.ad -.RS 13n -Successful completion. -.RE - -.sp -.ne 2 -.na -\fB\fBnon-zero\fR \fR -.ad -.RS 13n -An error occurred. -.RE - -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability Evolving -.TE - -.SH SEE ALSO -.sp -.LP -\fBdhcpconfig\fR(1M), \fBdhtadm\fR(1M), \fBpntadm\fR(1M), \fBin.dhcpd\fR(1M), -\fBdhcpsvc.conf\fR(4), \fBdhcp_network\fR(4), \fBdhcptab\fR(4), -\fBattributes\fR(5), \fBdhcp\fR(5), \fBdhcp_modules\fR(5) -.sp -.LP -\fI\fR -.sp -.LP -\fI\fR diff --git a/usr/src/man/man1m/dhtadm.1m b/usr/src/man/man1m/dhtadm.1m deleted file mode 100644 index 9ff782808e..0000000000 --- a/usr/src/man/man1m/dhtadm.1m +++ /dev/null @@ -1,658 +0,0 @@ -'\" te -.\" Copyright (c) 2002 by Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH DHTADM 1M "Aug 28, 2004" -.SH NAME -dhtadm \- DHCP configuration table management utility -.SH SYNOPSIS -.LP -.nf -\fBdhtadm\fR \fB-C\fR [\fB-r\fR \fIresource\fR] [\fB-p\fR \fIpath\fR] [\fB-u\fR \fIuninterpreted\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhtadm\fR \fB-A\fR \fB-s\fR \fIsymbol_name\fR \fB-d\fR \fIdefinition\fR [\fB-r\fR \fIresource\fR] - [\fB-p\fR \fIpath\fR] [\fB-u\fR \fIuninterpreted\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhtadm\fR \fB-A\fR \fB-m\fR \fImacro_name\fR \fB-d\fR \fIdefinition\fR [\fB-r\fR \fIresource\fR] - [\fB-p\fR \fIpath\fR] [\fB-u\fR \fIuninterpreted\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhtadm\fR \fB-M\fR \fB-s\fR \fIsymbol_name\fR \fB-d\fR \fIdefinition\fR [\fB-r\fR \fIresource\fR] - [\fB-p\fR \fIpath\fR] [\fB-u\fR \fIuninterpreted\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhtadm\fR \fB-M\fR \fB-s\fR \fIsymbol_name\fR \fB-n\fR \fInew_name\fR [\fB-r\fR \fIresource\fR] - [\fB-p\fR \fIpath\fR] [\fB-u\fR \fIuninterpreted\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhtadm\fR \fB-M\fR \fB-m\fR \fImacro_name\fR \fB-n\fR \fInew_name\fR [\fB-r\fR \fIresource\fR] [\fB-p\fR \fIpath\fR] - [\fB-u\fR \fIuninterpreted\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhtadm\fR \fB-M\fR \fB-m\fR \fImacro_name\fR \fB-d\fR \fIdefinition\fR [\fB-r\fR \fIresource\fR] - [\fB-p\fR \fIpath\fR] [\fB-u\fR \fIuninterpreted\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhtadm\fR \fB-M\fR \fB-m\fR \fImacro_name\fR \fB-e\fR \fIsymbol=value\fR [\fB-r\fR \fIresource\fR] - [\fB-p\fR \fIpath\fR] [\fB-u\fR \fIuninterpreted\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhtadm\fR \fB-D\fR \fB-s\fR \fIsymbol_name\fR [\fB-r\fR \fIresource\fR] [\fB-p\fR \fIpath\fR] - [\fB-u\fR \fIuninterpreted\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhtadm\fR \fB-D\fR \fB-m\fR \fImacro_name\fR [\fB-r\fR \fIresource\fR] [\fB-p\fR \fIpath\fR] - [\fB-u\fR \fIuninterpreted\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhtadm\fR \fB-P\fR [\fB-r\fR \fIresource\fR] [\fB-p\fR \fIpath\fR] [\fB-u\fR \fIuninterpreted\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhtadm\fR \fB-R\fR [\fB-r\fR \fIresource\fR] [\fB-p\fR \fIpath\fR] [\fB-u\fR \fIuninterpreted\fR] [\fB-g\fR] -.fi - -.LP -.nf -\fBdhtadm\fR \fB-B\fR [\fB-v\fR] [\fIbatchfile\fR] [\fB-g\fR] -.fi - -.SH DESCRIPTION -.sp -.LP -\fBdhtadm\fR manages the Dynamic Host Configuration Protocol (\fBDHCP\fR) -service configuration table, \fBdhcptab\fR. You can use it to add, delete, or -modify \fBDHCP\fR configuration macros or options or view the table. For a -description of the table format, see \fBdhcptab\fR(4).) -.sp -.LP -The \fBdhtadm\fR command can be run by root, or by other users assigned to the -DHCP Management profile. See \fBrbac\fR(5) and \fBuser_attr\fR(4). -.sp -.LP -After you make changes with \fBdhtadm\fR, you should issue a \fBSIGHUP\fR to -the DHCP server, causing it to read the \fBdhcptab\fR and pick up the changes. -Do this using the \fB-g\fR option. -.SH OPTIONS -.sp -.LP -One of the following function flags must be specified with the \fBdhtadm\fR -command: \fB-A\fR, \fB-B\fR, \fB-C\fR, \fB-D\fR, \fB-M\fR, \fB-P\fR or -\fB-R\fR. -.sp -.LP -The following options are supported: -.sp -.ne 2 -.na -\fB\fB-A\fR \fR -.ad -.RS 27n -Add a symbol or macro definition to the \fBdhcptab\fR table. -.sp -The following sub-options are required: -.sp -.ne 2 -.na -\fB\fB-d\fR \fIdefinition\fR\fR -.ad -.RS 18n -Specify a macro or symbol definition. -.sp -\fIdefinition\fR must be enclosed in single quotation marks. For macros, use -the form \fB-d\fR -\fB\&':\fIsymbol\fR=\fIvalue\fR:\fIsymbol\fR=\fIvalue\fR:'\fR. Enclose a -\fIvalue\fR that contains colons in double quotation marks. For symbols, the -definition is a series of fields that define a symbol's characteristics. The -fields are separated by commas. Use the form \fB-d\fR -\fB\&'\fIcontext\fR,\fIcode\fR,\fItype\fR,\fIgranularity\fR,\fImaximum\fR'\fR. -See \fBdhcptab\fR(4) for information about these fields. -.RE - -.sp -.ne 2 -.na -\fB\fB-m\fR \fImacro_name\fR\fR -.ad -.RS 18n -Specify the name of the macro to be added. -.sp -The \fB-d\fR option must be used with the \fB-m\fR option. The \fB-s\fR option -cannot be used with the \fB-m\fR option. -.RE - -.sp -.ne 2 -.na -\fB\fB-s\fR \fIsymbol_name\fR\fR -.ad -.RS 18n -Specify the name of the symbol to be added. -.sp -The \fB-d\fR option must be used with the \fB-s\fR option. The \fB-m\fR option -cannot be used with the \fB-s\fR option. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-B\fR\fR -.ad -.RS 27n -Batch process \fBdhtadm\fR commands. \fBdhtadm\fR reads from the specified file -or from standard input a series of \fBdhtadm\fR commands and execute them -within the same process. Processing many \fBdhtadm\fR commands using this -method is much faster than running an executable batchfile itself. Batch mode -is recommended for using \fBdhtadm\fR in scripts. -.sp -The following sub-option is optional: -.sp -.ne 2 -.na -\fB\fB-v\fR\fR -.ad -.RS 6n -Display commands to standard output as they are processed. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-C\fR \fR -.ad -.RS 27n -Create the \fBDHCP\fR service configuration table, \fBdhcptab\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-D\fR \fR -.ad -.RS 27n -Delete a symbol or macro definition. -.sp -The following sub-options are required: -.sp -.ne 2 -.na -\fB\fB-m\fR \fImacro_name\fR\fR -.ad -.RS 18n -Delete the specified macro. -.RE - -.sp -.ne 2 -.na -\fB\fB-s\fR \fIsymbol_name\fR\fR -.ad -.RS 18n -Delete the specified symbol. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-g\fR \fR -.ad -.RS 27n -Signal the DHCP daemon to reload the \fBdhcptab\fR after successful completion -of the operation. -.RE - -.sp -.ne 2 -.na -\fB\fB-M\fR \fR -.ad -.RS 27n -Modify an existing symbol or macro definition. -.sp -The following sub-options are required: -.sp -.ne 2 -.na -\fB\fB-d\fR \fIdefinition\fR\fR -.ad -.RS 17n -Specify a macro or symbol definition to modify. -.sp -The definition must be enclosed in single quotation marks. For macros, use the -form \fB-d\fR \fB\&':\fIsymbol\fR=\fIvalue\fR:\fIsymbol\fR=\fIvalue\fR:'\fR. -Enclose a \fIvalue\fR that contains colons in double quotation marks. For -symbols, the definition is a series of fields that define a symbol's -characteristics. The fields are separated by commas. Use the form \fB-d\fR -\fB\&'\fIcontext\fR,\fIcode\fR,\fItype\fR,\fIgranularity\fR,\fImaximum\fR'\fR. -See \fBdhcptab\fR(4) for information about these fields. -.RE - -.sp -.ne 2 -.na -\fB\fB-e\fR\fR -.ad -.RS 17n -This sub-option uses the \fIsymbol\fR \fB=\fR\fIvalue\fR argument. Use it to -edit a \fIsymbol\fR/\fIvalue\fR pair within a macro. To add a symbol which does -not have an associate value, enter: -.sp -.in +2 -.nf -\fIsymbol\fR\fB=_NULL_VALUE_\fR -.fi -.in -2 -.sp - -To delete a symbol definition from a macro, enter: -.sp -.in +2 -.nf -\fIsymbol\fR\fB=\fR -.fi -.in -2 -.sp - -.RE - -.sp -.ne 2 -.na -\fB\fB-m\fR\fR -.ad -.RS 17n -This sub-option uses the \fImacro_name\fR argument. The \fB-n\fR, \fB-d\fR, or -\fB-e\fR sub-options are legal companions for this sub-option.. -.RE - -.sp -.ne 2 -.na -\fB\fB-n\fR\fR -.ad -.RS 17n -This sub-option uses the \fInew_name\fR argument and modifies the name of the -object specified by the \fB-m\fR or \fB-s\fR sub-option. It is not limited to -macros. . Use it to specify a new macro name or symbol name. -.RE - -.sp -.ne 2 -.na -\fB\fB-s\fR\fR -.ad -.RS 17n -This sub-option uses the \fIsymbol_name\fR argument. Use it to specify a -symbol. The \fB-d\fR sub-option is a legal companion. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-p\fR\fI path\fR \fR -.ad -.RS 27n -Override the \fBdhcpsvc.conf\fR(4) configuration value for \fBPATH=\fR with -\fIpath\fR. See \fBdhcpsvc.conf\fR(4) for more details regarding \fIpath\fR. -See \fBdhcp_modules\fR(5) for information regarding data storage modules for -the \fBDHCP\fR service. -.RE - -.sp -.ne 2 -.na -\fB\fB-P\fR \fR -.ad -.RS 27n -Print (display) the \fBdhcptab\fR table. -.RE - -.sp -.ne 2 -.na -\fB\fB-r\fR\fI data_store_resource\fR \fR -.ad -.RS 27n -Override the \fBdhcpsvc.conf\fR(4) configuration value for \fBRESOURCE=\fR with -the \fIdata_store_resource\fR specified. See \fBdhcpsvc.conf\fR(4) for more -details on resource type. See\fI\fR for more information about adding support -for other data stores. See \fBdhcp_modules\fR(5) for information regarding data -storage modules for the \fBDHCP\fR service. -.RE - -.sp -.ne 2 -.na -\fB\fB-R\fR \fR -.ad -.RS 27n -Remove the \fBdhcptab\fR table. -.RE - -.sp -.ne 2 -.na -\fB\fB-u\fR\fI uninterpreted\fR\fR -.ad -.RS 27n -Data which is ignored by \fBdhtadm\fR, but passed to currently configured -public module, to be interpreted by the data store. The private layer provides -for module-specific configuration information through the use of the -\fBRESOURCE_CONFIG\fR keyword. Uninterpreted data is stored within -\fBRESOURCE_CONFIG\fR keyword of \fBdhcpsvc.conf\fR(4). See -\fBdhcp_modules\fR(5) for information regarding data storage modules for the -DHCP service. -.RE - -.SH EXAMPLES -.LP -\fBExample 1 \fRCreating the \fBDHCP\fR Service Configuration Table -.sp -.LP -The following command creates the \fBDHCP\fR service configuration table, -\fBdhcptab\fR: - -.sp -.in +2 -.nf -# dhtadm \fB-C\fR -.fi -.in -2 -.sp - -.LP -\fBExample 2 \fRAdding a Symbol Definition -.sp -.LP -The following command adds a \fBVendor\fR option symbol definition for a new -symbol called \fBMySym\fR to the \fBdhcptab\fR table in the \fBSUNWfiles\fR -resource in the \fB/var/mydhcp\fR directory: - -.sp -.in +2 -.nf -# dhtadm \fB-A\fR \fB-s\fR MySym - \fB-d\fR 'Vendor=SUNW.PCW.LAN,20,IP,1,0' - \fB-r\fR SUNWfiles \fB-p\fR /var/mydhcp -.fi -.in -2 -.sp - -.LP -\fBExample 3 \fRAdding a Macro Definition -.sp -.LP -The following command adds the \fBaruba\fR macro definition to the -\fBdhcptab\fR table. Note that symbol/value pairs are bracketed with colons -(\fB:\fR). - -.sp -.in +2 -.nf -# dhtadm \fB-A\fR \fB-m\fR aruba \e - \fB-d\fR ':Timeserv=10.0.0.10 10.0.0.11:DNSserv=10.0.0.1:' -.fi -.in -2 -.sp - -.LP -\fBExample 4 \fRModifying a Macro Definition -.sp -.LP -The following command modifies the \fBLocale\fR macro definition, setting the -value of the \fBUTCOffst\fR symbol to 18000 seconds. Note that any macro -definition which includes the definition of the \fBLocale\fR macro inherits -this change. - -.sp -.in +2 -.nf -# dhtadm \fB-M\fR \fB-m\fR Locale \fB-e\fR 'UTCOffst=18000' -.fi -.in -2 -.sp - -.LP -\fBExample 5 \fRDeleting a Symbol -.sp -.LP -The following command deletes the \fBTimeserv\fR symbol from the \fBaruba\fR -macro. Any macro definition which includes the definition of the \fBaruba\fR -macro inherits this change. - -.sp -.in +2 -.nf -# dhtadm \fB-M\fR \fB-m\fR aruba \fB-e\fR 'Timeserv=' -.fi -.in -2 -.sp - -.LP -\fBExample 6 \fRAdding a Symbol to a Macro -.sp -.LP -The following command adds the \fBHostname\fR symbol to the \fBaruba\fR macro. -Note that the \fBHostname\fR symbol takes no value, and thus requires the -special value \fB_NULL_VALUE_\fR. Note also that any macro definition which -includes the definition of the \fBaruba\fR macro inherits this change. - -.sp -.in +2 -.nf -# dhtadm \fB-M\fR \fB-m\fR aruba \fB-e\fR 'Hostname=_NULL_VALUE_' -.fi -.in -2 -.sp - -.LP -\fBExample 7 \fRRenaming a Macro -.sp -.LP -The following command renames the \fBLocale\fR macro to \fBMyLocale\fR. Note -that any \fBInclude\fR statements in macro definitions which include the -\fBLocale\fR macro also need to be changed. - -.sp -.in +2 -.nf -# dhtadm \fB-M\fR \fB-m\fR Locale \fB-n\fR MyLocale -.fi -.in -2 -.sp - -.LP -\fBExample 8 \fRDeleting a Symbol Definition -.sp -.LP -The following command deletes the \fBMySym\fR symbol definition. Note that any -macro definitions which use \fBMySym\fR needs to be modified. - -.sp -.in +2 -.nf -# dhtadm \fB-D\fR \fB-s\fR MySym -.fi -.in -2 -.sp - -.LP -\fBExample 9 \fRRemoving a dhcptab -.sp -.LP -The following command removes the \fBdhcptab\fR table in the NIS+ directory -specified. - -.sp -.in +2 -.nf -# dhtadm \fB-R\fR \fB-r\fR SUNWnisplus \fB-p\fR Test.Nis.Plus. -.fi -.in -2 -.sp - -.LP -\fBExample 10 \fRPrinting a dhcptab -.sp -.LP -The following command prints to standard output the contents of the -\fBdhcptab\fR that is located in the data store and path indicated in the -\fBdhcpsvc.conf\fR file:. - -.sp -.in +2 -.nf -# dhtadm \fB-P\fR -.fi -.in -2 -.sp - -.LP -\fBExample 11 \fRExecuting dhtadm in Batch Mode -.sp -.LP -The following command runs a series of \fBdhtadm\fR commands contained in a -batch file and signals the daemon to reload the \fBdhcptab\fR once the commands -have been executed: : - -.sp -.in +2 -.nf -# dhtadm -B addmacros -g -.fi -.in -2 -.sp - -.SH EXIT STATUS -.sp -.ne 2 -.na -\fB\fB0\fR \fR -.ad -.RS 6n -Successful completion. -.RE - -.sp -.ne 2 -.na -\fB\fB1\fR \fR -.ad -.RS 6n -Object already exists. -.RE - -.sp -.ne 2 -.na -\fB\fB2\fR \fR -.ad -.RS 6n -Object does not exist. -.RE - -.sp -.ne 2 -.na -\fB\fB3\fR \fR -.ad -.RS 6n -Non-critical error. -.RE - -.sp -.ne 2 -.na -\fB\fB4\fR \fR -.ad -.RS 6n -Critical error. -.RE - -.SH FILES -.sp -.ne 2 -.na -\fB\fB/etc/inet/dhcpsvc.conf\fR \fR -.ad -.RS 27n - -.RE - -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability Evolving -.TE - -.SH SEE ALSO -.sp -.LP -\fBdhcpconfig\fR(1M), \fBdhcpmgr\fR(1M), \fBin.dhcpd\fR(1M), -\fBdhcpsvc.conf\fR(4), \fBdhcp_network\fR(4), \fBdhcptab\fR(4), \fBhosts\fR(4), -\fBuser_attr\fR(4), \fBattributes\fR(5), \fBdhcp\fR(5), -\fBdhcp_modules\fR(5)\fBrbac\fR(5) -.sp -.LP -\fI\fR -.sp -.LP -\fI\fR -.sp -.LP -Alexander, S., and R. Droms, \fIDHCP Options and BOOTP Vendor Extensions\fR, -RFC 1533, Lachman Technology, Inc., Bucknell University, October 1993. -.sp -.LP -Droms, R., \fIInteroperation Between DHCP and BOOTP\fR, RFC 1534, Bucknell -University, October 1993. -.sp -.LP -Droms, R., \fIDynamic Host Configuration Protocol\fR, RFC 1541, Bucknell -University, October 1993. -.sp -.LP -Wimer, W., \fIClarifications and Extensions for the Bootstrap Protocol\fR, RFC -1542, Carnegie Mellon University, October 1993. diff --git a/usr/src/man/man1m/dsvclockd.1m b/usr/src/man/man1m/dsvclockd.1m deleted file mode 100644 index 3fec91a004..0000000000 --- a/usr/src/man/man1m/dsvclockd.1m +++ /dev/null @@ -1,82 +0,0 @@ -'\" te -.\" Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH DSVCLOCKD 1M "Dec 3, 2001" -.SH NAME -dsvclockd \- DHCP service lock daemon -.SH SYNOPSIS -.LP -.nf -\fB/usr/lib/inet/dsvclockd\fR [\fB-d\fR 1 | 2] [\fB-f\fR ] [\fB-v\fR] -.fi - -.SH DESCRIPTION -.sp -.LP -The \fBdsvclockd\fR daemon is a lock manager that works in conjunction with the -Dynamic Host Configuration Protocol (\fBDHCP\fR) Data Service Library -(\fBlibdhcpsvc\fR). It provides shared or exclusive access to the -\fBdhcp_network\fR(4) and \fBdhcptab\fR(4) tables. This service is used by the -\fBSUNWbinfiles\fR and \fBSUNWfiles\fR \fBDHCP\fR data store modules. See -\fBdhcp_modules\fR(5). -.sp -.LP -\fBdsvclockd\fR is started on demand by \fBlibdhcpsvc\fR. The \fBdsvclockd\fR -daemon should be started manually only if command line options need to be -specified. -.SH OPTIONS -.sp -.LP -The following options are supported: -.sp -.ne 2 -.na -\fB\fB-d\fR \fB1\fR | \fB2\fR\fR -.ad -.RS 12n -Set debug level. Two levels of debugging are currently available, \fB1\fR and -\fB2\fR. Level \fB2\fR is more verbose. -.RE - -.sp -.ne 2 -.na -\fB\fB-f\fR\fR -.ad -.RS 12n -Run in the foreground instead of as a daemon process. When this option is used, -messages are sent to standard error instead of to \fBsyslog\fR(3C). -.RE - -.sp -.ne 2 -.na -\fB\fB-v\fR\fR -.ad -.RS 12n -Provide verbose output. -.RE - -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability Unstable -.TE - -.SH SEE ALSO -.sp -.LP -\fBsyslog\fR(3C), \fBdhcp_network\fR(4), \fBdhcptab\fR(4), -\fBdhcp_modules\fR(5), \fBattributes\fR(5) diff --git a/usr/src/man/man1m/in.dhcpd.1m b/usr/src/man/man1m/in.dhcpd.1m deleted file mode 100644 index 09152473f2..0000000000 --- a/usr/src/man/man1m/in.dhcpd.1m +++ /dev/null @@ -1,496 +0,0 @@ -'\" te -.\" Copyright (c) 2004 by Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH IN.DHCPD 1M "Aug 10, 2004" -.SH NAME -in.dhcpd \- Dynamic Host Configuration Protocol server -.SH SYNOPSIS -.LP -.nf -\fB/usr/lib/inet/in.dhcpd\fR [\fB-denv\fR] [\fB-h\fR \fIrelay_hops\fR] [\fB-i\fR \fIinterface,\fR ...] - [\fB-l\fR \fIsyslog_local_facility\fR] [\fB-b\fR automatic | manual] - [\fB-o\fR \fIDHCP_offer_time\fR] [\fB-t\fR \fIdhcptab_rescan_interval\fR] -.fi - -.LP -.nf -\fB/usr/lib/inet/in.dhcpd\fR [\fB-dv\fR] [\fB-h\fR \fIrelay_hops\fR] [\fB-i\fR \fIinterface,\fR]... - [\fB-l\fR \fIsyslog_local_facility\fR] \fB-r\fR \fIIP_address\fR | \fIhostname,\fR ... -.fi - -.SH DESCRIPTION -.sp -.LP -\fBin.dhcpd\fR is a daemon that responds to Dynamic Host Configuration Protocol -(\fBDHCP\fR) requests and optionally to \fBBOOTP\fR protocol requests. The -daemon forks a copy of itself that runs as a background process. It must be run -as root. The daemon has two run modes, \fBDHCP\fR server (with optional -\fBBOOTP\fR compatibility mode) and \fBBOOTP\fR relay agent mode. -.sp -.LP -The first line in the \fBSYNOPSIS\fR section illustrates the options available -in the DHCP/BOOTP server mode. The second line in the SYNOPSIS section -illustrates the options available when the daemon is run in \fBBOOTP\fR relay -agent mode. -.sp -.LP -The \fBDHCP\fR and \fBBOOTP\fR protocols are used to provide configuration -parameters to Internet hosts. Client machines are allocated their \fBIP\fR -addresses as well as other host configuration parameters through this -mechanism. -.sp -.LP -The \fBDHCP\fR/\fBBOOTP\fR daemon manages two types of \fBDHCP\fR data tables: -the \fBdhcptab\fR configuration table and the DHCP network tables. -.sp -.LP -See \fBdhcptab\fR(4) regarding the dhcptab configuration table and -\fBdhcp_network\fR(4) regarding the \fBDHCP\fR network tables. -.sp -.LP -The \fBdhcptab\fR contains macro definitions defined using a \fBtermcap\fR-like -syntax which permits network administrators to define groups of \fBDHCP\fR -configuration parameters to be returned to clients. However, a \fBDHCP/BOOTP\fR -server always returns hostname, network broadcast address, network subnet mask, -and \fBIP\fR maximum transfer unit (\fBMTU\fR) if requested by a client -attached to the same network as the server machine. If those options have not -been explicitly configured in the \fBdhcptab\fR, \fBin.dhcpd\fR returns -reasonable default values. -.sp -.LP -The \fBdhcptab\fR is read at startup, upon receipt of a \fBSIGHUP\fR signal, or -periodically as specified by the \fB-t\fR option. A \fBSIGHUP\fR (sent using -the command \fBsvcadm refresh network/dhcp-server\fR) causes the DHCP/BOOTP -daemon to reread the \fBdhcptab\fR within an interval from \fB0\fR-\fB60\fR -seconds (depending on where the DHCP daemon is in its polling cycle). For busy -servers, users should run \fBsvcadm restart network/dhcp-server\fR to force the -\fBdhcptab\fR to be reread. -.sp -.LP -The DHCP network tables contain mappings of client identifiers to \fBIP\fR -addresses. These tables are named after the network they support and the -datastore used to maintain them. -.sp -.LP -The DHCP network tables are consulted during runtime. A client request received -from a network for which no DHCP network table exists is ignored. -.sp -.LP -This command may change in future releases of Solaris software. Scripts, -programs, or procedures that use this command might need modification when -upgrading to future Solaris software releases.The command line options provided -with the \fBin.dhcpd\fR daemon are used only for the current session, and -include only some of the server options you can set. The \fBdhcpsvc.conf\fR(4) -contains all the server default settings, and can be modified by using the -\fBdhcpmgr\fR utility. See \fBdhcpsvc.conf\fR(4) for more details. -.SH OPTIONS -.sp -.LP -The following options are supported: -.sp -.ne 2 -.na -\fB\fB-b\fR \fB automatic | manual\fR\fR -.ad -.sp .6 -.RS 4n -This option enables \fBBOOTP\fR compatibility mode, allowing the \fBDHCP\fR -server to respond to \fBBOOTP\fR clients. The option argument specifies whether -the \fBDHCP\fR server should automatically allocate permanent lease \fBIP\fR -addresses to requesting \fBBOOTP\fR clients if the clients are not registered -in the DHCP network tables (\fBautomatic\fR) or respond only to \fBBOOTP\fR -clients who have been manually registered in the DHCP network tables (\fB -manual\fR). This option only affects \fBDHCP\fR server mode. -.RE - -.sp -.ne 2 -.na -\fB\fB-d\fR\fR -.ad -.sp .6 -.RS 4n -Debugging mode. The daemon remains as a foreground process, and displays -verbose messages as it processes \fBDHCP\fR and/or \fBBOOTP\fR datagrams. -Messages are displayed on the current TTY. This option can be used in both -DHCP/BOOTP server mode and \fBBOOTP\fR relay agent mode. -.RE - -.sp -.ne 2 -.na -\fB\fB-h\fR\fI relay_hops\fR\fR -.ad -.sp .6 -.RS 4n -Specifies the maximum number of relay agent hops that can occur before the -daemon drops the DHCP/BOOTP datagram. The default number of relay agent hops is -4. This option affects both DHCP/BOOTP server mode and \fBBOOTP\fR relay agent -mode. -.RE - -.sp -.ne 2 -.na -\fB\fB-i\fR\fI interface, .\|.\|.\fR\fR -.ad -.sp .6 -.RS 4n -Selects the network interfaces that the daemon should monitor for DHCP/BOOTP -datagrams. The daemon ignores DHCP/BOOTP datagrams on network interfaces not -specified in this list. This option is only useful on machines that have -multiple network interfaces. If this option is not specified, then the daemon -listens for DHCP/BOOTP datagrams on all network interfaces. The option argument -consists of a comma-separated list of interface names. It affects both -DHCP/BOOTP server and \fBBOOTP\fR relay agent run modes. -.RE - -.sp -.ne 2 -.na -\fB\fB-l\fR \fIsyslog_local_facility\fR\fR -.ad -.sp .6 -.RS 4n -The presence of this option turns on transaction logging for the \fBDHCP\fR -server or \fBBOOTP\fR relay agent. The value specifies the \fBsyslog\fR local -facility (an integer from \fB0\fR to \fB7\fR inclusive) the DHCP daemon should -use for tagging the transactions. Using a facility separate from the -\fBLOG_DAEMON\fR facility allows the network administrator to capture these -transactions separately from other DHCP daemon events for such purposes as -generating transaction reports. See \fBsyslog\fR(3C), for details about local -facilities. Transactions are logged using a record with 9 space-separated -fields as follows: -.RS +4 -.TP -1. -Protocol: -.sp -.in +2 -.nf - Relay mode: "BOOTP" - Server mode: "BOOTP" or "DHCP" based upon client - type. -.fi -.in -2 -.sp - -.RE -.RS +4 -.TP -2. -Type: -.sp -.in +2 -.nf -Relay mode: "RELAY-CLNT", "RELAY-SRVR" -Server mode: "ASSIGN", "EXTEND", "RELEASE", - "DECLINE", "INFORM", "NAK" "ICMP-ECHO." -.fi -.in -2 -.sp - -.RE -.RS +4 -.TP -3. -Transaction time: absolute time in seconds (unix time) -.RE -.RS +4 -.TP -4. -Lease time: -.sp -.in +2 -.nf -Relay mode: Always 0. -Server mode: 0 for ICMP-ECHO events, absolute time in - seconds (unix time) otherwise -.fi -.in -2 -.sp - -.RE -.RS +4 -.TP -5. -Source IP address: Dotted Internet form -.LP -.nf -Relay mode: Relay interface IP on RELAY-CLNT, INADDR_ANY on RELAY-SRVR. Server mode: Client IP. -.fi - -.RE -.RS +4 -.TP -6. -Destination IP address: Dotted Internet form -.LP -.nf -Relay mode: Client IP on RELAY-CLNT, Server IP on RELAY-SRVR. Server mode: Server IP. -.fi - -.RE -.RS +4 -.TP -7. -Client Identifier: Hex representation (0-9, A-F) -.LP -.nf -Relay mode: MAC address Server mode: BOOTP - MAC address; DHCP - client id -.fi - -.RE -.RS +4 -.TP -8. -Vendor Class identifier (white space converted to -periods (.)). -.LP -.nf -Relay mode: Always "N/A" Server mode: Vendor class ID tokenized by converting white space characters to periods (.) -.fi - -.RE -.RS +4 -.TP -9. -MAC address: Hex representation (0-9, A-F) -.LP -.nf -Relay mode: MAC address Server mode: MAC address -.fi - -.RE -The format of this record is subject to change between releases. -.sp -Transactions are logged to the console if daemon is in debug mode (\fB-d\fR). -.sp -Logging transactions impact daemon performance. -.sp -It is suggested that you periodically rotate the DHCP transaction log file to -keep it from growing until it fills the filesystem. This can be done in a -fashion similar to that used for the general system message log -\fB/var/adm/messages\fR and is best accomplished using the facilities provided -by \fBlogadm\fR(1M). -.RE - -.sp -.ne 2 -.na -\fB\fB-n\fR\fR -.ad -.sp .6 -.RS 4n -Disable automatic duplicate \fBIP\fR address detection. When this option is -specified, the \fBDHCP\fR server does not attempt to verify that an \fBIP -address it is about to\fR offer a client is not in use. By default, the -\fBDHCP\fR server pings an \fBIP\fR address before offering it to a DHCP/BOOTP -client, to verify that the address is not in use by another machine. -.RE - -.sp -.ne 2 -.na -\fB\fB-o\fR\fI DHCP_offer_time\fR\fR -.ad -.sp .6 -.RS 4n -Specifies the number of seconds the \fBDHCP\fR server should cache the offers -it has extended to discovering \fBDHCP\fR clients. The default setting is -\fB10\fR seconds. On slow network media, this value can be increased to -compensate for slow network performance. This option affects only \fBDHCP\fR -server mode. -.RE - -.sp -.ne 2 -.na -\fB\fB-r\fR\fI IP_address | hostname, .\|.\|.\fR\fR -.ad -.sp .6 -.RS 4n -This option enables \fBBOOTP\fR relay agent mode. The option argument specifies -a comma-separated list of \fBIP\fR addresses or hostnames of \fBDHCP\fR or -\fBBOOTP\fR servers to which the relay agent is to forward \fBBOOTP\fR -requests. When the daemon is started in this mode, any \fBDHCP\fR tables are -ignored, and the daemon simply acts as a \fBBOOTP\fR relay agent. -.sp -A \fBBOOTP\fR relay agent listens to \fBUDP\fR port 68, and forwards -\fBBOOTP\fR request packets received on this port to the destinations specified -on the command line. It supports the \fBBROADCAST\fR flag described in -\fBRFC\fR 1542. A \fBBOOTP\fR relay agent can run on any machine that has -knowledge of local routers, and thus does not have to be an Internet gateway -machine. -.sp -Note that the proper entries must be made to the \fBnetmasks\fR database so -that the \fBDHCP\fR server being served by the \fBBOOTP\fR relay agents can -identify the subnet mask of the foreign BOOTP/DHCP client's network. See -\fBnetmasks\fR(4) for the format and use of this database. -.RE - -.sp -.ne 2 -.na -\fB\fB-t\fR\fI dhcptab_rescan_interval\fR\fR -.ad -.sp .6 -.RS 4n -Specifies the interval in minutes that the \fBDHCP\fR server should use to -schedule the automatic rereading of the \fBdhcptab\fR information. Typically, -you would use this option if the changes to the \fBdhcptab\fR are relatively -frequent. Once the contents of the \fBdhcptab\fR have stabilized, you can turn -off this option to avoid needless reinitialization of the server. -.RE - -.sp -.ne 2 -.na -\fB\fB-v\fR\fR -.ad -.sp .6 -.RS 4n -Verbose mode. The daemon displays more messages than in the default mode. Note -that verbose mode can reduce daemon efficiency due to the time taken to display -messages. Messages are displayed to the current \fBTTY\fR if the debugging -option is used; otherwise, messages are logged to the \fBsyslogd\fR facility. -This option can be used in both DHCP/BOOTP server mode and \fBBOOTP\fR relay -agent mode. -.RE - -.SH EXAMPLES -.LP -\fBExample 1 \fRStarting a \fBDHCP\fR Server in \fBBOOTP\fR Compatibility Mode -.sp -.LP -The following command starts a \fBDHCP\fR server in \fBBOOTP\fR compatibility -mode, permitting the server to automatically allocate permanent \fBIP\fR -addresses to \fBBOOTP\fR clients which are not registered in the server's -table; limits the server's attention to incoming datagrams on network devices -\fBle2\fR and \fBtr0\fR; drops \fBBOOTP\fR packets whose hop count exceeds 2; -configures the \fBDHCP\fR server to cache extended \fBDHCP\fR offers for 15 -seconds; and schedules \fBdhcptab\fR rescans to occur every 10 minutes: - -.sp -.in +2 -.nf -\fB# in.dhcpd \fR\fB-i\fR\fB le2,tr0 \fR\fB-h\fR\fB 2 \fR\fB-o\fR\fB 15 \fR\fB-t\fR\fB 10 \fR\fB-b\fR\fB automatic\fR -.fi -.in -2 -.sp - -.LP -\fBExample 2 \fRStarting the Daemon in \fBBOOTP\fR Relay Agent Mode -.sp -.LP -The following command starts the daemon in \fBBOOTP\fR relay agent mode, -registering the hosts \fBbladerunner\fR and \fB10.0.0.5\fR as relay -destinations, with debugging and verbose modes enabled, and drops \fBBOOTP\fR -packets whose hop count exceeds 5: - -.sp -.in +2 -.nf -\fB# in.dhcpd \fR\fB-d\fR\fB \fR\fB-v\fR\fB \fR\fB-h\fR\fB 5 \fR\fB-r\fR\fB bladerunner,10.0.0.5\fR -.fi -.in -2 -.sp - -.SH FILES -.sp -.ne 2 -.na -\fB\fB/etc/inet/dhcpsvc.conf\fR\fR -.ad -.sp .6 -.RS 4n - -.RE - -.sp -.ne 2 -.na -\fB\fB/etc/init/hosts\fR\fR -.ad -.sp .6 -.RS 4n - -.RE - -.sp -.ne 2 -.na -\fB\fB/usr/lib/inet/dhcp/nsu/rfc2136.so.1\fR\fR -.ad -.sp .6 -.RS 4n - -.RE - -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability Evolving -.TE - -.SH SEE ALSO -.sp -.LP -\fBsvcs\fR(1), \fBcron\fR(1M), \fBdhcpmgr\fR(1M), \fBdhtadm\fR(1M), -\fBinetadm\fR(1M), \fBinetd\fR(1M), \fBlogadm\fR(1M), \fBpntadm\fR(1M), -\fBsvcadm\fR(1M), \fBsyslogd\fR(1M), \fBsyslog\fR(3C), \fBdhcpsvc.conf\fR(4), -\fBdhcp_network\fR(4), \fBdhcptab\fR(4), \fBethers\fR(4), \fBhosts\fR(4), -\fBnetmasks\fR(4), \fBnsswitch.conf\fR(4), \fBattributes\fR(5), \fBdhcp\fR(5), -\fBsmf\fR(5) -.sp -.LP -\fI\fR -.sp -.LP -Alexander, S., and R. Droms, \fIDHCP Options and BOOTP Vendor Extensions\fR, -RFC 2132, Silicon Graphics, Inc., Bucknell University, March 1997. -.sp -.LP -Droms, R., \fIInteroperation Between DHCP and BOOTP\fR, RFC 1534, Bucknell -University, October 1993. -.sp -.LP -Droms, R., \fIDynamic Host Configuration Protocol\fR, RFC 2131, Bucknell -University, March 1997. -.sp -.LP -Wimer, W., \fIClarifications and Extensions for the Bootstrap Protocol\fR, RFC -1542, Carnegie Mellon University, October 1993. -.SH NOTES -.sp -.LP -The \fBin.dhcpd\fR service is managed by the service management facility, -\fBsmf\fR(5), under the service identifier: -.sp -.in +2 -.nf -svc:/network/dhcp-server -.fi -.in -2 -.sp - -.sp -.LP -Administrative actions on this service, such as enabling, disabling, or -requesting restart, can be performed using \fBsvcadm\fR(1M). Responsibility for -initiating and restarting this service is delegated to \fBinetd\fR(1M). Use -\fBinetadm\fR(1M) to make configuration changes and to view configuration -information for this service. The service's status can be queried using the -\fBsvcs\fR(1) command. diff --git a/usr/src/man/man1m/pntadm.1m b/usr/src/man/man1m/pntadm.1m deleted file mode 100644 index f50b753dd8..0000000000 --- a/usr/src/man/man1m/pntadm.1m +++ /dev/null @@ -1,737 +0,0 @@ -'\" te -.\" Copyright (c) 2003 by Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH PNTADM 1M "Jan 9, 2004" -.SH NAME -pntadm \- DHCP network table management utility -.SH SYNOPSIS -.LP -.nf -\fBpntadm\fR \fB-C\fR [\fB-r\fR \fIresource\fR] [\fB-p\fR \fIpath\fR] [\fB-u\fR \fIuninterpreted\fR] \fInetwork\fR -.fi - -.LP -.nf -\fBpntadm\fR \fB-A\fR \fIname_IP_address\fR [\fB-c\fR \fIcomment\fR] [\fB-e\fR \fImm/dd/yyyy\fR] - [\fB-f\fR \fInum\fR | \fIkeywords\fR] [\fB-h\fR \fIclient_hostname\fR] - [\fB-i\fR [\fB-a\fR] \fIclient_ID\fR] [\fB-m\fR [\fB-y\fR] \fImacro\fR] [\fB-s\fR \fIserver\fR] - [\fB-r\fR \fIresource\fR] [\fB-p\fR \fIpath\fR] [\fB-u\fR \fIuninterpreted\fR] \fInetwork\fR -.fi - -.LP -.nf -\fBpntadm\fR \fB-M\fR \fIname_IP_address\fR [\fB-c\fR \fIcomment\fR] [\fB-e\fR \fImm/dd/yyyy\fR] - [\fB-f\fR \fInum\fR | \fIkeywords\fR] [\fB-h\fR \fIclient_hostname\fR] - [\fB-i\fR [\fB-a\fR] \fIclient\fR \fI ID\fR] [\fB-m\fR [\fB-y\fR] \fImacro\fR] - [\fB-n\fR \fInew_client_IP_address\fR] [\fB-s\fR \fIserver\fR] [\fB-r\fR \fIresource\fR] - [\fB-p\fR \fIpath\fR] [\fB-u\fR uninterpreted] \fInetwork\fR -.fi - -.LP -.nf -\fBpntadm\fR \fB-D\fR \fIname_IP_address\fR [\fB-y\fR] [\fB-r\fR \fIresource\fR] [\fB-p\fR \fIpath\fR] - [\fB-u\fR uninterpreted] \fInetwork\fR -.fi - -.LP -.nf -\fBpntadm\fR \fB-P\fR [\fB-v\fR] [\fB-x\fR] [\fB-r\fR \fIresource\fR] [\fB-p\fR \fIpath\fR] - [\fB-u\fR uninterpreted] \fInetwork\fR -.fi - -.LP -.nf -\fBpntadm\fR \fB-R\fR [\fB-r\fR \fIresource\fR] [\fB-p\fR \fIpath\fR] [\fB-u\fR uninterpreted] \fInetwork\fR -.fi - -.LP -.nf -\fBpntadm\fR \fB-L\fR [\fB-r\fR \fIresource\fR] [\fB-p\fR \fIpath\fR] [\fB-u\fR uninterpreted] -.fi - -.LP -.nf -\fBpntadm\fR \fB-B\fR [\fB-v\fR] [\fIbatchfile\fR] -.fi - -.SH DESCRIPTION -.sp -.LP -The \fBpntadm\fR command is used to manage the Dynamic Host Configuration -Protocol (\fBDHCP\fR) network tables. It is used to add and remove networks -under \fBDHCP\fR management, and add, delete, or modify IP address records -within network tables, or to view tables. For a description of the format of -\fBDHCP\fR network tables, see \fBdhcp_network\fR(4). -.sp -.LP -\fBpntadm\fR can be run as root or by other users assigned to the \fBDHCP\fR -Management profile. See \fBrbac\fR(5) and \fBuser_attr\fR(4). -.sp -.LP -If the networks you want to add are subnetted, you need to update the -\fBnetmasks\fR(4) table. -.sp -.LP -One of the following options (function flags) must be specified with the -\fBpntadm\fR command: \fB-A\fR, \fB-B\fR, \fB-C\fR, \fB-D\fR, \fB-L\fR, -\fB-M\fR, \fB-P\fR, or\fB-R\fR. -.SH OPTIONS -.sp -.LP -The following options are supported: -.sp -.ne 2 -.na -\fB\fB-A\fR\fI name_IP_address\fR\fR -.ad -.RS 26n -Add a client entry with hostname or client IP address, \fIname_IP_address\fR, -to the named \fBDHCP\fR network table. -.sp -The following sub-options are optional: -.sp -.ne 2 -.na -\fB\fB-c\fR \fIcomment\fR\fR -.ad -.RS 22n -Comment text. The default is \fINULL\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-e\fR \fImm/dd/yyyy\fR\fR -.ad -.RS 22n -Absolute lease. The default is \fB0\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-f\fR \fInum\fR | \fIkeywords\fR\fR -.ad -.RS 22n -Flag value. The default is \fB00\fR. -.sp -The flag (\fB-f\fR) option can be specified either as a single number denoting -the intended flag value, or as a series of the following keywords, combined -using the plus (\fB+\fR) symbol: -.sp -.ne 2 -.na -\fB\fBDYNAMIC\fR or \fB00\fR\fR -.ad -.RS 19n -Server manager's assignment. -.RE - -.sp -.ne 2 -.na -\fB\fBPERMANENT\fR or \fB01\fR\fR -.ad -.RS 19n -Lease on entry is permanent. -.RE - -.sp -.ne 2 -.na -\fB\fBMANUAL\fR or \fB02\fR\fR -.ad -.RS 19n -Administrator managed assignment. -.RE - -.sp -.ne 2 -.na -\fB\fBUNUSABLE\fR or \fB04\fR\fR -.ad -.RS 19n -Entry is not valid. -.RE - -.sp -.ne 2 -.na -\fB\fBBOOTP\fR or \fB08\fR\fR -.ad -.RS 19n -Entry reserved for \fBBOOTP\fR clients. -.RE - -For a more detailed description of the flag values, see \fBdhcp_network\fR(4). -.RE - -.sp -.ne 2 -.na -\fB\fB-h\fR \fIclient_hostname\fR\fR -.ad -.RS 22n -Client hostname. The default is NULL. -.sp -When the \fB-h\fR option is used in this mode, the \fIclient_hostname\fR is -added to the hosts table within the resource used for storing host names -(files, NIS+ or DNS). The command will fail if this \fIclient_hostname\fR is -already present in the hosts table. -.RE - -.sp -.ne 2 -.na -\fB\fB-i\fR \fIclient_ID\fR [\fB-a\fR]\fR -.ad -.RS 22n -Client identifier [\fB-a\fR]. The default is \fB00\fR. -.sp -The \fB-i\fR option modified with \fB-a\fR specifies that the client identifier -is in \fBASCII\fR format, and thus needs to be converted to hexadecimal format -before insertion into the table. -.RE - -.sp -.ne 2 -.na -\fB\fB-m\fR \fImacro\fR [\fB-y\fR]\fR -.ad -.RS 22n -Macro name. Default is UNKNOWN. -.sp -The \fB-m\fR option modified with \fB-y\fR verifies the existence of the named -macro in the \fBdhcptab\fR table before adding the entry. -.RE - -.sp -.ne 2 -.na -\fB\fB-s\fR \fIserver\fR\fR -.ad -.RS 22n -Server IP or name. Default is system name (\fBuname\fR \fB-n\fR). -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-B\fR\fR -.ad -.RS 26n -Activate batch mode. \fBpntadm\fR will read from the specified file or from -standard input a series of \fBpntadm\fR commands and execute them within the -same process. Processing many \fBpntadm\fR commands using this method is much -faster than running an executable batchfile itself. Batch mode is recommended -for using \fBpntadm\fR in scripts. -.sp -The following sub-option is optional: -.sp -.ne 2 -.na -\fB\fB-v\fR\fR -.ad -.RS 6n -Display commands to standard output as they are processed. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-C\fR\fR -.ad -.RS 26n -Create the \fBDHCP\fR network table for the network specified by \fInetwork\fR. -See . For details, see \fBdhcp_network\fR(4) and \fBnetworks\fR(4). -.RE - -.sp -.ne 2 -.na -\fB\fB-D\fR \fI name_IP_address\fR\fR -.ad -.RS 26n -Delete the specified client entry with hostname or client IP address, -\fIname_IP_address\fR, in the named \fBDHCP\fR network table. (See -\fBdhcp_network\fR(4).) -.sp -The following sub-option is optional: -.sp -.ne 2 -.na -\fB\fB-y\fR\fR -.ad -.RS 6n -Remove associated host table entry. The \fB-y\fR option requests that all -hostnames associated with the \fBIP\fR address in the hosts table in the -resource be removed. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fB-L\fR\fR -.ad -.RS 26n -List the \fBDHCP\fR network tables presently configured, one per line, on -standard output. If none are found, no output is printed and an exit status of -\fB0\fR is returned. -.RE - -.sp -.ne 2 -.na -\fB\fB-M\fR \fI name_IP_address\fR\fR -.ad -.RS 26n -Modify the specified client entry with hostname or client IP address, -\fIname_IP_address\fR, in the named \fBDHCP\fR network table. See -\fBdhcp_network\fR(4). The default for the sub-options is what they currently -are set to. -.sp -The following sub-options are optional. -.sp -.ne 2 -.na -\fB\fB-c\fR \fIcomment\fR\fR -.ad -.RS 29n -New comment text. -.RE - -.sp -.ne 2 -.na -\fB\fB-e\fR \fImm/dd/yy\fR\fR -.ad -.RS 29n -New absolute lease expiration date. Time defaults to 12:00 AM of the day -specified. -.RE - -.sp -.ne 2 -.na -\fB\fB-f\fR \fInum\fR | \fIkeyboard\fR\fR -.ad -.RS 29n -New flag value, see explanation following the description of the \fB-A\fR -option. -.RE - -.sp -.ne 2 -.na -\fB\fB-h\fR \fIhost_name\fR\fR -.ad -.RS 29n -New client hostname. -.sp -The \fB-h\fR option allows you to change the current \fIhostname\fR associated -with the \fBIP\fR address or to add a new \fIhostname\fR to the hosts table if -an entry associated with this \fBIP\fR address does not exist. -.RE - -.sp -.ne 2 -.na -\fB\fB-i\fR \fIclient_ID\fR\fR -.ad -.RS 29n -New client identifier [\fB-a\fR]. -.RE - -.sp -.ne 2 -.na -\fB\fB-m\fR \fImacro\fR [\fB-y\fR]\fR -.ad -.RS 29n -Macro name defined in \fBdhcptab\fR. -.RE - -.sp -.ne 2 -.na -\fB\fB-n \fR \fInew_client_IP_address\fR\fR -.ad -.RS 29n -New \fBIP\fR address. -.RE - -.sp -.ne 2 -.na -\fB\fB-s\fR \fIserver\fR\fR -.ad -.RS 29n -New server \fBIP\fR or name. -.RE - - For more detailed description of the sub-options and flag values, see -\fBdhcp_network\fR(4). -.RE - -.sp -.ne 2 -.na -\fB\fB-P\fR\fR -.ad -.RS 26n -Display the named \fBDHCP\fR network table. -.sp -The following sub-options are optional: -.sp -.ne 2 -.na -\fB\fB-v\fR\fR -.ad -.RS 6n -Display lease time in full verbose format and resolve IP addresses for the -clients and server to hostnames. -.RE - -.sp -.ne 2 -.na -\fB\fB-x\fR\fR -.ad -.RS 6n -Display lease time in raw format. -.RE - -These flag codes are used with the \fB-P\fR sub-options: -.sp - -.sp -.TS -l l l -l l l . -\fB-v\fR \fB-x\fR Description -D 00 DYNAMIC -P 01 PERMANENT -M 02 MANUAL -U 04 UNUSABLE -B 08 BOOTP -.TE - -See \fBdhcp_network\fR(4) for information on these sub-options and associated -flag codes. -.RE - -.sp -.ne 2 -.na -\fB\fB-p\fR\fI path\fR\fR -.ad -.RS 26n -Override the \fBdhcpsvc.conf\fR(4) configuration value for data store resource -path, \fIpath\fR See \fBdhcpsvc.conf\fR(4) -.RE - -.sp -.ne 2 -.na -\fB\fB-R\fR\fR -.ad -.RS 26n -Remove the named DHCP network table. See \fBdhcp_network\fR(4). -.RE - -.sp -.ne 2 -.na -\fB\fB-r\fR \fIdata_store_resource\fR\fR -.ad -.RS 26n -Override the \fB/etc/inet/dhcpsvc.conf\fR configuration value for -\fBRESOURCE=\fR with the \fIdata_store_resource\fR specified. See the -\fBdhcpsvc.conf\fR(4) man page for more details on resource type, and the -\fI\fR for more information about adding support for other data stores. -.RE - -.sp -.ne 2 -.na -\fB\fB-u\fR uninterpreted\fR -.ad -.RS 26n -Data which will be ignored by \fBpntadm\fR, but passed to the currently -configured public module to be interpreted by the data store. This might be -used for a database account name or other authentication or authorization -parameters required by a particular data store. -.RE - -.SH OPERANDS -.sp -.LP -The following operand is supported: -.sp -.ne 2 -.na -\fB\fInetwork\fR\fR -.ad -.RS 11n -The network address or network name which corresponds to the \fBdhcp network\fR -table. See \fBdhcp_network\fR(4). -.RE - -.SH EXAMPLES -.LP -\fBExample 1 \fRCreating a Table for the \fB10.0.0.0\fR DHCP Network -.sp -.LP -The following command creates a table for the \fB10.0.0.0\fR (subnetted to -class C) \fBDHCP\fR network table. Note that if you have an alias for this -network in your \fBnetworks\fR(4) table, you can use that value rather than the -dotted Internet Address notation. - -.sp -.in +2 -.nf -example# \fBpntadm -C 10.0.0.0\fR -.fi -.in -2 -.sp - -.LP -\fBExample 2 \fRAdding an Entry to the \fB10.0.0.0\fR Table -.sp -.LP -The following command adds an entry to the \fB10.0.0.0\fR table in the -\fBfiles\fR resource in the \fB/var/mydhcp\fR directory: - -.sp -.in +2 -.nf -example# \fBpntadm -r SUNWfiles -p /var/mydhcp -A 10.0.0.1 10.0.0.0\fR -.fi -.in -2 -.sp - -.LP -\fBExample 3 \fRModifying the \fB10.0.0.1\fR Entry of the \fB10.0.0.0\fR Table -.sp -.LP -The following command modifies the \fB10.0.0.1\fR entry of the \fB10.0.0.0\fR -table, changing the macro name to \fBGreen\fR, setting the flags field to -\fBMANUAL\fR and \fBPERMANENT:\fR - -.sp -.in +2 -.nf -example# \fBpntadm -M 10.0.0.1 -m Green -f 'PERMANENT+MANUAL' 10.0.0.0\fR -.fi -.in -2 -.sp - -.LP -\fBExample 4 \fRChanging the \fB10.0.0.1\fR Entry to \fB10.0.0.2\fR -.sp -.LP -The following command changes the \fB10.0.0.1\fR entry to \fB10.0.0.2\fR, -making an entry in the \fBhosts\fR(4) table called \fBmyclient\fR: - -.sp -.in +2 -.nf -example# \fBpntadm -M 10.0.0.1 -n 10.0.0.2 -h myclient 10.0.0.0\fR -.fi -.in -2 -.sp - -.LP -\fBExample 5 \fRSetting the Client \fBID\fR as \fBASCII\fR -.sp -.LP -The following command sets the client \fBID\fR as \fBASCII\fR -\fBaruba.foo.com\fR for the \fBmyclient\fR entry: - -.sp -.in +2 -.nf -example# \fBpntadm -M myclient -i 'aruba.foo.com' -a 10.0.0.0\fR -.fi -.in -2 -.sp - -.LP -\fBExample 6 \fRDeleting the \fBmyclient\fREntry from the \fB10.0.0.0\fR Table -.sp -.LP -The following command deletes the \fBmyclient\fR (\fB10.0.0.2\fR) entry from -the \fB10.0.0.0\fR table: - -.sp -.in +2 -.nf -example# \fBpntadm -D myclient 10.0.0.0\fR -.fi -.in -2 -.sp - -.LP -\fBExample 7 \fRRemoving the Named DHCP Network Table -.sp -.LP -The following command removes the named \fBDHCP\fR network table in the NIS+ -directory specified: - -.sp -.in +2 -.nf -example# \fBpntadm -r SUNWnisplus -p Test.Nis.Plus. -R 10.0.0.0\fR -.fi -.in -2 -.sp - -.LP -\fBExample 8 \fRListing the Configured DHCP Network Tables -.sp -.LP -The following command lists the configured DHCP network tables: - -.sp -.in +2 -.nf -example# \fBpntadm -L\fR -192.168.0.0 -10.0.0.0 -.fi -.in -2 -.sp - -.LP -\fBExample 9 \fRExecuting \fBpntadm\fR Commands in Batch Mode -.sp -.LP -The following command runs a series of \fBpntadm\fR commands contained in a -batch file: - -.sp -.in +2 -.nf -example# \fBpntadm -B addclients\fR -.fi -.in -2 -.sp - -.SH EXIT STATUS -.sp -.ne 2 -.na -\fB\fB0\fR\fR -.ad -.RS 5n -Successful completion. -.RE - -.sp -.ne 2 -.na -\fB\fB1\fR\fR -.ad -.RS 5n -Object already exists. -.RE - -.sp -.ne 2 -.na -\fB\fB2\fR\fR -.ad -.RS 5n -Object does not exist. -.RE - -.sp -.ne 2 -.na -\fB\fB3\fR\fR -.ad -.RS 5n -Non-critical error. -.RE - -.sp -.ne 2 -.na -\fB\fB4\fR\fR -.ad -.RS 5n -Critical error. -.RE - -.SH FILES -.sp -.ne 2 -.na -\fB\fB/etc/inet/dhcpsvc.conf\fR\fR -.ad -.RS 26n - -.RE - -.sp -.ne 2 -.na -\fB\fB/etc/inet/hosts\fR\fR -.ad -.RS 26n - -.RE - -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability Evolving -.TE - -.SH SEE ALSO -.sp -.LP -\fBdhcpconfig\fR(1M), \fBdhcpmgr\fR(1M), \fBdhcp_network\fR(4), , -\fBdhcpsvc.conf\fR(4), \fBdhcptab\fR(4), \fBhosts\fR(4), \fBnetmasks\fR(4), -\fBnetworks\fR(4), \fBuser_attr\fR(4), \fBattributes\fR(5), \fBdhcp\fR(5), -\fBdhcp_modules\fR(5), \fBrbac\fR(5) -.sp -.LP -\fI\fR -.sp -.LP -\fI\fR -.sp -.LP -Alexander, S., and R. Droms, \fIDHCP Options and BOOTP Vendor Extensions\fR, -RFC 1533, Lachman Technology, Inc., Bucknell University, October 1993. -.sp -.LP -Droms, R., \fIInteroperation Between DHCP and BOOTP\fR, RFC 1534, Bucknell -University, October 1993. -.sp -.LP -Droms, R., \fIDynamic Host Configuration Protocol\fR, RFC 1541, Bucknell -University, October 1993. -.sp -.LP -Wimer, W., \fIClarifications and Extensions for the Bootstrap Protocol\fR, RFC -1542, Carnegie Mellon University, October 1993. diff --git a/usr/src/man/man3c/Makefile b/usr/src/man/man3c/Makefile index a2e6e99cbc..17be98f410 100644 --- a/usr/src/man/man3c/Makefile +++ b/usr/src/man/man3c/Makefile @@ -498,8 +498,12 @@ MANFILES= __fbufsize.3c \ wait3.3c \ waitpid.3c \ walkcontext.3c \ + wcpcpy.3c \ wcrtomb.3c \ + wcscasecmp.3c \ wcscoll.3c \ + wcsdup.3c \ + wcslen.3c \ wcsftime.3c \ wcsrtombs.3c \ wcsstr.3c \ @@ -1239,7 +1243,9 @@ MANLINKS= FD_CLR.3c \ watoi.3c \ watol.3c \ watoll.3c \ + wcpncpy.3c \ wcrtomb_l.3c \ + wcscasecmp_l.3c \ wcscat.3c \ wcschr.3c \ wcscmp.3c \ @@ -1247,10 +1253,12 @@ MANLINKS= FD_CLR.3c \ wcscpy.3c \ wcscspn.3c \ wcsetno.3c \ - wcslen.3c \ + wcsncasecmp.3c \ + wcsncasecmp_l.3c \ wcsncat.3c \ wcsncmp.3c \ wcsncpy.3c \ + wcsnlen.3c \ wcsnrtombs.3c \ wcsnrtombs_l.3c \ wcspbrk.3c \ @@ -2236,11 +2244,19 @@ backtrace_symbols.3c := LINKSRC = walkcontext.3c backtrace_symbols_fd.3c := LINKSRC = walkcontext.3c printstack.3c := LINKSRC = walkcontext.3c +wcpncpy.3c := LINKSRC = wcpcpy.3c + wcrtomb_l.3c := LINKSRC = wcrtomb.3c +wcscasecmp_l.3c := LINKSRC = wcscasecmp.3c +wcsncasecmp.3c := LINKSRC = wcscasecmp.3c +wcsncasecmp_l.3c := LINKSRC = wcscasecmp.3c + wcscoll_l.3c := LINKSRC = wcscoll.3c wscoll.3c := LINKSRC = wcscoll.3c +wcsnlen.3c := LINKSRC = wcslen.3c + wcsnrtombs.3c := LINKSRC = wcsrtombs.3c wcsnrtombs_l.3c := LINKSRC = wcsrtombs.3c wcsrtombs_l.3c := LINKSRC = wcsrtombs.3c @@ -2265,7 +2281,6 @@ wcschr.3c := LINKSRC = wcstring.3c wcscmp.3c := LINKSRC = wcstring.3c wcscpy.3c := LINKSRC = wcstring.3c wcscspn.3c := LINKSRC = wcstring.3c -wcslen.3c := LINKSRC = wcstring.3c wcsncat.3c := LINKSRC = wcstring.3c wcsncmp.3c := LINKSRC = wcstring.3c wcsncpy.3c := LINKSRC = wcstring.3c diff --git a/usr/src/man/man3c/wcpcpy.3c b/usr/src/man/man3c/wcpcpy.3c new file mode 100644 index 0000000000..b4a5ecad8e --- /dev/null +++ b/usr/src/man/man3c/wcpcpy.3c @@ -0,0 +1,116 @@ +.\" +.\" This file and its contents are supplied under the terms of the +.\" Common Development and Distribution License ("CDDL"), version 1.0. +.\" You may only use this file in accordance with the terms of version +.\" 1.0 of the CDDL. +.\" +.\" A full copy of the text of the CDDL should have accompanied this +.\" source. A copy of the CDDL is also available via the Internet at +.\" http://www.illumos.org/license/CDDL. +.\" +.\" +.\" Copyright 2014 Garrett D'Amore <garrett@damore.org> +.\" +.Dd "Jul 27, 2014" +.Dt WCPCPY 3C +.Os +.Sh NAME +.Nm wcpcpy , +.Nm wcpncpy +.Nd copy a wide-character string and return a pointer to its end +.Sh SYNOPSIS +.In wchar.h +. +.Ft "wchar_t *" +.Fo wcpcpy +.Fa "wchar_t *restrict ws1" +.Fa "const wchar_t *restrict ws2" +.Fc +. +.Ft "wchar_t *" +.Fo wcpncpy +.Fa "wchar_t *restrict ws1" +.Fa "const wchar_t *restrict ws2" +.Fa "size_t n" +.Fc +. +.Sh DESCRIPTION +The +.Fn wcpcpy +and +.Fn wcpncpy +functions copy the wide-character string pointed to by +.Fa ws2 +into the location pointed to by +.Fa ws1 . +They stop copying after a null wide-character is copied, or in the case +of +.Fn wcpncpy , +after +.Fa n +wide-characters have been copied. If +.Fa ws2 +contains fewer than +.Fa n +wide-characters, then the +.Fn wcpncpy +function pads wide-characters to the end of the destination +.Fa ws1 +until exactly +.Fa n +wide-characters have been written. +.Lp +In the case of +.Fn wcpncpy +a terminating null wide-character will +.Em not +be written if the length of +.Fa ws2 +exceeds +.Fa n . +.Lp +If +.Fa ws1 +and +.Fa ws2 +overlap, the result is undefined. +.Lp +The +.Fn wcpcpy +and +.Fn wcpncpy +functions are the wide-character equivalents of +.Fn stpcpy +and +.Fn stpncpy , +respectively. +.Sh RETURN VALUES +The +.Fn wcpcpy +and +.Fn wcpncpy +functions return a pointer to the last wide-character written. In the +case of +.Fn wcpncpy +this will always be equal to +.Po Fa ws1 Li + Fa n Li \(mi 1 Pc . +.Sh ERRORS +None. +.Sh INTERFACE STABILITY +.Sy Standard . +.Sh MT-LEVEL +.Sy MT-Safe . +.Sh SEE ALSO +.Xr stpcpy 3C , +.Xr stpncpy 3C , +.Xr wcscpy 3C , +.Xr wcsncpy 3C , +.Xr wchar.h 3HEAD , +.Xr standards 5 +.Sh STANDARDS +The +.Fn wcpcpy +and +.Fn wcpncpy +functions were introduced in +.St -p1003.1-2008 . diff --git a/usr/src/man/man3c/wcscasecmp.3c b/usr/src/man/man3c/wcscasecmp.3c new file mode 100644 index 0000000000..6a6aca9922 --- /dev/null +++ b/usr/src/man/man3c/wcscasecmp.3c @@ -0,0 +1,158 @@ +.\" +.\" This file and its contents are supplied under the terms of the +.\" Common Development and Distribution License ("CDDL"), version 1.0. +.\" You may only use this file in accordance with the terms of version +.\" 1.0 of the CDDL. +.\" +.\" A full copy of the text of the CDDL should have accompanied this +.\" source. A copy of the CDDL is also available via the Internet at +.\" http://www.illumos.org/license/CDDL. +.\" +.\" +.\" Copyright 2014 Garrett D'Amore <garrett@damore.org> +.\" +.Dd "Nov 4, 2014" +.Dt WCSCASECMP 3C +.Os +.Sh NAME +.Nm wcscasecmp , +.Nm wcscasecmp_l , +.Nm wcsncasecmp , +.Nm wcsncasecmp_l +.Nd case-insensitive wide-character string comparison +.Sh SYNOPSIS +.In wchar.h +. +.Ft int +.Fo wcscasecmp +.Fa "const wchar_t *ws1" +.Fa "const wchar_t *ws2" +.Fc +. +.Ft int +.Fo wcscasecmp_l +.Fa "const wchar_t *ws1" +.Fa "const wchar_t *ws2" +.Fa "locale_t loc" +.Fc +. +.Ft int +.Fo wcsncasecmp +.Fa "const wchar_t *ws1" +.Fa "const wchar_t *ws2" +.Fa "size_t n" +.Fc +. +.Ft int +.Fo wcsncasecmp_l +.Fa "const wchar_t *ws1" +.Fa "const wchar_t *ws2" +.Fa "size_t n" +.Fa "locale_t loc" +.Fc +.Sh DESCRIPTION +These functions perform case-insensitive comparison of wide-character +strings +.Fa ws1 +and +.Fa ws2 . +Pairs of wide-characters from each of +.Fa ws1 +and +.Fa ws2 +are compared consecutively, ignoring differences in case (if the +.\"POSIX\." locale upper case characters are treated as lower case). If +the two values are different, the comparision stops and either +a negative value is returned if the character from +.Fa ws1 +is less than that from +.Fa ws2 , +or a positive is returned if the character from +.Fa ws1 +is greater than that from +.Fa ws2 . +The comparison also stops if both characters are null wide-characters, +or, in the case of +.Fn wcsncasecmp +and +.Fn wcsncasecmp_l , +after +.Fa n +comparisons have been made without finding a difference. In either of +these two cases, 0 is returned. +.Lp +The +.Fn wcscasecmp +and +.Fn wcsncasecmp +functions use the +.Dv LC_CTYPE +category of the current locale to determine case. The +.Fn wcscasecmp_l +and +.Fn wcsncasecmp_l +functions use the +.Dv LC_CTYPE +category of the locale pointed to by +.Fa loc +to determine case. +.Lp +Passing +.Dv LC_GLOBAL_LOCALE +for +.Fa loc +results in undefined behavior. +.Lp +The +.Fn wcscasecmp , +.Fn wcsncasecmp , +.Fn wcscasecmp_l , +and +.Fn wcsncasecmp_l +functions are the wide-character equivalents of the +.Fn strcasecmp , +.Fn strncasecmp , +.Fn strcasemp_l , +and +.Fn strncasecmp_l +functions, respectively. +.Sh RETURN VALUES +These functions return a negative value if, ignoring case, +.Fa ws1 +is less than +.Fa ws1 , +or a positive value if +.Fa ws1 +is greater than +.Fa ws2 , +or 0 if the both +.Fa ws1 +and +.Fa ws2 +are the same. +.Sh ERRORS +None. +.Sh INTERFACE STABILITY +.Sy Standard . +.Sh MT-LEVEL +.Sy MT-Safe . +.Sh SEE ALSO +.Xr newlocale 3C , +.Xr setlocale 3C , +.Xr strcasecmp 3C , +.Xr strcasecmp_l 3C , +.Xr strncasecmp 3C , +.Xr strncasecmp_l 3C , +.Xr uselocale 3C , +.Xr wchar.h 3HEAD , +.Xr locale 5 , +.Xr standards 5 +.Sh STANDARDS +The +.Fn wcscasecmp , +.Fn wcsncasecmp , +.Fn wcscasecmp_l , +and +.Fn wcsncasecmp_l +functions were introduced in +.St -p1003.1-2008 . diff --git a/usr/src/man/man3c/wcsdup.3c b/usr/src/man/man3c/wcsdup.3c new file mode 100644 index 0000000000..80113744a9 --- /dev/null +++ b/usr/src/man/man3c/wcsdup.3c @@ -0,0 +1,73 @@ +.\" +.\" This file and its contents are supplied under the terms of the +.\" Common Development and Distribution License ("CDDL"), version 1.0. +.\" You may only use this file in accordance with the terms of version +.\" 1.0 of the CDDL. +.\" +.\" A full copy of the text of the CDDL should have accompanied this +.\" source. A copy of the CDDL is also available via the Internet at +.\" http://www.illumos.org/license/CDDL. +.\" +.\" +.\" Copyright 2014 Garrett D'Amore <garrett@damore.org> +.\" +.Dd "Nov 4, 2014" +.Dt WCSDUP 3C +.Os +.Sh NAME +.Nm wcsdup +.Nd duplicate wide-character string +.Sh SYNOPSIS +.In wchar.h +. +.Ft wchar_t +.Fo wcsdup +.Fa "const wchar_t *string" +.Fc +. +.Sh DESCRIPTION +The +.Fn wcsdup +function duplicates a wide-character +.Fa string , +allocating sufficient memory to store the copy, and then +copying from +.Fa string . +The resulting copy is returned. It may be deallocated with +.Xr free 3C +when it is no longer needed. The +.Fn wcsdup +function is the wide-character equivalent of +.Xr strdup 3C . +.Sh RETURN VALUES +On success, the function +.Fn wcsdup +returns the newly allocated copy of the string; on failure it +returns +.Dv NULL +and sets +.Va errno . +.Sh ERRORS +The +.Fn wcsdup +function will fail if: +.Bl -tag -width Er +.It Er ENOMEM +Insufficient memory was available to create the copy. +.El +.Sh INTERFACE STABILITY +.Sy Standard . +.Sh MT-LEVEL +.Sy MT-Safe . +.Sh SEE ALSO +.Xr free 3C , +.Xr strdup 3C , +.Xr wcslen 3C , +.Xr wchar.h 3HEAD , +.Xr locale 5 , +.Xr standards 5 +.Sh STANDARDS +The +.Fn wcsdup +function was introduced in +.St -p1003.1-2008 . diff --git a/usr/src/man/man3c/wcslen.3c b/usr/src/man/man3c/wcslen.3c new file mode 100644 index 0000000000..71a4bde897 --- /dev/null +++ b/usr/src/man/man3c/wcslen.3c @@ -0,0 +1,94 @@ +.\" +.\" This file and its contents are supplied under the terms of the +.\" Common Development and Distribution License ("CDDL"), version 1.0. +.\" You may only use this file in accordance with the terms of version +.\" 1.0 of the CDDL. +.\" +.\" A full copy of the text of the CDDL should have accompanied this +.\" source. A copy of the CDDL is also available via the Internet at +.\" http://www.illumos.org/license/CDDL. +.\" +.\" +.\" Copyright 2014 Garrett D'Amore <garrett@damore.org> +.\" +.Dd "Nov 4, 2014" +.Dt WCSLEN 3C +.Os +.Sh NAME +.Nm wcslen , +.Nm wcsnlen +.Nd get length of wide-character string +.Sh SYNOPSIS +.In wchar.h +. +.Ft size_t +.Fo wcslen +.Fa "const wchar_t *string" +.Fc +. +.Ft size_t +.Fo wcsnlen +.Fa "const wchar_t *string" +.Fa "size_t maxlen" +.Fc +. +.Sh DESCRIPTION +The +.Fn wcslen +and +.Fn wcsnlen +functions count the number of wide-characters that are present in +.Fa string . +They stop counting when they encounter a null wide-character. +The terminating null wide-character is not included in the count. +.Lp +Additionally, +.Fn wcsnlen +stops counting after it has counted +.Fa maxlen +wide-characters. +.Lp +The +.Fn wcslen +and +.Fn wcsnlen +functions are the wide-character equivalents of +.Xr strlen 3C +and +.Xr strnlen 3C , +respectively. +.Sh RETURN VALUES +The +.Fn wcslen +function returns the length of +.Fa string . +The +.Fn wcsnlen +function returns the smaller of the length of +.Fa string +and +.Fa maxlen . +.Sh ERRORS +None. +.Sh INTERFACE STABILITY +.Sy Standard . +.Sh MT-LEVEL +.Sy MT-Safe . +.Sh SEE ALSO +.Xr free 3C , +.Xr strlen 3C , +.Xr strnlen 3C , +.Xr wchar.h 3HEAD , +.Xr locale 5 , +.Xr standards 5 +.Sh STANDARDS +The +.Fn wcslen +function was introduced in +.St -xpg4 +and standardized in +.St -isoC-99 . +The +.Fn wcsnlen +function was introduced in +.St -p1003.1-2008 . diff --git a/usr/src/man/man3c/wcstring.3c b/usr/src/man/man3c/wcstring.3c index 72a3098f9b..d4d3f3e953 100644 --- a/usr/src/man/man3c/wcstring.3c +++ b/usr/src/man/man3c/wcstring.3c @@ -1,4 +1,5 @@ '\" te +.\" Copyright 2014 Garrett D'Amore <garrett@damore.org> .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved Portions Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at .\" http://www.opengroup.org/bookstore/. @@ -7,10 +8,10 @@ .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH WCSTRING 3C "Aug 14, 2002" +.TH WCSTRING 3C "Aug 15, 2014" .SH NAME wcstring, wcscat, wscat, wcsncat, wsncat, wcscmp, wscmp, wcsncmp, wsncmp, -wcscpy, wscpy, wcsncpy, wsncpy, wcslen, wslen, wcschr, wschr, wcsrchr, wsrchr, +wcscpy, wscpy, wcsncpy, wsncpy, wslen, wcschr, wschr, wcsrchr, wsrchr, windex, wrindex, wcspbrk, wspbrk, wcswcs, wcsspn, wsspn, wcscspn, wscspn, wcstok, wstok \- wide-character string operations .SH SYNOPSIS @@ -50,11 +51,6 @@ wcstok, wstok \- wide-character string operations .LP .nf -\fBsize_t\fR \fBwcslen\fR(\fBconst wchar_t *\fR\fIws\fR); -.fi - -.LP -.nf \fBwchar_t *\fR\fBwcschr\fR(\fBconst wchar_t *\fR\fIws\fR, \fBwchar_t\fR \fIwc\fR); .fi @@ -208,7 +204,6 @@ wcstok, wstok \- wide-character string operations .fi .SH DESCRIPTION -.sp .LP These functions operate on wide-character strings terminated by \fBwchar_t\fR \fINULL\fR characters. During appending or copying, these routines do not check @@ -216,7 +211,6 @@ for an overflow condition of the receiving string. In the following, \fIws\fR, \fIws1\fR, and \fIws2\fR point to wide-character strings terminated by a \fBwchar_t NULL\fR. .SS "wcscat(\|), wscat(\|)" -.sp .LP The \fBwcscat()\fR and \fBwscat()\fR functions append a copy of the wide-character string pointed to by \fIws2\fR (including the terminating null @@ -226,7 +220,6 @@ wide-character code at the end of \fIws1\fR. If copying takes place between objects that overlap, the behavior is undefined. Both functions return \fIs1\fR; no return value is reserved to indicate an error. .SS "wcsncat(\|), wsncat(\|)" -.sp .LP The \fBwcsncat()\fR and \fBwsncat()\fR functions append not more than \fIn\fR wide-character codes (a null wide-character code and wide-character codes that @@ -237,7 +230,6 @@ end of \fIws1\fR. A terminating null wide-character code is always appended to the result. Both functions return \fIws1\fR; no return value is reserved to indicate an error. .SS "wcscmp(\|), wscmp(\|)" -.sp .LP The \fBwcscmp()\fR and \fBwscmp()\fR functions compare the wide-character string pointed to by \fIws1\fR to the wide-character string pointed to by @@ -248,7 +240,6 @@ integer greater than, equal to, or less than zero, if the wide-character string pointed to by \fIws1\fR is greater than, equal to, or less than the wide-character string pointed to by \fIws2\fR. .SS "wcsncmp(\|), wsncmp(\|)" -.sp .LP The \fBwcsncmp()\fR and \fBwsncmp()\fR functions compare not more than \fIn\fR wide-character codes (wide-character codes that follow a null wide character @@ -261,7 +252,6 @@ than zero, if the possibly null-terminated array pointed to by \fIws1\fR is greater than, equal to, or less than the possibly null-terminated array pointed to by \fIws2\fR. .SS "wcscpy(\|), wscpy(\|)" -.sp .LP The \fBwcscpy()\fR and \fBwscpy()\fR functions copy the wide-character string pointed to by \fIws2\fR (including the terminating null wide-character code) @@ -269,7 +259,6 @@ into the array pointed to by \fIws1\fR. If copying takes place between objects that overlap, the behavior is undefined. Both functions return \fIws1\fR; no return value is reserved to indicate an error. .SS "wcsncpy(\|), wsncpy(\|)" -.sp .LP The \fBwcsncpy()\fR and \fBwsncpy()\fR functions copy not more than \fIn\fR wide-character codes (wide-character codes that follow a null wide character @@ -280,15 +269,13 @@ wide-character string that is shorter than \fIn\fR wide-character codes, null wide-character codes are appended to the copy in the array pointed to by \fIws1\fR, until a total \fIn\fR wide-character codes are written. Both functions return \fI ws1\fR; no return value is reserved to indicate an error. -.SS "wcslen(\|), wslen(\|)" -.sp +.SS "wslen(\|)" .LP -The \fBwcslen()\fR and \fBwslen()\fR functions compute the number of +The \fBwslen()\fR function computes the number of wide-character codes in the wide-character string to which \fIws\fR points, not -including the terminating null wide-character code. Both functions return +including the terminating null wide-character code. It returns \fIws\fR; no return value is reserved to indicate an error. .SS "wcschr(\|), wschr(\|)" -.sp .LP The \fBwcschr()\fR and \fBwschr()\fR functions locate the first occurrence of \fIwc\fR in the wide-character string pointed to by \fIws\fR. The value of @@ -298,7 +285,6 @@ The terminating null wide-character code is considered to be part of the wide-character string. Upon completion, both functions return a pointer to the wide-character code, or a null pointer if the wide-character code is not found. .SS "wcsrchr(\|), wsrchr(\|)" -.sp .LP The \fBwcsrchr()\fR and \fBwsrchr()\fR functions locate the last occurrence of \fIwc\fR in the wide-character string pointed to by \fIws\fR. The value of @@ -309,12 +295,10 @@ wide-character string. Upon successful completion, both functions return a pointer to the wide-character code, or a null pointer if \fIwc\fR does not occur in the wide-character string. .SS "windex(\|), wrindex(\|)" -.sp .LP The \fBwindex()\fR and \fBwrindex()\fR functions behave the same as \fBwschr()\fR and \fBwsrchr()\fR, respectively. .SS "wcspbrk(\|), wspbrk(\|)" -.sp .LP The \fBwcspbrk()\fR and \fBwspbrk()\fR functions locate the first occurrence in the wide character string pointed to by \fIws1\fR of any wide-character code @@ -322,7 +306,6 @@ from the wide-character string pointed to by \fIws2\fR. Upon successful completion, the function returns a pointer to the wide-character code, or a null pointer if no wide-character code from \fIws2\fR occurs in \fIws1\fR. .SS "wcswcs(\|)" -.sp .LP The \fBwcswcs()\fR function locates the first occurrence in the wide-character string pointed to by \fIws1\fR of the sequence of wide-character codes @@ -332,7 +315,6 @@ returns a pointer to the located wide-character string, or a null pointer if the wide-character string is not found. If \fIws2\fR points to a wide-character string with zero length, the function returns \fIws1\fR. .SS "wcsspn(\|), wsspn(\|)" -.sp .LP The \fBwcsspn()\fR and \fBwsspn()\fR functions compute the length of the maximum initial segment of the wide-character string pointed to by \fIws1\fR @@ -340,7 +322,6 @@ which consists entirely of wide-character codes from the wide-character string pointed to by \fIws2\fR. Both functions return the length \fIws1\fR; no return value is reserved to indicate an error. .SS "wcscspn(\|), wscspn(\|)" -.sp .LP The \fBwcscspn()\fR and \fBwscspn()\fR functions compute the length of the maximum initial segment of the wide-character string pointed to by \fIws1\fR @@ -349,26 +330,22 @@ wide-character string pointed to by \fIws2\fR. Both functions return the length of the initial substring of \fIws1\fR; no return value is reserved to indicate an error. .SS "wcstok(\|), wstok(\|)" -.sp .LP A sequence of calls to the \fBwcstok()\fR and \fBwstok()\fR functions break the wide-character string pointed to by \fIws1\fR into a sequence of tokens, each of which is delimited by a wide-character code from the wide-character string pointed to by \fIws2\fR. .SS "Default and other standards" -.sp .LP The third argument points to a caller-provided \fBwchar_t\fR pointer into which the \fBwcstok()\fR function stores information necessary for it to continue scanning the same wide-character string. This argument is not available with the XPG4 and SUS versions of \fBwcstok()\fR, nor is it available with the \fBwstok()\fR function. See \fBstandards\fR(5). -.sp .LP The first call in the sequence has \fIws1\fR as its first argument, and is followed by calls with a null pointer as their first argument. The separator string pointed to by \fIws2\fR may be different from call to call. -.sp .LP The first call in the sequence searches the wide-character string pointed to by \fIws1\fR for the first wide-character code that is \fInot\fR contained in the @@ -376,7 +353,6 @@ current separator string pointed to by \fIws2\fR. If no such wide-character code is found, then there are no tokens in the wide-character string pointed to by \fIws1\fR, and \fBwcstok()\fR and \fBwstok()\fR return a null pointer. If such a wide-character code is found, it is the start of the first token. -.sp .LP The \fBwcstok()\fR and \fBwstok()\fR functions then search from that point for a wide-character code that \fIis\fR contained in the current separator string. @@ -386,17 +362,14 @@ for a token will return a null pointer. If such a wide-character code is found, it is overwritten by a null wide character, which terminates the current token. The \fBwcstok()\fR and \fBwstok()\fR functions save a pointer to the following wide-character code, from which the next search for a token will start. -.sp .LP Each subsequent call, with a null pointer as the value of the first argument, starts searching from the saved pointer and behaves as described above. -.sp .LP Upon successful completion, both functions return a pointer to the first wide-character code of a token. Otherwise, if there is no token, a null pointer is returned. .SH ATTRIBUTES -.sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp @@ -416,15 +389,20 @@ MT-Level MT-Safe .TE .SH SEE ALSO -.sp .LP -\fBmalloc\fR(3C), \fBstring\fR(3C), \fBwcswidth\fR(3C), \fBwcwidth\fR(3C), -\fBattributes\fR(5), \fBstandards\fR(5) +\fBmalloc\fR(3C), +\fBstring\fR(3C), +\fBwcscasecmp\fR(3C), +\fBwcsdup\fR(3C), +\fBwcslen\fR(3C), +\fBwcswidth\fR(3C), +\fBwcwidth\fR(3C), +\fBattributes\fR(5), +\fBstandards\fR(5) .SH NOTES -.sp .LP The \fBwcscat()\fR, \fBwcsncat()\fR, \fBwcscmp()\fR, \fBwcsncmp()\fR, -\fBwcscpy()\fR, \fBwcsncpy()\fR, \fBwcslen()\fR, \fBwcschr()\fR, +\fBwcscpy()\fR, \fBwcsncpy()\fR, \fBwcschr()\fR, \fBwcsrchr()\fR, \fBwcspbrk()\fR, \fBwcswcs()\fR, \fBwcsspn()\fR, \fBwcscspn()\fR, and \fBwcstok()\fR functions are Standard. The \fBwscat()\fR, \fBwsncat()\fR, \fBwscmp()\fR, \fBwsncmp()\fR, \fBwscpy()\fR, \fBwsncpy()\fR, diff --git a/usr/src/man/man3head/wchar.h.3head b/usr/src/man/man3head/wchar.h.3head index c1906acbb5..00c2a27652 100644 --- a/usr/src/man/man3head/wchar.h.3head +++ b/usr/src/man/man3head/wchar.h.3head @@ -1,4 +1,5 @@ '\" te +.\" Copyright 2014 Garrett D'Amore <garrett@damore.org> .\" Copyright (c) 2001, The IEEE and The Open Group. All Rights Reserved. Portions Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved. .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at .\" http://www.opengroup.org/bookstore/. @@ -7,7 +8,7 @@ .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH WCHAR.H 3HEAD "Sep 10, 2004" +.TH WCHAR.H 3HEAD "Aug 15, 2014" .SH NAME wchar.h, wchar \- wide-character handling .SH SYNOPSIS @@ -17,7 +18,6 @@ wchar.h, wchar \- wide-character handling .fi .SH DESCRIPTION -.sp .LP The <\fBwchar.h\fR> header defines the following types: .sp @@ -115,7 +115,6 @@ The maximum value representable by an object of type \fBwchar_t\fR. .RS 13n The minimum value representable by an object of type \fBwchar_t\fR. .RE - .sp .ne 2 .na @@ -134,23 +133,16 @@ functions to indicate end-of-file. .RS 13n As described in <\fBstddef.h\fR>. .RE - -.sp .LP The tag \fBtm\fR is declared as naming an incomplete structure type, the contents of which are described in the header <\fBtime.h\fR>. -.sp .LP Inclusion of the <\fBwchar.h\fR> header can make visible all symbols from the headers <\fBctype.h\fR>, <\fBstring.h\fR>, <\fBstdarg.h\fR>, <\fBstddef.h\fR>, <\fBstdio.h\fR>, <\fBstdlib.h\fR>, and <\fBtime.h\fR>. .SH ATTRIBUTES -.sp -.LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp - -.sp .TS box; c | c @@ -161,14 +153,18 @@ Interface Stability Standard .TE .SH SEE ALSO -.sp -.LP \fBgetconf\fR(1), \fBbtowc\fR(3C), \fBconfstr\fR(3C), \fBfgetwc\fR(3C), \fBgetws\fR(3C), \fBfputwc\fR(3C), \fBfputws\fR(3C), \fBfwide\fR(3C), \fBfwprintf\fR(3C), \fBfwscanf\fR(3C), \fBgetwc\fR(3C), \fBgetwchar\fR(3C), \fBiswalpha\fR(3C), \fBiswctype\fR(3C), \fBmbsinit\fR(3C), \fBmbrlen\fR(3C), \fBmbrtowc\fR(3C), \fBmbsrtowcs\fR(3C), \fBtowlower\fR(3C), \fBtowupper\fR(3C), -\fBungetwc\fR(3C), \fBvfwprintf\fR(3C), \fBwcrtomb\fR(3C), \fBwcsrtombs\fR(3C), +\fBungetwc\fR(3C), \fBvfwprintf\fR(3C), +\fBwcpcpy\fR(3C), +\fBwcrtomb\fR(3C), +\fBwcscasecmp\fR(3C), +\fBwcsdup\fR(3C), +\fBwcslen\fR(3C), +\fBwcsrtombs\fR(3C), \fBwcstring\fR(3C), \fBwcsstr\fR(3C), \fBwcstod\fR(3C), \fBwcscoll\fR(3C), \fBwcsftime\fR(3C), \fBwcstol\fR(3C), \fBwcstoul\fR(3C), \fBwcswidth\fR(3C), \fBwcsxfrm\fR(3C), \fBwctob\fR(3C), \fBwctype\fR(3C), \fBwcwidth\fR(3C), diff --git a/usr/src/man/man3lib/libc.3lib b/usr/src/man/man3lib/libc.3lib index ab8eb92f24..38f86d50c8 100644 --- a/usr/src/man/man3lib/libc.3lib +++ b/usr/src/man/man3lib/libc.3lib @@ -5,11 +5,10 @@ .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .\" Copyright 2011 by Delphix. All rights reserved. -.TH LIBC 3LIB "Jul 1, 2014" +.TH LIBC 3LIB "Aug 15, 2014" .SH NAME libc \- C library .SH DESCRIPTION -.sp .LP Functions in this library provide various facilities defined by System V, ANSI C, POSIX, and so on. See \fBstandards\fR(5). In addition, those facilities @@ -17,7 +16,6 @@ previously defined in the internationalization and the wide-character libraries are now defined in this library, as are the facilities previously defined in the multithreading libraries, \fBlibthread\fR and \fBlibpthread\fR. .SH INTERFACES -.sp .LP The shared object \fBlibc.so.1\fR provides the public interfaces defined below. See \fBIntro\fR(3) for additional information on shared object interfaces. @@ -770,13 +768,16 @@ l l . \fBwaitid\fR \fBwaitpid\fR \fBwalkcontext\fR \fBwarn\fR \fBwarnx\fR \fBwatoll\fR +\fBwcpcpy\fR \fBwcpncpy\fR \fBwcrtomb\fR \fBwcrtomb_l\fR +\fBwcscasecmp\fR \fBwcscasecmp_l\fR \fBwcscat\fR \fBwcschr\fR \fBwcscmp\fR \fBwcscoll\fR \fBwcscoll_l\fR -\fBwcscpy\fR -\fBwcscspn\fR \fBwcsftime\fR +\fBwcscpy\fR \fBwcscspn\fR +\fBwcsdup\fR \fBwcsftime\fR \fBwcslen\fR \fBwcsncat\fR +\fBwcsncasecmp\fR \fBwcsncasecmp_l\fR \fBwcsncmp\fR \fBwcsncpy\fR \fBwcsnrtombs\fR \fBwcsnrtombs_l\fR \fBwcspbrk\fR \fBwcsrchr\fR @@ -937,7 +938,6 @@ l l . .TE .SH FILES -.sp .ne 2 .na \fB\fB/lib/libc.so.1\fR\fR @@ -976,7 +976,6 @@ symbols .RE .SH ATTRIBUTES -.sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp @@ -991,17 +990,14 @@ MT-Level Safe .TE .SH SEE ALSO -.sp .LP \fBpvs\fR(1), \fBIntro\fR(2), \fBIntro\fR(3), \fBattributes\fR(5), \fBlf64\fR(5), \fBstandards\fR(5) .SH NOTES -.sp .LP The synonyms compatibility library, \fBc_synonyms.so.1\fR, provides a mechanism to support old applications and libraries that were mistakenly built using now-obsolete synonym symbols from \fBlibc\fR. -.sp .LP Before the advent of direct binding (-B direct) \fBlibc\fR provided many functions with two names. For example, \fBgetpwent()\fR and \fB_getpwent()\fR. @@ -1010,7 +1006,6 @@ leading-underscore symbol was intended to be used by system libraries in order to avoid conflicting with an application that might define its own version of \fBgetpwent()\fR with completely different semantics. Standard-conforming applications may not define and use function names with leading underscores. -.sp .LP Solaris system libraries are now built with direct binding. This means that a system library that calls \fBgetpwent()\fR will bind directly to the instance @@ -1019,7 +1014,6 @@ linked defines a different \fBgetpwent()\fR for its own use. The application binds to its instance of \fBgetpwent()\fR and there is no resulting conflict. The direct binding mechanism is equally available to libraries not delivered with Solaris. -.sp .LP As a result of this evolution, most of the leading-underscore synonym symbols have been removed from \fBlibc\fR. This means that applications that call @@ -1050,7 +1044,6 @@ $ LD_PRELOAD=c_synonyms.so.1 ./application .in -2 .sp -.sp .LP The synonyms compatibility library is intended neither to enable the generation of applications that call the obsolete leading-underscore synonym functions, diff --git a/usr/src/man/man4/Makefile b/usr/src/man/man4/Makefile index 33b3cd7a92..d179643b98 100644 --- a/usr/src/man/man4/Makefile +++ b/usr/src/man/man4/Makefile @@ -57,9 +57,6 @@ _MANFILES= Intro.4 \ devices.4 \ dfstab.4 \ dhcp_inittab.4 \ - dhcp_network.4 \ - dhcpsvc.conf.4 \ - dhcptab.4 \ dialups.4 \ dir_ufs.4 \ driver.conf.4 \ diff --git a/usr/src/man/man4/dhcp_network.4 b/usr/src/man/man4/dhcp_network.4 deleted file mode 100644 index 19ecaa41ab..0000000000 --- a/usr/src/man/man4/dhcp_network.4 +++ /dev/null @@ -1,235 +0,0 @@ -'\" te -.\" Copyright (c) 2001 by Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH DHCP_NETWORK 4 "Mar 5, 2004" -.SH NAME -dhcp_network \- DHCP network tables -.SH DESCRIPTION -.sp -.LP -The Dynamic Host Configuration Protocol (\fBDHCP\fR) network tables are used to -map the client identifiers of \fBDHCP\fR clients to \fBIP\fR addresses and the -associated configuration parameters of that address. One \fBDHCP\fR network -table exists for each network served by the \fBDHCP\fR server, and each table -is named using the network's \fBIP\fR address. There is no table or file with -the name \fBdhcp_network\fR. -.sp -.LP -The \fBDHCP\fR network tables can exist as \fBASCII\fR text files, binary text -files, or \fBNIS+\fR tables, depending on the data store used. Since the format -of the file could change, the preferred method of managing the \fBDHCP\fR -network tables is through the use of \fBdhcpmgr\fR(1M) or the \fBpntadm\fR(1M) -command. -.sp -.LP -The \fBdhcp_network\fR file is used as a policy mechanism for whether -\fBin.dhcpd\fR(1M) leases addresses on a given network. If the \fBDHCP\fR -server is not serving leases or information to a network, there should be no -\fBdhcp_network\fR file for that network. To set the \fBDHCP\fR server in -\fBinformational\fR mode, where it responds to \fBINFORM\fR messages but does -not lease addresses on that network, create an empty \fBdhcp_network\fR file -for that network. For normal operations, where the \fBDHCP\fR server both -leases addresses and responds to \fBINFORM\fR packets, create a -\fBdhcp_network\fR file using \fBdhcpmgr\fR(1M) or \fBpntadm\fR(1M) and -populate it with leasable addresses. -.sp -.LP -The format of the records in a \fBDHCP\fR network table depends on the data -store used to maintain the table. However, an entry in a \fBDHCP\fR network -table must contain the following fields: -.sp -.ne 2 -.na -\fB\fBClient_ID\fR \fR -.ad -.RS 14n -The client identifier field, \fBClient_ID\fR, is an \fBASCII\fR hexadecimal -representation of the unique octet string value of the \fBDHCP\fR Client -Identifier Option (code 61) which identifies a \fBDHCP\fR client. In the -absence of the \fBDHCP\fR Client Identifier Option, the \fBDHCP\fR client is -identified using the form given below for \fBBOOTP\fR clients. The number of -characters in this field must be an even number, with a maximum length of 64 -characters. Valid characters are \fB0\fR \fB-\fR \fB9\fR and \fBA\fR-\fBF\fR. -Entries with values of \fB00\fR are freely available for dynamic allocation to -requesting clients. \fBBOOTP\fR clients are identified by the concatenation of -the network's hardware type (as defined by \fBRFC\fR 1340, titled "Assigned -Numbers") and the client's hardware address. For example, the following -\fBBOOTP\fR client has a hardware type of '\fB01\fR' (10mb ethernet) and a -hardware address of \fB8:0:20:11:12:b7\fR, so its client identifier would be: -\fB010800201112B7\fR -.RE - -.sp -.ne 2 -.na -\fB\fBFlags\fR \fR -.ad -.RS 14n -The \fBFlags\fR field is a decimal value, the bit fields of which can have a -combination of the following values: -.sp -.ne 2 -.na -\fB\fB1 (PERMANENT)\fR \fR -.ad -.RS 18n -Evaluation of the \fBLease\fR field is turned off (lease is permanent). If this -bit is not set, Evaluation of the \fBLease\fR field is enabled and the -\fBLease\fR is \fBDYNAMIC.\fR -.RE - -.sp -.ne 2 -.na -\fB\fB2 (MANUAL)\fR \fR -.ad -.RS 18n -This entry has a manual client \fBID\fR binding (cannot be reclaimed by -\fBDHCP\fR server). Client will not be allocated another address. -.RE - -.sp -.ne 2 -.na -\fB\fB4 (UNUSABLE)\fR \fR -.ad -.RS 18n -When set, this value means that either through \fBICMP\fR echo or client -\fBDECLINE,\fR this address has been found to be unusable. Can also be used by -the network administrator to \fIprevent\fR a certain client from booting, if -used in conjunction with the \fBMANUAL\fR flag. -.RE - -.sp -.ne 2 -.na -\fB\fB8 (BOOTP)\fR \fR -.ad -.RS 18n -This entry is reserved for allocation to \fBBOOTP\fR clients only. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fBClient_IP\fR \fR -.ad -.RS 14n -The \fBClient_IP\fR field holds the \fBIP\fR address for this entry. This value -must be unique in the database. -.RE - -.sp -.ne 2 -.na -\fB\fBServer_IP\fR \fR -.ad -.RS 14n -This field holds the \fBIP\fR address of the \fBDHCP\fR server which \fIowns\fR -this client \fBIP\fR address, and thus is responsible for initial allocation to -a requesting client. On a multi-homed DHCP server, this IP address must be the -first address returned by \fBgethostbyname\fR(3NSL). -.RE - -.sp -.ne 2 -.na -\fB\fBLease\fR \fR -.ad -.RS 14n -This numeric field holds the entry's absolute lease expiration time, and is in -seconds since \fBJanuary 1, 1970\fR. It can be decimal, or hexadecimal (if -\fB0x\fR prefixes number). The special value \fB-1\fR is used to denote a -permanent lease. -.RE - -.sp -.ne 2 -.na -\fB\fBMacro\fR \fR -.ad -.RS 14n -This \fBASCII\fR text field contains the \fBdhcptab\fR macro name used to look -up this entry's configuration parameters in the \fBdhcptab\fR(4) database. -.RE - -.sp -.ne 2 -.na -\fB\fBComment\fR \fR -.ad -.RS 14n -This \fBASCII\fR text field contains an optional comment. -.RE - -.SS "TREATISE ON LEASES" -.sp -.LP -This section describes how the \fBDHCP/BOOTP\fR server calculates a client's -configuration lease using information contained in the \fBdhcptab\fR(4) and -\fBDHCP\fR network tables. The server consults the \fBLeaseTim\fR and -\fBLeaseNeg\fR symbols in the \fBdhcptab\fR, and the \fBFlags\fR and -\fBLease\fR fields of the chosen IP address record in the \fBDHCP\fR network -table. -.sp -.LP -The server first examines the \fBFlags\fR field for the identified \fBDHCP\fR -network table record. If the \fBPERMANENT\fR flag is on, then the client's -lease is considered permanent. -.sp -.LP -If the \fBPERMANENT\fR flag is not on, the server checks if the client's lease -as represented by the \fBLease\fR field in the network table record has -expired. If the lease is not expired, the server checks if the client has -requested a new lease. If the \fBLeaseNeg\fR symbol has not been included in -the client's \fBdhcptab\fR parameters, then the client's requested lease -extension is ignored, and the lease is set to be the time remaining as shown by -the \fBLease\fR field. If the \fBLeaseNeg\fR symbol \fIhas\fR been included, -then the server will extend the client's lease to the value it requested if -this requested lease is less than or equal to the current time plus the value -of the client's \fBLeaseTim\fR \fBdhcptab\fR parameter. -.sp -.LP -If the client's requested lease is greater than policy allows (value of -\fBLeaseTim\fR), then the client is given a lease equal to the current time -plus the value of \fBLeaseTim\fR. If \fBLeaseTim\fR is not set, then the -default \fBLeaseTim\fR value is one hour. -.sp -.LP -For more information about the \fBdhcptab\fR symbols, see \fBdhcptab\fR(4). -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for a description of the following attribute: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability Evolving -.TE - -.SH SEE ALSO -.sp -.LP -\fBdhcpconfig\fR(1M), \fBdhcpmgr\fR(1M), \fBdhtadm\fR(1M), \fBin.dhcpd\fR(1M), -\fBpntadm\fR(1M), \fBdhcptab\fR(4), \fBdhcp\fR(5), \fBdhcp_modules\fR(5), -\fBattributes\fR(5) -.sp -.LP -\fISolaris DHCP Service Developer\&'s Guide\fR -.sp -.LP -\fISystem Administration Guide: IP Services\fR -.sp -.LP -Reynolds, J. and J. Postel, \fIAssigned Numbers\fR, STD 2, RFC 1340, -USC/Information Sciences Institute, July 1992. diff --git a/usr/src/man/man4/dhcpsvc.conf.4 b/usr/src/man/man4/dhcpsvc.conf.4 deleted file mode 100644 index 821a5c14cf..0000000000 --- a/usr/src/man/man4/dhcpsvc.conf.4 +++ /dev/null @@ -1,289 +0,0 @@ -'\" te -.\" Copyright (c) 2003 Sun Microsystems, Inc. All rights reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH DHCPSVC.CONF 4 "Jun 26, 2003" -.SH NAME -dhcpsvc.conf \- file containing service configuration parameters for the DHCP -service -.SH DESCRIPTION -.sp -.LP -The \fBdhcpsvc.conf\fR file resides in directory \fB/etc/inet\fR and contains -parameters for specifying Dynamic Host Configuration Protocol (\fBDHCP\fR) -service configuration settings, including the type and location of \fBDHCP\fR -data store used. -.sp -.LP -The description of the \fBdhcpsvc.conf\fR file in this man page is -informational only. The preferred method of setting or modifying values within -the \fBdhcpsvc.conf\fR file is by using \fBdhcpconfig\fR(1M) or the -\fBdhcpmgr\fR(1M) utility. Do not edit the \fBdhcpsvc.conf\fR file. -.sp -.LP -The \fBdhcpsvc.conf\fR file format is \fBASCII\fR; comment lines begin with the -crosshatch (\fB#\fR) character. Parameters consist of a keyword followed by an -equals (\fB=\fR) sign followed by the parameter value, of the form: -.sp -.in +2 -.nf -\fIKeyword\fR=\fIValue\fR -.fi -.in -2 -.sp - -.sp -.LP -The following \fIKeyword\fR and \fIValue\fR parameters are supported: -.sp -.ne 2 -.na -\fBBOOTP_COMPAT\fR -.ad -.RS 28n -String. \fBautomatic\fR or \fBmanual\fR. Enables support of \fBBOOTP\fR -clients. Default is no \fBBOOTP\fR. Value selects \fBBOOTP\fR address -allocation method. \fBautomatic\fR to support all BOOTP clients, \fBmanual\fR -to support only registered \fBBOOTP\fR clients. \fBserver\fR mode only -parameter. -.RE - -.sp -.ne 2 -.na -\fBCACHE_TIMEOUT\fR -.ad -.RS 28n -Integer. Number of seconds the server caches data from data store. Used to -improve performance. Default is 10 seconds. \fBserver\fR mode only parameter. -.RE - -.sp -.ne 2 -.na -\fBCONVER\fR -.ad -.RS 28n -Integer. Container version. Used by DHCP administrative tools to identify which -version of the public module is being used to administer the data store. -\fBCONVER\fR should \fBnot\fR be changed manually. -.RE - -.sp -.ne 2 -.na -\fBDAEMON_ENABLED\fR -.ad -.RS 28n -\fBTRUE\fR/\fBFALSE\fR. If \fBTRUE\fR, the DHCP daemon can be run. If -\fBFALSE\fR, DHCP daemon process exits immediately if the daemon is started. -Default is \fBTRUE\fR. Generic parameter. -.RE - -.sp -.ne 2 -.na -\fBHOSTS_DOMAIN\fR -.ad -.RS 28n -String. Defines name service domain that DHCP administration tools use when -managing the hosts table. Valid only when \fBHOSTS_RESOURCE\fR is set to -\fBnisplus\fR or \fBdns\fR. -.RE - -.sp -.ne 2 -.na -\fBHOSTS_RESOURCE\fR -.ad -.RS 28n -String. Defines what name service resource should be used by the DHCP -administration tools when managing the hosts table. Current valid values are -\fBfiles\fR, \fBnisplus\fR, and \fBdns\fR. -.RE - -.sp -.ne 2 -.na -\fBICMP_VERIFY\fR -.ad -.RS 28n -\fBTRUE\fR/\fBFALSE\fR. Toggles \fBICMP\fR echo verification of IP addresses. -Default is \fBTRUE\fR. \fBserver\fR mode only parameter. -.RE - -.sp -.ne 2 -.na -\fBINTERFACES\fR -.ad -.RS 28n -String. Comma-separated list of interface names to listen to. Generic -parameter. -.RE - -.sp -.ne 2 -.na -\fBLOGGING_FACILITY\fR -.ad -.RS 28n -Integer. Local facility number (\fB0\fR-\fB7\fR inclusive) to log \fBDHCP\fR -events to. Default is not to log transactions. Generic parameter. -.RE - -.sp -.ne 2 -.na -\fBOFFER_CACHE_TIMEOUT\fR -.ad -.RS 28n -Integer. Number of seconds before \fBOFFER\fR cache timeouts occur. Default is -\fB10\fR seconds. \fBserver\fR mode only parameter. -.RE - -.sp -.ne 2 -.na -\fBOWNER_IP\fR -.ad -.RS 28n -String. List of supplemental ownership addresses that will be used by the DHCP -server in determining the \fBdhcp_network\fR records that are under its -management. Addresses are in the dotted Internet form of an IPv4 address. -Primary value is the IP address associated with the system's primary interface -(\fInodename\fR == \fIhostname\fR). Server-mode-only parameter. Note that using -\fBOWNER_IP\fR has some performance impact, thus using a large number might not -be advisable. -.RE - -.sp -.ne 2 -.na -\fBPATH\fR -.ad -.RS 28n -Path to DHCP data tables within the data store specified by the RESOURCE -parameter. The value of the \fBPATH\fR keyword is specific to the RESOURCE. -.RE - -.sp -.ne 2 -.na -\fBRELAY_DESTINATIONS\fR -.ad -.RS 28n -String. Comma-separated list of host names and/or \fBIP\fR addresses of relay -destinations. \fBrelay\fR mode only parameter. -.RE - -.sp -.ne 2 -.na -\fBRELAY_HOPS \fR -.ad -.RS 28n -Integer. Max number of \fBBOOTP\fR relay hops before packet is dropped. Default -is \fB4\fR. Generic parameter. -.RE - -.sp -.ne 2 -.na -\fBRESCAN_INTERVAL\fR -.ad -.RS 28n -Integer. Number of minutes between automatic \fBdhcptab\fR rescans. Default is -not to do rescans. \fBserver\fR mode only parameter. -.RE - -.sp -.ne 2 -.na -\fBRESOURCE\fR -.ad -.RS 28n -Data store resource used. Use this parameter to name the public module. See the -\fBPATH\fR keyword in \fBdhcp_modules\fR(5). -.RE - -.sp -.ne 2 -.na -\fBRESOURCE_CONFIG\fR -.ad -.RS 28n -String. The private layer provides for module-specific configuration -information through the use of the \fBRESOURCE_CONFIG\fR keyword. See -\fBdhcp_modules\fR(5). -.sp -Providers can access \fBRESOURCE_CONFIG\fR using the configure function by -specifying an optional service provider layer API function: -.sp -.in +2 -.nf -int configure(const char *configp); -.fi -.in -2 - -If this function is defined by the public module provider, it is called during -module load time by the private layer, with the contents of the -\fBRESOURCE_CONFIG\fR string acquired by the administrative interface (in the -case of the \fBdhcpmgr\fR, through the use of a public module-specific java -bean extending the \fBdhcpmgr\fR to provide a configuration dialog for this -information. -.RE - -.sp -.ne 2 -.na -\fBRUN_MODE\fR -.ad -.RS 28n -\fBserver\fR or \fBrelay\fR. Selects daemon run mode. Default is \fBserver\fR. -.RE - -.sp -.ne 2 -.na -\fBSECONDARY_SERVER_TIMEOUT\fR -.ad -.RS 28n -Integer. The number of seconds a secondary server waits for a primary server to -respond before responding itself. Default is \fB20\fR seconds. This is a server -mode only parameter. -.RE - -.sp -.ne 2 -.na -\fBUPDATE_TIMEOUT\fR -.ad -.RS 28n -Integer. Number of seconds to wait for a response from the DNS server before -timing out. If this parameter is present, the DHCP daemon updates DNS on behalf -of DHCP clients, and waits the number of seconds specified for a response -before timing out. You can use \fBUPDATE_TIMEOUT\fR without specifying a number -to enable DNS updates with the default timeout of 15 seconds. If this parameter -is not present, the DHCP daemon does not update DNS for DHCP clients. -.RE - -.sp -.ne 2 -.na -\fBVERBOSE\fR -.ad -.RS 28n -\fBTRUE\fR/\fBFALSE\fR. Toggles verbose mode, determining amount of status and -error messages reported by the daemon. Default is \fBFALSE\fR. Set to -\fBTRUE\fR only for debugging. Generic parameter. -.RE - -.SH SEE ALSO -.sp -.LP -\fBdhcpmgr\fR(1M), \fBin.dhcpd\fR(1M), \fBdhcp\fR(5), \fBdhcp_modules\fR(5) -.sp -.LP -\fISystem Administration Guide: IP Services\fR diff --git a/usr/src/man/man4/dhcptab.4 b/usr/src/man/man4/dhcptab.4 deleted file mode 100644 index a2e82c150a..0000000000 --- a/usr/src/man/man4/dhcptab.4 +++ /dev/null @@ -1,394 +0,0 @@ -'\" te -.\" Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH DHCPTAB 4 "Mar 15, 2002" -.SH NAME -dhcptab \- DHCP configuration parameter table -.SH DESCRIPTION -.sp -.LP -The \fBdhcptab\fR configuration table allows network administrators to organize -groups of configuration parameters as macro definitions, which can then be -referenced in the definition of other useful macros. These macros are then used -by the \fBDHCP\fR server to return their values to \fBDHCP\fR and \fBBOOTP\fR -clients. -.sp -.LP -The preferred method of managing the \fBdhcptab\fR is through the use of the -\fBdhcpmgr\fR(1M) or \fBdhtadm\fR(1M) utility. The description of \fBdhcptab\fR -entries included in this manual page is intended for informational purposes -only, and should not be used to manually edit entries. -.sp -.LP -You can view the contents of the \fBdhcptab\fR using the DHCP manager's tabs -for Macros and Options, or using the \fBdhtadm -P\fR command. -.SS "Syntax of dhcptab Entries" -.sp -.LP -The format of a \fBdhcptab\fR table depends on the data store used to maintain -it. However, any \fBdhcptab\fR must contain the following fields in each -record: -.sp -.ne 2 -.na -\fB\fBName\fR\fR -.ad -.RS 9n -This field identifies the macro or symbol record and is used as a search key -into the \fBdhcptab\fR table. The name of a macro or symbol must consist of -\fBASCII\fR characters, with the length limited to 128 characters. Names can -include spaces, except at the end of the name. The name is not case-sensitive. -.RE - -.sp -.ne 2 -.na -\fB\fBType\fR\fR -.ad -.RS 9n -This field specifies the type of record and is used as a search key into the -\fBdhcptab\fR. Currently, there are only two legal values for \fBType\fR: -.sp -.ne 2 -.na -\fB\fBm\fR\fR -.ad -.RS 5n -This record is a \fBDHCP\fR macro definition. -.RE - -.sp -.ne 2 -.na -\fB\fBs\fR\fR -.ad -.RS 5n -This record is a \fBDHCP\fR symbol definition. It is used to define vendor and -site-specific options. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fBValue\fR\fR -.ad -.RS 9n -This field contains the value for the specified type of record. For the \fBm\fR -type, the value will consist of a series of symbol=value pairs, separated by -the colon (\fB:\fR) character. For the \fBs\fR type, the value will consist of -a series of fields, separated by a comma (\fB,\fR), which define a symbol's -characteristics. Once defined, a symbol can be used in macro definitions. -.RE - -.SS "Symbol Characteristics" -.sp -.LP -The Value field of a symbols definition contain the following fields describing -the characteristics of a symbol: -.sp -.ne 2 -.na -\fB\fBContext\fR\fR -.ad -.RS 15n -This field defines the context in which the symbol definition is to be used. It -can have one of the following values: -.sp -.ne 2 -.na -\fB\fBSite\fR\fR -.ad -.RS 27n -This symbol defines a site-specific option, codes 128-254. -.RE - -.sp -.ne 2 -.na -\fB\fBVendor=Client Class ...\fR\fR -.ad -.RS 27n -This symbol defines a vendor-specific option, codes 1-254. The Vendor context -takes \fBASCII\fR string arguments which identify the client class that this -vendor option is associated with. Multiple client class names can be specified, -separated by white space. Only those clients whose client class matches one of -these values will see this option. For Sun machines, the Vendor client class -matches the value returned by the command \fBuname -i\fR on the client, with -periods replacing commas. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fBCode\fR\fR -.ad -.RS 15n -This field specifies the option code number associated with this symbol. Valid -values are 128-254 for site-specific options, and 1-254 for vendor-specific -options. -.RE - -.sp -.ne 2 -.na -\fB\fBType\fR\fR -.ad -.RS 15n -This field defines the type of data expected as a value for this symbol, and is -not case-sensitive. Legal values are: -.sp -.ne 2 -.na -\fB\fBASCII\fR\fR -.ad -.RS 11n -\fBNVT ASCII\fR text. Value is enclosed in double-quotes (\fB"\fR). Granularity -setting has no effect on symbols of this type, since \fBASCII\fR strings have a -natural granularity of one (1). -.RE - -.sp -.ne 2 -.na -\fB\fBBOOLEAN\fR\fR -.ad -.RS 11n -No value is associated with this data type. Presence of symbols of this type -denote boolean \fBTRUE,\fR whereas absence denotes \fBFALSE.\fR Granularity and -Miximum values have no meaning for symbols of this type. -.RE - -.sp -.ne 2 -.na -\fB\fBIP\fR\fR -.ad -.RS 11n -Dotted decimal form of an Internet address. Multi-IP address granularity is -supported. -.RE - -.sp -.ne 2 -.na -\fB\fBNUMBER\fR\fR -.ad -.RS 11n -An unsigned number with a supported granularity of \fB1\fR, \fB2\fR, \fB4\fR, -and \fB8\fR octets. -.sp -Valid \fBNUMBER\fR types are: \fBUNUMBER8\fR, \fBSNUMBER8\fR, \fBUNUMBER16\fR, -\fBSNUMBER16\fR, \fBUNUMBER32\fR, \fBSNUMBER32\fR, \fBUNUMBER64\fR, and -\fBSNUMBER64\fR. See \fBdhcp_inittab\fR(4) for details. -.RE - -.sp -.ne 2 -.na -\fB\fBOCTET\fR\fR -.ad -.RS 11n -Uninterpreted \fBASCII\fR representation of binary data. The client identifier -is one example of an \fBOCTET\fR string. Valid characters are \fB0\fR-\fB9\fR, -\fBa\fR-\fBf\fR, \fBA\fR-\fBF\fR. One \fBASCII\fR character represents one -nibble (4 bits), thus two \fBASCII\fR characters are needed to represent an 8 -bit quantity. The granularity setting has no effect on symbols of this type, -since \fBOCTET\fR strings have a natural granularity of one (\fB1\fR). -.sp -For example, to encode a sequence of bytes with decimal values \fB77\fR, -\fB82\fR, \fB5\fR, \fB240\fR, \fB14\fR, the option value would be encoded as -\fB4d5205f00e\fR. A macro which supplies a value for option code \fB78\fR, -\fBSLP_DA\fR, with a \fB0\fR Mandatory byte and Directory Agents at -\fB192.168.1.5\fR and \fB192.168.0.133\fR would appear in the \fBdhcptab\fR -as: -.sp -.in +2 -.nf -slpparams -Macro -:SLP_DA=00c0a80105c0a80085: -.fi -.in -2 - -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fBGranularity\fR\fR -.ad -.RS 15n -This value specifies how many objects of \fBType\fR define a single -\fBinstance\fR of the symbol value. For example, the static route option is -defined to be a variable list of routes. Each route consists of two \fBIP\fR -addresses, so the \fBType\fR is defined to be \fBIP\fR, and the data's -granularity is defined to be \fB2\fR \fBIP\fR addresses. The granularity field -affects the \fBIP\fR and \fBNUMBER\fR data types. -.RE - -.sp -.ne 2 -.na -\fB\fBMaximum\fR\fR -.ad -.RS 15n -This value specifies the maximum items of \fBGranularity\fR which are -permissible in a definition using this symbol. For example, there can only be -one \fBIP\fR address specified for a subnet mask, so the \fBMaximum\fR number -of items in this case is one (\fB1\fR). A \fBMaximum\fR value of zero -(\fB0\fR) means that a variable number of items is permitted. -.RE - -.sp -.LP -The following example defines a site-specific option (symbol) called -\fBMystatRt\fR, of code \fB130\fR, type \fBIP,\fR and granularity \fB2\fR, and -a \fBMaximum\fR of \fB0\fR. This definition corresponds to the internal -definition of the static route option (\fBStaticRt\fR). -.sp -.in +2 -.nf -MystatRt s Site,130,IP,2,0 -.fi -.in -2 - -.sp -.LP -The following example demonstrates how a SLP Service Scope symbol -(\fBSLP_SS\fR) with a scope value of \fBhappy\fR and mandatory byte set to -\fB0\fR is encoded. The first octet of the option is the Mandatory octet, which -is set either to \fB0\fR or \fB1\fR. In this example, it is set to \fB0 -(00)\fR. The balance of the value is the hexidecimal ASCII code numbers -representing the name \fBhappy\fR, that is, \fB6861707079\fR. -.sp -.in +2 -.nf -SLP_SS=006861707079 -.fi -.in -2 - -.SS "Macro Definitions" -.sp -.LP -The following example illustrates a macro defined using the \fBMystatRt\fR site -option symbol just defined: -.sp -.in +2 -.nf -10netnis m :MystatRt=3.0.0.0 10.0.0.30: -.fi -.in -2 - -.sp -.LP -Macros can be specified in the \fBMacro\fR field in \fBDHCP\fR network tables -(see \fBdhcp_network\fR(4)), which will bind particular macro definitions to -specific \fBIP addresses.\fR -.sp -.LP -Up to four macro definitions are consulted by the \fBDHCP\fR server to -determine the options that are returned to the requesting client. -.sp -.LP -These macros are processed in the following order: -.sp -.ne 2 -.na -\fB\fBClient Class\fR\fR -.ad -.RS 21n -A macro named using the \fBASCII\fR representation of the client class (e.g. -\fBSUNW.Ultra-30\fR) is searched for in the \fBdhcptab\fR. If found, its -symbol/value pairs will be selected for delivery to the client. This mechanism -permits the network administrator to select configuration parameters to be -returned to all clients of the same class. -.RE - -.sp -.ne 2 -.na -\fB\fBNetwork\fR\fR -.ad -.RS 21n -A macro named by the dotted Internet form of the network address of the -client's network (for example, \fB10.0.0.0\fR) is searched for in the -\fBdhcptab\fR. If found, its symbol/value pairs will be combined with those of -the \fBClient Class\fR macro. If a symbol exists in both macros, then the -\fBNetwork\fR macro value overrides the value defined in the \fBClient Class\fR -macro. This mechanism permits the network administrator to select configuration -parameters to be returned to all clients on the same network. -.RE - -.sp -.ne 2 -.na -\fB\fBIP Address\fR\fR -.ad -.RS 21n -This macro may be named anything, but must be specified in the \fBDHCP\fR -network table for the IP address record assigned to the requesting client. If -this macro is found in the \fBdhcptab\fR, then its symbol/value pairs will be -combined with those of the \fBClient Class\fR macro and the \fBNetwork\fR -macro. This mechanism permits the network administrator to select configuration -parameters to be returned to clients using a particular \fBIP\fR address. It -can also be used to deliver a macro defined to include "server-specific" -information by including this macro definition in all \fBDHCP\fR network table -entries owned by a specific server. -.RE - -.sp -.ne 2 -.na -\fB\fBClient Identifier\fR\fR -.ad -.RS 21n -A macro named by the \fBASCII\fR representation of the client's unique -identifier as shown in the \fBDHCP\fR network table (see -\fBdhcp_network\fR(4)). If found, its symbol/value pairs are combined to the -sum of the \fBClient Class\fR, \fBNetwork\fR, and \fBIP Address\fR macros. Any -symbol collisions are replaced with those specified in the client identifier -macro. The client mechanism permits the network administrator to select -configuration parameters to be returned to a particular client, regardless of -what network that client is connected to. -.RE - -.sp -.LP -Refer to \fISystem Administration Guide: IP Services\fR for more information -about macro processing. -.sp -.LP -Refer to the \fBdhcp_inittab\fR(4) man page for more information about symbols -used in Solaris DHCP. -.SH SEE ALSO -.sp -.LP -\fBdhcpmgr\fR(1M), \fBdhtadm\fR(1M), \fBin.dhcpd\fR(1M), \fBdhcp_inittab\fR(4), -\fBdhcp_network\fR(4), \fBdhcp\fR(5) -.sp -.LP -\fISystem Administration Guide: IP Services\fR -.sp -.LP -Alexander, S., and R. Droms, \fIDHCP Options and BOOTP Vendor Extensions\fR, -RFC 2132, Silicon Graphics, Inc., Bucknell University, March 1997. -.sp -.LP -Droms, R., \fIInteroperation Between DHCP and BOOTP\fR, RFC 1534, Bucknell -University, October 1993. -.sp -.LP -Droms, R., \fIDynamic Host Configuration Protocol\fR, RFC 2131, Bucknell -University, March 1997. -.sp -.LP -Wimer, W., \fIClarifications and Extensions for the Bootstrap Protocol\fR, RFC -1542, Carnegie Mellon University, October 1993. diff --git a/usr/src/man/man5/Makefile b/usr/src/man/man5/Makefile index 868e22eaf0..466d5c0f16 100644 --- a/usr/src/man/man5/Makefile +++ b/usr/src/man/man5/Makefile @@ -41,7 +41,6 @@ MANFILES= Intro.5 \ crypt_unix.5 \ device_clean.5 \ dhcp.5 \ - dhcp_modules.5 \ environ.5 \ epoll.5 \ eqn.5 \ diff --git a/usr/src/man/man5/dhcp.5 b/usr/src/man/man5/dhcp.5 index b6370b7cc5..6a662bd6b1 100644 --- a/usr/src/man/man5/dhcp.5 +++ b/usr/src/man/man5/dhcp.5 @@ -1,13 +1,13 @@ '\" te +.\" Copyright 2014 Garrett D'Amore <garrett@damore.org> .\" Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved. .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH DHCP 5 "Jan 5, 2007" +.TH DHCP 5 "Aug 15, 2014" .SH NAME dhcp \- Dynamic Host Configuration Protocol .SH DESCRIPTION -.sp .LP Dynamic Host Configuration Protocol (\fBDHCP\fR) enables host systems in a \fBTCP/IP\fR network to be configured automatically for the network as they @@ -15,28 +15,23 @@ boot. \fBDHCP\fR uses a client/server mechanism: servers store configuration information for clients, and provide that information upon a client's request. The information can include the client's \fBIP\fR address and information about network services available to the client. -.sp .LP -This manual page provides a brief summary of the Solaris \fBDHCP\fR +This manual page provides a brief summary of the \fBDHCP\fR implementation. -.SS "Solaris DHCP Client" -.sp +.SS "DHCP Client" .LP -The Solaris DHCP client is implemented as background daemon, +The DHCP client is implemented as background daemon, \fBdhcpagent\fR(1M). -.sp .LP For IPv4, this daemon is started automatically during bootup if there exists at least one \fBdhcp.\fR\fIinterface\fR file in \fB/etc\fR. Only interfaces with a corresponding \fB\fR\fB/etc/dhcp.\fR\fB\fIinterface\fR\fR file are automatically configured during boot. -.sp .LP For IPv6, this daemon is started automatically when commanded by \fBin.ndpd\fR (based on IPv6 Routing Advertisement messages). No \fB/etc/dhcp\fR.\fIinterface\fR file is necessary, but such a file can be used to specify an interface as "primary," provided that IPv4 DHCP is also in use. -.sp .LP Network parameters needed for system configuration during bootup are extracted from the information received by the daemon through the use of the @@ -44,80 +39,30 @@ from the information received by the daemon through the use of the changing the tunables in the \fB/etc/default/dhcpagent\fR file. The daemon is controlled by the \fBifconfig\fR(1M) utility. Check the status of the daemon using the \fBnetstat\fR(1M) and \fBifconfig\fR(1M) commands. -.SS "Solaris DHCP Server" -.sp -.LP -The Solaris \fBDHCP\fR server is implemented as a background daemon, -\fBin.dhcpd\fR(1M). This daemon can deliver network configuration information -to either \fBBOOTP\fR or \fBDHCP\fR clients. The Solaris \fBDHCP\fR service can -be managed using the \fBdhcpmgr\fR(1M) \fBGUI\fR or the command line utilities -\fBdhcpconfig\fR(1M), \fBdhtadm\fR(1M), and \fBpntadm\fR(1M). -.SS "DHCP Configuration Tables" -.sp -.LP -The Solaris \fBDHCP\fR server stores client configuration information in the -following two types of tables: -.sp -.ne 2 -.na -\fB\fBdhcptab\fR tables\fR -.ad -.RS 23n -Contain macros and options (also known as symbols), used to construct a package -of configuration information to send to each \fBDHCP\fR client. There exists -only one \fBdhcptab\fR for the \fBDHCP\fR service. The \fBdhcptab\fR(4) can be -viewed and modified using the \fBdhtadm\fR(1M) command or \fBdhcpmgr\fR(1M) -graphical utility. See \fBdhcptab\fR(4) for more information about the syntax -of \fBdhcptab\fR records. See \fBdhcp_inittab\fR(4) for more information about -the \fBDHCP\fR options and symbols. -.RE - -.sp -.ne 2 -.na -\fB\fBDHCP\fR network tables\fR -.ad -.RS 23n -\fBDHCP\fR network tables, which contain mappings of client \fBID\fRs to -\fBIP\fR addresses and parameters associated with those addresses. Network -tables are named with the \fBIP\fR address of the network, and can be created, -viewed, and modified using the \fBpntadm\fR command or \fBdhcpmgr\fR graphical -utility. See \fBdhcp_network\fR(4) for more information about network tables. -.RE - .SH SEE ALSO -.sp .LP -\fBdhcpinfo\fR(1), \fBdhcpagent\fR(1M), \fBdhcpconfig\fR(1M), -\fBdhcpmgr\fR(1M), \fBdhtadm\fR(1M), \fBifconfig\fR(1M), \fBin.dhcpd\fR(1M), -\fBin.ndpd\fR(1M), \fBnetstat\fR(1M), \fBpntadm\fR(1M), \fBsyslog\fR(3C), +\fBdhcpinfo\fR(1), \fBdhcpagent\fR(1M), +\fBifconfig\fR(1M), +\fBin.ndpd\fR(1M), \fBnetstat\fR(1M), +\fBsyslog\fR(3C), \fBdhcp_network\fR(4), \fBdhcptab\fR(4), \fBdhcpsvc.conf\fR(4), \fBdhcp_inittab\fR(4), \fBndpd.conf\fR(4), \fBdhcp_modules\fR(5) -.sp -.LP -\fISolaris DHCP Service Developer\&'s Guide\fR -.sp .LP Alexander, S., and R. Droms. \fIRFC 2132, DHCP Options and BOOTP Vendor Extensions\fR. Silicon Graphics, Inc. Bucknell University. March 1997. -.sp .LP Droms, R. \fIRFC 1534, Interoperation Between DHCP and BOOTP\fR. Bucknell University. October 1993. -.sp .LP Droms, R. \fIRFC 2131, Dynamic Host Configuration Protocol\fR. Bucknell University. March 1997. -.sp .LP Wimer, W. \fIRFC 1542, Clarifications and Extensions for the Bootstrap Protocol\fR. Carnegie Mellon University. October 1993. -.sp .LP Lemon, T. and B. Sommerfeld. \fIRFC 4361, Node-specific Client Identifiers for Dynamic Host Configuration Protocol Version Four (DHCPv4)\fR. Nominum and Sun Microsystems. February 2006. -.sp .LP Droms, R. \fIRFC 3315, Dynamic Host Configuration Protocol for IPv6 (DHCPv6)\fR. Cisco Systems. July 2003. diff --git a/usr/src/man/man5/dhcp_modules.5 b/usr/src/man/man5/dhcp_modules.5 deleted file mode 100644 index 79b32b93ee..0000000000 --- a/usr/src/man/man5/dhcp_modules.5 +++ /dev/null @@ -1,89 +0,0 @@ -'\" te -.\" Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH DHCP_MODULES 5 "Jan 24, 2003" -.SH NAME -dhcp_modules \- data storage modules for the DHCP service -.SH DESCRIPTION -.sp -.LP -This man page describes the characteristics of data storage modules (public -modules) for use by the Solaris Dynamic Host Configuration Protocol -(\fBDHCP\fR) service. -.sp -.LP -Public modules are the part of the \fBDHCP\fR service architecture that -encapsulate the details of storing \fBDHCP\fR service data in a data storage -service. Examples of data storage services are \fBNIS+\fR, Oracle, and -\fBufs\fR file systems. -.sp -.LP -Public modules are dynamic objects which can be shipped separately from the -Solaris \fBDHCP\fR service. Once installed, a public module is visible to the -\fBDHCP\fR service, and can be selected for use by the service through the -\fBDHCP\fR service management interfaces (\fBdhcpmgr\fR(1M), -\fBdhcpconfig\fR(1M), \fBdhtadm\fR(1M), and \fBpntadm\fR(1M)). -.sp -.LP -Public modules may be provided by Sun Microsystems, Inc or by third parties. -.sp -.LP -The Solaris \fBDHCP\fR service management architecture provides a mechanism for -plugging in public module-specific administration functionality into the -\fBdhcpmgr\fR(1M) and \fBdhcpconfig\fR(1M) utilities. This functionality is in -the form of a Java Bean, which is provided by the public module vendor. This -Java Bean collects public module-specific configuration from the user (you) and -provides it to the Solaris \fBDHCP\fR service. -.sp -.LP -The Solaris \fBDHCP\fR service bundles three modules with the service, which -are described below. There are three \fBdhcpsvc.conf\fR(4) \fBDHCP\fR service -configuration parameters pertaining to public modules: \fBRESOURCE\fR, -\fBPATH\fR, and \fBRESOURCE_CONFIG\fR. See \fBdhcpsvc.conf\fR(4) for more -information about these parameters. -.SS "SUNWfiles" -.sp -.LP -This module stores its data in \fBASCII\fR files. Although the format is -\fBASCII\fR, hand-editing is discouraged. It is useful for \fBDHCP\fR service -environments that support several hundred to a couple thousand of clients and -lease times are a few hours or more. -.sp -.LP -This module's data may be shared between \fBDHCP\fR servers through the use of -\fBNFS\fR. -.SS "SUNWbinfiles" -.sp -.LP -This module stores its data in binary files. It is useful for \fBDHCP\fR -service environments with many networks and many thousands of clients. This -module provides an order of magnitude increase in performance and capacity over -SUNWfiles. -.sp -.LP -This module's data cannot be shared between \fBDHCP\fR servers. -.SS "SUNWnisplus" -.sp -.LP -This module stores its data within a \fBNIS+\fR domain. It is useful in -environments where \fBNIS+\fR is already deployed and facilitates sharing among -multiple \fBDHCP\fR servers. This module suports several hundred to a few -thousand clients with lease times of several hours or more. -.sp -.LP -The \fBNIS+\fR service should be hosted on a machine with ample \fBCPU\fR -power, memory, and disk space, as the load on \fBNIS+\fR is significant when it -is used to store \fBDHCP\fR data. Periodic checkpointing of the \fBNIS+\fR -service is necessary in order to roll the transaction logs and keep the -\fBNIS+\fR service operating at its highest efficiency. See \fBnisping\fR(1M) -and \fBcrontab\fR(1) for more information. -.SH SEE ALSO -.sp -.LP -\fBcrontab\fR(1), \fBdhcpconfig\fR(1M), \fBdhcpmgr\fR(1M), \fBdhtadm\fR(1M), -\fBnisping\fR(1M), \fBpntadm\fR(1M), \fBdhcpsvc.conf\fR(4), \fBdhcp\fR(5) -.sp -.LP -\fISolaris DHCP Service Developer\&'s Guide\fR diff --git a/usr/src/pkg/manifests/SUNWcs.mf b/usr/src/pkg/manifests/SUNWcs.mf index 7c8d7e6b25..ce3a1b915f 100644 --- a/usr/src/pkg/manifests/SUNWcs.mf +++ b/usr/src/pkg/manifests/SUNWcs.mf @@ -201,9 +201,6 @@ dir path=usr/lib/iconv dir path=usr/lib/inet dir path=usr/lib/inet/$(ARCH32) dir path=usr/lib/inet/$(ARCH64) -dir path=usr/lib/inet/dhcp -dir path=usr/lib/inet/dhcp/nsu -dir path=usr/lib/inet/dhcp/svc dir path=usr/lib/locale dir path=usr/lib/locale/C dir path=usr/lib/locale/C/LC_COLLATE diff --git a/usr/src/pkg/manifests/consolidation-osnet-osnet-message-files.mf b/usr/src/pkg/manifests/consolidation-osnet-osnet-message-files.mf index cd9fd8743e..9dc4691a6a 100644 --- a/usr/src/pkg/manifests/consolidation-osnet-osnet-message-files.mf +++ b/usr/src/pkg/manifests/consolidation-osnet-osnet-message-files.mf @@ -20,6 +20,7 @@ # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2014 Garrett D'Amore <garrett@damore.org> set name=pkg.fmri \ value=pkg:/consolidation/osnet/osnet-message-files@$(PKGVERS) @@ -54,22 +55,6 @@ dir path=usr/share/lib/locale/com/sun dir path=usr/share/lib/locale/com/sun/admin dir path=usr/share/lib/locale/com/sun/admin/pm dir path=usr/share/lib/locale/com/sun/admin/pm/client -dir path=usr/share/lib/locale/com/sun/dhcpmgr -dir path=usr/share/lib/locale/com/sun/dhcpmgr/bridge -dir path=usr/share/lib/locale/com/sun/dhcpmgr/cli -dir path=usr/share/lib/locale/com/sun/dhcpmgr/cli/common -dir path=usr/share/lib/locale/com/sun/dhcpmgr/cli/dhcpbatch -dir path=usr/share/lib/locale/com/sun/dhcpmgr/cli/dhcpconfig -dir path=usr/share/lib/locale/com/sun/dhcpmgr/cli/dhtadm -dir path=usr/share/lib/locale/com/sun/dhcpmgr/cli/pntadm -dir path=usr/share/lib/locale/com/sun/dhcpmgr/client -dir path=usr/share/lib/locale/com/sun/dhcpmgr/client/SUNWbinfiles -dir path=usr/share/lib/locale/com/sun/dhcpmgr/client/SUNWfiles -dir path=usr/share/lib/locale/com/sun/dhcpmgr/client/help -dir path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/art -dir path=usr/share/lib/locale/com/sun/dhcpmgr/common -dir path=usr/share/lib/locale/com/sun/dhcpmgr/data -dir path=usr/share/lib/locale/com/sun/dhcpmgr/ui dir path=usr/share/lib/locale/com/sun/slp file path=usr/lib/help/auths/locale/AllSolAuthsHeader.html file path=usr/lib/help/auths/locale/AuditHeader.html @@ -338,112 +323,6 @@ file path=usr/share/lib/locale/com/sun/admin/pm/client/pmHelpResources.java \ group=lp file path=usr/share/lib/locale/com/sun/admin/pm/client/pmResources.java \ group=lp -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/bridge/ResourceBundle.properties -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/cli/common/ResourceBundle.properties -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/cli/dhcpbatch/ResourceBundle.properties -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/cli/dhcpconfig/ResourceBundle.properties -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/cli/dhtadm/ResourceBundle.properties -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/cli/pntadm/ResourceBundle.properties -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/OptionDescriptions.properties -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/ResourceBundle.properties -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/SUNWbinfiles/ResourceBundle.properties -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/SUNWfiles/ResourceBundle.properties -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/art/bannersmc.gif -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/art/dot1.gif -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/art/dot2.gif -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/art/folder.gif -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/art/macro2.gif -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/art/macroflow.gif -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/art/tip2.gif -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_addr_create.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_addr_del.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_addr_dup.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_addr_how.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_addr_mod.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_addr_multi.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_addr_ref.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_addr_rel.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_addr_view.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_addr_wiz.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_config_wiz.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_convert_wiz.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_export_wiz.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_import_wiz.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_macro_create.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_macro_del.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_macro_dup.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_macro_how.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_macro_mod.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_macro_ref.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_macro_view.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_macros_about.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_main_hlp.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_main_how.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_main_idx.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_main_menus.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_main_top.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_net_del.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_net_ref.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_net_wiz.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_option_create.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_option_del.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_option_dup.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_option_how.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_option_mod.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_option_ref.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_option_tags.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_option_view.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_relay_choose.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_relay_config.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_relay_dis.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_relay_enable.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_relay_how.html -file path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_relay_ref.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_relay_serv.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_relay_unconfig.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_server_serv.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_server_unconfig.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/client/help/dhcp_solaris_about.html -file \ - path=usr/share/lib/locale/com/sun/dhcpmgr/common/ResourceBundle.properties -file path=usr/share/lib/locale/com/sun/dhcpmgr/data/ResourceBundle.properties -file path=usr/share/lib/locale/com/sun/dhcpmgr/ui/ResourceBundle.properties file path=usr/share/lib/locale/com/sun/slp/ClientLib_en.properties group=sys file path=usr/share/lib/locale/com/sun/slp/Server_en.properties group=sys legacy pkg=SUNW0on arch=all \ diff --git a/usr/src/pkg/manifests/network-dhcp-dhcpmgr.mf b/usr/src/pkg/manifests/network-dhcp-dhcpmgr.mf index ed2e55e64d..d691399421 100644 --- a/usr/src/pkg/manifests/network-dhcp-dhcpmgr.mf +++ b/usr/src/pkg/manifests/network-dhcp-dhcpmgr.mf @@ -21,87 +21,9 @@ # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2014 Garrett D'Amore <garrett@damore.org> # set name=pkg.fmri value=pkg:/network/dhcp/dhcpmgr@$(PKGVERS) -set name=pkg.description \ - value="Graphical management interface for the DHCP server" -set name=pkg.summary value="DHCP Manager" -set name=info.classification \ - value=org.opensolaris.category.2008:System/Services +set name=pkg.obsolete value=true set name=variant.arch value=$(ARCH) -dir path=usr group=sys -dir path=usr/sadm -dir path=usr/sadm/admin -dir path=usr/sadm/admin/bin -dir path=usr/sadm/admin/dhcpmgr -dir path=usr/sadm/admin/dhcpmgr/help -dir path=usr/sadm/admin/dhcpmgr/help/art -dir path=usr/share/man/man1m -file path=usr/sadm/admin/bin/dhcpmgr mode=0555 -file path=usr/sadm/admin/dhcpmgr/SUNWfiles.jar mode=0444 -file path=usr/sadm/admin/dhcpmgr/dhcpmgr.jar mode=0444 -file path=usr/sadm/admin/dhcpmgr/dhcpmgr.so.1 mode=0755 -file path=usr/sadm/admin/dhcpmgr/help/art/bannersmc.gif mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/art/dot1.gif mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/art/dot2.gif mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/art/folder.gif mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/art/macro2.gif mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/art/macroflow.gif mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/art/tip2.gif mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_addr_create.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_addr_del.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_addr_dup.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_addr_how.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_addr_mod.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_addr_multi.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_addr_ref.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_addr_rel.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_addr_view.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_addr_wiz.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_config_wiz.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_convert_wiz.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_export_wiz.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_import_wiz.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_macro_create.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_macro_del.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_macro_dup.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_macro_how.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_macro_mod.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_macro_ref.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_macro_view.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_macros_about.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_main_hlp.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_main_how.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_main_idx.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_main_menus.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_main_top.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_net_del.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_net_ref.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_net_wiz.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_option_create.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_option_del.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_option_dup.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_option_how.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_option_mod.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_option_ref.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_option_tags.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_option_view.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_relay_choose.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_relay_config.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_relay_dis.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_relay_enable.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_relay_how.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_relay_ref.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_relay_serv.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_relay_unconfig.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_server_serv.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_server_unconfig.html mode=0444 -file path=usr/sadm/admin/dhcpmgr/help/dhcp_solaris_about.html mode=0444 -file path=usr/share/man/man1m/dhcpmgr.1m -legacy pkg=SUNWdhcm desc="Graphical management interface for the DHCP server" \ - name="DHCP Manager" -license cr_Sun license=cr_Sun -license lic_CDDL license=lic_CDDL -link path=usr/sbin/dhcpmgr target=../sadm/admin/bin/dhcpmgr -depend fmri=runtime/java type=require diff --git a/usr/src/pkg/manifests/service-network-dhcp-datastore-binfiles.mf b/usr/src/pkg/manifests/service-network-dhcp-datastore-binfiles.mf index 2a384add46..a235605aa7 100644 --- a/usr/src/pkg/manifests/service-network-dhcp-datastore-binfiles.mf +++ b/usr/src/pkg/manifests/service-network-dhcp-datastore-binfiles.mf @@ -21,31 +21,10 @@ # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2014 Garrett D'Amore <garrett@damore.org> # set name=pkg.fmri \ value=pkg:/service/network/dhcp/datastore/binfiles@$(PKGVERS) -set name=pkg.description \ - value="Binary File Format Public module exporting Version 1 of the Service Provider Interface. Used to store DHCP data, this module has much better performance than the ASCII files and nisplus public modules." -set name=pkg.summary \ - value="Binary File Format Data Module for BOOTP/DHCP Services" -set name=info.classification \ - value=org.opensolaris.category.2008:System/Services +set name=pkg.obsolete value=true set name=variant.arch value=$(ARCH) -dir path=usr group=sys -dir path=usr/lib -dir path=usr/lib/inet -dir path=usr/lib/inet/dhcp -dir path=usr/lib/inet/dhcp/svc -dir path=usr/sadm -dir path=usr/sadm/admin -dir path=usr/sadm/admin/dhcpmgr -file path=usr/lib/inet/dhcp/svc/ds_SUNWbinfiles.so.1 -file path=usr/sadm/admin/dhcpmgr/SUNWbinfiles.jar mode=0444 -legacy pkg=SUNWdhcsb \ - desc="Binary File Format Public module exporting Version 1 of the Service Provider Interface. Used to store DHCP data, this module has much better performance than the ASCII files and nisplus public modules." \ - name="Binary File Format Data Module for BOOTP/DHCP Services" -license cr_Sun license=cr_Sun -license lic_CDDL license=lic_CDDL -link path=usr/lib/inet/dhcp/svc/ds_SUNWbinfiles.so \ - target=./ds_SUNWbinfiles.so.1 diff --git a/usr/src/pkg/manifests/service-network-dhcp.mf b/usr/src/pkg/manifests/service-network-dhcp.mf index 333754086b..32b39894ee 100644 --- a/usr/src/pkg/manifests/service-network-dhcp.mf +++ b/usr/src/pkg/manifests/service-network-dhcp.mf @@ -21,72 +21,9 @@ # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2014 Garrett D'Amore <garrett@damore.org> # set name=pkg.fmri value=pkg:/service/network/dhcp@$(PKGVERS) -set name=pkg.description \ - value="Usr filesystem portion of the SunOS BOOTP/DHCP service, which uses the BOOT Protocol and/or Dynamic Host Configuration Protocol to provide network configuration parameters to BOOTP/DHCP clients. Administration utilities for the service are included." -set name=pkg.summary value="BOOTP/DHCP Server Services" -set name=info.classification \ - value=org.opensolaris.category.2008:System/Services +set name=pkg.obsolete value=true set name=variant.arch value=$(ARCH) -dir path=etc group=sys -dir path=etc/inet group=sys -dir path=etc/init.d group=sys -dir path=lib -dir path=lib/svc -dir path=lib/svc/manifest group=sys -dir path=lib/svc/manifest/network group=sys -dir path=usr group=sys -dir path=usr/include -dir path=usr/lib -dir path=usr/lib/inet -dir path=usr/lib/inet/dhcp -dir path=usr/lib/inet/dhcp/nsu -dir path=usr/lib/inet/dhcp/svc -dir path=usr/lib/inet/dhcp/svcadm -dir path=usr/sbin -dir path=usr/share/man -dir path=usr/share/man/man1m -dir path=usr/share/man/man5 -file path=etc/init.d/dhcp group=sys mode=0744 -file path=lib/svc/manifest/network/dhcp-server.xml group=sys mode=0444 -file path=usr/include/dhcp_svc_public.h -file path=usr/lib/inet/dhcp/nsu/rfc2136.so.1 -file path=usr/lib/inet/dhcp/svc/ds_SUNWfiles.so.0 -file path=usr/lib/inet/dhcp/svc/ds_SUNWfiles.so.1 -file path=usr/lib/inet/dhcp/svcadm/dhcpcli.jar mode=0444 -file path=usr/lib/inet/dhcp/svcadm/dhcpcommon.jar mode=0444 -file path=usr/lib/inet/dhcp/svcadm/dhcpconfig mode=0555 -file path=usr/lib/inet/dhcp/svcadm/dhcpsvc.jar mode=0444 -file path=usr/lib/inet/dhcp/svcadm/dhtadm mode=0555 -file path=usr/lib/inet/dhcp/svcadm/pntadm mode=0555 -file path=usr/lib/inet/dsvclockd mode=0555 -file path=usr/lib/inet/in.dhcpd mode=0555 -file path=usr/lib/libdhcpsvc.so.1 -file path=usr/sbin/dhcpconfig mode=0555 -file path=usr/sbin/dhtadm mode=0555 -file path=usr/sbin/pntadm mode=0555 -file path=usr/share/man/man1m/dhcpconfig.1m -file path=usr/share/man/man1m/dhtadm.1m -file path=usr/share/man/man1m/dsvclockd.1m -file path=usr/share/man/man1m/in.dhcpd.1m -file path=usr/share/man/man1m/pntadm.1m -file path=usr/share/man/man4/dhcp_network.4 -file path=usr/share/man/man4/dhcpsvc.conf.4 -file path=usr/share/man/man4/dhcptab.4 -file path=usr/share/man/man5/dhcp_modules.5 -legacy pkg=SUNWdhcsr \ - desc="Root filesystem portion of the SunOS BOOTP/DHCP service, which uses the BOOT Protocol and/or Dynamic Host Configuration Protocol to provide network configuration parameters to BOOTP/DHCP clients. Administration utilities for the service are included." \ - name="BOOTP/DHCP Server Services, (Root)" -legacy pkg=SUNWdhcsu \ - desc="Usr filesystem portion of the SunOS BOOTP/DHCP service, which uses the BOOT Protocol and/or Dynamic Host Configuration Protocol to provide network configuration parameters to BOOTP/DHCP clients. Administration utilities for the service are included." \ - name="BOOTP/DHCP Server Services, (Usr)" -license cr_Sun license=cr_Sun -license lic_CDDL license=lic_CDDL -license usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/THIRDPARTYLICENSE \ - license=usr/src/cmd/cmd-inet/usr.lib/in.dhcpd/THIRDPARTYLICENSE -link path=usr/lib/inet/dhcp/svc/ds_SUNWfiles.so target=./ds_SUNWfiles.so.1 -depend fmri=network/dhcp/dhcpmgr type=require -depend fmri=network/ftp type=require -depend fmri=runtime/java type=require diff --git a/usr/src/pkg/manifests/system-library.man3c.inc b/usr/src/pkg/manifests/system-library.man3c.inc index d9f6759bba..8b32d6af19 100644 --- a/usr/src/pkg/manifests/system-library.man3c.inc +++ b/usr/src/pkg/manifests/system-library.man3c.inc @@ -487,9 +487,13 @@ file path=usr/share/man/man3c/wait.3c file path=usr/share/man/man3c/wait3.3c file path=usr/share/man/man3c/waitpid.3c file path=usr/share/man/man3c/walkcontext.3c +file path=usr/share/man/man3c/wcpcpy.3c file path=usr/share/man/man3c/wcrtomb.3c +file path=usr/share/man/man3c/wcscasecmp.3c file path=usr/share/man/man3c/wcscoll.3c +file path=usr/share/man/man3c/wcsdup.3c file path=usr/share/man/man3c/wcsftime.3c +file path=usr/share/man/man3c/wcslen.3c file path=usr/share/man/man3c/wcsrtombs.3c file path=usr/share/man/man3c/wcsstr.3c file path=usr/share/man/man3c/wcstod.3c @@ -1193,9 +1197,9 @@ link path=usr/share/man/man3c/strcoll_l.3c target=strcoll.3c link path=usr/share/man/man3c/strcpy.3c target=string.3c link path=usr/share/man/man3c/strcspn.3c target=string.3c link path=usr/share/man/man3c/strdup.3c target=string.3c +link path=usr/share/man/man3c/strerror_r.3c target=strerror.3c link path=usr/share/man/man3c/strfmon_l.3c target=strfmon.3c link path=usr/share/man/man3c/strftime_l.3c target=strftime.3c -link path=usr/share/man/man3c/strerror_r.3c target=strerror.3c link path=usr/share/man/man3c/strlcat.3c target=string.3c link path=usr/share/man/man3c/strlcpy.3c target=string.3c link path=usr/share/man/man3c/strlen.3c target=string.3c @@ -1300,7 +1304,9 @@ link path=usr/share/man/man3c/watof.3c target=wcstod.3c link path=usr/share/man/man3c/watoi.3c target=wcstol.3c link path=usr/share/man/man3c/watol.3c target=wcstol.3c link path=usr/share/man/man3c/watoll.3c target=wcstol.3c +link path=usr/share/man/man3c/wcpncpy.3c target=wcpcpy.3c link path=usr/share/man/man3c/wcrtomb_l.3c target=wcrtomb.3c +link path=usr/share/man/man3c/wcscasecmp_l.3c target=wcscasecmp.3c link path=usr/share/man/man3c/wcscat.3c target=wcstring.3c link path=usr/share/man/man3c/wcschr.3c target=wcstring.3c link path=usr/share/man/man3c/wcscmp.3c target=wcstring.3c @@ -1308,10 +1314,12 @@ link path=usr/share/man/man3c/wcscoll_l.3c target=wcscoll.3c link path=usr/share/man/man3c/wcscpy.3c target=wcstring.3c link path=usr/share/man/man3c/wcscspn.3c target=wcstring.3c link path=usr/share/man/man3c/wcsetno.3c target=cset.3c -link path=usr/share/man/man3c/wcslen.3c target=wcstring.3c +link path=usr/share/man/man3c/wcsncasecmp.3c target=wcscasecmp.3c +link path=usr/share/man/man3c/wcsncasecmp_l.3c target=wcscasecmp.3c link path=usr/share/man/man3c/wcsncat.3c target=wcstring.3c link path=usr/share/man/man3c/wcsncmp.3c target=wcstring.3c link path=usr/share/man/man3c/wcsncpy.3c target=wcstring.3c +link path=usr/share/man/man3c/wcsnlen.3c target=wcslen.3c link path=usr/share/man/man3c/wcsnrtombs.3c target=wcsrtombs.3c link path=usr/share/man/man3c/wcsnrtombs_l.3c target=wcsrtombs.3c link path=usr/share/man/man3c/wcspbrk.3c target=wcstring.3c diff --git a/usr/src/tools/findunref/exception_list.open b/usr/src/tools/findunref/exception_list.open index 662bc0a826..6c67558afd 100644 --- a/usr/src/tools/findunref/exception_list.open +++ b/usr/src/tools/findunref/exception_list.open @@ -22,8 +22,8 @@ # Copyright 2014 Gary Mills # # Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2014 Garrett D'Amore <garrett@damore.org> # - # # open-tree exception list # @@ -182,7 +182,6 @@ # Ignore sample source code. # ./usr/src/cmd/sendmail/libmilter/example.c -./usr/src/lib/libdhcpsvc/modules/templates # # Ignore .xcl files that aren't used because the program is statically linked. diff --git a/usr/src/uts/common/os/printf.c b/usr/src/uts/common/os/printf.c index 3ef207d77b..5d1e69253f 100644 --- a/usr/src/uts/common/os/printf.c +++ b/usr/src/uts/common/os/printf.c @@ -112,7 +112,7 @@ retry: "%s: [ID %u FACILITY_AND_PRIORITY] ", mod_containing_pc(site), msgid); msgp += snprintf(msgp, bufend - msgp, prefix); - if (dip) + if (dip != NULL) msgp += snprintf(msgp, bufend - msgp, "%s%d: ", ddi_driver_name(dip), ddi_get_instance(dip)); msgp += vsnprintf(msgp, bufend - msgp, fmt, adx); |
