summaryrefslogtreecommitdiff
path: root/usr/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib')
-rw-r--r--usr/src/lib/Makefile6
-rw-r--r--usr/src/lib/libdhcpdu/Makefile65
-rw-r--r--usr/src/lib/libdhcpdu/Makefile.com56
-rw-r--r--usr/src/lib/libdhcpdu/common/mapfile45
-rw-r--r--usr/src/lib/libdhcpdu/common/rfc2136.c916
-rw-r--r--usr/src/lib/libdhcpdu/i386/Makefile31
-rw-r--r--usr/src/lib/libdhcpdu/inc.flg30
-rw-r--r--usr/src/lib/libdhcpdu/sparc/Makefile32
-rw-r--r--usr/src/lib/libdhcpsvc/Makefile38
-rw-r--r--usr/src/lib/libdhcpsvc/Makefile.com32
-rw-r--r--usr/src/lib/libdhcpsvc/Makefile.subdirs44
-rw-r--r--usr/src/lib/libdhcpsvc/Makefile.targ33
-rw-r--r--usr/src/lib/libdhcpsvc/head/Makefile51
-rw-r--r--usr/src/lib/libdhcpsvc/head/dhcp_svc_confkey.m4122
-rw-r--r--usr/src/lib/libdhcpsvc/head/dhcp_svc_confopt.h76
-rw-r--r--usr/src/lib/libdhcpsvc/head/dhcp_svc_private.h201
-rw-r--r--usr/src/lib/libdhcpsvc/head/dhcp_svc_public.h261
-rw-r--r--usr/src/lib/libdhcpsvc/modules/Makefile32
-rw-r--r--usr/src/lib/libdhcpsvc/modules/Makefile.com40
-rw-r--r--usr/src/lib/libdhcpsvc/modules/Makefile.targ44
-rw-r--r--usr/src/lib/libdhcpsvc/modules/binfiles/Makefile30
-rw-r--r--usr/src/lib/libdhcpsvc/modules/binfiles/Makefile.com46
-rw-r--r--usr/src/lib/libdhcpsvc/modules/binfiles/dhcp_network.c1489
-rw-r--r--usr/src/lib/libdhcpsvc/modules/binfiles/dhcp_network.h123
-rw-r--r--usr/src/lib/libdhcpsvc/modules/binfiles/dhcptab.c779
-rw-r--r--usr/src/lib/libdhcpsvc/modules/binfiles/dhcptab.h102
-rw-r--r--usr/src/lib/libdhcpsvc/modules/binfiles/general.c107
-rw-r--r--usr/src/lib/libdhcpsvc/modules/binfiles/i386/Makefile32
-rw-r--r--usr/src/lib/libdhcpsvc/modules/binfiles/mapfile-vers65
-rw-r--r--usr/src/lib/libdhcpsvc/modules/binfiles/sparc/Makefile32
-rw-r--r--usr/src/lib/libdhcpsvc/modules/binfiles/tools/Makefile49
-rw-r--r--usr/src/lib/libdhcpsvc/modules/binfiles/tools/printnet.c129
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files/Makefile30
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files/Makefile.com47
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files/dhcp_network.c771
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files/dhcp_network.h102
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files/dhcptab.c577
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files/dhcptab.h81
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files/general.c112
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files/i386/Makefile32
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files/mapfile-vers65
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files/sparc/Makefile32
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files0/Makefile30
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files0/Makefile.com51
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files0/dhcp_network.c668
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files0/dhcp_network.h82
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files0/dhcptab.c505
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files0/dhcptab.h79
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files0/i386/Makefile33
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files0/mapfile-vers64
-rw-r--r--usr/src/lib/libdhcpsvc/modules/files0/sparc/Makefile33
-rw-r--r--usr/src/lib/libdhcpsvc/modules/templates/Makefile30
-rw-r--r--usr/src/lib/libdhcpsvc/modules/templates/Makefile.com44
-rw-r--r--usr/src/lib/libdhcpsvc/modules/templates/dhcp_network.c147
-rw-r--r--usr/src/lib/libdhcpsvc/modules/templates/dhcptab.c145
-rw-r--r--usr/src/lib/libdhcpsvc/modules/templates/general.c66
-rw-r--r--usr/src/lib/libdhcpsvc/modules/templates/i386/Makefile32
-rw-r--r--usr/src/lib/libdhcpsvc/modules/templates/sparc/Makefile32
-rw-r--r--usr/src/lib/libdhcpsvc/modules/util/util.c451
-rw-r--r--usr/src/lib/libdhcpsvc/modules/util/util.h61
-rw-r--r--usr/src/lib/libdhcpsvc/private/Makefile38
-rw-r--r--usr/src/lib/libdhcpsvc/private/Makefile.com48
-rw-r--r--usr/src/lib/libdhcpsvc/private/README.synch176
-rw-r--r--usr/src/lib/libdhcpsvc/private/confopt.c415
-rw-r--r--usr/src/lib/libdhcpsvc/private/dsvcd_synch.c326
-rw-r--r--usr/src/lib/libdhcpsvc/private/errmsgs.c80
-rw-r--r--usr/src/lib/libdhcpsvc/private/i386/Makefile32
-rw-r--r--usr/src/lib/libdhcpsvc/private/inc.flg30
-rw-r--r--usr/src/lib/libdhcpsvc/private/llib-ldhcpsvc34
-rw-r--r--usr/src/lib/libdhcpsvc/private/mapfile-vers76
-rw-r--r--usr/src/lib/libdhcpsvc/private/private.c871
-rw-r--r--usr/src/lib/libdhcpsvc/private/public.c188
-rw-r--r--usr/src/lib/libdhcpsvc/private/sparc/Makefile32
-rw-r--r--usr/src/lib/libdhcpsvc/tests/Makefile53
-rw-r--r--usr/src/lib/libdhcpsvc/tests/specs/applications.txt75
-rw-r--r--usr/src/lib/libdhcpsvc/tests/specs/private.txt1060
-rw-r--r--usr/src/lib/libdhcpsvc/tests/specs/public.txt1201
-rw-r--r--usr/src/lib/libdhcpsvc/tests/specs/refplat.txt52
-rw-r--r--usr/src/lib/libdhcpsvc/tests/test_confopt.c89
-rw-r--r--usr/src/lib/libdhcpsvc/tests/test_private.c539
-rw-r--r--usr/src/lib/libdhcputil/common/dhcp_symbol.h11
81 files changed, 6 insertions, 14960 deletions
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