dladm.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 <stdio.h>
#include <ctype.h>
#include <locale.h>
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <fcntl.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 <libdevinfo.h>
#include <libdlpi.h>
#include <libdladm.h>
#include <libdllink.h>
#include <libdlstat.h>
#include <libdlaggr.h>
#include <libdlwlan.h>
#include <libdlvlan.h>
#include <libdlvnic.h>
#include <libdlether.h>
#include <libinetutil.h>
#include <bsm/adt_event.h>
#include <libdlvnic.h>
#include <sys/processor.h>
#include <net/if_types.h>
#include <stddef.h>
#include <ofmt.h>
#define MAXPORT 256
#define MAXVNIC 256
#define MAXLINELEN 1024
#define SMF_UPGRADE_FILE "/var/svc/profile/upgrade"
#define SMF_UPGRADEDATALINK_FILE "/var/svc/profile/upgrade_datalink"
#define SMF_DLADM_UPGRADE_MSG " # added by dladm(1M)"
#define DLADM_DEFAULT_COL 80
/*
* used by the wifi show-* commands to set up ofmt_field_t structures.
*/
#define WIFI_CMD_SCAN 0x00000001
#define WIFI_CMD_SHOW 0x00000002
typedef struct show_state {
} show_state_t;
typedef struct show_grp_state {
typedef struct show_vnic_state {
char vs_vnic[MAXLINKNAMELEN];
char vs_link[MAXLINKNAMELEN];
typedef struct show_usage_state_s {
/*
* callback functions for printing output and error diagnostics.
*/
typedef void cmdfunc_t(int, char **, const char *);
static cmdfunc_t do_show_linkmap;
static cmdfunc_t do_show_ether;
static cmdfunc_t do_up_vnic;
static cmdfunc_t do_show_usage;
static void do_up_vnic_common(int, char **, const char *, boolean_t);
static void altroot_cmd(char *, int, char **);
static int get_one_kstat(const char *, const char *, uint8_t,
void *, boolean_t);
static void get_mac_stats(const char *, pktsum_t *);
static void get_link_stats(const char *, pktsum_t *);
static const char *get_linkstate(const char *, boolean_t, char *);
static const char *get_linkduplex(const char *, boolean_t, char *);
static void show_ether_xprop(void *, dladm_ether_info_t *);
static void die(const char *, ...);
static void die_optdup(int);
static void die_opterr(int, int, const char *);
static void die_dlerr(dladm_status_t, const char *, ...);
static void warn(const char *, ...);
static void warn_dlerr(dladm_status_t, const char *, ...);
typedef struct cmd {
char *c_name;
const char *c_usage;
} cmd_t;
{ "rename-link", do_rename_link,
" rename-link <oldlink> <newlink>" },
{ "show-link", do_show_link,
" show-link [-pP] [-o <field>,..] [-s [-i <interval>]] "
"[<link>]\n" },
{ "create-aggr", do_create_aggr,
" create-aggr [-t] [-P <policy>] [-L <mode>] [-T <time>] "
"[-u <address>]\n"
"\t\t -l <link> [-l <link>...] <link>" },
{ "delete-aggr", do_delete_aggr,
" delete-aggr [-t] <link>" },
{ "add-aggr", do_add_aggr,
" add-aggr [-t] -l <link> [-l <link>...] <link>" },
{ "remove-aggr", do_remove_aggr,
" remove-aggr [-t] -l <link> [-l <link>...] <link>" },
{ "modify-aggr", do_modify_aggr,
" modify-aggr [-t] [-P <policy>] [-L <mode>] [-T <time>] "
"[-u <address>]\n"
"\t\t <link>" },
{ "show-aggr", do_show_aggr,
" show-aggr [-pPLx] [-o <field>,..] [-s [-i <interval>]] "
"[<link>]\n" },
{ "scan-wifi", do_scan_wifi,
" scan-wifi [-p] [-o <field>,...] [<link>]" },
{ "connect-wifi", do_connect_wifi,
" connect-wifi [-e <essid>] [-i <bssid>] [-k <key>,...] "
"[-s wep|wpa]\n"
"\t\t [-a open|shared] [-b bss|ibss] [-c] [-m a|b|g] "
"[-T <time>]\n"
"\t\t [<link>]" },
{ "disconnect-wifi", do_disconnect_wifi,
" disconnect-wifi [-a] [<link>]" },
{ "show-wifi", do_show_wifi,
" show-wifi [-p] [-o <field>,...] [<link>]\n" },
{ "set-linkprop", do_set_linkprop,
" set-linkprop [-t] -p <prop>=<value>[,...] <name>" },
{ "reset-linkprop", do_reset_linkprop,
" reset-linkprop [-t] [-p <prop>,...] <name>" },
{ "show-linkprop", do_show_linkprop,
" show-linkprop [-cP] [-o <field>,...] [-p <prop>,...] "
"<name>\n" },
{ "show-ether", do_show_ether,
" show-ether [-px][-o <field>,...] <link>\n" },
{ "create-secobj", do_create_secobj,
" create-secobj [-t] [-f <file>] -c <class> <secobj>" },
{ "delete-secobj", do_delete_secobj,
" delete-secobj [-t] <secobj>[,...]" },
{ "show-secobj", do_show_secobj,
" show-secobj [-pP] [-o <field>,...] [<secobj>,...]\n" },
{ "create-vlan", do_create_vlan,
" create-vlan [-ft] -l <link> -v <vid> [link]" },
{ "delete-vlan", do_delete_vlan,
" delete-vlan [-t] <link>" },
{ "show-vlan", do_show_vlan,
" show-vlan [-pP] [-o <field>,..] [<link>]\n" },
{ "delete-phys", do_delete_phys,
" delete-phys <link>" },
{ "show-phys", do_show_phys,
" show-phys [-pP] [-o <field>,..] [-H] [<link>]\n"},
{ "create-vnic", do_create_vnic,
" create-vnic [-t] -l <link> [-m <value> | auto |\n"
"\t\t {factory [-n <slot-id>]} | {random [-r <prefix>]}]\n"
"\t\t [-v <vid> [-f]] [-p <prop>=<value>[,...]] [-H] "
"<vnic-link>" },
{ "delete-vnic", do_delete_vnic,
" delete-vnic [-t] <vnic-link>" },
{ "show-vnic", do_show_vnic,
" show-vnic [-pP] [-l <link>] [-s [-i <interval>]] "
"[<link>]\n" },
{ "create-etherstub", do_create_etherstub,
" create-etherstub [-t] <link>" },
{ "delete-etherstub", do_delete_etherstub,
" delete-etherstub [-t] <link>" },
{ "show-etherstub", do_show_etherstub,
" show-etherstub [-t] [<link>]\n" },
{ "show-usage", do_show_usage,
" show-usage [-a] [-d | -F <format>] "
};
{ 0, 0, 0, 0 }
};
static const struct option show_lopts[] = {
{ 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 const struct option showeth_lopts[] = {
{ 0, 0, 0, 0 }
};
static const struct option vnic_lopts[] = {
{ 0, 0, 0, 0 }
};
static const struct option etherstub_lopts[] = {
{ 0, 0, 0, 0 }
};
static const struct option usage_opts[] = {
{ 0, 0, 0, 0 }
};
/*
* structures for 'dladm show-ether'
*/
static const char *ptype[] = {LEI_ATTR_NAMES};
typedef struct ether_fields_buf_s
{
char eth_link[15];
char eth_ptype[8];
char eth_state[8];
char eth_autoneg[5];
char eth_spdx[31];
char eth_pause[6];
char eth_rem_fault[16];
static ofmt_field_t ether_fields[] = {
/* name, field width, offset callback */
{ "LINK", 16,
{ "PTYPE", 9,
{ "STATE", 9,
{ "AUTO", 6,
{ "SPEED-DUPLEX", 32,
{ "PAUSE", 7,
{ "REM_FAULT", 17,
{NULL, 0,
0, NULL}}
;
typedef struct print_ether_state {
const char *es_link;
/*
* structures for 'dladm show-link -s' (print statistics)
*/
typedef enum {
static ofmt_field_t link_s_fields[] = {
/* name, field width, index, callback */
;
typedef struct link_args_s {
char *link_s_link;
} link_args_t;
/*
* buffer used by print functions for show-{link,phys,vlan} commands.
*/
typedef struct link_fields_buf_s {
char link_name[MAXLINKNAMELEN];
char link_class[DLADM_STRSIZE];
char link_mtu[11];
char link_state[DLADM_STRSIZE];
char link_over[MAXLINKNAMELEN];
char link_phys_state[DLADM_STRSIZE];
char link_phys_media[DLADM_STRSIZE];
char link_phys_speed[DLADM_STRSIZE];
char link_flags[6];
char link_vlan_vid[6];
/*
* structures for 'dladm show-link'
*/
static ofmt_field_t link_fields[] = {
/* name, field width, index, callback */
{ "LINK", 12,
{ "CLASS", 9,
{ "MTU", 7,
{ "STATE", 9,
{ "OVER", DLPI_LINKNAME_MAX,
;
/*
* structures for 'dladm show-aggr'
*/
typedef struct laggr_fields_buf_s {
char laggr_name[DLPI_LINKNAME_MAX];
char laggr_policy[9];
char laggr_lacpactivity[14];
char laggr_lacptimer[DLADM_STRSIZE];
char laggr_flags[7];
typedef struct laggr_args_s {
int laggr_lport; /* -1 indicates the aggr itself */
const char *laggr_link;
} laggr_args_t;
static ofmt_field_t laggr_fields[] = {
/* name, field width, offset, callback */
{ "LINK", 16,
{ "POLICY", 9,
{ "LACPACTIVITY", 14,
{ "LACPTIMER", 12,
{ "FLAGS", 8,
;
/*
* structures for 'dladm show-aggr -x'.
*/
typedef enum {
static ofmt_field_t aggr_x_fields[] = {
/* name, field width, index callback */
;
/*
* structures for 'dladm show-aggr -s'.
*/
typedef enum {
static ofmt_field_t aggr_s_fields[] = {
;
/*
* structures for 'dladm show-aggr -L'.
*/
typedef enum {
static ofmt_field_t aggr_l_fields[] = {
/* name, field width, index */
;
/*
* structures for 'dladm show-phys'
*/
static ofmt_field_t phys_fields[] = {
/* name, field width, offset */
{ "LINK", 13,
{ "MEDIA", 21,
{ "STATE", 11,
{ "SPEED", 7,
{ "DUPLEX", 10,
{ "DEVICE", 13,
{ "FLAGS", 7,
;
/*
* structures for 'dladm show-phys -m'
*/
typedef enum {
static ofmt_field_t phys_m_fields[] = {
/* name, field width, offset */
;
/*
* structures for 'dladm show-phys -H'
*/
typedef enum {
static ofmt_field_t phys_h_fields[] = {
;
/*
* structures for 'dladm show-vlan'
*/
static ofmt_field_t vlan_fields[] = {
{ "LINK", 16,
{ "VID", 9,
{ "OVER", 13,
{ "FLAGS", 7,
;
/*
* structures common to 'dladm scan-wifi' and 'dladm show-wifi'
* callback will be determined in parse_wifi_fields.
*/
static ofmt_field_t wifi_common_fields[] = {
/*
* the 'show-wifi' command supports all the fields in wifi_common_fields
* plus the AUTH and STATUS fields.
*/
/* copy wifi_common_fields here */
};
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";
/*
* structures for 'dladm show-linkprop'
*/
typedef enum {
static ofmt_field_t linkprop_fields[] = {
/* name, field width, index */
;
#define MAX_PROP_LINE 512
typedef struct show_linkprop_state {
char ls_link[MAXLINKNAMELEN];
char *ls_line;
char **ls_propvals;
typedef struct set_linkprop_state {
const char *ls_name;
typedef struct linkprop_args_s {
char *ls_propname;
/*
* structures for 'dladm show-secobj'
*/
typedef struct secobj_fields_buf_s {
char ss_obj_name[DLADM_SECOBJ_VAL_MAX];
char ss_class[20];
char ss_val[30];
static ofmt_field_t secobj_fields[] = {
{ "OBJECT", 21,
{ "CLASS", 21,
{ "VALUE", 31,
;
/*
* structures for 'dladm show-vnic'
*/
typedef struct vnic_fields_buf_s
{
char vnic_link[DLPI_LINKNAME_MAX];
char vnic_over[DLPI_LINKNAME_MAX];
char vnic_speed[6];
char vnic_macaddr[19];
char vnic_macaddrtype[19];
char vnic_vid[6];
static ofmt_field_t vnic_fields[] = {
{ "LINK", 13,
{ "OVER", 13,
{ "SPEED", 7,
{ "MACADDRESS", 21,
{ "MACADDRTYPE", 20,
{ "VID", 7,
;
/*
* structures for 'dladm show-usage'
*/
typedef struct usage_fields_buf_s {
char usage_link[12];
char usage_duration[10];
char usage_ipackets[9];
char usage_rbytes[10];
char usage_opackets[9];
char usage_obytes[10];
char usage_bandwidth[14];
static ofmt_field_t usage_fields[] = {
{ "LINK", 13,
{ "DURATION", 11,
{ "IPACKETS", 10,
{ "RBYTES", 11,
{ "OPACKETS", 10,
{ "OBYTES", 11,
{ "BANDWIDTH", 15,
;
/*
* structures for 'dladm show-usage link'
*/
typedef struct usage_l_fields_buf_s {
char usage_l_link[12];
char usage_l_stime[13];
char usage_l_etime[13];
char usage_l_rbytes[8];
char usage_l_obytes[8];
char usage_l_bandwidth[14];
static ofmt_field_t usage_l_fields[] = {
/* name, field width, offset */
{ "LINK", 13,
{ "START", 14,
{ "END", 14,
{ "RBYTES", 9,
{ "OBYTES", 9,
{ "BANDWIDTH", 15,
;
static char *progname;
static sig_atomic_t signalled;
/*
* Handle to libdladm. Opened in main() before the sub-command
* specific function is called.
*/
#define DLADM_ETHERSTUB_NAME "etherstub"
static void
usage(void)
{
int i;
"\n"));
}
/* close dladm handle if it was opened */
exit(1);
}
int
{
int i;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
if (argc < 2)
usage();
/* Open the libdladm handle */
}
exit(0);
}
}
usage();
return (0);
}
/*ARGSUSED*/
static int
{
char timebuf[20];
/*
* Only show usage information for existing links unless '-a'
* is specified.
*/
if (!state->us_showall) {
return (status);
}
if ((flags & DLADM_OPT_ACTIVE) == 0)
return (DLADM_STATUS_LINKINVAL);
}
return (DLADM_STATUS_OK);
}
static int
{
char buf[DLADM_STRSIZE];
double bw;
/*
* Only show usage information for existing links unless '-a'
* is specified.
*/
if (!state->us_showall) {
return (status);
}
if ((flags & DLADM_OPT_ACTIVE) == 0)
return (DLADM_STATUS_LINKINVAL);
}
if (!state->us_printheader) {
(void) printf("# Time");
}
(void) printf("\n");
}
} else {
}
(void) printf("\n");
}
}
return (DLADM_STATUS_OK);
}
buf);
buf);
return (DLADM_STATUS_OK);
}
static int
{
char buf[DLADM_STRSIZE];
/*
* Only show usage information for existing links unless '-a'
* is specified.
*/
if (!state->us_showall) {
return (status);
}
if ((flags & DLADM_OPT_ACTIVE) == 0)
return (DLADM_STATUS_LINKINVAL);
}
return (DLADM_STATUS_OK);
}
static boolean_t
valid_formatspec(char *formatspec_str)
{
return (B_TRUE);
return (B_FALSE);
}
/*ARGSUSED*/
static void
{
int opt;
char *fields_str = NULL;
char *formatspec_str = NULL;
char *all_l_fields =
"link,start,end,rbytes,obytes,bandwidth";
switch (opt) {
case 'd':
break;
case 'a':
break;
case 'f':
break;
case 's':
break;
case 'e':
break;
case 'o':
fields_str = optarg;
break;
case 'F':
break;
default:
break;
}
}
die("show-usage requires a file");
if (!state.us_showall &&
((flags & DLADM_OPT_ACTIVE) == 0))) {
}
}
die("incompatible -d and -F options");
if (state.us_parsable)
&ofmt);
} else {
&ofmt);
}
if (d_arg) {
/* Print log dates */
!F_arg) {
/* Print summary */
/* Print log entries for named resource */
} else {
/* Print time and information for each link */
}
if (status != DLADM_STATUS_OK)
}
static void
{
char option;
int key = 0;
char name[MAXLINKNAMELEN];
char propstr[DLADM_STRSIZE];
int i;
switch (option) {
case 'd':
die("too many ports specified");
break;
case 'P':
if (P_arg)
break;
case 'u':
if (u_arg)
mac_addr))
break;
case 'l':
/*
* Ended with digit, possibly a link name.
*/
die("too many ports specified");
break;
}
/* FALLTHROUGH */
case 'L':
if (l_arg)
break;
case 'T':
if (T_arg)
break;
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'f':
flags |= DLADM_OPT_FORCE;
break;
case 'R':
break;
case 'p':
break;
default:
break;
}
}
usage();
/* get key value or the aggregation name (required last argument) */
usage();
}
if (!dladm_valid_linkname(name))
} else {
}
for (n = 0; n < ndev; n++) {
}
}
for (n = 0; n < nlink; n++) {
}
}
lacp_timer, flags);
if (status != DLADM_STATUS_OK)
goto done;
!= DLADM_STATUS_OK)
die("invalid aggregation property");
return;
if (status != DLADM_STATUS_OK)
goto done;
if (pstatus != DLADM_STATUS_OK) {
"aggr creation succeeded but "
}
}
done:
if (status != DLADM_STATUS_OK) {
if (status == DLADM_STATUS_NONOTIF) {
"detection; must use -f (see dladm(1M))\n");
} else {
}
}
}
/*
* arg is either the key or the aggr name. Validate it and convert it to
* the linkid if altroot is NULL.
*/
static dladm_status_t
{
int key = 0;
return (DLADM_STATUS_LINKINVAL);
return (DLADM_STATUS_OK);
NULL);
} else {
}
return (status);
}
static void
{
char option;
opterr = 0;
switch (option) {
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
break;
}
}
/* get key value or the aggregation name (required last argument) */
usage();
if (status != DLADM_STATUS_OK)
goto done;
done:
if (status != DLADM_STATUS_OK)
}
static void
{
char option;
NULL)) != -1) {
switch (option) {
case 'd':
die("too many ports specified");
break;
case 'l':
die("too many ports specified");
break;
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'f':
flags |= DLADM_OPT_FORCE;
break;
case 'R':
break;
default:
break;
}
}
usage();
/* get key value or the aggregation name (required last argument) */
usage();
goto done;
}
for (n = 0; n < ndev; n++) {
}
}
for (n = 0; n < nlink; n++) {
}
}
done:
if (status != DLADM_STATUS_OK) {
/*
* checking DLADM_STATUS_NOTSUP is a temporary workaround
* and should be removed once 6399681 is fixed.
*/
if (status == DLADM_STATUS_NOTSUP) {
gettext("%s: add operation failed: %s\n"),
gettext("link capabilities don't match"));
} else if (status == DLADM_STATUS_NONOTIF) {
"detection; must use -f (see dladm(1M))\n");
} else {
}
}
}
static void
{
char option;
switch (option) {
case 'd':
die("too many ports specified");
break;
case 'l':
die("too many ports specified");
break;
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
break;
}
}
usage();
/* get key value or the aggregation name (required last argument) */
usage();
if (status != DLADM_STATUS_OK)
goto done;
for (n = 0; n < ndev; n++) {
}
}
for (n = 0; n < nlink; n++) {
}
}
done:
if (status != DLADM_STATUS_OK)
}
static void
{
char option;
uint8_t modify_mask = 0;
opterr = 0;
NULL)) != -1) {
switch (option) {
case 'P':
break;
case 'u':
if (modify_mask & DLADM_AGGR_MODIFY_MAC)
mac_addr))
break;
case 'l':
case 'L':
break;
case 'T':
break;
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
break;
}
}
if (modify_mask == 0)
die("at least one of the -PulT options must be specified");
/* get key value or the aggregation name (required last argument) */
usage();
if (status != DLADM_STATUS_OK)
goto done;
flags);
done:
if (status != DLADM_STATUS_OK)
}
/*ARGSUSED*/
static void
{
/*
* get the key or the name of the aggregation (optional last argument)
*/
if (argc == 2) {
goto done;
} else if (argc > 2) {
usage();
}
done:
if (status != DLADM_STATUS_OK) {
if (argc == 2) {
} else {
}
}
}
static void
{
char drv[DLPI_LINKNAME_MAX];
int vid = 0;
char option;
char vlan[MAXLINKNAMELEN];
char propstr[DLADM_STRSIZE];
opterr = 0;
switch (option) {
case 'v':
if (vid != 0)
break;
case 'l':
break;
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
case 'p':
break;
case 'f':
flags |= DLADM_OPT_FORCE;
break;
default:
break;
}
}
/* get vlan name if there is any */
usage();
}
} else {
(ppa >= 1000) ||
DLPI_SUCCESS)) {
}
}
}
!= DLADM_STATUS_OK)
die("invalid vlan property");
}
}
static void
{
char option;
opterr = 0;
switch (option) {
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
break;
}
}
/* get VLAN link name (required last argument) */
usage();
NULL);
if (status != DLADM_STATUS_OK)
goto done;
done:
if (status != DLADM_STATUS_OK)
}
/*ARGSUSED*/
static void
{
}
static void
{
char option;
opterr = 0;
switch (option) {
case 'R':
break;
default:
break;
}
}
/* get link1 and link2 name (required the last 2 arguments) */
usage();
}
/*ARGSUSED*/
static void
{
/* get link name (required the last argument) */
if (argc > 2)
usage();
if (argc == 2) {
}
if (argc == 2)
else
}
}
/*ARGSUSED*/
static int
{
char name[MAXLINKNAMELEN];
char mediabuf[DLADM_STRSIZE];
char classbuf[DLADM_STRSIZE];
MAXLINKNAMELEN) == DLADM_STATUS_OK) {
}
return (DLADM_WALK_CONTINUE);
}
/*ARGSUSED*/
static void
{
if (argc != 1)
die("invalid arguments");
"CLASS", "MEDIA", "FLAGS");
}
/*
* Delete inactive physical links.
*/
/*ARGSUSED*/
static int
{
!= DLADM_STATUS_OK) {
return (DLADM_WALK_CONTINUE);
}
return (DLADM_WALK_CONTINUE);
}
/*ARGSUSED*/
static void
{
if (argc > 1)
usage();
/*
* Force all the devices to attach, therefore all the network physical
* devices can be known to the dlmgmtd daemon.
*/
}
/*
* Print the active topology information.
*/
static dladm_status_t
{
char tmpbuf[MAXLINKNAMELEN];
if (class == DATALINK_CLASS_VLAN) {
if (status != DLADM_STATUS_OK)
goto done;
if (status != DLADM_STATUS_OK)
goto done;
} else if (class == DATALINK_CLASS_AGGR) {
int i;
if (status != DLADM_STATUS_OK)
goto done;
goto done;
}
if (status != DLADM_STATUS_OK) {
goto done;
}
}
}
} else if (class == DATALINK_CLASS_VNIC) {
goto done;
}
}
done:
return (status);
}
static dladm_status_t
{
char link[MAXLINKNAMELEN];
goto done;
}
goto done;
}
if (class == DATALINK_CLASS_PHYS) {
DLADM_OPT_ACTIVE)) != DLADM_STATUS_OK) {
goto done;
}
if (!dpa.dp_novanity)
goto link_mtu;
/*
* This is a physical link that does not have
* vanity naming support.
*/
DLPI_SUCCESS) {
goto done;
}
dlpi_close(dh);
goto done;
}
dlpi_close(dh);
} else {
if (status != DLADM_STATUS_OK)
goto done;
}
}
"%s", link);
"%u", mtu);
}
if (status != DLADM_STATUS_OK)
goto done;
done:
return (status);
}
/* ARGSUSED */
static int
{
/*
* first get all the link attributes into lbuf;
*/
if (status != DLADM_STATUS_OK)
goto done;
done:
return (DLADM_WALK_CONTINUE);
}
static boolean_t
{
case LINK_S_LINK:
break;
case LINK_S_IPKTS:
break;
case LINK_S_RBYTES:
break;
case LINK_S_IERRORS:
break;
case LINK_S_OPKTS:
break;
case LINK_S_OBYTES:
break;
case LINK_S_OERRORS:
break;
default:
die("invalid input");
break;
}
return (B_TRUE);
}
static int
{
char link[DLPI_LINKNAME_MAX];
if (state->ls_firstonly) {
if (state->ls_donefirst)
return (DLADM_WALK_CONTINUE);
} else {
}
DLPI_LINKNAME_MAX) != DLADM_STATUS_OK) {
return (DLADM_WALK_CONTINUE);
}
if (class == DATALINK_CLASS_PHYS) {
return (DLADM_WALK_CONTINUE);
}
if (dpa.dp_novanity)
else
} else {
}
return (DLADM_WALK_CONTINUE);
}
static dladm_status_t
{
"%s", link);
if (ginfop->lg_mac_fixed) {
} else {
}
return (DLADM_STATUS_OK);
}
static boolean_t
{
int portnum;
static char tmpbuf[DLADM_STRSIZE];
stat = l->laggr_status;
if (is_port) {
portnum = l->laggr_lport;
goto err;
}
goto err;
}
}
case AGGR_X_LINK:
break;
case AGGR_X_PORT:
if (is_port)
break;
*stat = DLADM_STATUS_OK;
return (B_TRUE);
case AGGR_X_SPEED:
if (is_port) {
B_FALSE)) / 1000000ull));
} else {
B_TRUE)) / 1000000ull));
}
break;
case AGGR_X_DUPLEX:
if (is_port)
else
break;
case AGGR_X_STATE:
if (is_port)
else
break;
case AGGR_X_ADDRESS:
(void) dladm_aggr_macaddr2str(
tmpbuf);
break;
case AGGR_X_PORTSTATE:
if (is_port) {
tmpbuf);
}
break;
}
err:
return (B_TRUE);
}
static dladm_status_t
{
int i;
if (status != DLADM_STATUS_OK)
goto done;
largs.laggr_lport = i;
if (status != DLADM_STATUS_OK)
goto done;
}
done:
return (status);
}
static boolean_t
{
int portnum;
if (!is_port) {
return (B_FALSE); /* cannot happen! */
}
stat = l->laggr_status;
portnum = l->laggr_lport;
goto err;
}
case AGGR_L_LINK:
break;
case AGGR_L_PORT:
/*
* buf already contains portname as a result of the
* earlier call to dladm_datalink_id2info().
*/
break;
case AGGR_L_AGGREGATABLE:
break;
case AGGR_L_SYNC:
break;
case AGGR_L_COLL:
break;
case AGGR_L_DIST:
break;
case AGGR_L_DEFAULTED:
break;
case AGGR_L_EXPIRED:
break;
}
*stat = DLADM_STATUS_OK;
return (B_TRUE);
err:
return (B_TRUE);
}
static dladm_status_t
{
int i;
largs.laggr_lport = i;
if (status != DLADM_STATUS_OK)
goto done;
}
done:
return (status);
}
static boolean_t
{
int portnum;
stat = l->laggr_status;
*stat = DLADM_STATUS_OK;
if (is_port) {
portnum = l->laggr_lport;
goto err;
}
diff_stats = l->laggr_diffstats;
}
case AGGR_S_LINK:
break;
case AGGR_S_PORT:
/*
* if (is_port), buf has port name. Otherwise we print
* STR_UNDEF_VAL
*/
break;
case AGGR_S_IPKTS:
if (is_port) {
} else {
l->laggr_pktsumtot->ipackets);
}
break;
case AGGR_S_RBYTES:
if (is_port) {
diff_stats->rbytes);
} else {
l->laggr_pktsumtot->rbytes);
}
break;
case AGGR_S_OPKTS:
if (is_port) {
} else {
l->laggr_pktsumtot->opackets);
}
break;
case AGGR_S_OBYTES:
if (is_port) {
diff_stats->obytes);
} else {
l->laggr_pktsumtot->obytes);
}
break;
case AGGR_S_IPKTDIST:
if (is_port) {
(double)diff_stats->ipackets/
}
break;
case AGGR_S_OPKTDIST:
if (is_port) {
(double)diff_stats->opackets/
}
break;
}
return (B_TRUE);
err:
return (B_TRUE);
}
static dladm_status_t
{
int i;
/* sum the ports statistics */
/* Allocate memory to keep stats of each port */
/* Bail out; no memory */
return (DLADM_STATUS_NOMEM);
}
DLADM_OPT_ACTIVE)) != DLADM_STATUS_OK) {
goto done;
}
/*
* Let's re-use gs_prevstats[] to store the difference of the
* counters since last use. We will store the new stats from
* port_stat[] once we have the stats displayed.
*/
&state->gs_prevstats[i]);
&state->gs_prevstats[i]);
}
if (status != DLADM_STATUS_OK)
goto done;
largs.laggr_lport = i;
if (status != DLADM_STATUS_OK)
goto done;
}
done:
return (status);
}
static dladm_status_t
{
char link[MAXLINKNAMELEN];
return (status);
}
return (DLADM_STATUS_NOTFOUND);
if (status != DLADM_STATUS_OK)
return (status);
else if (state->gs_extended)
else
done:
return (status);
}
/* ARGSUSED */
static int
{
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
char linkname[MAXLINKNAMELEN];
char *fields_str = NULL;
char *all_active_fields = "link,class,mtu,state,over";
char *all_inactive_fields = "link,class,over";
char *allstat_fields =
"link,ipackets,rbytes,ierrors,opackets,obytes,oerrors";
opterr = 0;
switch (option) {
case 'p':
if (p_arg)
break;
case 's':
if (s_arg)
break;
case 'P':
if (flags != DLADM_OPT_ACTIVE)
break;
case 'S':
if (S_arg)
break;
case 'o':
fields_str = optarg;
break;
case 'i':
if (i_arg)
break;
default:
break;
}
}
die("the option -i can be used only with -s or -S");
die("the -s option cannot be used with -S");
die("the option -P cannot be used with -s");
/* get link name (optional last argument) */
uint32_t f;
>= MAXLINKNAMELEN) {
gettext("%s: link name too long\n"),
progname);
exit(1);
}
}
if (!(f & flags)) {
"a temporary link" : "temporarily removed");
}
usage();
}
die("-p requires -o");
if (S_arg) {
return;
}
die("\"-o all\" is invalid with -p");
if (s_arg)
else if (flags & DLADM_OPT_ACTIVE)
else
}
if (s_arg) {
return;
}
if (state.ls_parsable)
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static void
{
int option;
int key;
char *fields_str = NULL;
char *all_fields =
"link,policy,addrpolicy,lacpactivity,lacptimer,flags";
char *all_lacp_fields =
"link,port,aggregatable,sync,coll,dist,defaulted,expired";
char *all_stats_fields =
"link,port,ipackets,rbytes,opackets,obytes,ipktdist,opktdist";
char *all_extended_fields =
"link,port,speed,duplex,state,address,portstate";
opterr = 0;
switch (option) {
case 'L':
if (L_arg)
break;
case 'p':
if (p_arg)
break;
case 'x':
if (x_arg)
break;
case 'P':
if (flags != DLADM_OPT_ACTIVE)
break;
case 's':
if (s_arg)
break;
case 'o':
fields_str = optarg;
break;
case 'i':
if (i_arg)
break;
default:
break;
}
}
die("-p requires -o");
die("\"-o all\" is invalid with -p");
die("the option -i can be used only with -s");
die("the option -%c cannot be used with -s",
}
die("the option -P cannot be used with -L");
/* get aggregation key or aggrname (optional last argument) */
} else {
}
if (status != DLADM_STATUS_OK)
usage();
}
else if (state.gs_extended)
else
}
pf = aggr_l_fields;
pf = aggr_s_fields;
} else if (state.gs_extended) {
pf = aggr_x_fields;
} else {
pf = laggr_fields;
}
if (state.gs_parsable)
if (s_arg) {
return;
}
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
goto done;
if (!dpa.dp_novanity) {
} else {
/*
* This is a physical link that does not have
* vanity naming support.
*/
}
islink)) / 1000000ull));
} else {
"%s", link);
}
done:
return (status);
}
typedef struct {
char *ms_link;
/*
* callback for ofmt_print()
*/
static boolean_t
{
case PHYS_M_LINK:
break;
case PHYS_M_SLOT:
if (is_primary)
else
break;
case PHYS_M_ADDRESS:
break;
case PHYS_M_INUSE:
gettext("no"));
break;
case PHYS_M_CLIENT:
/*
* CR 6678526: resolve link id to actual link name if
* it is valid.
*/
break;
}
return (B_TRUE);
}
typedef struct {
char *hs_link;
static boolean_t
{
case PHYS_H_LINK:
break;
case PHYS_H_GROUP:
break;
case PHYS_H_GRPTYPE:
break;
case PHYS_H_RINGS:
break;
case PHYS_H_CLIENTS:
} else {
}
break;
}
return (B_TRUE);
}
/*
* callback for dladm_walk_macaddr, invoked for each MAC address slot
*/
static boolean_t
{
return (B_TRUE);
}
/*
* invoked by show-phys -m for each physical data-link
*/
static dladm_status_t
{
}
/*
* callback for dladm_walk_hwgrp, invoked for each MAC hwgrp
*/
static boolean_t
{
return (B_TRUE);
}
/* invoked by show-phys -H for each physical data-link */
static dladm_status_t
{
}
static dladm_status_t
{
char link[MAXLINKNAMELEN];
goto done;
}
if (class != DATALINK_CLASS_PHYS) {
goto done;
}
goto done;
}
else
done:
return (status);
}
/* ARGSUSED */
static int
{
return (DLADM_WALK_CONTINUE);
}
/*
* Print the active topology information.
*/
static dladm_status_t
{
goto done;
}
goto done;
}
goto done;
}
done:
return (status);
}
/* ARGSUSED */
static int
{
if (status != DLADM_STATUS_OK)
goto done;
done:
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
char *fields_str = NULL;
char *all_active_fields =
"link,media,state,speed,duplex,device";
char *all_inactive_fields = "link,device,media,flags";
char *all_mac_fields = "link,slot,address,inuse,client";
char *all_hwgrp_fields =
"link,group,grouptype,rings,clients";
opterr = 0;
switch (option) {
case 'p':
if (p_arg)
break;
case 'P':
if (flags != DLADM_OPT_ACTIVE)
break;
case 'o':
fields_str = optarg;
break;
case 'm':
break;
case 'H':
break;
default:
break;
}
}
die("-p requires -o");
die("-m cannot combine with -H");
die("\"-o all\" is invalid with -p");
/* get link name (optional last argument) */
}
usage();
}
/*
* We can only display the factory MAC addresses of
* active data-links.
*/
die("-m not compatible with -P");
}
} else {
}
}
pf = phys_m_fields;
pf = phys_h_fields;
} else {
pf = phys_fields;
}
if (state.ls_parsable)
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static void
{
int option;
char *fields_str = NULL;
opterr = 0;
switch (option) {
case 'p':
if (p_arg)
break;
case 'P':
if (flags != DLADM_OPT_ACTIVE)
break;
case 'o':
fields_str = optarg;
break;
default:
break;
}
}
/* get link name (optional last argument) */
}
usage();
}
fields_str = NULL;
if (state.ls_parsable)
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static void
{
char devname[MAXLINKNAMELEN];
char name[MAXLINKNAMELEN];
char option;
char propstr[DLADM_STRSIZE];
int vid = 0;
opterr = 0;
switch (option) {
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
case 'l':
die("link name too long");
break;
case 'm':
/*
* A fixed MAC address must be specified
* by its value, not by the keyword 'fixed'.
*/
die("'fixed' is not a valid MAC address");
}
&mac_addr_type) != DLADM_STATUS_OK) {
/* MAC address specified by value */
if (maclen == -1)
die("invalid MAC address");
else
die("out of memory");
}
}
break;
case 'n':
errno = 0;
die("invalid slot number");
break;
case 'p':
break;
case 'r':
if (mac_prefix_len == -1)
die("invalid MAC address");
else
die("out of memory");
}
break;
case 'v':
if (vid != 0)
break;
case 'f':
flags |= DLADM_OPT_FORCE;
break;
case 'H':
break;
default:
}
}
/*
* 'f' - force, flag can be specified only with 'v' - vlan.
*/
die("-f option can only be used with -v");
usage();
/* check required options */
if (!l_arg)
usage();
usage();
/* the VNIC id is the required operand */
usage();
if (!dladm_valid_linkname(name))
!= DLADM_STATUS_OK)
die("invalid vnic property");
flags);
if (status != DLADM_STATUS_OK)
}
static void
{
/*
* Let the delete continue anyway.
*/
return;
}
if (is_etherstub != etherstub) {
}
}
static void
{
char option;
opterr = 0;
NULL)) != -1) {
switch (option) {
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
}
}
/* get vnic name (required last argument) */
usage();
NULL);
if (status != DLADM_STATUS_OK)
if ((flags & DLADM_OPT_ACTIVE) != 0) {
}
if ((flags & DLADM_OPT_PERSIST) != 0) {
}
if (status != DLADM_STATUS_OK)
}
static void
{
}
/* ARGSUSED */
static void
{
char *type;
/*
*/
if (argc == 2) {
NULL);
if (status != DLADM_STATUS_OK)
goto done;
} else if (argc > 2) {
usage();
}
if (vlan)
else
done:
if (status != DLADM_STATUS_OK) {
if (argc == 2) {
} else {
}
}
}
static void
{
}
static void
dump_vnics_head(const char *dev)
{
(void) printf("\tipackets rbytes opackets obytes ");
(void) printf("%%ipkts %%opkts\n");
else
(void) printf("\n");
}
static void
{
if (tot_stats) {
(void) printf("\t-");
} else {
}
(void) printf("\t-");
} else {
}
}
(void) printf("\n");
*old_stats = *vnic_stats;
}
/*
* Called from the walker dladm_vnic_walk_sys() for each vnic to display
* vnic information or statistics.
*/
static dladm_status_t
{
char devname[MAXLINKNAMELEN];
char vnic_name[MAXLINKNAMELEN];
return (status);
/*
* Want all etherstub but it's not one, or want
* non-etherstub and it's one.
*/
return (DLADM_STATUS_OK);
}
return (DLADM_STATUS_OK);
}
return (DLADM_STATUS_BADARG);
if (!is_etherstub &&
return (DLADM_STATUS_BADARG);
/* print vnic statistics */
if (state->vs_firstonly) {
if (state->vs_donefirst)
return (0);
}
if (!state->vs_printstats) {
/*
* get vnic statistics and add to the sum for the
* named device.
*/
} else {
/* get and print vnic statistics */
&state->vs_totalstats);
}
return (DLADM_STATUS_OK);
} else {
"%s", vnic_name);
if (!is_etherstub) {
"%s", devname);
/ 1000000ull));
switch (vnic->va_mac_addr_type) {
case VNIC_MAC_ADDR_TYPE_FIXED:
sizeof (vbuf.vnic_macaddrtype),
gettext("fixed"));
break;
sizeof (vbuf.vnic_macaddrtype),
gettext("random"));
break;
sizeof (vbuf.vnic_macaddrtype),
gettext("factory, slot %d"),
vnic->va_mac_slot);
break;
}
mstr));
}
}
return (DLADM_STATUS_OK);
}
}
/* ARGSUSED */
static int
{
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
char *fields_str = NULL;
char *all_e_fields = "link";
opterr = 0;
NULL)) != -1) {
switch (option) {
case 'p':
break;
case 'P':
break;
case 'l':
if (etherstub)
die("option not supported for this command");
die("link name too long");
break;
case 's':
if (s_arg) {
die("the option -s cannot be specified "
"more than once");
}
break;
case 'i':
if (i_arg) {
die("the option -i cannot be specified "
"more than once");
}
break;
case 'o':
fields_str = optarg;
break;
default:
}
}
die("the option -i can be used only with -s");
/* get vnic ID (optional last argument) */
if (status != DLADM_STATUS_OK) {
}
usage();
}
if (l_arg) {
if (status != DLADM_STATUS_OK) {
}
}
if (etherstub)
}
pf = vnic_fields;
if (state.vs_parsable)
if (s_arg) {
/* Display vnic statistics */
return;
}
/* Display vnic information */
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static void
{
}
static void
{
char option;
char name[MAXLINKNAMELEN];
name[0] = '\0';
opterr = 0;
switch (option) {
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
}
}
/* the etherstub id is the required operand */
usage();
if (!dladm_valid_linkname(name))
if (status != DLADM_STATUS_OK)
}
static void
{
}
/* ARGSUSED */
static void
{
}
static void
{
if (state->ls_parsable)
/*
* If an interval is specified, continuously show the stats
* only for the first MAC port.
*/
for (;;) {
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
if (interval == 0)
break;
}
}
static void
{
/*
* If an interval is specified, continuously show the stats
* only for the first group.
*/
for (;;) {
if (linkid == DATALINK_ALL_LINKID)
else
if (interval == 0)
break;
}
}
/* ARGSUSED */
static void
{
/* Display vnic statistics */
/*
* If an interval is specified, and a vnic ID is not specified,
* continuously show the stats only for the first vnic.
*/
for (;;) {
/* Get stats for each vnic */
if (!specific_link) {
} else {
}
}
/* Show totals */
(void) printf("Total");
(void) printf("\t%-10llu",
(void) printf("%-12llu",
(void) printf("%-10llu",
(void) printf("%-12llu\n",
}
/* Show stats for each vnic */
if (!specific_link) {
} else {
}
}
if (interval == 0)
break;
}
}
static void
{
char module[DLPI_LINKNAME_MAX];
return;
warn("kstat open operation failed");
return;
}
(void) kstat_close(kcp);
}
static void
{
warn("kstat_open operation failed");
return;
}
(void) kstat_close(kcp);
}
static int
{
warn("kstat open operation failed");
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 int
{
char module[DLPI_LINKNAME_MAX];
if (islink) {
} else {
return (-1);
}
}
static uint64_t
{
return (ifspeed);
}
static const char *
{
return (buf);
}
}
static const char *
{
&linkduplex, islink) != 0) {
return (buf);
}
}
static int
{
if (cmdtype == WIFI_CMD_SCAN) {
} else if (cmdtype == WIFI_CMD_SHOW) {
sizeof (wifi_common_fields));
} else {
return (-1);
}
}
0, ofmt);
return (0);
}
typedef struct print_wifi_state {
char *ws_link;
typedef struct wlan_scan_args_s {
void *ws_attr;
static boolean_t
{
char tmpbuf[DLADM_STRSIZE];
return (B_TRUE);
}
return (B_TRUE);
case DLADM_WLAN_ATTR_ESSID:
break;
case DLADM_WLAN_ATTR_BSSID:
break;
case DLADM_WLAN_ATTR_SECMODE:
break;
case DLADM_WLAN_ATTR_STRENGTH:
break;
case DLADM_WLAN_ATTR_MODE:
break;
case DLADM_WLAN_ATTR_SPEED:
break;
case DLADM_WLAN_ATTR_AUTH:
break;
case DLADM_WLAN_ATTR_BSSTYPE:
break;
}
return (B_TRUE);
}
static boolean_t
{
return (B_TRUE);
}
static int
{
char link[MAXLINKNAMELEN];
sizeof (link))) != DLADM_STATUS_OK) {
return (DLADM_WALK_CONTINUE);
}
if (status != DLADM_STATUS_OK)
return (DLADM_WALK_CONTINUE);
}
static boolean_t
{
static char tmpbuf[DLADM_STRSIZE];
}
return (B_TRUE);
}
static boolean_t
{
}
static int
{
char link[MAXLINKNAMELEN];
sizeof (link))) != DLADM_STATUS_OK) {
return (DLADM_WALK_CONTINUE);
}
/* dladm_wlan_get_linkattr() memsets attr with 0 */
if (status != DLADM_STATUS_OK)
return (DLADM_WALK_CONTINUE);
}
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':
break;
default:
}
}
die("-p requires -o");
die("\"-o all\" is invalid with -p");
}
usage();
}
state.ws_parsable) < 0)
die("invalid field(s) specified");
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
static void
{
}
static void
{
}
typedef struct wlan_count_attr {
/* ARGSUSED */
static int
{
return (DLADM_WALK_CONTINUE);
}
static int
{
uint_t i;
int nfields = 1;
if (c == ',')
nfields++;
}
return (-1);
goto fail;
for (i = 0; i < nfields; i++) {
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;
char buf[DLADM_STRSIZE];
opterr = 0;
switch (option) {
case 'e':
if (status != DLADM_STATUS_OK)
/*
* Try to connect without doing a scan.
*/
break;
case 'i':
if (status != DLADM_STATUS_OK)
break;
case 'a':
if (status != DLADM_STATUS_OK)
break;
case 'm':
if (status != DLADM_STATUS_OK)
break;
case 'b':
}
break;
case 's':
}
break;
case 'k':
else
break;
case 'T':
timeout = -1;
break;
}
break;
case 'c':
break;
default:
break;
}
}
if (keysecmode == DLADM_WLAN_SECMODE_NONE) {
die("key required for security mode '%s'",
}
} else {
die("incompatible -s and -k options");
}
}
usage();
}
if (linkid == DATALINK_ALL_LINKID) {
die("no wifi links are available");
die("link name is required when more than one wifi "
"link is available");
}
}
if ((flags & DLADM_WLAN_CONNECT_NOSCAN) != 0) {
/*
* Try again with scanning and filtering.
*/
goto again;
}
if (status == DLADM_STATUS_NOTFOUND) {
die("no wifi networks are available");
} else {
die("no wifi networks with the specified "
"criteria are available");
}
}
}
}
/* ARGSUSED */
static int
{
if (status != DLADM_STATUS_OK)
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
opterr = 0;
switch (option) {
case 'a':
break;
default:
break;
}
}
}
usage();
}
if (linkid == DATALINK_ALL_LINKID) {
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 != DLADM_STATUS_OK)
}
static void
char **pptr)
{
int i;
char buf[DLADM_STRSIZE];
&valcnt);
if (status != DLADM_STATUS_OK) {
if (status == DLADM_STATUS_TEMPONLY) {
if (type == DLADM_PROP_VAL_MODIFIABLE &&
statep->ls_persist) {
valcnt = 1;
} else {
return;
}
} else if (status == DLADM_STATUS_NOTSUP ||
statep->ls_persist) {
valcnt = 1;
if (type == DLADM_PROP_VAL_CURRENT ||
else
} else if (status == DLADM_STATUS_NOTDEFINED) {
} else {
if (statep->ls_proplist &&
"cannot get link property '%s' for %s",
}
return;
}
}
for (i = 0; i < valcnt; i++) {
else
break;
}
if (valcnt > 0)
if (statep->ls_parsable) {
"%s", buf);
} else {
}
}
static boolean_t
{
case LINKPROP_LINK:
break;
case LINKPROP_PROPERTY:
break;
case LINKPROP_VALUE:
/*
* If we failed to query the link property, for example, query
* the persistent value of a non-persistable link property,
* simply skip the output.
*/
goto skip;
break;
case LINKPROP_PERM:
goto skip;
break;
case LINKPROP_DEFAULT:
goto skip;
break;
case LINKPROP_POSSIBLE:
goto skip;
break;
default:
die("invalid input");
break;
}
return (B_TRUE);
skip:
}
static boolean_t
{
/* if used with -p flag, always print output */
return (B_TRUE);
if (status == DLADM_STATUS_OK)
return (B_TRUE);
/*
* A system wide default value is not available for the
* property. Check if current value can be retrieved.
*/
return (status == DLADM_STATUS_OK);
}
/* ARGSUSED */
static int
void *arg)
{
/*
* This will need to be fixed when kernel interfaces are added
* to enable walking of all known private properties. For now,
* we are limited to walking persistent private properties only.
*/
return (DLADM_WALK_CONTINUE);
if (!statep->ls_parsable &&
return (DLADM_WALK_CONTINUE);
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
char propstr[DLADM_STRSIZE];
char *fields_str = NULL;
opterr = 0;
switch (option) {
case 'p':
break;
case 'c':
break;
case 'P':
break;
case 'o':
fields_str = optarg;
break;
default:
break;
}
}
}
usage();
}
!= DLADM_STATUS_OK)
die("invalid link properties specified");
if (state.ls_parsable)
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static int
{
int i;
char *buf;
return (DLADM_WALK_CONTINUE);
}
return (DLADM_WALK_CONTINUE);
}
/*
* 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.
*
* Note that failure of dlpi_open() does not necessarily mean invalid
* link properties, because dlpi_open() may fail because of incorrect
* autopush configuration. Therefore, we ingore the return value of
* dlpi_open().
*/
if (!statep->ls_persist)
die("insufficient memory");
for (i = 0; i < DLADM_MAX_PROP_VALCNT; i++) {
sizeof (char *) * DLADM_MAX_PROP_VALCNT +
i * DLADM_PROP_VAL_MAX;
}
(sizeof (char *) + DLADM_PROP_VAL_MAX) * DLADM_MAX_PROP_VALCNT;
}
} else {
}
dlpi_close(dh);
return (DLADM_WALK_CONTINUE);
}
static dladm_status_t
{
if (status != DLADM_STATUS_OK) {
}
return (status);
}
static int
{
if (status != DLADM_STATUS_OK) {
}
if (s != DLADM_STATUS_OK)
status = s;
}
if (status != DLADM_STATUS_OK)
return (DLADM_WALK_CONTINUE);
}
static void
{
int i, option;
char errmsg[DLADM_STRSIZE];
char propstr[DLADM_STRSIZE];
opterr = 0;
switch (option) {
case 'p':
break;
case 't':
break;
case 'R':
break;
default:
}
}
/* get link name (required last argument) */
usage();
die("invalid link properties specified");
die("link property must be specified");
}
NULL);
if (status != DLADM_STATUS_OK)
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) {
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 < DLADM_MAX_PROP_VALCNT; j++) {
j * DLADM_PROP_VAL_MAX;
}
&valcnt);
if (s != DLADM_STATUS_OK) {
break;
}
*ptr = '\0';
for (j = 0; j < valcnt; j++) {
propvals[j]);
break;
}
warn("link property '%s' must be one of: %s",
} else
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_WPA) {
return (EINVAL);
return (error);
}
if (class == DLADM_SECOBJ_CLASS_WEP) {
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);
}
return (ENOENT);
}
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, wpa", 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 (!dladm_valid_secobj_name(obj_name))
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;
int nfields = 1;
opterr = 0;
switch (option) {
case 't':
break;
case 'R':
if (status != DLADM_STATUS_OK) {
"specified");
}
break;
default:
break;
}
}
die("secure object name required");
if (c == ',')
nfields++;
}
die("no memory");
usage();
if (!success)
for (i = 0; i < nfields; i++) {
if (!temp) {
} else {
}
if (status != DLADM_STATUS_OK) {
"'%s'", field);
}
if (pstatus != DLADM_STATUS_OK) {
"secure object '%s'", field);
}
}
exit(1);
}
}
typedef struct show_secobj_state {
static boolean_t
{
char buf[DLADM_STRSIZE];
if (statep->ss_persist)
flags);
if (status != DLADM_STATUS_OK)
obj_name);
if (getuid() == 0) {
}
return (B_TRUE);
}
static void
{
int option;
uint_t i;
char *fields_str = NULL;
char *def_fields = "object,class";
char *all_fields = "object,class,value";
opterr = 0;
switch (option) {
case 'p':
break;
case 'P':
break;
case 'o':
else
fields_str = optarg;
break;
default:
break;
}
}
die("option -c requires -o");
die("\"-o all\" is invalid with -p");
if (state.ss_parsable)
die("secure object name required");
if (c == ',')
obj_fields++;
}
die("no memory");
for (i = 0; i < obj_fields; i++) {
break;
}
return;
usage();
if (status != DLADM_STATUS_OK)
}
/*ARGSUSED*/
static int
{
return (DLADM_WALK_CONTINUE);
}
/*ARGSUSED*/
void
{
int option;
opterr = 0;
switch (option) {
case 'w':
break;
default:
/*
* Because init-linkprop is not a public command,
* print the usage instead.
*/
usage();
break;
}
}
usage();
}
if (linkid == DATALINK_ALL_LINKID) {
/*
* linkprops of links of other classes have been initialized as
* part of the dladm up-xxx operation.
*/
} else {
}
}
static void
{
int option;
char *fields_str = NULL;
switch (option) {
case 'x':
break;
case 'p':
break;
case 'o':
fields_str = optarg;
break;
default:
break;
}
}
if (state.es_parsable)
} else {
die("invalid link specified");
}
}
static int
{
return (DLADM_WALK_CONTINUE);
}
if (status != DLADM_STATUS_OK)
goto cleanup;
sizeof (ebuf.eth_rem_fault));
if (statep->es_extended)
return (DLADM_WALK_CONTINUE);
}
/* ARGSUSED */
static void
{
if (status != DLADM_STATUS_OK)
}
/*
* "-R" option support. It is used for live upgrading. Append dladm commands
* to a upgrade script which will be run when the alternative root boots up:
*
* - If the /etc/dladm/datalink.conf file exists on the alternative root,
* append dladm commands to the <altroot>/var/svc/profile/upgrade_datalink
* plumbs various interfaces.
*
* - If the /etc/dladm/datalink.conf file does not exist on the alternative
* which will be run in the manifest-import service.
*
* Note that the SMF team is considering to move the manifest-import service
* to be run at the very begining of boot. Once that is done, the need for
* the /var/svc/profile/upgrade_datalink script will not exist any more.
*/
static void
{
char path[MAXPATHLEN];
int i;
/*
* Check for the existence of the /etc/dladm/datalink.conf
* configuration file, and determine the name of script file.
*/
altroot);
} else {
}
for (i = 0; i < argc; i++) {
/*
* Directly write to the file if it is not the "-R <altroot>"
* option. In which case, skip it.
*/
else
i ++;
}
exit(0);
}
/*
* Convert the string to an integer. Note that the string must not have any
* trailing non-integer characters.
*/
static boolean_t
{
int val;
errno = 0;
return (B_FALSE);
return (B_TRUE);
}
/* PRINTFLIKE1 */
static void
{
(void) putchar('\n');
}
/* PRINTFLIKE2 */
static void
{
char errmsg[DLADM_STRSIZE];
}
/*
* Also closes the dladm handle if it is not NULL.
*/
/* PRINTFLIKE2 */
static void
{
char errmsg[DLADM_STRSIZE];
/* close dladm handle if it was opened */
}
/* PRINTFLIKE1 */
static void
{
(void) putchar('\n');
/* close dladm handle if it was opened */
}
static void
die_optdup(int opt)
{
}
static void
{
switch (opterr) {
case ':':
break;
case '?':
default:
break;
}
}
static void
{
int i;
sizeof (ebuf.eth_rem_fault));
}
}
static boolean_t
{
return (B_TRUE);
}
return (B_FALSE);
}
/*
* default output callback function that, when invoked,
* prints string which is offset by ofmt_arg->ofmt_id within buf.
*/
static boolean_t
{
char *value;
return (B_TRUE);
}
static void
{
char buf[OFMT_BUFSIZE];
if (oferr == OFMT_SUCCESS)
return;
/*
* All errors are considered fatal in parsable mode.
* NOMEM errors are always fatal, regardless of mode.
* For other errors, we print diagnostics in human-readable
* mode and processs what we can.
*/
} else {
}
}