/*
* 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 2001-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <strings.h>
#include <string.h>
#include <fcntl.h>
#include <assert.h>
#include <libipp.h>
#include <libnvpair.h>
/*
* Debug macros
*/
/*
* DBG_IO |
*/
DBG_ERR |
0;
do { \
if (flags & ipp_debug_flags) \
} while (0)
do { \
if (flags & ipp_debug_flags) \
} while (0)
do { \
if (flags & ipp_debug_flags) \
b); \
} while (0)
do { \
if (flags & ipp_debug_flags) \
b, c); \
} while (0)
#else /* defined(DEBUG) && !defined(lint) */
#endif /* defined(DEBUG) && !defined(lint) */
/*
* Control device node
*/
/*
* Structures.
*/
typedef struct array_desc_t {
char *name;
char **array;
int nelt;
} array_desc_t;
/*
* Prototypes
*/
static int nvlist_callback(nvlist_t *, void *);
static int string_callback(nvlist_t *, void *);
static int string_array_callback(nvlist_t *, void *);
/*
* API functions
*/
int
const char *modname,
const char *aname,
{
int rc;
/*
* Sanity check the arguments.
*/
return (-1);
}
/*
* Add our data to the nvlist. (This information will be removed for
* use by ippctl).
*/
IPPCTL_OP_ACTION_CREATE)) != 0) {
goto failed;
}
(char *)modname)) != 0) {
goto failed;
}
goto failed;
}
goto failed;
}
/*
* Talk to the kernel.
*/
return (-1);
}
int
const char *aname,
{
int rc;
/*
* Sanity check the arguments.
*/
return (-1);
}
/*
* Create an nvlist for our data as none is passed into the function.
*/
goto failed;
}
IPPCTL_OP_ACTION_DESTROY)) != 0) {
goto failed;
}
goto failed;
}
goto failed;
}
/*
* Talk to the kernel.
*/
return (-1);
}
int
const char *aname,
{
int rc;
/*
* Sanity check the arguments.
*/
return (-1);
}
/*
* Add our data to the nvlist.
*/
IPPCTL_OP_ACTION_MODIFY)) != 0) {
goto failed;
}
goto failed;
}
goto failed;
}
/*
* Talk to the kernel.
*/
return (-1);
}
int
const char *aname,
void *arg,
{
int rc;
/*
* Sanity check the arguments.
*/
return (-1);
}
/*
* Create an nvlist for our data.
*/
}
IPPCTL_OP_ACTION_INFO)) != 0) {
goto failed;
}
goto failed;
}
goto failed;
}
/*
* Talk to the kernel.
*/
return (-1);
}
int
const char *aname,
char **modnamep)
{
int rc;
/*
* Sanity check the arguments.
*/
return (-1);
}
/*
* Create an nvlist for our data.
*/
goto failed;
}
IPPCTL_OP_ACTION_MOD)) != 0) {
goto failed;
}
goto failed;
}
/*
* Talk to the kernel.
*/
return (-1);
}
int
char ***modname_arrayp,
int *neltp)
{
int rc;
/*
* Sanity check the arguments.
*/
return (-1);
}
/*
* Create an nvlist for our data.
*/
}
IPPCTL_OP_LIST_MODS)) != 0) {
goto failed;
}
/*
* Talk to the kernel.
*/
}
return (rc);
return (-1);
}
int
const char *modname,
char ***aname_arrayp,
int *neltp)
{
int rc;
/*
* Sanity check the arguments.
*/
return (-1);
}
/*
* Create an nvlist for our data.
*/
}
IPPCTL_OP_MOD_LIST_ACTIONS)) != 0) {
goto failed;
}
(char *)modname)) != 0) {
goto failed;
}
/*
* Talk to the kernel.
*/
}
return (rc);
return (-1);
}
void
char *buf)
{
}
void
char **array,
int nelt)
{
int i;
for (i = 0; i < nelt; i++)
}
static int
void *arg)
{
int rc;
/*
* Callback function used by ipp_action_create() and
* ipp_action_modify()
*/
/*
* Duplicate the nvlist and set the given pointer to point at the new
* copy.
*/
return (-1);
}
return (0);
}
static int
void *arg)
{
char *name;
char *ptr;
int rc;
/*
* Callback function used by ipp_action_mod()
*/
/*
* Look up the module name from the nvlist.
*/
return (-1);
}
/*
* Allocate a duplicate string.
*/
return (-1);
}
/*
* Set the given pointer to point at the string.
*/
return (0);
}
static int
void *arg)
{
char **dst;
char **src;
int i;
int rc;
/*
* Callback function used by ipp_list_mods()
*/
/*
* Look up the module name from the nvlist.
*/
&nelt)) != 0) {
return (-1);
}
/*
* Allocate an array.
*/
return (-1);
}
/*
* For each string in the array, allocate a new buffer and copy
* the string into it.
*/
for (i = 0; i < nelt; i++) {
while (--i >= 0) {
}
return (-1);
}
}
/*
* Set the information to be passed back.
*/
return (0);
}
static int
void *arg)
{
int rc;
int fd;
int count;
int rval;
/*
* Sanity check the 'command' nvlist.
*/
return (-1);
}
/*
* Pack the nvlist and then free the original.
*/
0)) != 0) {
return (-1);
}
/*
* Open the control device node.
*/
goto command_failed;
}
/*
* Set up an ioctl structure to point at the packed nvlist.
*/
/*
* Issue a command ioctl, passing the ioctl structure.
*/
goto command_failed;
}
/*
* Get back the length of the first data buffer.
*/
goto command_failed;
}
/*
* Try to re-use the command buffer as the first data buffer.
*/
count = 0;
while (nextbuflen != 0) {
/*
* Check whether the buffer we have is long enough for the
* next lot of data. If it isn't, allocate a new one of
* the appropriate length.
*/
if (nextbuflen > thisbuflen) {
"failed to allocate data buffer\n");
goto data_failed;
}
}
/*
* Set up an ioctl structure to point at the data buffer.
*/
/*
* Issue a data ioctl, passing the ioctl structure.
*/
goto data_failed;
}
/*
* Get the length of the *next* data buffer, if there is
* one.
*/
/*
* Unpack the nvlist that the current data buffer should
* now contain.
*/
goto data_failed;
}
/*
* The first data buffer should contain the kernel function's
* return code. Subsequent buffers contain nvlists which
* should be passed to the given callback function.
*/
if (count == 0) {
&rval)) != 0) {
goto data_failed;
}
} else {
/*
* The callback function returned
* a non-zero value. Abort any further
* data collection.
*/
}
}
/*
* Free the nvlist now that we have extracted the return
* code or called the callback function.
*/
count++;
}
/*
* Free the data buffer as data collection is now complete.
*/
/*
* Close the control device.
*/
/*
* If the kernel returned an error, we should return an error.
* and set errno.
*/
if (rval != 0) {
return (-1);
}
return (0);
if (fd != -1)
return (-1);
return (-1);
}