/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this 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 <alloca.h>
#include <string.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 *
{
unsigned int i;
return (NULL);
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
{
unsigned int i;
return (-1);
}
return (-1);
}
;
return (-1);
}
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
{
int dd;
int error;
unsigned int entry;
return (-1);
}
return (-1);
return (-1);
}
return (-1);
}
break;
continue;
*eol = '\0';
if (*cp == '#') {
goto nomem;
} else {
continue;
*value = '\0';
goto nomem;
goto nomem;
}
}
/* always allocate a spare slot for the zeroed entry */
goto nomem;
entry++;
}
return (-1);
return (0);
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
{
int err;
return (-1);
}
char *valp;
return (-1); /* NOMEM */
errno = 0;
err = 0;
} else
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
* specified by the mode argument (and modified by the umask). Caller is
* responsible for freeing the array.
*/
int
{
int tdd;
char *tmpbuf;
return (-1);
}
/* guess at final file size */
} else
}
if (size == 0) {
return (-1);
}
thr_self());
return (-1);
else
ddp[i].co_comment);
/* Nuke the file if we can't successfully update it */
return (-1);
}
}
/* Move new file into place */
return (-1);
}
return (0);
}
/*
* Frees the memory associated with the ddp array.
*/
void
{
unsigned int i;
return;
} else
}
}
/*
* Deletes the configuration file.
*/
int
delete_dsvc_conf(void)
{
}
/*
* 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
{
return (-1);
}
return (-1);
}
errno = 0;
return (0);
}
return (-1);
}
/*
* Given a dhcp_confopt_t structure, fill in a dsvc_datastore_t.
* Data is copied from dhcp_confopt_t structure.
*/
int
{
return (DSVC_INVAL);
return (DSVC_BAD_CONVER);
return (DSVC_BAD_RESOURCE);
return (DSVC_BAD_PATH);
}
/*
* RESOURCE_CONFIG is optional - underlying service will complain
* if it isn't right.
*/
return (DSVC_SUCCESS);
}