linkprop.c revision 3361618b69459cc57ec852687200c4c3550ca822
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdlib.h>
#include <strings.h>
#include <errno.h>
#include <ctype.h>
#include <stddef.h>
#include <fcntl.h>
#include <unistd.h>
#include <libdevinfo.h>
#include <zone.h>
#include <libdllink.h>
#include <libdladm_impl.h>
#include <libdlwlan_impl.h>
#include <libdlwlan.h>
#include <libdlvlan.h>
#include <libdlvnic.h>
#include <libintl.h>
#include <dlfcn.h>
#include <link.h>
#include <inet/wifi_ioctl.h>
#include <libdladm.h>
#include <libdlstat.h>
#include <sys/mac_flow.h>
#include <inttypes.h>
#include <sys/ethernet.h>
#include <sys/sysmacros.h>
/*
* The linkprop get() callback.
* - pd: pointer to the prop_desc_t
* - propstrp: a property string array to keep the returned property.
* Caller allocated.
* - cntp: number of returned properties.
* Caller also uses it to indicate how many it expects.
*/
struct prop_desc;
typedef struct prop_desc prop_desc_t;
/*
* The linkprop set() callback.
* - propval: a val_desc_t array which keeps the property values to be set.
* - cnt: number of properties to be set.
* - flags: additional flags passed down the system call.
*
* pd_set takes val_desc_t given by pd_check(), translates it into
* a format suitable for kernel consumption. This may require allocation
* of ioctl buffers etc. pd_set() may call another common routine (used
* by all other pd_sets) which invokes the ioctl.
*/
/*
* The linkprop check() callback.
* - propstrp: property string array which keeps the property to be checked.
* - cnt: number of properties.
* - propval: return value; the property values of the given property strings.
*
* pd_check checks that the input values are valid. It does so by
* iteraring through the pd_modval list for the property. If
* the modifiable values cannot be expressed as a list, a pd_check
* specific to this property can be used. If the input values are
* verified to be valid, pd_check allocates a val_desc_t and fills it
* with either a val_desc_t found on the pd_modval list or something
* generated on the fly.
*/
typedef struct link_attr_s {
char *pp_name;
} link_attr_t;
const char *, uint_t, dladm_status_t *);
const char *, char **, uint_t *, dladm_prop_type_t,
uint_t);
static link_attr_t *dladm_name2prop(const char *);
static const char *dladm_perm2str(uint_t, char *);
struct prop_desc {
/*
* link property name
*/
char *pd_name;
/*
* default property value, can be set to { "", NULL }
*/
/*
* list of optional property values, can be NULL.
*
* This is set to non-NULL if there is a list of possible property
* values. pd_optval would point to the array of possible values.
*/
/*
* count of the above optional property values. 0 if pd_optval is NULL.
*/
/*
* callback to set link property;
* set to NULL if this property is read-only
*/
/*
* callback to get modifiable link property
*/
/*
* callback to get current link property
*/
/*
* callback to validate link property value, set to NULL if pd_optval
* is not NULL. In that case, validate the value by comparing it with
* the pd_optval. Return a val_desc_t array pointer if the value is
* valid.
*/
/*
* indicate link classes this property applies to.
*/
/*
* indicate link media type this property applies to.
*/
};
/*
* Supported link properties enumerated in the prop_table[] array are
* computed using the callback functions in that array. To compute the
* property value, multiple distinct system calls may be needed (e.g.,
* rates). The link_attr[] table enumerates the interfaces to the kernel,
*/
static link_attr_t link_attr[] = {
/* wl_rates_t has variable length */
/* wl_rates_t has variable length */
/* wl_wpa_ess_t has variable length */
/* wl_wpa_ie_t has variable length */
{ MAC_PROP_PRIVATE, 0, "driver-private"}
};
static val_desc_t link_duplex_vals[] = {
{ "half", LINK_DUPLEX_HALF },
{ "full", LINK_DUPLEX_HALF }
};
static val_desc_t link_status_vals[] = {
{ "up", LINK_STATE_UP },
{ "down", LINK_STATE_DOWN }
};
static val_desc_t link_01_vals[] = {
{ "1", 1 },
{ "0", 0 }
};
static val_desc_t link_flow_vals[] = {
{ "no", LINK_FLOWCTRL_NONE },
{ "tx", LINK_FLOWCTRL_TX },
{ "rx", LINK_FLOWCTRL_RX },
{ "bi", LINK_FLOWCTRL_BI }
};
static val_desc_t link_priority_vals[] = {
{ "low", MPL_LOW },
{ "medium", MPL_MEDIUM },
{ "high", MPL_HIGH }
};
static val_desc_t link_tagmode_vals[] = {
{ "normal", LINK_TAGMODE_NORMAL },
{ "vlanonly", LINK_TAGMODE_VLANONLY }
};
static val_desc_t dladm_wlan_radio_vals[] = {
{ "on", DLADM_WLAN_RADIO_ON },
{ "off", DLADM_WLAN_RADIO_OFF }
};
static val_desc_t dladm_wlan_powermode_vals[] = {
{ "off", DLADM_WLAN_PM_OFF },
{ "fast", DLADM_WLAN_PM_FAST },
{ "max", DLADM_WLAN_PM_MAX }
};
static prop_desc_t prop_table[] = {
{ "channel", { NULL, 0 },
do_get_channel_prop, NULL, 0,
do_get_radio_prop, NULL, 0,
{ "duplex", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_autoneg_cap", { "1", 1 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "flowctrl", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_10gfdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "en_10gfdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_1000fdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "en_1000fdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_1000hdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "en_1000hdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_100fdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "en_100fdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_100hdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "en_100hdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_10fdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "en_10fdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_10hdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "en_10hdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
NULL, 0,
DL_ETHER }
};
static resource_prop_t rsrc_prop_table[] = {
{"maxbw", do_extract_maxbw},
{"priority", do_extract_priority},
{"cpus", do_extract_cpus}
};
#define DLADM_MAX_RSRC_PROP (sizeof (rsrc_prop_table) / \
sizeof (resource_prop_t))
/*
* when retrieving private properties, we pass down a buffer with
* DLADM_PROP_BUF_CHUNK of space for the driver to return the property value.
*/
#define DLADM_PROP_BUF_CHUNK 1024
const char *, char **, uint_t);
const char *, char **, uint_t *);
datalink_id_t, void *, int (*)(dladm_handle_t,
datalink_id_t, const char *, void *));
/*
* Unfortunately, MAX_SCAN_SUPPORT_RATES is too small to allow all
* rates to be retrieved. However, we cannot increase it at this
* time because it will break binary compatibility with unbundled
* WiFi drivers and utilities. So for now we define an additional
* constant, MAX_SUPPORT_RATES, to allow all rates to be retrieved.
*/
#define MAX_SUPPORT_RATES 64
#define AP_ANCHOR "[anchor]"
#define AP_DELIMITER '.'
static dladm_status_t
{
int i, j;
for (j = 0; j < val_cnt; j++) {
for (i = 0; i < pdp->pd_noptval; i++) {
if (strcasecmp(*prop_val,
break;
}
}
if (i == pdp->pd_noptval) {
goto done;
}
}
done:
return (status);
}
static dladm_status_t
{
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_TEMPONLY);
if (!(flags & DLADM_OPT_ACTIVE))
return (DLADM_STATUS_OK);
return (DLADM_STATUS_PROPRDONLY);
return (DLADM_STATUS_NOMEM);
} else {
}
if (status != DLADM_STATUS_OK)
goto done;
} else {
return (DLADM_STATUS_NOTSUP);
cnt = 1;
return (DLADM_STATUS_NOMEM);
if (defval) {
sizeof (val_desc_t));
if (status != DLADM_STATUS_OK)
goto done;
}
} else {
return (status);
}
}
if (needfree) {
for (i = 0; i < cnt; i++)
}
done:
return (status);
}
static dladm_status_t
{
int i;
NULL, 0);
if (status != DLADM_STATUS_OK)
return (status);
for (i = 0; i < DLADM_MAX_PROPS; i++) {
continue;
status = s;
break;
} else {
if (s != DLADM_STATUS_OK &&
s != DLADM_STATUS_NOTSUP)
status = s;
}
}
if (!found) {
if (prop_name[0] == '_') {
/* other private properties */
} else {
}
}
return (status);
}
/*
*/
{
return (DLADM_STATUS_BADARG);
}
/*
* Check for valid link property against the flags passed
* and set the link property when active flag is passed.
*/
if (status != DLADM_STATUS_OK)
return (status);
if (flags & DLADM_OPT_PERSIST) {
}
return (status);
}
/*
* Walk all link properties of the given specific link.
*
* Note: this function currently lacks the ability to walk _all_ private
* properties if the link, because there is no kernel interface to
* retrieve all known private property names. Once such an interface
* is added, this function should be fixed accordingly.
*/
{
int i;
return (DLADM_STATUS_BADARG);
NULL, 0);
if (status != DLADM_STATUS_OK)
return (status);
/* public */
for (i = 0; i < DLADM_MAX_PROPS; i++) {
continue;
continue;
break;
}
}
/* private */
return (status);
}
/*
* Get linkprop of the given specific link.
*/
{
int i;
if (type == DLADM_PROP_VAL_DEFAULT)
else if (type == DLADM_PROP_VAL_MODIFIABLE)
return (DLADM_STATUS_BADARG);
for (i = 0; i < DLADM_MAX_PROPS; i++)
break;
if (i == DLADM_MAX_PROPS) {
if (prop_name[0] == '_') {
/*
* private property.
*/
if (type == DLADM_PROP_VAL_PERSISTENT)
else
dld_flags));
} else {
return (DLADM_STATUS_NOTFOUND);
}
}
pdp = &prop_table[i];
NULL, 0);
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_BADARG);
switch (type) {
case DLADM_PROP_VAL_CURRENT:
break;
case DLADM_PROP_VAL_PERM:
} else {
}
*prop_val[0] = '\0';
*val_cntp = 1;
if (status == DLADM_STATUS_OK)
break;
case DLADM_PROP_VAL_DEFAULT:
/*
* If defaults are not defined for the property,
* pd_defval.vd_name should be null. If the driver
* has to be contacted for the value, vd_name should
* be the empty string (""). Otherwise, dladm will
* just print whatever is in the table.
*/
break;
}
} else {
}
*val_cntp = 1;
break;
break;
}
if (cnt == 0) {
} else {
for (i = 0; i < cnt; i++) {
}
}
break;
return (DLADM_STATUS_TEMPONLY);
break;
default:
break;
}
return (status);
}
/*ARGSUSED*/
static int
{
DLADM_MAX_PROP_VALCNT)) == NULL) {
return (DLADM_WALK_CONTINUE);
}
for (i = 0; i < valcnt; i++) {
sizeof (char *) * DLADM_MAX_PROP_VALCNT +
i * DLADM_PROP_VAL_MAX;
}
goto done;
}
done:
return (DLADM_WALK_CONTINUE);
}
/*ARGSUSED*/
static int
{
NULL, 0);
if (status != DLADM_STATUS_OK)
return (DLADM_WALK_TERMINATE);
return (DLADM_WALK_CONTINUE);
}
{
if (linkid == DATALINK_ALL_LINKID) {
} else if (any_media ||
0) == DLADM_STATUS_OK) &&
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
char zone_name[ZONENAME_MAX];
char *cp;
if (flags != 0)
return (DLADM_STATUS_NOTSUP);
&status, perm_flags);
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 1;
if (zid != GLOBAL_ZONEID) {
return (dladm_errno2status(errno));
}
} else {
*prop_val[0] = '\0';
}
return (DLADM_STATUS_OK);
}
typedef int (*zone_get_devroot_t)(char *, char *, size_t);
static int
{
char root[MAXPATHLEN];
void *dlhandle;
void *sym;
int ret;
return (-1);
return (-1);
}
return (ret);
}
static dladm_status_t
{
char path[MAXPATHLEN];
char name[MAXLINKNAMELEN];
char zone_name[ZONENAME_MAX];
int ret;
return (dladm_errno2status(errno));
return (dladm_errno2status(errno));
return (dladm_errno2status(errno));
if (status != DLADM_STATUS_OK)
goto cleanup;
if (add)
else
if (ret != 0) {
goto cleanup;
}
if (di_prof_commit(prof) != 0)
if (prof)
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
char link[MAXLINKNAMELEN];
char *cp;
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
if (status != DLADM_STATUS_OK)
return (status);
/* Do nothing if setting to current value */
return (status);
if (zid_new != GLOBAL_ZONEID) {
/*
* If the new zoneid is the global zone, we could destroy
* the link (in the case of an implicitly-created VLAN) as a
* result of setting the zoneid. In that case, we defer the
* operation to the end of this function to avoid recreating
* the VLAN and getting a different linkid during the rollback
* if other operation fails.
*
* Otherwise, this operation will hold a reference to the
* link and prevent a link renaming, so we need to do it
* before other operations.
*/
if (status != DLADM_STATUS_OK)
return (status);
}
if (zid_old != GLOBAL_ZONEID) {
goto rollback1;
}
/*
* It is okay to fail to update the /dev entry (some
* vanity-named links do not have a /dev entry).
*/
B_FALSE);
}
if (zid_new != GLOBAL_ZONEID) {
goto rollback2;
}
} else {
if (status != DLADM_STATUS_OK)
goto rollback2;
}
return (DLADM_STATUS_OK);
if (zid_old != GLOBAL_ZONEID)
if (zid_old != GLOBAL_ZONEID)
if (zid_new != GLOBAL_ZONEID) {
}
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
char *zone_name;
char linkname[MAXLINKNAMELEN];
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
return (DLADM_STATUS_NOMEM);
goto done;
}
goto done;
}
goto done;
}
if (zoneid != GLOBAL_ZONEID) {
sizeof (flags)) < 0) {
goto done;
}
if (!(flags & ZF_NET_EXCL)) {
goto done;
}
}
return (DLADM_STATUS_OK);
done:
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
&status, perm_flags);
return (status);
(*prop_val)[0] = '\0';
} else {
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
return (DLADM_STATUS_NOMEM);
if (status != DLADM_STATUS_OK) {
return (status);
}
return (DLADM_STATUS_MINMAXBW);
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
int i;
&status, perm_flags);
return (status);
return (DLADM_STATUS_TOOSMALL);
if (ncpus == 0) {
(*prop_val)[0] = '\0';
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
for (i = 0; i < ncpus; i++) {
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
return (status);
case MAC_PROP_MAXBW:
break;
case MAC_PROP_PRIO:
break;
default:
return (DLADM_STATUS_BADARG);
}
} else {
case MAC_PROP_MAXBW:
sizeof (uint64_t));
break;
case MAC_PROP_PRIO:
sizeof (mac_priority_level_t));
break;
default:
return (DLADM_STATUS_BADARG);
}
}
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
/*
* CPU bindings can be set on VNIC and regular physical links.
* However VNICs fails the dladm_phys_info test(). So apply
* the phys_info test only on physical links.
*/
return (status);
}
/*
* We set intr_cpu to -1. The interrupt will be retargetted,
* if possible when the setup is complete in MAC.
*/
}
}
return (status);
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
int i, j, rc;
return (DLADM_STATUS_NOMEM);
for (i = 0; i < val_cnt; i++) {
errno = 0;
return (DLADM_STATUS_CPUMAX);
}
if (rc < 1) {
return (DLADM_STATUS_CPUERR);
}
return (DLADM_STATUS_CPUNOTONLINE);
}
}
/* Check for duplicates */
for (i = 0; i < val_cnt; i++) {
for (j = 0; j < val_cnt; j++) {
return (DLADM_STATUS_BADARG);
}
}
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
int i;
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
&status, perm_flags);
return (status);
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
return (DLADM_STATUS_NOMEM);
if (status != DLADM_STATUS_OK) {
return (status);
}
return (DLADM_STATUS_BADVAL);
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
sizeof (mac_priority_level_t));
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
struct dlautopush dlap;
int i, len;
if (flags & MAC_PROP_DEFAULT)
return (DLADM_STATUS_NOTDEFINED);
*val_cnt = 1;
&status, perm_flags);
(*prop_val)[0] = '\0';
return (DLADM_STATUS_OK);
}
if (i != 0) {
len += 1;
}
}
}
done:
return (DLADM_STATUS_OK);
}
/*
* Add the specified module to the dlautopush structure; returns a
* DLADM_STATUS_* code.
*/
{
return (DLADM_STATUS_BADVAL);
/*
* We don't allow multiple anchors, and the anchor must
* be after at least one module.
*/
if (dlap->dap_anchor != 0)
return (DLADM_STATUS_BADVAL);
return (DLADM_STATUS_BADVAL);
return (DLADM_STATUS_OK);
}
return (DLADM_STATUS_BADVALCNT);
FMNAMESZ + 1);
return (DLADM_STATUS_OK);
}
/*
* Currently, both '.' and ' '(space) can be used as the delimiters between
* autopush modules. The former is used in dladm set-linkprop, and the
* latter is used in the autopush(1M) file.
*/
/* ARGSUSED */
static dladm_status_t
{
char *module;
struct dlautopush *dlap;
char val[DLADM_PROP_VAL_MAX];
char delimiters[4];
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
return (DLADM_STATUS_NOMEM);
if (status != DLADM_STATUS_OK)
return (status);
}
} else {
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
uint_t i;
return (DLADM_STATUS_NOMEM);
B_FALSE);
if (status != DLADM_STATUS_OK)
goto done;
goto done;
}
if (wrp->wl_rates_rates[0] == 0) {
prop_val[0][0] = '\0';
*val_cnt = 1;
goto done;
}
for (i = 0; i < wrp->wl_rates_num; i++) {
}
done:
return (status);
}
static dladm_status_t
{
}
}
/* ARGSUSED */
static dladm_status_t
{
switch (media) {
case DL_ETHER:
/*
* Speed for ethernet links is unbounded. E.g., 802.11b
* links can have a speed of 5.5 Gbps.
*/
return (DLADM_STATUS_NOTSUP);
case DL_WIFI:
default:
return (DLADM_STATUS_BADARG);
}
}
static dladm_status_t
{
int i;
return (DLADM_STATUS_NOMEM);
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
/*
* can currently set rate on WIFI links only.
*/
return (DLADM_STATUS_PROPRDONLY);
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
done:
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
int i;
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
goto done;
}
for (i = 0; i < MAX_SUPPORT_RATES; i++) {
i * DLADM_STRSIZE;
}
media, 0, &perm_flags);
if (status != DLADM_STATUS_OK)
goto done;
for (i = 0; i < modval_cnt; i++) {
break;
}
}
if (i == modval_cnt)
done:
return (status);
}
static dladm_status_t
int buflen)
{
}
/* ARGSUSED */
static dladm_status_t
{
char buf[WLDP_BUFSIZE];
!= DLADM_STATUS_OK)
goto done;
goto done;
}
*val_cnt = 1;
done:
return (status);
}
static dladm_status_t
int buflen)
{
}
/* ARGSUSED */
static dladm_status_t
{
const char *s;
char buf[WLDP_BUFSIZE];
!= DLADM_STATUS_OK)
goto done;
switch (mode.wl_ps_mode) {
case WL_PM_AM:
s = "off";
break;
case WL_PM_MPS:
s = "max";
break;
case WL_PM_FAST:
s = "fast";
break;
default:
goto done;
}
*val_cnt = 1;
done:
return (status);
}
static dladm_status_t
{
switch (*pm) {
case DLADM_WLAN_PM_OFF:
break;
case DLADM_WLAN_PM_MAX:
break;
case DLADM_WLAN_PM_FAST:
break;
default:
return (DLADM_STATUS_NOTSUP);
}
}
/* ARGSUSED */
static dladm_status_t
{
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
return (status);
}
static dladm_status_t
{
}
/* ARGSUSED */
static dladm_status_t
{
const char *s;
char buf[WLDP_BUFSIZE];
!= DLADM_STATUS_OK)
goto done;
switch (radio) {
case B_TRUE:
s = "on";
break;
case B_FALSE:
s = "off";
break;
default:
goto done;
}
*val_cnt = 1;
done:
return (status);
}
static dladm_status_t
{
wl_radio_t r;
switch (*radio) {
case DLADM_WLAN_RADIO_ON:
r = B_TRUE;
break;
case DLADM_WLAN_RADIO_OFF:
r = B_FALSE;
break;
default:
return (DLADM_STATUS_NOTSUP);
}
sizeof (r), B_TRUE));
}
/* ARGSUSED */
static dladm_status_t
{
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
return (status);
}
static dladm_status_t
{
char buf[MAXLINELEN];
int i;
if (status != DLADM_STATUS_OK)
return (status);
/*
* reset case.
*/
if (val_cnt == 0) {
if (status == DLADM_STATUS_OK)
goto done;
}
buf[0] = '\0';
for (i = 0; i < val_cnt; i++) {
if (i != val_cnt - 1)
}
buf);
if (status == DLADM_STATUS_OK)
done:
return (status);
}
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
return (status);
if (status != DLADM_STATUS_OK)
goto done;
goto done;
}
}
done:
return (status);
}
/*
* Walk persistent private link properties of a link.
*/
static dladm_status_t
{
char last_attr[MAXLINKATTRLEN];
char attr[MAXLINKATTRLEN];
char attrval[MAXLINKATTRVALLEN];
return (DLADM_STATUS_BADARG);
if (status != DLADM_STATUS_OK)
return (status);
last_attr[0] = '\0';
if (attr[0] == '_') {
break;
}
}
return (DLADM_STATUS_OK);
}
static link_attr_t *
dladm_name2prop(const char *prop_name)
{
link_attr_t *p;
break;
}
return (p);
}
static link_attr_t *
{
link_attr_t *p;
break;
}
return (p);
}
static dld_ioc_macprop_t *
{
int dsize;
return (NULL);
}
return (dip);
}
static dld_ioc_macprop_t *
{
link_attr_t *p;
p = dladm_name2prop(prop_name);
}
static dld_ioc_macprop_t *
{
link_attr_t *p;
p = dladm_id2prop(propid);
}
/* ARGSUSED */
static dladm_status_t
{
void *val;
return (status);
else {
/*
* No need (yet) to distinguish these from arrays of same size.
*/
switch (dip->pr_valsize) {
case 1:
break;
case 2:
break;
case 4:
break;
default:
break;
}
}
else
dip->pr_valsize = 0;
done:
return (status);
}
{
return (status);
}
static dld_ioc_macprop_t *
{
return (NULL);
if (*status != DLADM_STATUS_OK) {
return (NULL);
}
if (perm_flags != NULL)
return (dip);
}
/* ARGSUSED */
static dladm_status_t
{
if (val_cnt != 1)
return (DLADM_STATUS_BADVAL);
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
KSTAT_DATA_UINT32, &link_duplex)) != 0)
return (status);
switch (link_duplex) {
case LINK_DUPLEX_FULL:
break;
case LINK_DUPLEX_HALF:
break;
default:
break;
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
KSTAT_DATA_UINT64, &ifspeed)) != 0)
return (status);
if ((ifspeed % 1000000) != 0) {
} else {
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
return (status);
switch (link_state) {
case LINK_STATE_UP:
break;
case LINK_STATE_DOWN:
break;
default:
break;
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
&status, perm_flags);
return (status);
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
uint32_t v = 0;
&status, perm_flags);
return (status);
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/*
* Determines the size of the structure that needs to be sent to drivers
* for retrieving the property range values.
*/
static int
{
*sz = sizeof (mac_propval_range_t);
--count;
switch (r->mpr_type) {
case MAC_PROPVAL_UINT32:
return (0);
default:
break;
}
*sz = 0;
return (EINVAL);
}
/* ARGSUSED */
static dladm_status_t
{
sz = sizeof (mac_propval_range_t);
/*
* As caller we don't know number of value ranges, the driver
* supports. To begin with we assume that number to be 1. If the
* buffer size is insufficient, driver returns back with the
* actual count of value ranges. See mac.h for more details.
*/
return (status);
if (status != DLADM_STATUS_OK) {
if (status == DLADM_STATUS_TOOSMALL) {
int err;
goto retry;
} else {
}
}
return (status);
}
case MAC_PROPVAL_UINT32: {
} else {
}
}
break;
}
default:
break;
}
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
&status, perm_flags);
return (status);
switch (mode) {
case LINK_TAGMODE_NORMAL:
break;
case LINK_TAGMODE_VLANONLY:
break;
default:
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
&status, perm_flags);
return (status);
switch (v) {
case LINK_FLOWCTRL_NONE:
break;
case LINK_FLOWCTRL_RX:
break;
case LINK_FLOWCTRL_TX:
break;
case LINK_FLOWCTRL_BI:
break;
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
int i, slen;
int bufsize = 0;
link_attr_t *p;
return (DLADM_STATUS_BADARG);
p = dladm_name2prop(prop_name);
if (p->pp_id != MAC_PROP_PRIVATE)
return (DLADM_STATUS_BADARG);
if (!(flags & DLADM_OPT_ACTIVE))
return (DLADM_STATUS_OK);
/*
* private properties: all parsing is done in the kernel.
* allocate a enough space for each property + its separator (',').
*/
for (i = 0; i < val_cnt; i++) {
}
/*
* getting default value. so use more buffer space.
*/
}
return (status);
slen = 0;
} else {
for (i = 0; i < val_cnt; i++) {
int plen = 0;
/*
* add a "," separator and update dp.
*/
if (i != (val_cnt -1))
}
}
if (status == DLADM_STATUS_OK)
return (status);
}
static dladm_status_t
{
link_attr_t *p;
return (DLADM_STATUS_BADARG);
p = dladm_name2prop(prop_name);
if (p->pp_id != MAC_PROP_PRIVATE)
return (DLADM_STATUS_BADARG);
/*
* private properties: all parsing is done in the kernel.
*/
return (status);
if (type == DLADM_PROP_VAL_PERM) {
} else if (type == DLADM_PROP_VAL_MODIFIABLE) {
*prop_val[0] = '\0';
} else {
}
*val_cnt = 1;
} else if ((status == DLADM_STATUS_NOTSUP) &&
(type == DLADM_PROP_VAL_CURRENT)) {
}
return (status);
}
static dladm_status_t
{
int i;
/*
* Allocate buffer needed for prop_vals array. We can have at most
* DLADM_MAX_PROP_VALCNT char *prop_vals[] entries, where
* each entry has max size DLADM_PROP_VAL_MAX
*/
bufsize =
(sizeof (char *) + DLADM_PROP_VAL_MAX) * DLADM_MAX_PROP_VALCNT;
for (i = 0; i < DLADM_MAX_PROP_VALCNT; i++) {
sizeof (char *) * DLADM_MAX_PROP_VALCNT +
i * DLADM_PROP_VAL_MAX;
}
/*
* For properties which have pdp->pd_defval.vd_name as a non-empty
* string, the "" itself is used to reset the property (exceptions
* are zone and autopush, which populate vdp->vd_val). So
* libdladm can copy pdp->pd_defval over to the val_desc_t passed
* down on the setprop using the global values in the table. For
* other cases (vd_name is ""), doing reset-linkprop will cause
* libdladm to do a getprop to find the default value and then do
* a setprop to reset the value to default.
*/
if (status == DLADM_STATUS_OK) {
if (perm_flags == MAC_PROP_PERM_RW) {
}
else
}
return (status);
}
int
{
switch (wl_prop) {
case MAC_PROP_WL_ESSID:
return (WL_ESSID);
case MAC_PROP_WL_BSSID:
return (WL_BSSID);
case MAC_PROP_WL_BSSTYPE:
return (WL_BSS_TYPE);
case MAC_PROP_WL_LINKSTATUS:
return (WL_LINKSTATUS);
return (WL_DESIRED_RATES);
return (WL_SUPPORTED_RATES);
case MAC_PROP_WL_AUTH_MODE:
return (WL_AUTH_MODE);
case MAC_PROP_WL_ENCRYPTION:
return (WL_ENCRYPTION);
case MAC_PROP_WL_RSSI:
return (WL_RSSI);
case MAC_PROP_WL_PHY_CONFIG:
return (WL_PHY_CONFIG);
case MAC_PROP_WL_CAPABILITY:
return (WL_CAPABILITY);
case MAC_PROP_WL_WPA:
return (WL_WPA);
case MAC_PROP_WL_SCANRESULTS:
return (WL_SCANRESULTS);
case MAC_PROP_WL_POWER_MODE:
return (WL_POWER_MODE);
case MAC_PROP_WL_RADIO:
return (WL_RADIO);
case MAC_PROP_WL_ESS_LIST:
return (WL_ESS_LIST);
case MAC_PROP_WL_KEY_TAB:
return (WL_WEP_KEY_TAB);
case MAC_PROP_WL_CREATE_IBSS:
return (WL_CREATE_IBSS);
case MAC_PROP_WL_SETOPTIE:
return (WL_SETOPTIE);
case MAC_PROP_WL_DELKEY:
return (WL_DELKEY);
case MAC_PROP_WL_KEY:
return (WL_KEY);
case MAC_PROP_WL_MLME:
return (WL_MLME);
default:
return (-1);
}
}
{
void *dp;
return (status);
}
return (DLADM_STATUS_BADARG);
if (!(flags & DLADM_OPT_ACTIVE))
return (DLADM_STATUS_TEMPONLY);
return (DLADM_STATUS_NOMEM);
if (set)
if (status == DLADM_STATUS_NOTSUP) {
if (set) {
} else {
}
} else if (status == DLADM_STATUS_OK) {
if (!set)
}
return (status);
}
static dladm_status_t
{
return (DLADM_STATUS_NOMEM);
if (status == DLADM_STATUS_OK)
return (status);
}
static dladm_status_t
{
return (DLADM_STATUS_NOMEM);
return (status);
}
{
}
/*
* Retrieve the one link property from the database
*/
/*ARGSUSED*/
static int
{
/*
* it is fine to point to prop_name since prop_name points to the
* prop_table[n].pd_name.
*/
return (DLADM_WALK_CONTINUE);
}
/*
* Retrieve all link properties for a link from the database and
* return a property list.
*/
{
return (dladm_errno2status(errno));
return (status);
}
/*
* Retrieve the named property from a proplist, check the value and
* convert to a kernel structure.
*/
static dladm_status_t
{
int i, j;
/* Find named property in proplist */
break;
}
/* Property not in list */
return (DLADM_STATUS_OK);
for (i = 0; i < DLADM_MAX_PROPS; i++) {
return (DLADM_STATUS_NOMEM);
continue;
return (DLADM_STATUS_BADARG);
/* Check property value */
} else {
}
if (status != DLADM_STATUS_OK)
return (status);
for (j = 0; j < DLADM_MAX_RSRC_PROP; j++) {
continue;
/* Extract kernel structure */
} else {
}
break;
}
if (status != DLADM_STATUS_OK)
return (status);
break;
}
return (status);
}
/*
* Extract properties from a proplist and convert to mac_resource_props_t.
*/
{
mrp);
if (status != DLADM_STATUS_OK)
return (status);
mrp);
if (status != DLADM_STATUS_OK)
return (status);
mrp);
if (status != DLADM_STATUS_OK)
return (status);
return (status);
}
static const char *
{
return (buf);
}
{
&perms);
if (status != DLADM_STATUS_OK)
return (status);
return (status);
}
dladm_attr_is_linkprop(const char *name)
{
/* non-property attribute names */
const char *nonprop[] = {
/* dlmgmtd core attributes */
"name",
"class",
"media",
/* other attributes for vlan, aggr, etc */
};
int i;
is_nonprop = B_TRUE;
break;
}
}
return (!is_nonprop);
}