service.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <wordexp.h>
#include <string.h>
#include <malloc.h>
#include <libintl.h>
#include <errno.h>
#include <dhcp_svc_private.h>
#include <dhcp_svc_confkey.h>
#include <jni.h>
#include <libscf.h>
#include <com_sun_dhcpmgr_bridge_Bridge.h>
#include "exception.h"
#include "dd_misc.h"
#include "class_cache.h"
#define DHCP_SERVER_INST "svc:/network/dhcp-server:default"
#define DHCPD_FNAME "in.dhcpd"
#define CONFOPT_MODE 0644
/*
* Gets called when the library is loaded.
*/
/*ARGSUSED*/
void *reserved)
{
return (JNI_ERR);
}
return (JNI_VERSION_1_2);
}
/*
* Determine whether an upgrade of the datastore is necessary.
*/
/*ARGSUSED*/
{
int cfgVersion;
int curVersion;
int rcode;
/* Get the data store configuration */
if (rcode != DSVC_SUCCESS) {
} else {
if (curVersion == cfgVersion) {
}
}
}
return (result);
}
/*
* Retrieve the data store object for the specified resource.
*/
/*ARGSUSED*/
{
char *resource;
/* Make sure we have the classes & methods we need */
/* exception thrown */
return (NULL);
}
/* exception thrown */
return (NULL);
}
/* Retrieve the resource argument */
/* exception thrown */
return (NULL);
}
}
return (dsObject);
}
/*
* Retrieve the list of data stores available for DHCP. Returns an array of
* DHCP datastore names.
*/
/*ARGSUSED*/
{
char **list;
int i, len;
/* Make sure we have the classes & methods we need */
/* exception thrown */
return (NULL);
}
/* exception thrown */
return (NULL);
}
/* Get the list */
return (NULL);
}
/* Compute the length of the array, store in len */
/* Construct the array */
/* exception thrown */
return (NULL);
}
/* For each store, create an object and add it to the array */
for (i = 0; i < len; ++i) {
/* exception thrown */
break;
}
}
/* exception thrown */
break;
}
break;
}
}
return (jlist);
}
/*
* Read the config file for DHCP and return its contents as a DhcpdOptions
* object.
*/
/*ARGSUSED*/
{
/* Make sure we have the classes & methods we need */
/* exception thrown */
return (NULL);
}
/* exception thrown */
return (NULL);
}
/* exception thrown */
return (NULL);
}
/* Get the data */
if (read_dsvc_conf(&cfgs) != 0) {
} else {
/* Construct returned options object */
/* exception thrown */
return (NULL);
}
/* Load the option settings into the options object */
for (;;) {
} else {
break;
}
}
return (NULL);
}
++cfgs;
}
}
return (cfgobj);
}
/*
* Write the DHCP config file. Takes a DhcpdOptions object as input
*/
/*ARGSUSED*/
{
int i;
const char *tmpstr;
/* Make sure we can get at the classes we need */
/* exception thrown */
return;
}
if (cfg_getall == NULL) {
/* exception thrown */
return;
}
/* exception thrown */
return;
}
/* exception thrown */
return;
}
/* Get the resource array from the config object */
return;
}
/* Allocate array to convert into; extra zero'd item to signal end */
return;
}
/* Now copy data into local array */
for (i = 0; i < reslen; ++i) {
/* exception thrown */
return;
}
/* Set record type */
return;
}
} else {
}
/*
* Get the key from the object, convert to a char *,
* and then duplicate into the cfgs array so that
* free_dsvc_conf can be used correctly.
* Do the same thing for the value.
*/
/* exception thrown */
gettext("Error converting key"));
return;
}
/* Out of memory, fail */
return;
}
gettext("Error converting value"));
return;
}
/* Out of memory, fail */
return;
}
}
/* Now write the new data */
}
}
/*
* Remove the DHCP config file
*/
/*ARGSUSED*/
{
if (delete_dsvc_conf() != 0) {
}
}
/*
* Start up the daemon.
*/
/*ARGSUSED*/
{
char *s;
int ret;
/*
* We first get the current state of the server according to
* svc.startd; if it's "disabled", we can just enable it.
* In any other case, we want to send a refresh so that
* dependencies are re-evaluated, which will be the case if the
* service was marked enabled by the profile, yet the
* config file didn't exist to allow it to run.
*/
if (strcmp(SCF_STATE_STRING_DISABLED, s) == 0)
else
free(s);
if (ret == 0)
return;
}
/* Something wasn't right, return exception with error from smf */
}
/*
* Shut down the daemon.
*/
/*ARGSUSED*/
{
if (smf_disable_instance(DHCP_SERVER_INST, 0) != 0) {
}
}
/*
* Tell the daemon to re-read the dhcptab.
*/
/*ARGSUSED*/
{
int err;
if (err == -1) {
/* dd_signal couldn't find in.dhcpd running */
} else {
}
}
}
/*
* Make the resource location.
*/
/*ARGSUSED*/
{
int rcode;
/* Create a dsvc_datastore_t using args and DHCP config file */
/* exception thrown */
return;
}
/* If the location does not already exist, go create it. */
if (rcode != DSVC_SUCCESS) {
}
}
}
/*
* Check if the server is running; returns true if so, false if not.
*/
/*ARGSUSED*/
{
return (JNI_TRUE);
} else {
return (JNI_FALSE);
}
}
/*
* Retrieve the list of interfaces on the system which are candidates for
* use by the DHCP daemon. Returns an array of IPInterface objects.
*/
/*ARGSUSED*/
{
struct ip_interface **list;
int i;
/* Locate the class and constructor we need */
if (ipif_class == NULL) {
/* exception thrown */
return (NULL);
}
return (NULL);
}
/* Retrieve interface list */
list = dd_get_interfaces();
gettext("Error in dd_get_interfaces"));
return (NULL);
}
/* Compute length of list */
/* Construct the array */
/* exception thrown */
for (i = 0; i < len; i++) {
}
return (NULL);
}
/* For each interface, construct an object and add to the array */
for (i = 0; i < len; ++i) {
/* exception thrown */
break;
}
break;
}
}
for (i = 0; i < len; i++) {
}
return (jlist);
}
/*
* Parse a line into arguments.
*/
/*ARGSUSED*/
{
int flags = WRDE_NOCMD;
char *line;
int i, ret;
/* Go ahead and get the class for a String class */
/* exception thrown */
return (NULL);
}
/* Retrieve the line argument */
/* exception thrown */
return (NULL);
}
/* Retrieve argument list */
if (ret != 0) {
/* Free memory for the one error case where it's allocated */
if (ret == WRDE_NOSPACE)
return (NULL);
}
/* Construct the array */
/* exception thrown */
return (NULL);
}
/* For each argument, create an object and add it to the array */
/* exception thrown */
break;
}
break;
}
}
return (jlist);
}