inetcfg_nic.c revision d62bc4badc1c1f1549c961cfb8b420e650e1272b
/*
* 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"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <libdevinfo.h>
#include <inetcfg.h>
/*
* Always traverse the device tree from the root.
*/
#define NIC_DEVTREE_ROOT "/"
/*
* Private structure used to create a linked list
* of interfaces.
*/
typedef struct niclist {
} niclist_t;
/*
* Private structure used by di_walk_minor().
*/
typedef struct wlkreq {
int *wr_numif;
int *wr_syserr;
int *wr_err;
} wlkreq_t;
/*
* Called by di_walk_node() to walk the list of device nodes and
* force all nodes of type "network" to be loaded.
*
* Returns: DI_WALK_CONTINUE
*/
static int
{
char *pdevtype;
int ret;
/*
* Only want to process nodes whose device_type is "network".
*/
return (DI_WALK_CONTINUE);
}
/*
* If the instance is '-1', then the driver for the device
* has not been loaded - so force it to be loaded. Ignore
* errors loading the driver.
*/
if (node != DI_NODE_NIL) {
}
}
return (DI_WALK_CONTINUE);
}
/*
* Force all "network" drivers to be loaded.
*
* Returns: ICFG_SUCCESS or ICFG_FAILURE. In the case of
* ICFG_FAILURE, syserr will contain the errno.
*/
static int
nic_load_drivers(int *syserr)
{
int ret;
if (root_node == DI_NODE_NIL) {
return (ICFG_FAILURE);
}
/*
* Create handle to PROM
*/
return (ICFG_FAILURE);
}
/*
* Walk nodes and make sure all network devices have
* drivers loaded so that devinfo has accurate data.
*/
if (ret != 0) {
return (ICFG_FAILURE);
}
/*
* Clean up handles
*/
return (ICFG_SUCCESS);
}
/*
* Add an interface to the niclist.
*
* Returns: ICFG_SUCCESS or ICFG_FAILURE. In the case of
* ICFG_FAILURE, syserr will contain the errno.
*/
static int
{
/*
* Allocate new niclist.
*/
return (ICFG_FAILURE);
}
/*
* If instance is -1, then no need to append instance.
*/
if (instance == -1) {
} else {
}
/*
* Add entry to list.
*/
return (ICFG_SUCCESS);
}
/*
* Called by di_walk_minor() to walk the list
* of ddi_network minor device nodes and add
* the interface to the niclist.
*
* Returns: DI_WALK_CONTINUE or DI_WALK_TERMINATE.
*/
static int
{
char *name;
char *nodetype;
int instance;
int ret;
/*
* Look for network devices only. Unfortunately, our walk will
* include nodes with nodetypes of NULL.
*/
return (DI_WALK_CONTINUE);
}
/*
* In the case of DDM_MINOR minor nodes, the minor
* name is the name of the driver. However, if the name
* doesn't include the instance, then it's not one
* one we're interested in. In the case of other
* minor nodes, we should be able to get the driver name
* and its instance from the node properties. If they are
* not valid, then we're not interested in them.
*/
return (DI_WALK_CONTINUE);
}
instance = -1;
} else {
(instance == -1)) {
return (DI_WALK_CONTINUE);
}
}
/*
* Add this one to the niclist.
*/
if (ret != ICFG_SUCCESS) {
return (DI_WALK_TERMINATE);
}
return (DI_WALK_CONTINUE);
}
/*
* Frees the resources associated with a niclist.
*/
static void
{
}
}
/*
* Drives the walk of the network minor device nodes to
* build the niclist.
*
* Returns: ICFG_SUCCESS or ICFG_FAILURE. In the case of
* ICFG_FAILURE, syserr will contain the errno.
*/
static int
{
int err = ICFG_SUCCESS;
int ret;
if (root_node == DI_NODE_NIL) {
return (ICFG_FAILURE);
}
/*
* di_walk_minor() only allows one arg to be passed to walker.
*/
if (ret != 0) {
return (ICFG_FAILURE);
}
/*
* On error, free the partially formed list.
*/
if (err != ICFG_SUCCESS) {
*numif = 0;
}
return (err);
}
/*
* Convert a niclist into an icfg_if_t array.
*
* Returns: ICFG_SUCCESS or ICFG_FAILURE. In the case of
* ICFG_FAILURE, syserr will contain the errno.
*/
static int
int *syserr)
{
return (ICFG_FAILURE);
}
listp++;
}
return (ICFG_SUCCESS);
}
/*
* Returns the list of network devices installed
* on the machine as an icfg_if_t array.
*
* Returns: ICFG_SUCCESS or ICFG_FAILURE. In the case of
* ICFG_FAILURE, errno will be set.
*/
int
{
int syserr;
int ret;
goto out;
}
goto out;
}
ICFG_SUCCESS) {
goto out;
}
out:
return (ret);
}