/*
* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libdlwlan.h>
#include <libnvpair.h>
#include "libnwam_impl.h"
#include <libnwam_priv.h>
#include <libnwam.h>
/*
* Internal implementation of libnwam in-memory objects and values. Objects
* are nvlists.
*/
void
{
uint_t i;
return;
switch (value->nwv_value_type) {
case NWAM_VALUE_TYPE_BOOLEAN:
break;
case NWAM_VALUE_TYPE_INT64:
break;
case NWAM_VALUE_TYPE_UINT64:
break;
case NWAM_VALUE_TYPE_STRING:
for (i = 0; i < value->nwv_value_numvalues; i++)
break;
}
}
{
char **values_string;
int i, j;
return (NWAM_NO_MEMORY);
switch (value_type) {
case NWAM_VALUE_TYPE_BOOLEAN:
return (NWAM_NO_MEMORY);
}
for (i = 0; i < numvalues; i++)
break;
case NWAM_VALUE_TYPE_INT64:
return (NWAM_NO_MEMORY);
}
for (i = 0; i < numvalues; i++)
break;
case NWAM_VALUE_TYPE_UINT64:
return (NWAM_NO_MEMORY);
}
for (i = 0; i < numvalues; i++)
break;
case NWAM_VALUE_TYPE_STRING:
return (NWAM_NO_MEMORY);
}
for (i = 0; i < numvalues; i++) {
}
if (err != NWAM_SUCCESS) {
for (j = 0; j < i; j++)
free(
return (err);
}
}
break;
default:
break;
}
return (NWAM_SUCCESS);
}
{
void *values;
switch (old->nwv_value_type) {
case NWAM_VALUE_TYPE_BOOLEAN:
break;
case NWAM_VALUE_TYPE_INT64:
break;
case NWAM_VALUE_TYPE_UINT64:
break;
case NWAM_VALUE_TYPE_STRING:
break;
default:
return (NWAM_INVALID_ARG);
}
}
{
valuep));
}
{
}
{
valuep));
}
{
}
{
valuep));
}
{
}
{
valuep));
}
{
}
{
return (NWAM_SUCCESS);
}
{
if (err != NWAM_SUCCESS)
return (err);
if (numvalues != 1)
return (NWAM_ENTITY_MULTIPLE_VALUES);
return (NWAM_SUCCESS);
}
{
return (NWAM_SUCCESS);
}
{
if (err != NWAM_SUCCESS)
return (err);
if (numvalues != 1)
return (NWAM_ENTITY_MULTIPLE_VALUES);
return (NWAM_SUCCESS);
}
{
return (NWAM_SUCCESS);
}
{
if (err != NWAM_SUCCESS)
return (err);
if (numvalues != 1)
return (NWAM_ENTITY_MULTIPLE_VALUES);
return (NWAM_SUCCESS);
}
{
return (NWAM_SUCCESS);
}
{
char **myvaluesp;
if (err != NWAM_SUCCESS)
return (err);
if (numvalues != 1)
return (NWAM_ENTITY_MULTIPLE_VALUES);
return (NWAM_SUCCESS);
}
{
return (NWAM_SUCCESS);
}
{
return (NWAM_SUCCESS);
}
/*
* Generic object data functions. We hide nvlist implementation
* from NCP, ENM and location implementations.
*/
{
int nverr;
return (nwam_errno_to_nwam_error(nverr));
return (NWAM_SUCCESS);
}
void
{
}
{
int nverr;
return (nwam_errno_to_nwam_error(nverr));
return (NWAM_SUCCESS);
}
/*
* Functions to walk, set and get properties in nvlist, translating
*/
{
int nverr;
return (nwam_errno_to_nwam_error(nverr));
}
return (NWAM_LIST_END);
}
{
int nverr, i;
/* convert EINVAL to NOT_FOUND */
return (NWAM_ENTITY_NOT_FOUND);
return (nwam_errno_to_nwam_error(nverr));
}
switch (nvpair_type(prop)) {
case DATA_TYPE_BOOLEAN_ARRAY:
return (nwam_errno_to_nwam_error(nverr));
valuep)) != NWAM_SUCCESS)
return (err);
break;
case DATA_TYPE_INT64_ARRAY:
return (nwam_errno_to_nwam_error(nverr));
valuep)) != NWAM_SUCCESS)
return (err);
break;
case DATA_TYPE_UINT64_ARRAY:
return (nwam_errno_to_nwam_error(nverr));
valuep)) != NWAM_SUCCESS)
return (err);
break;
case DATA_TYPE_STRING_ARRAY:
return (nwam_errno_to_nwam_error(nverr));
valuep)) != NWAM_SUCCESS)
return (err);
break;
case DATA_TYPE_NVLIST_ARRAY:
/*
* This is an array of id lists. For all nwam objects, the
* id info is contained in a single nvpair named 'name' and
* of type string. Extract each applicable name string, and
* return an array of these strings.
*/
&numvalues)) != 0)
return (nwam_errno_to_nwam_error(nverr));
return (NWAM_NO_MEMORY);
for (i = 0; i < numvalues; i++) {
&strs[i])) != 0) {
return (nwam_errno_to_nwam_error(nverr));
}
}
valuep)) != NWAM_SUCCESS) {
return (err);
}
break;
default:
/* Should not happen */
return (NWAM_ERROR_INTERNAL);
}
return (NWAM_SUCCESS);
}
{
int nverr;
return (nwam_errno_to_nwam_error(nverr));
return (NWAM_SUCCESS);
}
{
int nverr;
char **valstr;
return (err);
switch (type) {
case NWAM_VALUE_TYPE_BOOLEAN:
&numvalues)) != NWAM_SUCCESS)
return (err);
return (nwam_errno_to_nwam_error(nverr));
break;
case NWAM_VALUE_TYPE_INT64:
&numvalues)) != NWAM_SUCCESS)
return (err);
return (nwam_errno_to_nwam_error(nverr));
break;
case NWAM_VALUE_TYPE_UINT64:
&numvalues)) != NWAM_SUCCESS)
return (err);
return (nwam_errno_to_nwam_error(nverr));
break;
case NWAM_VALUE_TYPE_STRING:
&numvalues)) != NWAM_SUCCESS)
return (err);
return (nwam_errno_to_nwam_error(nverr));
break;
default:
return (NWAM_INVALID_ARG);
}
return (NWAM_SUCCESS);
}
/* Map uint64 values to their string counterparts */
struct nwam_value_entry {
const char *value_string;
};
{
{ NULL, 0 }
};
{
{ NULL, 0 }
};
{
{ NULL, 0 }
};
{
{ NULL, 0 }
};
{
{ NULL, 0 }
};
{
{ NULL, 0 }
};
{
{ NULL, 0 }
};
{
{ NULL, 0 }
};
{
{ NULL, 0 }
};
{
{ "none", DLADM_WLAN_SECMODE_NONE },
{ "wep", DLADM_WLAN_SECMODE_WEP },
{ "wpa", DLADM_WLAN_SECMODE_WPA },
{ NULL, 0 }
};
struct nwam_prop_value_entry {
const char *prop_name;
} prop_value_entry_table[] =
{
};
/*
* Convert uint64 values for property propname into a string representing
* that value. Used by enum values.
*/
const char **valstrp)
{
int i, j;
continue;
return (NWAM_SUCCESS);
}
}
/*
* If trying to get the string for an enum value that doesn't
* exist, return NWAM_LIST_END. Otherwise, the input enum
* value doesn't exist for the given property.
*/
return (NWAM_LIST_END);
else
return (NWAM_ENTITY_INVALID_VALUE);
}
return (NWAM_INVALID_ARG);
}
/*
* Convert string to appropriate uint64 value.
*/
{
int i, j;
continue;
== 0) {
return (NWAM_SUCCESS);
}
}
return (NWAM_ENTITY_INVALID_VALUE);
}
return (NWAM_INVALID_ARG);
}
/* Conditional activation functions */
{
char *string;
switch (object_type) {
break;
break;
break;
break;
break;
break;
break;
break;
break;
default:
return (NWAM_INVALID_ARG);
}
switch (condition) {
case NWAM_CONDITION_IS:
break;
case NWAM_CONDITION_IS_NOT:
break;
case NWAM_CONDITION_CONTAINS:
return (NWAM_INVALID_ARG);
break;
return (NWAM_INVALID_ARG);
break;
return (NWAM_INVALID_ARG);
break;
return (NWAM_INVALID_ARG);
break;
default:
return (NWAM_INVALID_ARG);
/* NOTREACHED */
break;
}
return (NWAM_NO_MEMORY);
switch (object_type) {
"%s %s %s active", object_type_string,
break;
"%s %s %s", object_type_string,
break;
default:
return (NWAM_INVALID_ARG);
}
return (NWAM_SUCCESS);
}
{
object_namep != NULL);
return (NWAM_NO_MEMORY);
return (NWAM_INVALID_ARG);
}
== 0)
else if (strcmp(object_type_string,
else if (strcmp(object_type_string,
else if (strcmp(object_type_string,
else if (strcmp(object_type_string,
else if (strcmp(object_type_string,
else if (strcmp(object_type_string,
else if (strcmp(object_type_string,
else if (strcmp(object_type_string,
else {
return (NWAM_INVALID_ARG);
}
if (*object_typep == NWAM_CONDITION_OBJECT_TYPE_NCP ||
return (NWAM_INVALID_ARG);
}
return (NWAM_NO_MEMORY);
}
}
if (*object_namep != NULL)
free(*object_namep);
return (NWAM_INVALID_ARG);
}
else if (strcmp(condition_string,
else if (strcmp(condition_string,
else if (strcmp(condition_string,
else {
if (*object_namep != NULL)
free(*object_namep);
return (NWAM_INVALID_ARG);
}
if (*object_typep == NWAM_CONDITION_OBJECT_TYPE_NCP ||
if ((*conditionp != NWAM_CONDITION_IS &&
*conditionp != NWAM_CONDITION_IS_NOT) ||
free(*object_namep);
return (NWAM_INVALID_ARG);
}
} else {
switch (*conditionp) {
case NWAM_CONDITION_CONTAINS:
if (*object_typep !=
*object_typep !=
free(*object_namep);
return (NWAM_INVALID_ARG);
}
break;
if (*object_typep !=
free(*object_namep);
return (NWAM_INVALID_ARG);
}
break;
}
free(*object_namep);
return (NWAM_INVALID_ARG);
}
free(*object_namep);
return (NWAM_NO_MEMORY);
}
}
return (NWAM_SUCCESS);
}
{
*ratep = 0;
switch (object_type) {
(*ratep)++;
/* FALLTHRU */
(*ratep)++;
/* FALLTHRU */
(*ratep)++;
/* FALLTHRU */
(*ratep)++;
/* FALLTHRU */
(*ratep)++;
/* FALLTHRU */
(*ratep)++;
break;
default:
return (NWAM_INVALID_ARG);
}
switch (condition) {
case NWAM_CONDITION_IS:
(*ratep)++;
/* FALLTHRU */
case NWAM_CONDITION_CONTAINS:
(*ratep)++;
/* FALLTHRU */
(*ratep)++;
/* FALLTHRU */
case NWAM_CONDITION_IS_NOT:
(*ratep)++;
break;
default:
return (NWAM_INVALID_ARG);
}
return (NWAM_SUCCESS);
}