2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2001 by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#include <stdio.h>
2N/A#include <stdlib.h>
2N/A#include <alloca.h>
2N/A#include <strings.h>
2N/A#include <sys/types.h>
2N/A#include <arpa/inet.h>
2N/A#include <sys/socket.h>
2N/A#include <fcntl.h>
2N/A#include <errno.h>
2N/A#include <dhcp_svc_confopt.h>
2N/A#include <dhcp_svc_private.h>
2N/A#include <dhcp_svc_public.h>
2N/A#include <libinetutil.h>
2N/A
2N/A/*
2N/A * Argument: resource, and path in that resource.
2N/A */
2N/Aint
2N/Amain(int argc, char *argv[])
2N/A{
2N/A int nmods, i, error;
2N/A boolean_t dsp_valid = B_FALSE;
2N/A char **mods, **listpp;
2N/A uint32_t count;
2N/A dsvc_datastore_t dsp;
2N/A dsvc_handle_t handle;
2N/A char cid[DN_MAX_CID_LEN * 2 + 1];
2N/A uint_t cidlen;
2N/A char cip[INET_ADDRSTRLEN], sip[INET_ADDRSTRLEN];
2N/A uint32_t query;
2N/A dt_rec_t dt, *dtp, *ntp;
2N/A dt_rec_list_t *resdtp, *wtp;
2N/A dn_rec_t dn, *dnp;
2N/A dn_rec_list_t *resdnp, *wnp;
2N/A
2N/A if (argc != 3) {
2N/A (void) fprintf(stderr, "Usage: %s <resource> <path>\n",
2N/A argv[0]);
2N/A return (1);
2N/A }
2N/A
2N/A /* enumerate_dd() */
2N/A (void) printf("enumerate_dd: ... ");
2N/A error = enumerate_dd(&mods, &nmods);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A
2N/A if (error != DSVC_SUCCESS)
2N/A return (1);
2N/A
2N/A (void) printf("enumerate_dd: count of modules: %d\n", nmods);
2N/A for (i = 0; i < nmods; i++) {
2N/A (void) printf(" %d is: %s\n", i, mods[i]);
2N/A if (strcmp(argv[1], mods[i]) == 0) {
2N/A dsp.d_location = argv[2];
2N/A dsp.d_resource = strdup(mods[i]);
2N/A dsp.d_conver = DSVC_CUR_CONVER;
2N/A dsp_valid = B_TRUE;
2N/A }
2N/A free(mods[i]);
2N/A }
2N/A free(mods);
2N/A
2N/A if (!dsp_valid) {
2N/A (void) printf("%s: no module for resource `%s'\n", argv[0],
2N/A argv[1]);
2N/A return (1);
2N/A }
2N/A
2N/A (void) printf("\nstarting testing on %s, tables @ %s\n",
2N/A argv[1], argv[2]);
2N/A
2N/A /*
2N/A * Using the datastore struct we built from arguments, begin poking
2N/A * at the user selected public module.
2N/A */
2N/A
2N/A /* status_dd */
2N/A (void) printf("status_dd: ... ");
2N/A error = status_dd(&dsp);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A
2N/A (void) printf("Datastore version is %d\n", dsp.d_conver);
2N/A
2N/A /* mklocation_dd */
2N/A (void) printf("mklocation_dd of %s: ... ", dsp.d_location);
2N/A error = mklocation_dd(&dsp);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A
2N/A /* list_dd - dhcptab */
2N/A (void) printf("\nlist_dd of dhcptab containers: ... ");
2N/A error = list_dd(&dsp, DSVC_DHCPTAB, &listpp, &count);
2N/A (void) printf(" %s\n", dhcpsvc_errmsg(error));
2N/A if (error == DSVC_SUCCESS) {
2N/A (void) printf(" %d dhcptab container(s): ", count);
2N/A for (i = 0; i < count; i++) {
2N/A (void) printf("%s ", listpp[i] != NULL ?
2N/A listpp[i] : "NULL");
2N/A free(listpp[i]);
2N/A }
2N/A (void) printf("\n");
2N/A free(listpp);
2N/A } else {
2N/A (void) printf("list_dd: listpp: 0x%p, count: %d\n",
2N/A (void *)listpp, count);
2N/A }
2N/A
2N/A /* open_dd - dhcptab (create) */
2N/A (void) printf("open_dd: dhcptab: ... ");
2N/A error = open_dd(&handle, &dsp, DSVC_DHCPTAB, "dhcptab",
2N/A DSVC_CREATE | DSVC_READ | DSVC_WRITE);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A if (error != DSVC_SUCCESS)
2N/A return (1);
2N/A
2N/A /* add_dd_entry - dhcptab */
2N/A {
2N/A dt_rec_t recs[5];
2N/A
2N/A (void) strcpy(recs[0].dt_key, "172.21.0.0");
2N/A recs[0].dt_type = DT_MACRO;
2N/A recs[0].dt_value = ":Router=172.21.0.1:Subnet=255.255.0.0:";
2N/A
2N/A (void) strcpy(recs[1].dt_key, "172.20.64.0");
2N/A recs[1].dt_type = DT_MACRO;
2N/A recs[1].dt_value =
2N/A ":Router=172.20.64.2:Subnet=255.255.255.192:";
2N/A
2N/A (void) strcpy(recs[2].dt_key, "172.20.64.64");
2N/A recs[2].dt_type = DT_MACRO;
2N/A recs[2].dt_value =
2N/A ":Router=172.20.64.65:Subnet=255.255.255.192:";
2N/A
2N/A (void) strcpy(recs[3].dt_key, "172.20.64.128");
2N/A recs[3].dt_type = DT_MACRO;
2N/A recs[3].dt_value =
2N/A ":Router=172.20.64.129:Subnet=255.255.255.128:";
2N/A
2N/A (void) strcpy(recs[4].dt_key, "172.22.0.0");
2N/A recs[4].dt_type = DT_MACRO;
2N/A recs[4].dt_value =
2N/A ":Router=172.22.0.1:Subnet=255.255.0.0:MTU=4532:";
2N/A
2N/A (void) printf("add_dd_entry: ... key type value\n");
2N/A for (i = 0; i < sizeof (recs) / sizeof (dt_rec_t); i++) {
2N/A (void) printf(" %s %c %s ... ",
2N/A recs[i].dt_key, recs[i].dt_type, recs[i].dt_value);
2N/A error = add_dd_entry(handle, &recs[i]);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A if (error != DSVC_SUCCESS)
2N/A break;
2N/A }
2N/A }
2N/A
2N/A /* lookup_dd - dhcptab - macro called '172.20.64.128', then delete it */
2N/A
2N/A DSVC_QINIT(query);
2N/A DSVC_QEQ(query, DT_QKEY);
2N/A DSVC_QEQ(query, DT_QTYPE);
2N/A
2N/A (void) memset(&dt, 0, sizeof (dt));
2N/A (void) strcpy(dt.dt_key, "172.20.64.128");
2N/A dt.dt_type = 'm';
2N/A
2N/A (void) printf("lookup_dd: macro %s ... ", dt.dt_key);
2N/A error = lookup_dd(handle, B_FALSE, query, -1, &dt, (void **)&resdtp,
2N/A &count);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A
2N/A if (error == DSVC_SUCCESS) {
2N/A if (count != 1) {
2N/A (void) printf("lookup_dd: expected 1 record, got %d\n",
2N/A count);
2N/A }
2N/A
2N/A for (i = 0, wtp = resdtp; i < count && wtp != NULL; i++) {
2N/A dtp = wtp->dtl_rec;
2N/A (void) printf(" %s %c %s\n",
2N/A dtp->dt_key, dtp->dt_type, dtp->dt_value);
2N/A wtp = wtp->dtl_next;
2N/A }
2N/A free_dd_list(handle, resdtp);
2N/A }
2N/A
2N/A /* Delete it */
2N/A (void) printf("delete_dd_entry: %s ... ", dt.dt_key);
2N/A error = delete_dd_entry(handle, &dt);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A
2N/A
2N/A /*
2N/A * lookup_dd - dhcptab - macro called '172.21.0.0', and modify its
2N/A * definition and replace the value.
2N/A */
2N/A
2N/A DSVC_QINIT(query);
2N/A DSVC_QEQ(query, DT_QKEY);
2N/A
2N/A (void) memset(&dt, 0, sizeof (dt));
2N/A (void) strcpy(dt.dt_key, "172.21.0.0");
2N/A
2N/A (void) printf("lookup_dd: macro %s ... ", dt.dt_key);
2N/A error = lookup_dd(handle, B_FALSE, query, 1, &dt, (void **)&resdtp,
2N/A &count);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A
2N/A if (error == DSVC_SUCCESS) {
2N/A if (count != 1) {
2N/A (void) printf("lookup_dd: expected 1 record, "
2N/A "got %d\n", count);
2N/A } else {
2N/A dtp = resdtp->dtl_rec;
2N/A (void) printf(" %s %c %s\n", dtp->dt_key,
2N/A dtp->dt_type, dtp->dt_value);
2N/A
2N/A ntp = alloc_dtrec(dtp->dt_key, dtp->dt_type,
2N/A ":Subnet=255.255.0.0:Router=172.21.0.1 "
2N/A "172.21.0.2:MTU=1500:");
2N/A if (ntp != NULL) {
2N/A ntp->dt_sig = dtp->dt_sig;
2N/A
2N/A /* Modify it */
2N/A (void) printf("modify_dd_entry: macro %s ... ",
2N/A dt.dt_key);
2N/A error = modify_dd_entry(handle, dtp, ntp);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A free_dd(handle, ntp);
2N/A }
2N/A }
2N/A free_dd_list(handle, resdtp);
2N/A }
2N/A
2N/A /* lookup_dd - all records */
2N/A
2N/A DSVC_QINIT(query);
2N/A
2N/A (void) printf("lookup_dd: all records ... ");
2N/A error = lookup_dd(handle, B_FALSE, query, -1, &dt, (void **)&resdtp,
2N/A &count);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A if (error == DSVC_SUCCESS) {
2N/A for (i = 0, wtp = resdtp; i < count && wtp != NULL; i++) {
2N/A dtp = wtp->dtl_rec;
2N/A (void) printf(" %s %c %s\n", dtp->dt_key,
2N/A dtp->dt_type, dtp->dt_value);
2N/A wtp = wtp->dtl_next;
2N/A }
2N/A free_dd_list(handle, resdtp);
2N/A }
2N/A
2N/A /* close_dd - dhcptab */
2N/A (void) printf("close_dd: dhcptab ... ");
2N/A error = close_dd(&handle);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A
2N/A /* list_dd - dhcp network containers */
2N/A (void) printf("list_dd: dhcptab ... ");
2N/A error = list_dd(&dsp, DSVC_DHCPTAB, &listpp, &count);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A if (error == DSVC_SUCCESS) {
2N/A (void) printf(" %d dhcp network container(s): ", count);
2N/A for (i = 0; i < count; i++) {
2N/A (void) printf("%s ", listpp[i] != NULL ?
2N/A listpp[i] : "NULL");
2N/A free(listpp[i]);
2N/A }
2N/A free(listpp);
2N/A (void) printf("\n");
2N/A } else {
2N/A (void) printf("list_dd: listpp: 0x%p, count: %d\n",
2N/A (void *)listpp, count);
2N/A }
2N/A
2N/A /* remove_dd - dhcptab */
2N/A (void) printf("remove_dd: dhcptab ... ");
2N/A error = remove_dd(&dsp, DSVC_DHCPTAB, NULL);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A
2N/A /* open_dd - 129.148.5.0 create */
2N/A (void) printf("\nopen_dd: 129.148.5.0: ... ");
2N/A error = open_dd(&handle, &dsp, DSVC_DHCPNETWORK, "129.148.5.0",
2N/A DSVC_CREATE | DSVC_READ | DSVC_WRITE);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A if (error != DSVC_SUCCESS)
2N/A return (1);
2N/A
2N/A /* add_dd_entry - 129.148.5.0 */
2N/A {
2N/A uchar_t cid0[7] = { 0x01, 0x08, 0x00, 0x20, 0x00, 0x00, 0x01 };
2N/A dn_rec_t recs[5] = { 0 };
2N/A
2N/A recs[0].dn_cid_len = sizeof (cid0);
2N/A recs[0].dn_flags = 2;
2N/A recs[0].dn_cip.s_addr = 0x81940502;
2N/A recs[0].dn_sip.s_addr = 0x81940501;
2N/A (void) memcpy(recs[0].dn_cid, cid0, sizeof (cid0));
2N/A (void) strlcpy(recs[0].dn_macro, "myserv", DSVC_MAX_MACSYM_LEN);
2N/A (void) strlcpy(recs[0].dn_comment, "dave", DN_MAX_COMMENT_LEN);
2N/A
2N/A recs[1].dn_cid_len = 1;
2N/A recs[1].dn_flags = 1;
2N/A recs[1].dn_cip.s_addr = 0x81940503;
2N/A recs[1].dn_sip.s_addr = 0x81940501;
2N/A (void) strlcpy(recs[1].dn_macro, "myserv", DSVC_MAX_MACSYM_LEN);
2N/A (void) strlcpy(recs[1].dn_comment, "meem", DN_MAX_COMMENT_LEN);
2N/A
2N/A recs[2].dn_cid_len = 1;
2N/A recs[2].dn_cip.s_addr = 0x81940504;
2N/A recs[2].dn_sip.s_addr = 0x81940501;
2N/A (void) strlcpy(recs[2].dn_macro, "myserv", DSVC_MAX_MACSYM_LEN);
2N/A (void) strlcpy(recs[2].dn_comment, "cpj", DN_MAX_COMMENT_LEN);
2N/A
2N/A recs[3].dn_cid_len = 1;
2N/A recs[3].dn_cip.s_addr = 0x81940505;
2N/A recs[3].dn_sip.s_addr = 0x81940501;
2N/A (void) strlcpy(recs[3].dn_macro, "myserv", DSVC_MAX_MACSYM_LEN);
2N/A (void) strlcpy(recs[3].dn_comment, "mwc", DN_MAX_COMMENT_LEN);
2N/A
2N/A recs[4].dn_cid_len = 1;
2N/A recs[4].dn_cip.s_addr = 0x81940506;
2N/A recs[4].dn_sip.s_addr = 0x81940501;
2N/A (void) strlcpy(recs[4].dn_macro, "myserv", DSVC_MAX_MACSYM_LEN);
2N/A (void) strlcpy(recs[4].dn_comment, "markh", DN_MAX_COMMENT_LEN);
2N/A
2N/A (void) printf("add_dd_entry: ... cid flag cip sip lease "
2N/A "macro comment\n");
2N/A for (i = 0; i < sizeof (recs) / sizeof (dn_rec_t); i++) {
2N/A cidlen = sizeof (cid);
2N/A (void) octet_to_hexascii(recs[i].dn_cid,
2N/A recs[i].dn_cid_len, cid, &cidlen);
2N/A (void) printf(" %s %d %s %s %u %s %s ... ",
2N/A cid, recs[i].dn_flags,
2N/A inet_ntop(AF_INET, &recs[i].dn_cip, cip,
2N/A INET_ADDRSTRLEN),
2N/A inet_ntop(AF_INET, &recs[i].dn_sip, sip,
2N/A INET_ADDRSTRLEN),
2N/A recs[i].dn_lease, recs[i].dn_macro,
2N/A recs[i].dn_comment);
2N/A
2N/A error = add_dd_entry(handle, &recs[i]);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A if (error != DSVC_SUCCESS)
2N/A break;
2N/A }
2N/A }
2N/A
2N/A /* lookup_dd - lookup all records. */
2N/A DSVC_QINIT(query);
2N/A
2N/A (void) printf("lookup_dd: 129.148.5.0 ... ");
2N/A error = lookup_dd(handle, B_FALSE, query, -1, &dn, (void **)&resdnp,
2N/A &count);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A if (error == DSVC_SUCCESS) {
2N/A for (i = 0, wnp = resdnp; i < count && wnp != NULL; i++) {
2N/A dnp = wnp->dnl_rec;
2N/A cidlen = sizeof (cid);
2N/A (void) octet_to_hexascii(dnp->dn_cid,
2N/A dnp->dn_cid_len, cid, &cidlen);
2N/A (void) inet_ntop(AF_INET, &dnp->dn_cip,
2N/A cip, INET_ADDRSTRLEN);
2N/A (void) inet_ntop(AF_INET, &dnp->dn_sip,
2N/A sip, INET_ADDRSTRLEN);
2N/A (void) printf(" %s %02u %s %s %u '%s' #%s\n",
2N/A cid, dnp->dn_flags, cip, sip, dnp->dn_lease,
2N/A dnp->dn_macro, dnp->dn_comment);
2N/A wnp = wnp->dnl_next;
2N/A }
2N/A free_dd_list(handle, resdnp);
2N/A }
2N/A
2N/A /* delete_dd_entry - 129.148.5.3 */
2N/A dn.dn_sig = 0;
2N/A dn.dn_cip.s_addr = ntohl(inet_addr("129.148.5.3"));
2N/A (void) printf("delete_dd_entry: 129.148.5.3 ... ");
2N/A error = delete_dd_entry(handle, &dn);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A
2N/A /*
2N/A * lookup_dd - 129.148.5.0 - record with cid of 01080020000001, modify
2N/A * flags to MANUAL+BOOTP, lease to -1, macro to foobar, and server to
2N/A * 129.148.174.27.
2N/A */
2N/A DSVC_QINIT(query);
2N/A DSVC_QEQ(query, DN_QCID);
2N/A
2N/A (void) memset(&dn, 0, sizeof (dn));
2N/A dn.dn_cid[0] = 0x1;
2N/A dn.dn_cid[1] = 0x8;
2N/A dn.dn_cid[2] = 0x0;
2N/A dn.dn_cid[3] = 0x20;
2N/A dn.dn_cid[4] = 0x0;
2N/A dn.dn_cid[5] = 0x0;
2N/A dn.dn_cid[6] = 0x1;
2N/A dn.dn_cid_len = 7;
2N/A
2N/A (void) printf("lookup_dd: 01080020000001 ... ");
2N/A error = lookup_dd(handle, B_FALSE, query, 1, &dn, (void **)&resdnp,
2N/A &count);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A
2N/A if (error == DSVC_SUCCESS) {
2N/A if (count != 1) {
2N/A (void) printf("lookup_dd: expected 1 record, got %d\n",
2N/A count);
2N/A } else {
2N/A dnp = resdnp->dnl_rec;
2N/A dn = *dnp; /* struct copy */
2N/A
2N/A dn.dn_flags = DN_FMANUAL | DN_FBOOTP_ONLY;
2N/A dn.dn_lease = DHCP_PERM;
2N/A (void) strcpy(dn.dn_macro, "foobar");
2N/A dn.dn_sip.s_addr = ntohl(inet_addr("129.148.174.27"));
2N/A
2N/A /* Modify it */
2N/A (void) printf("modify_dd_entry: 01080020000001 ... ");
2N/A error = modify_dd_entry(handle, dnp, &dn);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A }
2N/A free_dd_list(handle, resdnp);
2N/A }
2N/A
2N/A /* lookup_dd - lookup all fields with DN_FMANUAL set */
2N/A
2N/A DSVC_QINIT(query);
2N/A DSVC_QEQ(query, DN_QFMANUAL);
2N/A
2N/A (void) memset(&dn, 0, sizeof (dn));
2N/A dn.dn_flags = DN_FMANUAL;
2N/A
2N/A (void) printf("lookup_dd: F_MANUAL ... ");
2N/A error = lookup_dd(handle, B_FALSE, query, 1, &dn, (void **)&resdnp,
2N/A &count);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A
2N/A if (error == DSVC_SUCCESS) {
2N/A if (count != 1) {
2N/A (void) printf("lookup_dd: expected 1 record, "
2N/A "got %d\n", count);
2N/A } else {
2N/A dnp = resdnp->dnl_rec;
2N/A cidlen = sizeof (cid);
2N/A (void) octet_to_hexascii(dnp->dn_cid,
2N/A dnp->dn_cid_len, cid, &cidlen);
2N/A (void) inet_ntop(AF_INET, &dnp->dn_cip,
2N/A cip, INET_ADDRSTRLEN);
2N/A (void) inet_ntop(AF_INET, &dnp->dn_sip,
2N/A sip, INET_ADDRSTRLEN);
2N/A (void) printf(" %s %02u %s %s %u '%s' #%s\n",
2N/A cid, dnp->dn_flags, cip, sip, dnp->dn_lease,
2N/A dnp->dn_macro, dnp->dn_comment);
2N/A }
2N/A free_dd_list(handle, resdnp);
2N/A }
2N/A
2N/A /* lookup_dd - lookup all records. */
2N/A
2N/A DSVC_QINIT(query);
2N/A
2N/A (void) printf("lookup_dd: 129.148.5.0 ...");
2N/A error = lookup_dd(handle, B_FALSE, query, -1, &dn, (void **)&resdnp,
2N/A &count);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A
2N/A if (error == DSVC_SUCCESS) {
2N/A for (i = 0, wnp = resdnp; i < count && wnp != NULL; i++) {
2N/A cidlen = sizeof (cid);
2N/A dnp = wnp->dnl_rec;
2N/A (void) octet_to_hexascii(dnp->dn_cid,
2N/A dnp->dn_cid_len, cid, &cidlen);
2N/A (void) inet_ntop(AF_INET, &dnp->dn_cip,
2N/A cip, INET_ADDRSTRLEN);
2N/A (void) inet_ntop(AF_INET, &dnp->dn_sip,
2N/A sip, INET_ADDRSTRLEN);
2N/A (void) printf(" %s %02u %s %s %u '%s' #%s\n",
2N/A cid, dnp->dn_flags, cip, sip, dnp->dn_lease,
2N/A dnp->dn_macro, dnp->dn_comment);
2N/A wnp = wnp->dnl_next;
2N/A }
2N/A free_dd_list(handle, resdnp);
2N/A }
2N/A
2N/A /* close_dd - 129.148.5.0 */
2N/A (void) printf("close_dd: 129.148.5.0 ... ");
2N/A error = close_dd(&handle);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A
2N/A /* list_dd - dhcp network containers */
2N/A (void) printf("list_dd: ... ");
2N/A error = list_dd(&dsp, DSVC_DHCPNETWORK, &listpp, &count);
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A if (error == DSVC_SUCCESS) {
2N/A (void) printf(" %d dhcp network container(s): ", count);
2N/A for (i = 0; i < count; i++) {
2N/A (void) printf("%s ", listpp[i] != NULL ?
2N/A listpp[i] : "NULL");
2N/A free(listpp[i]);
2N/A }
2N/A free(listpp);
2N/A (void) printf("\n");
2N/A } else {
2N/A (void) printf("list_dd: listpp: 0x%p, count: %d\n",
2N/A (void *)listpp, count);
2N/A }
2N/A
2N/A /* remove_dd - 129.148.5.0 */
2N/A (void) printf("remove_dd_entry: 129.148.5.0 ... ");
2N/A error = remove_dd(&dsp, DSVC_DHCPNETWORK, "129.148.5.0");
2N/A (void) printf("%s\n", dhcpsvc_errmsg(error));
2N/A
2N/A return (0);
2N/A}