llp.c revision 6ba597c56d749c61b4f783157f63196d7b2445f0
/*
* 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
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* This file is here for legacy support.
*/
#include <atomic.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <libdllink.h>
#include <libscf.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <libnwam.h>
#include "known_wlans.h"
#include "llp.h"
#include "ncu.h"
#include "util.h"
/*
* This file formerly contained the routines that manipulate Link Layer
* Profiles (aka LLPs) and various support functions. Now only code
* since this legacy configuration needs to be translated into the User NCP.
*/
#define OUR_OLD_DHCP_WAIT_TIME_PROP_NAME "dhcp_wait_time"
#define OUR_OLD_USE_NET_SVC_PROP_NAME "use_net_svc"
#define OUR_OLD_IDLE_TIME_PROP_NAME "idle_time"
/*
* Global variable to hold the highest priority. Need to use the atomic
* integer arithmetic functions to update it.
*/
static uint32_t llp_highest_pri;
static enum interface_type
find_if_type(const char *name)
{
enum interface_type type;
"returning IF_UNKNOWN");
return (IF_UNKNOWN);
}
/*
* We'll need to update our tunnel detection once
* names won't necessarily be ip.tunN.
*/
type = IF_WIRELESS;
}
return (type);
}
static void
llp_list_free(void)
{
}
}
static void
initialize_llp(void)
{
}
static llp_t *
llp_lookup(const char *link)
{
return (NULL);
break;
}
return (llp);
}
/*
* Create the named LLP with default settings. Called only in main thread.
*/
static llp_t *
{
return (NULL);
}
name);
return (NULL);
}
/*
* should be a no-op, but for now, make sure we only
* create llps for wired and wireless interfaces.
*/
return (NULL);
}
return (llp);
}
static int
parse_llp_config(void)
{
static const char STATICSTR[] = "static";
static const char DHCP[] = "dhcp";
static const char IPV6[] = "ipv6";
static const char NOIPV6[] = "noipv6";
static const char PRIORITY[] = "priority";
int lnum;
return (errno);
"open legacy LLP config file: %m");
return (-1);
}
cp++;
continue;
"parsing legacy LLP conf file line %d...", lnum);
"not enough tokens; ignoring entry", lnum);
continue;
}
"cannot add entry", lnum);
continue;
}
"missing ipaddr for static config", lnum);
"cannot save address", lnum);
} else {
}
(void) 0;
"cannot save address", lnum);
} else {
}
"parse_llp_config: line %d: "
"missing priority value", lnum);
} else {
}
} else {
}
}
return (0);
}
/*
* Translate legacy LLP config into the user NCP.
*/
static int
upgrade_llp_config(void)
{
char *strval;
const char *prop;
switch (parse_llp_config()) {
case -1:
return (0);
case ENOENT:
return (ENOENT);
default:
break;
}
!= NWAM_SUCCESS) {
return (0);
}
!= NWAM_SUCCESS ||
nwam_strerror(err));
break;
}
/* Link NCU properties */
!= NWAM_SUCCESS)
break;
!= NWAM_SUCCESS)
break;
!= NWAM_SUCCESS)
break;
/* IP NCU properties */
/* Set v4 address and specify static addrsrc */
prop)) != NWAM_SUCCESS)
break;
prop)) != NWAM_SUCCESS)
break;
}
/* Set v6 address and specify static addrsrc */
prop)) != NWAM_SUCCESS)
break;
prop)) != NWAM_SUCCESS)
break;
}
if (!wp->llp_ipv6onlink) {
prop)) != NWAM_SUCCESS)
break;
}
nwam_strerror(err));
/* Schedule a retry - root filesystem may be readonly */
return (EAGAIN);
}
}
if (err != NWAM_SUCCESS) {
}
return (0);
}
/*
* Upgrade legacy llp and known_wifi_nets files. Note - it is possible that
* the root filesystem is not writable at this point, so we need to schedule
* a retry of the upgrade operation in the event that committing the new
* config fails.
*/
/* ARGSUSED0 */
void
{
switch (upgrade_llp_config()) {
case -1:
case ENOENT:
/* Nothing readable to upgrade */
break;
case EAGAIN:
/*
* Schedule retry in NWAMD_READONLY_RETRY_INTERVAL seconds
* as root fs may be readonly.
*
* The upgrade event is of type NCU, but has no associated
* object (we use the event type to map to the appropriate
* method we specify type NCU while not specifying an
* object since all NCUs have to be upgraded.
*/
NWAM_OBJECT_TYPE_NCP, 0, NULL);
if (upgrade_event == NULL)
return;
return;
default:
break;
}
/*
* If static_configured is set, then at least one static address is
*/
if (static_configured) {
"static address configured, enabling User NCP");
(void) pthread_mutex_lock(&active_ncp_mutex);
(void) pthread_mutex_unlock(&active_ncp_mutex);
}
/* upgrade /etc/nwam/known_wifi_nets */
/*
* SMF property nwamd/dhcp_wait_time in Phase 0/0.5 has been
* replaced by nwamd/ncu_wait_time property. If the dhcp_wait_time
* property exists (which means it has been changed by the user),
* set its value to ncu_wait_time and remove the property.
*/
OUR_OLD_DHCP_WAIT_TIME_PROP_NAME, &dhcp_wait_time) == 0) {
"converted '%s' to '%s' with value of %lld",
}
/*
* If the user has changed Phase 0/0.5 properties that don't exist in
* Phase 1, manifest-import reports a warning; but those properties are
* not removed. nwamd/use_net_svc and nwamd/idle_time are two
* properties that don't exist in Phase 1. If they exist, remove them.
*/
OUR_OLD_IDLE_TIME_PROP_NAME, &idle_time) == 0) {
}
OUR_OLD_USE_NET_SVC_PROP_NAME, &use_net_svc) == 0) {
}
"creating version property, setting to 1\n");
OUR_VERSION_PROP_NAME, 1U);
(void) smf_refresh_instance(OUR_FMRI);
}