/*
* 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 <ctype.h>
#include <libnetcfg.h>
#include "libnwam_impl.h"
#include <libnwam_priv.h>
#include <libnwam.h>
#include <libscf.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
/*
* Functions to support creating, modifying, destroying, querying the
* state of and changing the state of ENM (External Network Modifier)
* objects. ENMs represent services or scripts that can be enabled
* either manually or conditionally for a combination of the set of
* available conditions (an IP address is present, a location is active etc).
*/
"specifies the ENM activation mode - valid values are:\n"
"\'manual\', \'conditional-any\' and \'conditional-all\'",
"specifies the activation condition. Conditions are of the form:\n"
"ncp|ncu|enm|loc name is|is-not active\n"
"ip-address is|is-not|is-in-range|is-not-in-range| 1.2.3.4[/24]\n"
"advertised-domain is|is-not|contains|does-not-contain string\n"
"system-domain is|is-not|contains|does-not-contain string\n"
"essid is|is-not|contains|does-not-contain string\n"
"bssid is|is-not string",
"specifies if manual ENM is to be enabled",
"specifies SMF FMRI of service to be enabled on ENM activation",
"specifies absolute path to start script to be run on ENM "
"activation",
"specifies absolute path to stop script to be run on ENM "
"deactivation",
};
sizeof (*enm_prop_table_entries))
static uint64_t
{
switch (activation) {
return (NWAM_FLAG_ACTIVATION_MODE_MANUAL);
default:
return (0);
}
}
{
}
{
enmhp)) != NWAM_SUCCESS)
return (err);
/*
* The initial activation mode is set, and the FMRI property is set,
* if specified.
*/
&actval)) != NWAM_SUCCESS ||
!= NWAM_SUCCESS) ||
!= NWAM_SUCCESS) {
goto finish;
}
}
}
if (err != NWAM_SUCCESS) {
}
return (err);
}
{
int err = 0;
else
return (nwam_errno_to_nwam_error(err));
}
{
}
{
}
{
return (!enmh->nwh_committed);
}
/* ARGSUSED3 */
static int
{
!= NWAM_SUCCESS)
return (err);
/*
* Get a bitmapped flag value corresponding to this enm's
* activation value - if the activation value is not recognized,
* actflag will be set to 0, and will thus fail to match
* any bit flag passed in by the caller.
*/
&actval) != NWAM_SUCCESS) {
return (NWAM_INVALID_ARG);
}
return (NWAM_INVALID_ARG);
}
if (actflag & walkfilter) {
return (NWAM_SUCCESS);
}
return (NWAM_INVALID_ARG);
}
int *retp)
{
if (err != NWAM_SUCCESS)
return (err);
enm_selectcb));
}
void
{
}
{
}
{
void *olddata;
return (err);
/*
* If the activation-mode is not manual, allow the enabled
* property to be deleted.
*/
return (NWAM_ENTITY_READ_ONLY);
return (err);
if (manual)
return (NWAM_ENTITY_READ_ONLY);
}
/*
* Duplicate data, remove property and validate. If validation
* fails, revert to data duplicated prior to remove.
*/
!= NWAM_SUCCESS)
return (err);
!= NWAM_SUCCESS) {
return (err);
}
return (err);
}
return (NWAM_SUCCESS);
}
{
!= NWAM_SUCCESS ||
return (err);
return (NWAM_ENTITY_READ_ONLY);
}
{
}
int (*cb)(const char *, nwam_value_t, void *),
{
}
{
return (err);
}
{
}
{
descriptionp));
}
{
}
/* Property-specific value validation functions follow */
static nwam_error_t
{
return (NWAM_ENTITY_INVALID_VALUE);
switch (activation_mode) {
return (NWAM_SUCCESS);
}
return (NWAM_ENTITY_INVALID_VALUE);
}
{
/*
* Make sure enm is internally consistent: must have either
* an fmri or a start string; and if activation type is conditional,
* the condition string must be specified.
*/
!= NWAM_SUCCESS) &&
!= NWAM_SUCCESS)) {
} else {
}
return (NWAM_ENTITY_MISSING_MEMBER);
}
&activationval) != NWAM_SUCCESS) {
return (NWAM_ENTITY_MISSING_MEMBER);
}
!= NWAM_SUCCESS) {
return (NWAM_ENTITY_INVALID_VALUE);
}
&conditionval) != NWAM_SUCCESS) {
return (NWAM_ENTITY_MISSING_MEMBER);
}
/*
* Are conditions self-referential? In other words, do any
* of the activation conditions refer to this ENM?
*/
&numvalues) != NWAM_SUCCESS) {
return (NWAM_ENTITY_INVALID_VALUE);
}
return (NWAM_INVALID_ARG);
}
for (i = 0; i < numvalues; i++) {
!= NWAM_SUCCESS) {
return (NWAM_ENTITY_INVALID_VALUE);
}
if (object_name != NULL &&
return (NWAM_ENTITY_INVALID_VALUE);
}
}
}
if (activation == NWAM_ACTIVATION_MODE_MANUAL) {
&enabledval) != NWAM_SUCCESS) {
return (NWAM_ENTITY_MISSING_MEMBER);
}
}
}
{
}
/*
* Given a property, return expected property data type
*/
{
}
{
}
/*
* Determine if the ENM has manual activation-mode or not.
*/
{
&actval)) != NWAM_SUCCESS)
return (err);
if (err != NWAM_SUCCESS)
return (err);
else
return (NWAM_SUCCESS);
}
/* Determine if ENM is enabled or not */
static nwam_error_t
{
&enabledval)) != NWAM_SUCCESS)
return (err);
return (err);
}
{
/* Only enms with manual activation-mode can be enabled */
return (err);
if (!manual)
return (NWAM_ENTITY_NOT_MANUAL);
/* Make sure ENM is not enabled */
return (err);
if (enabled)
return (NWAM_ENTITY_ENABLED);
}
{
/* Only enms with manual activation-mode can be disabled */
return (err);
if (!manual)
return (NWAM_ENTITY_NOT_MANUAL);
/* Make sure ENM is enabled */
return (err);
if (!enabled)
return (NWAM_ENTITY_DISABLED);
}
{
return (nwam_get_default_proplist(enm_prop_table,
}
{
}