dladm.c revision 13994ee84c09002288df157a5da6aa7349a1010f
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <fcntl.h>
#include <stdarg.h>
#include <string.h>
#include <stropts.h>
#include <errno.h>
#include <kstat.h>
#include <strings.h>
#include <getopt.h>
#include <unistd.h>
#include <priv.h>
#include <termios.h>
#include <pwd.h>
#include <auth_attr.h>
#include <auth_list.h>
#include <libintl.h>
#include <libdlpi.h>
#include <libdladm.h>
#include <liblaadm.h>
#include <libmacadm.h>
#include <libwladm.h>
#include <libinetutil.h>
#include <bsm/adt_event.h>
#define AGGR_DRV "aggr"
#define MAXPORT 256
#define DUMP_LACP_FORMAT " %-9s %-8s %-7s %-12s " \
"%-5s %-4s %-4s %-9s %-7s\n"
typedef struct pktsum_s {
} pktsum_t;
typedef struct show_link_state {
typedef struct show_grp_state {
typedef struct show_mac_state {
typedef struct port_state {
char *state_name;
} port_state_t;
static port_state_t port_states[] = {
{"standby", AGGR_PORT_STATE_STANDBY },
{"attached", AGGR_PORT_STATE_ATTACHED }
};
typedef void cmdfunc_t(int, char **);
static void link_stats(const char *, uint_t);
static void get_mac_stats(const char *, pktsum_t *);
static void get_link_stats(const char *, pktsum_t *);
static uint64_t mac_ifspeed(const char *);
static char *mac_link_state(const char *);
static char *mac_link_duplex(const char *);
static void die(const char *, ...);
static void die_optdup(int);
static void die_opterr(int, int);
static void die_laerr(laadm_diag_t, const char *, ...);
static void die_wlerr(wladm_status_t, const char *, ...);
static void die_dlerr(dladm_status_t, const char *, ...);
static void warn(const char *, ...);
static void warn_wlerr(wladm_status_t, const char *, ...);
static void warn_dlerr(dladm_status_t, const char *, ...);
typedef struct cmd {
char *c_name;
} cmd_t;
{ "show-link", do_show_link },
{ "show-dev", do_show_dev },
{ "create-aggr", do_create_aggr },
{ "delete-aggr", do_delete_aggr },
{ "add-aggr", do_add_aggr },
{ "remove-aggr", do_remove_aggr },
{ "modify-aggr", do_modify_aggr },
{ "show-aggr", do_show_aggr },
{ "up-aggr", do_up_aggr },
{ "down-aggr", do_down_aggr },
{ "scan-wifi", do_scan_wifi },
{ "connect-wifi", do_connect_wifi },
{ "disconnect-wifi", do_disconnect_wifi },
{ "show-wifi", do_show_wifi },
{ "show-linkprop", do_show_linkprop },
{ "set-linkprop", do_set_linkprop },
{ "reset-linkprop", do_reset_linkprop },
{ "create-secobj", do_create_secobj },
{ "delete-secobj", do_delete_secobj },
{ "show-secobj", do_show_secobj },
{ "init-linkprop", do_init_linkprop },
{ "init-secobj", do_init_secobj }
};
{ 0, 0, 0, 0 }
};
static const struct option prop_longopts[] = {
{ 0, 0, 0, 0 }
};
static const struct option wifi_longopts[] = {
{ 0, 0, 0, 0 }
};
static char *progname;
static sig_atomic_t signalled;
static void
usage(void)
{
"\tshow-link [-p] [-s [-i <interval>]] [<name>]\n"
"\tshow-dev [-p] [-s [-i <interval>]] [<dev>]\n"
"\n"
"\tcreate-aggr [-t] [-R <root-dir>] [-P <policy>] [-l <mode>]\n"
"\t [-T <time>] [-u <address>] -d <dev> ... <key>\n"
"\tmodify-aggr [-t] [-R <root-dir>] [-P <policy>] [-l <mode>]\n"
"\t [-T <time>] [-u <address>] <key>\n"
"\tdelete-aggr [-t] [-R <root-dir>] <key>\n"
"\tadd-aggr [-t] [-R <root-dir>] -d <dev> ... <key>\n"
"\tremove-aggr [-t] [-R <root-dir>] -d <dev> ... <key>\n"
"\tshow-aggr [-pL][-s [-i <interval>]] [<key>]\n"
"\n"
"\tscan-wifi [-p] [-o <field>,...] [<name>]\n"
"\tconnect-wifi [-e <essid>] [-i <bssid>] [-k <key>,...]"
" [-s wep]\n"
"\t [-a open|shared] [-b bss|ibss] [-c] [-m a|b|g]\n"
"\t [-T <time>] [<name>]\n"
"\tdisconnect-wifi [-a] [<name>]\n"
"\tshow-wifi [-p] [-o <field>,...] [<name>]\n"
"\n"
"\tset-linkprop [-t] [-R <root-dir>] -p <prop>=<value>[,...]"
" <name>\n"
"\treset-linkprop [-t] [-R <root-dir>] [-p <prop>,...] <name>\n"
"\tshow-linkprop [-cP][-p <prop>,...] <name>\n"
"\n"
"\tcreate-secobj [-t] [-R <root-dir>] [-f <file>] -c <class>"
" <secobj>\n"
"\tdelete-secobj [-t] [-R <root-dir>] <secobj>[,...]\n"
"\tshow-secobj [-pP][<secobj>,...]\n"));
exit(1);
}
int
{
int i;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
if (argc < 2)
usage();
if (!priv_ineffect(PRIV_SYS_NET_CONFIG) ||
die("insufficient privileges");
exit(0);
}
}
usage();
return (0);
}
static void
{
char option;
int key;
laadm_diag_t diag = 0;
opterr = 0;
switch (option) {
case 'd':
die("too many <dev> arguments");
MAXNAMELEN) >= MAXNAMELEN)
die("device name too long");
nport++;
break;
case 'P':
if (P_arg)
break;
case 'u':
if (u_arg)
mac_addr))
break;
case 'l':
if (l_arg)
break;
case 'T':
if (T_arg)
break;
case 't':
break;
case 'R':
break;
default:
break;
}
}
if (nport == 0)
usage();
/* get key value (required last argument) */
usage();
}
static void
{
int key;
char option;
laadm_diag_t diag = 0;
opterr = 0;
NULL)) != -1) {
switch (option) {
case 't':
break;
case 'R':
break;
default:
break;
}
}
/* get key value (required last argument) */
usage();
}
static void
{
char option;
int key;
laadm_diag_t diag = 0;
opterr = 0;
NULL)) != -1) {
switch (option) {
case 'd':
die("too many <dev> arguments");
MAXNAMELEN) >= MAXNAMELEN)
die("device name too long");
nport++;
break;
case 't':
break;
case 'R':
break;
default:
break;
}
}
if (nport == 0)
usage();
/* get key value (required last argument) */
usage();
/*
* checking ENOTSUP is a temporary workaround
* and should be removed once 6399681 is fixed.
*/
gettext("%s: add operation failed: %s\n"),
gettext("device capabilities don't match"));
}
}
}
static void
{
char option;
int key;
laadm_diag_t diag = 0;
opterr = 0;
switch (option) {
case 'd':
die("too many <dev> arguments");
MAXNAMELEN) >= MAXNAMELEN)
die("device name too long");
nport++;
break;
case 't':
break;
case 'R':
break;
default:
break;
}
}
if (nport == 0)
usage();
/* get key value (required last argument) */
usage();
}
static void
{
char option;
int key;
uint8_t modify_mask = 0;
laadm_diag_t diag = 0;
opterr = 0;
NULL)) != -1) {
switch (option) {
case 'P':
if (modify_mask & LAADM_MODIFY_POLICY)
break;
case 'u':
if (modify_mask & LAADM_MODIFY_MAC)
mac_addr))
break;
case 'l':
break;
case 'T':
break;
case 't':
break;
case 'R':
break;
default:
break;
}
}
if (modify_mask == 0)
die("at least one of the -PulT options must be specified");
/* get key value (required last argument) */
usage();
}
static void
{
int key = 0;
laadm_diag_t diag = 0;
/* get aggregation key (optional last argument) */
if (argc == 2) {
} else if (argc > 2) {
usage();
}
if (key != 0) {
key);
} else {
}
}
}
static void
{
int key = 0;
/* get aggregation key (optional last argument) */
if (argc == 2) {
} else if (argc > 2) {
usage();
}
if (laadm_down(key) < 0) {
if (key != 0) {
die("could not bring down aggregation '%u': %s",
} else {
die("could not bring down aggregations: %s",
}
}
}
#define TYPE_WIDTH 10
static void
{
char type[TYPE_WIDTH];
if (!legacy) {
int instance;
} else {
}
return;
(void) printf("%s type=%s mtu=%d key=%u\n",
} else {
(void) printf("%s type=%s mtu=%d device=%s\n",
}
} else {
(void) printf("%s type=legacy mtu=%d device=%s\n",
}
}
static void
{
char type[TYPE_WIDTH];
if (!legacy) {
int instance;
} else {
}
return;
} else {
}
} else {
}
}
static int
{
int err;
int fd;
/*
* A return value of ENODEV means that the specified
* device is not gldv3.
*/
(void) dlpi_close(fd);
} else {
return (-1);
}
} else {
/*
* If the return value is not ENODEV, this means that
* user is either passing in a bogus interface name
* or a vlan interface name that doesn't exist yet.
*/
return (-1);
}
return (0);
}
/* ARGSUSED */
static void
{
if (state->ls_parseable) {
} else {
}
}
static void
{
if (state->ls_firstonly) {
if (state->ls_donefirst)
return;
} else {
}
}
static void
{
char policy_str[LAADM_POLICY_STR_LEN];
if (!parseable) {
} else {
(void) printf(" policy=%s",
(void) printf(" address=%s",
(void) printf(" address-type=%s\n",
}
}
static void
{
const char *lacp_timer_str =
if (!parseable) {
} else {
}
}
static void
{
(void) printf("\tipackets rbytes opackets obytes ");
(void) printf("%%ipkts %%opkts\n");
}
static void
dump_ports_lacp_head(void)
{
gettext("expired"));
}
static void
dump_ports_head(void)
{
"state\n"));
}
static char *
{
int i;
for (i = 0; i < NPORTSTATES; i++) {
state = &port_states[i];
return (state->state_name);
}
return ("unknown");
}
static void
{
if (!parseable) {
1000000ull));
} else {
1000000ull));
}
}
static void
{
(void) printf(DUMP_LACP_FORMAT,
}
static void
{
(void) printf("\t-");
else
(void) printf("\t-");
else
(void) printf("\n");
*old_stats = *port_stats;
}
static int
{
int i;
return (0);
if (state->gs_firstonly) {
return (0);
} else {
}
/* show statistics */
/* sum the ports statistics */
&state->gs_prevstats[i]);
}
(void) printf(" Total");
}
/* show LACP info */
} else {
if (!state->gs_parseable)
if (state->gs_parseable)
if (state->gs_parseable)
(void) printf("\n");
}
}
return (0);
}
static int
{
return (-1);
return (-1);
switch (type) {
case KSTAT_DATA_UINT64:
break;
case KSTAT_DATA_UINT32:
break;
default:
return (-1);
}
return (0);
}
static void
{
if (!state->ms_parseable) {
} else {
(void) printf(" speed=%u",
}
}
/*ARGSUSED*/
static void
{
if (state->ms_firstonly) {
if (state->ms_donefirst)
return;
} else {
}
}
static void
{
int option;
int interval = 0;
opterr = 0;
switch (option) {
case 'p':
break;
case 's':
if (s_arg)
break;
case 'i':
if (i_arg)
break;
default:
break;
}
}
die("the option -i can be used only with -s");
/* get link name (optional last argument) */
usage();
if (s_arg) {
return;
}
} else {
}
}
static void
{
int option;
int key = 0;
int interval = 0;
opterr = 0;
switch (option) {
case 'L':
if (L_arg)
die("the option -L cannot be used with -i "
"or -s");
}
break;
case 'p':
break;
case 's':
if (s_arg)
if (L_arg)
die("the option -s cannot be used with -L");
break;
case 'i':
if (i_arg)
if (L_arg)
die("the option -i cannot be used with -L");
break;
default:
break;
}
}
die("the option -i can be used only with -s");
/* get aggregation key (optional last argument) */
usage();
}
if (s_arg) {
return;
}
}
static void
{
int option;
int interval = 0;
opterr = 0;
switch (option) {
case 'p':
break;
case 's':
if (s_arg)
break;
case 'i':
if (i_arg)
break;
default:
break;
}
}
die("the option -i can be used only with -s");
/* get dev name (optional last argument) */
usage();
int index;
/*
* Check for invalid devices.
* aggregations and vlans are not considered devices.
*/
}
if (s_arg) {
return;
}
else
}
/* ARGSUSED */
static void
{
/*
* If an interval is specified, continuously show the stats
* only for the first MAC port.
*/
for (;;) {
(void) printf("\t\tipackets rbytes ierrors ");
(void) printf("opackets obytes oerrors\n");
else
if (interval == 0)
break;
}
}
/* ARGSUSED */
static void
{
/*
* If an interval is specified, continuously show the stats
* only for the first group.
*/
for (;;) {
if (interval == 0)
break;
}
}
/* ARGSUSED */
static void
{
/*
* If an interval is specified, continuously show the stats
* only for the first MAC port.
*/
for (;;) {
(void) printf("\t\tipackets rbytes ierrors ");
(void) printf("opackets obytes oerrors\n");
else
if (interval == 0)
break;
}
}
/* accumulate stats (s1 += (s2 - s3)) */
static void
{
}
/* compute stats differences (s1 = s2 - s3) */
static void
{
}
/*
* In the following routines, we do the first kstat_lookup() assuming that
* the device is gldv3-based and that the kstat name is the one passed in
* as the "name" argument. If the lookup fails, we redo the kstat_lookup()
* omitting the kstat name. This second lookup is needed for getting kstats
* from legacy devices. This can fail too if the device is not attached or
* the device is legacy and doesn't export the kstats we need.
*/
static void
{
warn("kstat open operation failed");
return;
}
/*
* The kstat query could fail if the underlying MAC
* driver was already detached.
*/
(void) kstat_close(kcp);
return;
}
goto bail;
goto bail;
goto bail;
goto bail;
goto bail;
goto bail;
goto bail;
(void) kstat_close(kcp);
return;
bail:
(void) kstat_close(kcp);
}
static void
{
int instance;
return;
}
static void
{
int instance;
return;
}
static int
void *val)
{
int instance;
warn("kstat open operation failed");
return (-1);
}
return (-1);
/*
* The kstat query could fail if the underlying MAC
* driver was already detached.
*/
goto bail;
}
warn("kstat read failed");
goto bail;
}
goto bail;
(void) kstat_close(kcp);
return (0);
bail:
(void) kstat_close(kcp);
return (-1);
}
static uint64_t
mac_ifspeed(const char *dev)
{
return (ifspeed);
}
static char *
mac_link_state(const char *dev)
{
char *state_str = "unknown";
&link_state) != 0) {
return (state_str);
}
switch (link_state) {
case LINK_STATE_UP:
state_str = "up";
break;
case LINK_STATE_DOWN:
state_str = "down";
break;
default:
break;
}
return (state_str);
}
static char *
mac_link_duplex(const char *dev)
{
char *duplex_str = "unknown";
&link_duplex) != 0) {
return (duplex_str);
}
switch (link_duplex) {
case LINK_DUPLEX_FULL:
duplex_str = "full";
break;
case LINK_DUPLEX_HALF:
duplex_str = "half";
break;
default:
break;
}
return (duplex_str);
}
#define WIFI_CMD_SCAN 0x00000001
#define WIFI_CMD_SHOW 0x00000002
typedef struct wifi_field {
const char *wf_name;
const char *wf_header;
} wifi_field_t;
static wifi_field_t wifi_fields[] = {
;
static char *all_scan_wifi_fields =
"link,essid,bssid,sec,strength,mode,speed,bsstype";
static char *all_show_wifi_fields =
"link,status,essid,sec,strength,mode,speed,auth,bssid,bsstype";
static char *def_scan_wifi_fields =
"link,essid,bssid,sec,strength,mode,speed";
static char *def_show_wifi_fields =
"link,status,essid,sec,strength,mode,speed";
#define WIFI_MAX_FIELD_LEN 32
typedef struct {
char *s_buf;
char **s_fields; /* array of pointer to the fields in s_buf */
} split_t;
/*
* Free the split_t structure pointed to by `sp'.
*/
static void
{
}
/*
* Split `str' into at most `maxfields' fields, each field at most `maxlen' in
* length. Return a pointer to a split_t containing the split fields, or NULL
* on failure.
*/
static split_t *
{
return (NULL);
return (NULL);
goto fail;
goto fail;
}
return (sp);
fail:
return (NULL);
}
static int
{
uint_t i, j;
if (cmdtype == WIFI_CMD_SCAN) {
} else if (cmdtype == WIFI_CMD_SHOW) {
} else {
return (-1);
}
return (-1);
goto fail;
for (j = 0; j < WIFI_MAX_FIELDS; j++) {
wifi_fields[j].wf_name) == 0) {
good_match = wifi_fields[j].
break;
}
}
if (!good_match)
goto fail;
wf[i] = &wifi_fields[j];
}
*countp = i;
return (0);
fail:
return (-1);
}
typedef struct print_wifi_state {
const char *ws_link;
static void
{
int i;
for (i = 0; i < statep->ws_nfields; i++) {
else
}
(void) printf("\n");
}
static void
const char *value)
{
if (statep->ws_parseable) {
} else {
if (value[0] == '\0')
value = "--";
if (statep->ws_lastfield) {
return;
}
}
}
if (!statep->ws_lastfield)
(void) putchar(' ');
}
static void
{
char buf[WLADM_STRSIZE];
const char *str = "";
return;
}
return;
}
case WLADM_WLAN_ATTR_ESSID:
break;
case WLADM_WLAN_ATTR_BSSID:
break;
case WLADM_WLAN_ATTR_SECMODE:
break;
case WLADM_WLAN_ATTR_STRENGTH:
break;
case WLADM_WLAN_ATTR_MODE:
break;
case WLADM_WLAN_ATTR_SPEED:
break;
case WLADM_WLAN_ATTR_AUTH:
break;
case WLADM_WLAN_ATTR_BSSTYPE:
break;
}
}
static boolean_t
{
int i;
if (!statep->ws_parseable)
}
statep->ws_overflow = 0;
for (i = 0; i < statep->ws_nfields; i++) {
}
(void) putchar('\n');
return (B_TRUE);
}
static boolean_t
{
if (status != WLADM_STATUS_OK)
return (B_TRUE);
}
static void
{
char buf[WLADM_STRSIZE];
const char *str = "";
return;
}
}
static boolean_t
{
int i;
if (status != WLADM_STATUS_OK)
if (!statep->ws_parseable)
}
statep->ws_overflow = 0;
for (i = 0; i < statep->ws_nfields; i++) {
}
(void) putchar('\n');
return (B_TRUE);
}
static void
{
int option;
char *fields_str = NULL;
if (cmd == WIFI_CMD_SCAN)
else if (cmd == WIFI_CMD_SHOW)
else
return;
opterr = 0;
switch (option) {
case 'o':
fields_str = optarg;
break;
case 'p':
if (fields_str == NULL)
fields_str = "all";
break;
default:
break;
}
}
usage();
die("invalid field(s) specified");
if (status != WLADM_STATUS_OK)
} else {
}
}
static void
{
}
static void
{
}
typedef struct wlan_count_attr {
const char *wc_link;
static boolean_t
{
return (B_TRUE);
}
static int
{
uint_t i;
return (-1);
goto fail;
char *s;
goto fail;
*s = '\0';
}
if (status != DLADM_STATUS_OK) {
if (status == DLADM_STATUS_NOTFOUND) {
}
if (status != DLADM_STATUS_OK)
goto fail;
}
}
*key_countp = i;
return (0);
fail:
return (-1);
}
static void
{
int option;
opterr = 0;
switch (option) {
case 'e':
if (status != WLADM_STATUS_OK)
/*
* Try to connect without doing a scan.
*/
break;
case 'i':
if (status != WLADM_STATUS_OK)
break;
case 'a':
if (status != WLADM_STATUS_OK)
break;
case 'm':
if (status != WLADM_STATUS_OK)
break;
case 'b':
if (status != WLADM_STATUS_OK)
break;
case 's':
if (status != WLADM_STATUS_OK)
break;
case 'k':
break;
case 'T':
timeout = -1;
break;
}
break;
case 'c':
break;
default:
break;
}
}
if (keysecmode == WLADM_SECMODE_NONE) {
die("key required for security mode 'wep'");
} else {
die("incompatible -s and -k options");
}
usage();
die("no wifi links are available");
die("link name is required when more than one wifi "
"link is available");
}
}
if (status != WLADM_STATUS_OK) {
if ((flags & WLADM_OPT_NOSCAN) != 0) {
/*
* Try again with scanning and filtering.
*/
flags &= ~WLADM_OPT_NOSCAN;
goto again;
}
if (status == WLADM_STATUS_NOTFOUND) {
die("no wifi networks are available");
} else {
die("no wifi networks with the specified "
"criteria are available");
}
}
}
}
/* ARGSUSED */
static boolean_t
{
if (status != WLADM_STATUS_OK)
return (B_TRUE);
}
static void
{
int option;
opterr = 0;
switch (option) {
case 'a':
break;
default:
break;
}
}
usage();
if (!all_links) {
die("no wifi links are available");
die("link name is required when more than "
"one wifi link is available");
}
} else {
return;
}
}
if (status != WLADM_STATUS_OK)
}
#define MAX_PROPS 32
#define MAX_PROP_VALS 32
#define MAX_PROP_LINE 512
typedef struct prop_info {
char *pi_name;
char *pi_val[MAX_PROP_VALS];
} prop_info_t;
typedef struct prop_list {
char *pl_buf;
} prop_list_t;
typedef struct show_linkprop_state {
const char *ls_link;
char *ls_line;
char **ls_propvals;
static void
{
}
}
static int
{
int len, i;
return (-1);
goto fail;
for (i = 0; i < len; i++) {
char c = buf[i];
continue;
if (match) {
buf[i] = '\0';
if (*curr == '\0')
goto fail;
}
goto fail;
if (novalues)
goto fail;
} else {
goto fail;
if (c == ',')
}
}
return (0);
fail:
return (-1);
}
static void
print_linkprop_head(void)
{
(void) printf("%-15s %-14s %-14s %-30s \n",
"PROPERTY", "VALUE", "DEFAULT", "POSSIBLE");
}
static void
char **pptr)
{
int i;
char buf[DLADM_STRSIZE];
if (status != DLADM_STATUS_OK) {
valcnt = 1;
if (type == DLADM_PROP_VAL_CURRENT)
else
} else {
propname);
}
}
for (i = 0; i < valcnt; i++) {
else
break;
}
if (valcnt > 0)
if (statep->ls_parseable) {
} else {
}
}
static boolean_t
{
if (statep->ls_parseable)
else
if (!statep->ls_parseable)
}
return (B_TRUE);
}
static void
{
char linkname[MAXPATHLEN];
char *buf;
opterr = 0;
switch (option) {
case 'p':
die("invalid link properties specified");
break;
case 'c':
break;
case 'P':
break;
default:
break;
}
}
usage();
die("link name must be specified");
/*
* When some WiFi links are opened for the first time, their hardware
* automatically scans for APs and does other slow operations. Thus,
* if there are no open links, the retrieval of link properties
* (below) will proceed slowly unless we hold the link open.
*/
die("insufficient memory");
for (i = 0; i < MAX_PROP_VALS; i++) {
i * DLADM_PROP_VAL_MAX;
}
(sizeof (char *) + DLADM_PROP_VAL_MAX) * MAX_PROP_VALS;
if (!show_linkprop(&state,
break;
}
} else {
if (status != DLADM_STATUS_OK)
}
}
static dladm_status_t
{
if (status != DLADM_STATUS_OK) {
if (reset) {
} else {
}
}
return (status);
}
static void
{
int i, option;
char errmsg[DLADM_STRSIZE];
opterr = 0;
switch (option) {
case 'p':
die("invalid link properties specified");
break;
case 't':
break;
case 'R':
if (status != DLADM_STATUS_OK) {
"specified");
}
break;
default:
break;
}
}
usage();
die("link name must be specified");
if (!reset)
die("link property must be specified");
if (status != DLADM_STATUS_OK) {
"on '%s'", link);
}
if (!temp) {
if (s != DLADM_STATUS_OK)
status = s;
}
goto done;
}
char **val;
if (reset) {
count = 0;
} else {
if (count == 0) {
warn("no value specified for '%s'",
continue;
}
}
if (s == DLADM_STATUS_OK) {
if (!temp) {
s = set_linkprop_persist(link,
if (s != DLADM_STATUS_OK)
status = s;
}
continue;
}
status = s;
switch (s) {
case DLADM_STATUS_NOTFOUND:
break;
case DLADM_STATUS_BADVAL: {
int j;
die("insufficient memory");
for (j = 0; j < MAX_PROP_VALS; j++) {
j * DLADM_PROP_VAL_MAX;
}
*ptr = '\0';
for (j = 0; j < valcnt && s == DLADM_STATUS_OK; j++) {
propvals[j]);
break;
}
warn("link property '%s' must be one of: %s",
break;
}
default:
if (reset) {
} else {
}
break;
}
}
done:
if (status != DLADM_STATUS_OK)
exit(1);
}
static void
{
}
static void
{
}
static int
{
int error = 0;
if (class != DLADM_SECOBJ_CLASS_WEP)
return (ENOENT);
switch (len) {
case 5: /* ASCII key sizes */
case 13:
break;
case 10: /* Hex key sizes, not preceded by 0x */
case 26:
break;
case 12: /* Hex key sizes, preceded by 0x */
case 28:
return (EINVAL);
break;
default:
return (EINVAL);
}
return (error);
}
/* ARGSUSED */
static void
{
}
static int
{
int c;
void (*sigfunc)(int);
/*
* Turn off echo -- but before we do so, defer SIGINT handling
* so that a ^C doesn't leave the terminal corrupted.
*/
if (try == 1)
else
while (signalled == 0) {
c = getchar();
if (c == '\n' || c == '\r') {
if (len != 0)
break;
(void) putchar('\n');
goto again;
}
break;
(void) putchar('*');
}
(void) putchar('\n');
/*
* Restore terminal setting and handle deferred signals.
*/
if (signalled != 0)
return (len);
}
static int
{
int rval;
if (rval == 0) {
}
return (rval);
} else {
for (;;) {
break;
continue;
len--;
}
break;
}
}
}
static boolean_t
check_auth(const char *auth)
{
return (B_FALSE);
}
static void
{
char *errstr;
if (create) {
errstr = "ADT_dladm_create_secobj";
} else {
errstr = "ADT_dladm_delete_secobj";
}
/* fill in audit info */
if (create) {
} else {
}
if (success) {
}
} else {
ADT_FAIL_VALUE_AUTH) != 0) {
}
}
(void) adt_end_session(ah);
}
#define MAX_SECOBJS 32
#define MAX_SECOBJ_NAMELEN 32
static void
{
char *class_name = NULL;
opterr = 0;
switch (option) {
case 'f':
}
break;
case 'c':
class_name = optarg;
if (status != DLADM_STATUS_OK) {
die("invalid secure object class '%s', "
"valid values are: wep", optarg);
}
break;
case 't':
break;
case 'R':
if (status != DLADM_STATUS_OK) {
"specified");
}
break;
default:
break;
}
}
usage();
if (class == -1)
die("secure object class required");
die("secure object name required");
if (!success)
if (rval != 0) {
switch (rval) {
case ENOENT:
die("invalid secure object class");
break;
case EINVAL:
die("invalid secure object value");
break;
case ENOTSUP:
die("verification failed");
break;
default:
break;
}
}
if (status != DLADM_STATUS_OK) {
obj_name);
}
if (temp)
return;
if (status != DLADM_STATUS_OK) {
"object '%s'", obj_name);
}
}
static void
{
int i, option;
opterr = 0;
switch (option) {
case 't':
break;
case 'R':
if (status != DLADM_STATUS_OK) {
"specified");
}
break;
default:
break;
}
}
die("invalid secure object name(s): '%s'",
}
usage();
die("secure object name required");
if (!success)
if (!temp) {
} else {
}
if (status != DLADM_STATUS_OK) {
}
if (pstatus != DLADM_STATUS_OK) {
}
}
exit(1);
}
typedef struct show_secobj_state {
static void
{
(void) putchar('\n');
}
static boolean_t
{
char buf[DLADM_STRSIZE];
if (statep->ss_persist)
if (status != DLADM_STATUS_OK)
if (!statep->ss_parseable)
}
if (statep->ss_parseable) {
} else {
}
if (statep->ss_parseable)
else
}
}
(void) putchar('\n');
return (B_TRUE);
}
static void
{
int option;
uint_t i;
opterr = 0;
switch (option) {
case 'p':
break;
case 'P':
break;
case 'd':
if (getuid() != 0)
die("insufficient privileges");
break;
default:
break;
}
}
die("invalid secure object name(s): '%s'",
}
break;
}
return;
usage();
if (status != DLADM_STATUS_OK)
}
/* ARGSUSED */
static void
{
if (status != DLADM_STATUS_OK)
}
/* ARGSUSED */
static void
{
status = dladm_init_secobj();
if (status != DLADM_STATUS_OK)
}
static boolean_t
{
int val;
errno = 0;
return (B_FALSE);
return (B_TRUE);
}
/* PRINTFLIKE1 */
static void
{
(void) putchar('\n');
}
/* PRINTFLIKE2 */
static void
{
char errmsg[WLADM_STRSIZE];
}
/* PRINTFLIKE2 */
static void
{
char errmsg[DLADM_STRSIZE];
}
/* PRINTFLIKE2 */
static void
{
if (diag == 0)
else
}
/* PRINTFLIKE2 */
static void
{
char errmsg[WLADM_STRSIZE];
}
/* PRINTFLIKE2 */
static void
{
char errmsg[DLADM_STRSIZE];
}
/* PRINTFLIKE1 */
static void
{
(void) putchar('\n');
}
static void
die_optdup(int opt)
{
}
static void
{
switch (opterr) {
case ':':
break;
case '?':
default:
break;
}
}