dd_misc.c revision 36e852a172cba914383d7341c988128b2c667fbd
/*
* 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
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <dhcp_svc_private.h>
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <libintl.h>
#include <procfs.h>
#include <malloc.h>
#include <ctype.h>
#include <jni.h>
#include "exception.h"
#include "class_cache.h"
#include "dd_misc.h"
#define PROCFS_DIR "/proc"
/*
* Frees the list of data store strings.
*/
static void
{
while (count-- > 0) {
}
}
/*
* Determines if a given data store name is valid.
*/
static boolean_t
{
char **module;
int count;
int ndx;
int rcode;
if (rcode != DSVC_SUCCESS) {
} else {
}
}
}
}
return (isValid);
}
/*
* Call a java object's int getter method.
*/
static boolean_t
int id,
int *value) {
} else {
} else {
}
}
return (noException);
}
/*
* Convert a possibly multi-byte string to a jstring.
*/
{
jbyteArray bytes = 0;
int len;
/* exception thrown */
return (NULL);
}
/* exception thrown */
return (NULL);
}
/* exception thrown */
return (NULL);
}
return (result);
}
/*
* Convert a jstring to a possibly multi-byte string.
*/
char *
jbyteArray bytes = 0;
char *result;
/* exception thrown */
return (NULL);
}
/* exception thrown */
return (NULL);
}
/* exception thrown */
return (NULL);
}
return (NULL);
}
return (result);
}
/*
* Convert a jstring to a UTF-8 string.
*/
char **nativeString)
{
if (javaString != NULL) {
const char *str;
} else {
if (*nativeString == NULL) {
}
}
} else {
*nativeString = NULL;
}
return (noException);
}
/*
* Call a java object's string getter method.
*/
int id,
char **value) {
return (B_FALSE);
}
return (B_FALSE);
}
return (B_FALSE);
}
}
return (B_TRUE);
}
/*
* Reads the DHCP configuration file and creates a dsvc_datastore_t.
*/
int result;
if (result != 0) {
} else {
if (result != DSVC_SUCCESS) {
}
}
return (noException);
}
/*
* Makes a dsvc_datastore_t using the DHCP configuration file and overriding
* the settings with the arguments if they are non-NULL.
*/
jthrowable e;
int version = DSVC_CUR_CONVER;
/* Locate the class we need */
/* exception thrown */
return (B_FALSE);
}
/* Obtain the DHCP config file data store settings */
if (!is_no_defaults_exception(env, e)) {
return (B_FALSE);
}
}
/* Get the resource */
jdatastore, &resource)) {
/* exception thrown */
return (B_FALSE);
}
/* If resource was passed in, then override config setting */
}
/* Validate the resource */
}
return (B_FALSE);
}
/* Get the location */
jdatastore, &location)) {
/* exception thrown */
return (B_FALSE);
}
/* If location was passed in, then override config setting */
}
/* Must be defined */
return (B_FALSE);
}
/* Get the config string */
jdatastore, &config)) {
/* exception thrown */
return (B_FALSE);
}
/* If config string was passed in, then override config setting */
}
/* Get the version */
jdatastore, &version)) {
/* exception thrown */
return (B_FALSE);
}
/* If version was passed in, then override config setting */
if (version != DSVC_CUR_CONVER) {
}
return (B_TRUE);
}
/*
* Frees the strings in a dsvc_datastore_t structure.
*/
void
}
/*
* Returns the list of possible data stores for DHCP data.
* List returned is terminated with a NULL.
*/
char **
{
char **module;
int count;
int ndx;
int rcode;
if (rcode != DSVC_SUCCESS) {
return (NULL);
}
if (count == 0) {
return (NULL);
}
return (NULL);
}
break;
}
}
}
return (dsl);
}
/*
* Free a data store list created by dd_data_stores().
*/
void
dd_free_data_stores(char **dsl)
{
int i = 0;
}
}
}
/*
* Send a signal to a process whose command name is as specified
*/
int
{
return (-1);
}
return (errno);
} else {
return (0);
}
}
/*
* Return a process's pid
*/
{
int proc_fd;
char buf[MAXPATHLEN];
/*
* Read entries in /proc, each one is in turn a directory
* containing files relating to the process's state. We read
* the psinfo file to get the command name.
*/
return (retval);
}
continue; /* skip this one */
}
break;
}
}
}
return (retval);
}
/*
* Get list of physical, non-loopback interfaces for the system. Those are
* the ones in.dhcpd will support.
*/
struct ip_interface **
{
int s;
int num_ifs;
int i;
struct ip_interface **tmpret;
int retcnt = 0;
struct sockaddr_in *sin;
/*
* Open socket, needed for doing the ioctls. Then get number of
* interfaces so we know how much memory to allocate, then get
* all the interface configurations.
*/
(void) close(s);
return (NULL);
}
(void) close(s);
return (NULL);
}
(void) close(s);
return (NULL);
}
/*
* For each interface, stuff its name, address and netmask into the
* structure that we return. Filter out loopback and virtual
* interfaces as they are of no interest for DHCP.
*/
continue; /* Ignore a virtual interface */
}
continue; /* Can't get flags? Ignore it. */
}
continue; /* Ignore if loopback or down */
}
/* Get more space to store this in */
while (retcnt-- > 0)
(void) close(s);
return (NULL);
}
while (retcnt-- > 0)
(void) close(s);
return (NULL);
}
(void) close(s);
while (retcnt-- > 0) {
}
return (NULL);
}
/*LINTED - alignment*/
(void) close(s);
while (retcnt-- > 0) {
}
return (NULL);
}
/*LINTED - alignment*/
++retcnt;
}
/* Null-terminate the list */
if (retcnt > 0) {
while (retcnt-- > 0)
(void) close(s);
return (NULL);
}
}
(void) close(s);
return (ret);
}