/*
* 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
*/
/*
*/
#include <assert.h>
#include <errno.h>
#include <priv.h>
#include <s10_brand.h>
#include <string.h>
#include <zone.h>
#include "libnetcfg.h"
#include "libnetcfg_impl.h"
/*
* Utility functions for libnetcfg
*/
/*
* Restrict privileges to those needed for basic operations.
*/
int
netcfg_drop_privileges(void)
{
int err = 0;
return (errno);
return (err);
}
/*
* Elevate privileges so we can zone_enter() in order to perform a non-global
* zone op from the global zone. Only one thread will elevate privileges at a
* time which is guaranteed by netcfg_db_lock() in
*/
int
{
int err = 0;
return (errno);
return (err);
}
/*
* Attempt to realloc the passed-in array to double its size. On
* success, pass out new element count and buf pointer and return
* NETCFG_SUCCESS; on failure, the passed-in pointers are unchanged
* and an error code is returned.
*/
{
void *newbuf;
return (NETCFG_NO_MEMORY);
return (NETCFG_SUCCESS);
}
/*
* If the given nvlist contains a string value named NETCFG_OBJECT_DB_NAME,
* returns a pointer to the value associated with that name. Otherwise,
* returns NULL.
*/
char *
{
return (val);
}
/*
* If the given nvlist contains an int64 value named NETCFG_OBJECT_DB_ZONE,
* returns the value associated with that name. Otherwise, returns
* MAX_ZONEID + 1 (-1 and 0 both have meaning as zoneids).
*/
{
return (val);
}
/*
* If in a non-global zone, checks the brand name and sets the passed-in
* arg 'is_s10' appropriately.
*/
{
/*
* ZONE_ATTR_BRAND doesn't exist for the global zone,
* so we need to special-case it.
*/
if (zoneid == GLOBAL_ZONEID) {
return (0);
}
return (NETCFG_FAILURE);
return (NETCFG_SUCCESS);
}
/*
* Compare two nvlists containing object IDs. The match must be exact,
* i.e. the lists must have exactly the same pairs, with exceptions for
* non-string and NETCFG_OBJECT_DB_NAME and NETCFG_OBJECT_DB_ZONE pairs.
*
* Return B_TRUE if the lists match, B_FALSE otherwise.
*/
{
/*
* Make sure every entry in list b appears in list a, and that
* each string value matches. db-name and zoneid pairs do not
* matter.
*/
if (!NETCFG_IDLIST_NVPAIR_IS_ID(nvp))
continue;
return (B_FALSE);
bcnt++;
}
acnt++;
}
}
/*
* For each pair in list dst, look up the name in list src. If the name
* exists in src, change the value in dst to match the value in src.
*
* Only modifies pairs that are of type string.
*
* Assumes that NV_UNIQUE_NAME was specified when dst was allocated.
*/
void
{
continue;
}
}
int err; \
if (err != 0) \
return (err); \
if (nelem == 0) \
return (ENOENT); \
if (nelem != 1) \
return (EINVAL); \
return (0);
/*
* Given an nvlist, extract a single value from the named nvpair. The
* pair type must be an array type, and there must be one (and only one)
* value in the array.
*/
int
{
}
int
{
}
int
{
}
int
{
}
int
{
}
int
{
char **strs;
}
int err; \
if (err != 0) \
return (err); \
if (nelem == 0) \
return (ENOENT); \
if (nelem != 1) \
return (EINVAL); \
return (0);
/*
* Given an nvpair, extract a single value. The pair type must be an array
* type, and there must be one (and only one) value in the array.
*/
int
{
}
int
{
}
int
{
}
int
{
}
int
{
}
int
{
char **strs;
}
int err; \
return (ENOMEM); \
return (err);
/*
* Given an nvlist, add a single value to the named nvpair. The pair
* type must be an array type.
*/
int
{
}
int
{
}
int
{
}
int
{
}
int
{
}
int
{
char **array;
}