dladm.c revision 6be03d0bfa1168f0c0751e49fa681e3c985251d1
/*
* 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 2008 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 <libdllink.h>
#include <libdlaggr.h>
#include <libdlwlan.h>
#include <libdlvlan.h>
#include <libdlvnic.h>
#include <libinetutil.h>
#include <bsm/adt_event.h>
#include <stddef.h>
#define AGGR_DRV "aggr"
#define STR_UNDEF_VAL "--"
#define MAXPORT 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 CMD_TYPE_ANY 0xffffffff
#define WIFI_CMD_SCAN 0x00000001
#define WIFI_CMD_SHOW 0x00000002
/*
* Data structures and routines for printing output.
* All non-parseable output is assumed to be in a columnar format.
* Multiple fields in parsable output are separated by ':'; single
* field output is printed as-is.
*
* Each sub-command is associated with a global array of pointers,
* print_field_t *fields[], where the print_field_t contains information
* about the format in which the output is to be printed.
*
* Sub-commands may be implemented in one of two ways:
* (i) the implementation could get all field values into a character
* buffer, with pf_offset containing the offset (for pf_name) within
* the buffer. The sub-command would make the needed system calls
* to obtain all possible column values and then invoke the
* dladm_print_field() function to print the specific fields
* requested in the command line. See the comments for dladm_print_field
* for further details.
* (ii) Alternatively, each fields[i] entry could store a pf_index value
* that uniquely identifies the column to be printed. The implementation
* of the sub-command would then invoke dladm_print_output() with a
* callback function whose semantics are described below (see comments
* for dladm_print_output())
*
* Thus, an implementation of a sub-command must provide the following:
*
* static print_field_t sub_command_fields[] = {
* {<name>, <header>,<field width>, <offset_or_index>, cmdtype},
* :
* {<name>, <header>,<field width>, <offset_or_index>, cmdtype}
* };
*
* #define SUB_COMMAND_MAX_FIELDS sizeof \
* (sub_comand_fields) / sizeof (print_field_t))
*
* print_state_t sub_command_print_state;
*
* The function that parses command line arguments (typically
* do_sub_command()) should then contain an invocation like:
*
* fields = parse_output_fields(fields_str, sub_command_fields,
* SUB_COMMAND_MAX_FIELDS, CMD_TYPE_ANY, &nfields);
*
* and store the resulting fields and nfields value in a print_state_t
* structure tracked for the command.
*
* sub_command_print_state.ps_fields = fields;
* sub_command_print_state.ps_nfields = nfields;
*
* To print the column header for the output, the print_header()
* function must then be invoked by do_sub_command().
*
* Then if method (i) is used for the sub_command, the do_sub_command()
* function should make the necessary system calls to fill up the buffer
* and then invoke dladm_print_field(). An example of this method is
* the implementation of do_show_link() and show_link();
*
* If method (ii) is used, do_sub_command should invoke dladm_print_output()
* with a callback function that will be called for each field to be printed.
* The callback function will be passed a pointer to the print_field_t
* for the field, and the pf_index may then be used to identify the
* system call required to find the value to be printed. An example of
* this implementation may be found in the do_show_dev() and print_dev()
* invocation.
*/
typedef struct print_field_s {
const char *pf_name; /* name of column to be printed */
const char *pf_header; /* header for this column */
union {
}_pf_un;
/*
* The state of the output is tracked in a print_state_t structure.
* Each ps_fields[i] entry points at the global print_field_t array for
* the sub-command, where ps_nfields is the number of requested fields.
*/
typedef struct print_state_s {
typedef char *(*print_callback_t)(print_field_t *, void *);
/*
* print the header for the output
*/
static void print_header(print_state_t *);
/*
* to print output values, call dladm_print_output with a callback
* function (*func)() that should parse the args and return an
* unformatted character buffer with the value to be printed.
*
* dladm_print_output() prints the character buffer using the formatting
* information provided in the print_field_t for that column.
*/
print_callback_t, void *);
/*
* helper function that, when invoked as dladm_print_field(pf, buf)
* prints string which is offset by pf->pf_offset within buf
*/
static char *dladm_print_field(print_field_t *, void *);
#define MAX_FIELD_LEN 32
typedef struct pktsum_s {
} pktsum_t;
typedef struct show_state {
} show_state_t;
typedef struct show_grp_state {
typedef void cmdfunc_t(int, char **, const char *);
static cmdfunc_t do_show_linkmap;
static cmdfunc_t do_show_ether;
static void altroot_cmd(char *, int, char **);
static int show_linkprop_onelink(datalink_id_t, void *);
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 int show_etherprop(datalink_id_t, void *);
static void show_ether_xprop(datalink_id_t, void *);
char *, boolean_t);
static char *pause_str(int, int);
#define IS_FDX 0x10
#define IS_HDX 0x01
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;
{ "show-link", do_show_link,
"\tshow-link\t[-pP] [-o <field>,..] [-s [-i <interval>]] [<link>]"},
{ "rename-link", do_rename_link,
"\trename-link\t[-R <root-dir>] <oldlink> <newlink>\n" },
{ "show-dev", do_show_dev,
"\tshow-dev\t[-p] [-o <field>,..] [-s [-i <interval>]] [<dev>]\n" },
{ "create-aggr", do_create_aggr,
"\tcreate-aggr\t[-t] [-R <root-dir>] [-P <policy>] [-L <mode>]\n"
"\t\t\t[-T <time>] [-u <address>] [-l <link>] ... <link>" },
{ "delete-aggr", do_delete_aggr,
"\tdelete-aggr\t[-t] [-R <root-dir>] <link>" },
{ "add-aggr", do_add_aggr,
"\tadd-aggr\t[-t] [-R <root-dir>] [-l <link>] ... <link>" },
{ "remove-aggr", do_remove_aggr,
"\tremove-aggr\t[-t] [-R <root-dir>] [-l <link>] ... <link>"},
{ "modify-aggr", do_modify_aggr,
"\tmodify-aggr\t[-t] [-R <root-dir>] [-P <policy>] [-L <mode>]\n"
"\t\t\t[-T <time>] [-u <address>] <link>" },
{ "show-aggr", do_show_aggr,
"\tshow-aggr\t[-pPLx] [-o <field>,..] [-s [-i <interval>]] "
"[<link>]\n" },
{ "scan-wifi", do_scan_wifi,
"\tscan-wifi\t[-p] [-o <field>,...] [<link>]" },
{ "connect-wifi", do_connect_wifi,
"\tconnect-wifi\t[-e <essid>] [-i <bssid>] [-k <key>,...] "
"[-s wep|wpa]\n"
"\t\t\t[-a open|shared] [-b bss|ibss] [-c] [-m a|b|g]\n"
"\t\t\t[-T <time>] [<link>]" },
{ "disconnect-wifi", do_disconnect_wifi,
"\tdisconnect-wifi\t[-a] [<link>]" },
{ "show-wifi", do_show_wifi,
"\tshow-wifi\t[-p] [-o <field>,...] [<link>]\n" },
{ "show-linkprop", do_show_linkprop,
"\tshow-linkprop\t[-cP] [-o <field>,...] [-p <prop>,...] <name>"},
{ "set-linkprop", do_set_linkprop,
"\tset-linkprop\t[-t] [-R <root-dir>] -p <prop>=<value>[,...] "
"<name>" },
{ "reset-linkprop", do_reset_linkprop,
"\treset-linkprop\t[-t] [-R <root-dir>] [-p <prop>,...] <name>\n" },
{ "show-ether", do_show_ether,
"\tshow-ether\t[-px][-o <field>,...] <link>\n" },
{ "create-secobj", do_create_secobj,
"\tcreate-secobj\t[-t] [-R <root-dir>] [-f <file>] -c <class> "
"<secobj>" },
{ "delete-secobj", do_delete_secobj,
"\tdelete-secobj\t[-t] [-R <root-dir>] <secobj>[,...]" },
{ "show-secobj", do_show_secobj,
"\tshow-secobj\t[-pP] [-o <field>,...] [<secobj>,...]\n" },
{ "create-vlan", do_create_vlan,
"\tcreate-vlan\t[-ft] [-R <root-dir>] -l <link> -v <vid> [link]" },
{ "delete-vlan", do_delete_vlan,
"\tdelete-vlan\t[-t] [-R <root-dir>] <link>" },
{ "show-vlan", do_show_vlan,
"\tshow-vlan\t[-pP] [-o <field>,..] [<link>]\n" },
{ "delete-phys", do_delete_phys,
"\tdelete-phys\t<link>" },
{ "show-phys", do_show_phys,
"\tshow-phys\t[-pP] [-o <field>,..] [<link>]" },
};
{ 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 }
};
/*
* structures for 'dladm show-ether'
*/
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 print_field_t ether_fields[] = {
/* name, header, field width, offset, cmdtype */
{ "link", "LINK", 15,
{ "ptype", "PTYPE", 8,
{ "state", "STATE", 8,
{ "auto", "AUTO", 5,
{ "speed-duplex", "SPEED-DUPLEX", 31,
{ "pause", "PAUSE", 6,
{ "rem_fault", "REM_FAULT", 16,
;
typedef struct print_ether_state {
const char *es_link;
/*
* structures for 'dladm show-dev'.
*/
typedef enum {
static print_field_t dev_fields[] = {
/* name, header, field width, index, cmdtype */
;
/*
* structures for 'dladm show-dev -s' (print statistics)
*/
typedef enum {
static print_field_t devs_fields[] = {
/* name, header, field width, index, cmdtype */
;
typedef struct dev_args_s {
char *devs_link;
} dev_args_t;
static char *print_dev_stats(print_field_t *, void *);
static char *print_dev(print_field_t *, void *);
/*
* 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 print_field_t link_fields[] = {
/* name, header, field width, offset, cmdtype */
{ "link", "LINK", 11,
{ "class", "CLASS", 8,
{ "mtu", "MTU", 6,
{ "state", "STATE", 8,
;
/*
* 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 print_field_t laggr_fields[] = {
/* name, header, field width, offset, cmdtype */
{ "link", "LINK", 15,
{ "policy", "POLICY", 8,
{ "lacpactivity", "LACPACTIVITY", 13,
{ "lacptimer", "LACPTIMER", 11,
{ "flags", "FLAGS", 7,
;
/*
* structures for 'dladm show-aggr -x'.
*/
typedef enum {
static print_field_t aggr_x_fields[] = {
/* name, header, field width, index, cmdtype */
;
#define AGGR_X_MAX_FIELDS \
(sizeof (aggr_x_fields) / sizeof (print_field_t))
/*
* structures for 'dladm show-aggr -s'.
*/
typedef enum {
static print_field_t aggr_s_fields[] = {
/* name, header, field width, index, cmdtype */
;
#define AGGR_S_MAX_FIELDS \
(sizeof (aggr_l_fields) / sizeof (print_field_t))
/*
* structures for 'dladm show-dev -L'.
*/
typedef enum {
static print_field_t aggr_l_fields[] = {
/* name, header, field width, index, cmdtype */
;
#define AGGR_L_MAX_FIELDS \
(sizeof (aggr_l_fields) / sizeof (print_field_t))
/*
* structures for 'dladm show-phys'
*/
static print_field_t phys_fields[] = {
/* name, header, field width, offset, cmdtype */
{ "link", "LINK", 12,
{ "media", "MEDIA", 20,
{ "state", "STATE", 10,
{ "speed", "SPEED", 6,
{ "duplex", "DUPLEX", 9,
{ "device", "DEVICE", 12,
{ "flags", "FLAGS", 6,
;
/*
* structures for 'dladm show-vlan'
*/
static print_field_t vlan_fields[] = {
/* name, header, field width, offset, cmdtype */
{ "link", "LINK", 15,
{ "vid", "VID", 8,
{ "over", "OVER", 12,
{ "flags", "FLAGS", 6,
;
/*
* structures for 'dladm show-wifi'
*/
static print_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";
/*
* structures for 'dladm show-linkprop'
*/
typedef enum {
static print_field_t linkprop_fields[] = {
/* name, header, field width, index, cmdtype */
;
#define LINKPROP_MAX_FIELDS \
(sizeof (linkprop_fields) / sizeof (print_field_t))
#define MAX_PROPS 32
#define MAX_PROP_LINE 512
typedef struct prop_info {
char *pi_name;
char *pi_val[DLADM_MAX_PROP_VALCNT];
} prop_info_t;
typedef struct prop_list {
char *pl_buf;
} prop_list_t;
typedef struct show_linkprop_state {
char ls_link[MAXLINKNAMELEN];
char *ls_line;
char **ls_propvals;
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 print_field_t secobj_fields[] = {
/* name, header, field width, offset, cmdtype */
{ "object", "OBJECT", 20,
{ "class", "CLASS", 20,
{ "value", "VALUE", 30,
;
static char *progname;
static sig_atomic_t signalled;
static void
usage(void)
{
int i;
"\n"));
}
exit(1);
}
int
{
int i;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
if (argc < 2)
usage();
exit(0);
}
}
usage();
return (0);
}
static void
{
char option;
int key = 0;
char name[MAXLINKNAMELEN];
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;
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);
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);
} 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;
done:
if (status != DLADM_STATUS_OK)
}
/*ARGSUSED*/
static void
{
/*
* get the key or the name of the aggregation (optional last argument)
*/
if (argc == 2) {
DLADM_OPT_PERSIST)) != DLADM_STATUS_OK) {
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];
opterr = 0;
switch (option) {
case 'v':
if (vid != 0)
break;
case 'l':
break;
case 'f':
flags |= DLADM_OPT_FORCE;
break;
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
break;
}
}
/* get vlan name if there is any */
usage();
}
} else {
(ppa >= 1000) ||
DLPI_SUCCESS)) {
}
}
}
if (status == DLADM_STATUS_NOTSUP) {
"MTU; must use -f (see dladm(1M))\n", link);
} else {
}
}
}
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();
if (status != DLADM_STATUS_OK)
goto done;
done:
if (status != DLADM_STATUS_OK)
}
/*ARGSUSED*/
static void
{
/*
* get the name of the VLAN (optional last argument)
*/
if (argc > 2)
usage();
if (argc == 2) {
if (status != DLADM_STATUS_OK)
goto done;
}
done:
if (status != DLADM_STATUS_OK) {
if (argc == 2) {
} else {
}
}
}
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 (status != DLADM_STATUS_OK)
}
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
{
NULL, 0) != DLADM_STATUS_OK) {
return (DLADM_WALK_CONTINUE);
}
(void) dladm_phys_delete(linkid);
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 (!state->ls_parseable)
else
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);
}
static int
{
/*
* first get all the link attributes into lbuf;
*/
if (status != DLADM_STATUS_OK)
goto done;
}
dladm_print_field, (void *)&lbuf);
done:
return (DLADM_WALK_CONTINUE);
}
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 {
}
print_dev_stats, &largs);
return (DLADM_WALK_CONTINUE);
}
static dladm_status_t
{
"%s", link);
if (ginfop->lg_mac_fixed) {
} else {
}
}
dladm_print_field, (void *)&lbuf);
return (DLADM_STATUS_OK);
}
static char *
{
const laggr_args_t *l = arg;
int portnum;
static char buf[DLADM_STRSIZE];
stat = l->laggr_status;
*stat = DLADM_STATUS_OK;
if (is_port) {
portnum = l->laggr_lport;
goto err;
}
DLADM_OPT_ACTIVE)) != DLADM_STATUS_OK) {
goto err;
}
}
case AGGR_X_LINK:
break;
case AGGR_X_PORT:
if (is_port)
break;
return ("");
break;
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(
buf);
break;
case AGGR_X_PORTSTATE:
if (is_port)
(void) dladm_aggr_portstate2str(
else
return ("");
break;
}
return (buf);
err:
buf[0] = '\0';
return (buf);
}
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 char *
{
const laggr_args_t *l = arg;
int portnum;
static char buf[DLADM_STRSIZE];
if (!is_port) {
return (NULL); /* cannot happen! */
}
stat = l->laggr_status;
portnum = l->laggr_lport;
goto err;
}
case AGGR_L_LINK:
break;
case AGGR_L_PORT:
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 (buf);
err:
buf[0] = '\0';
return (buf);
}
static dladm_status_t
{
int i;
}
largs.laggr_lport = i;
if (status != DLADM_STATUS_OK)
goto done;
}
done:
return (status);
}
static char *
{
const laggr_args_t *l = arg;
int portnum;
static char buf[DLADM_STRSIZE];
stat = l->laggr_status;
*stat = DLADM_STATUS_OK;
if (is_port) {
portnum = l->laggr_lport;
DLADM_OPT_ACTIVE)) != DLADM_STATUS_OK) {
goto err;
}
goto err;
}
}
case AGGR_S_LINK:
break;
case AGGR_S_PORT:
if (is_port)
break;
return ("");
break;
case AGGR_S_IPKTS:
if (is_port) {
} else {
l->laggr_pktsumtot->ipackets);
}
break;
case AGGR_S_RBYTES:
if (is_port) {
} 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) {
} else {
l->laggr_pktsumtot->obytes);
}
break;
case AGGR_S_IPKTDIST:
if (is_port) {
(double)diff_stats.opackets/
} else {
return ("");
}
break;
case AGGR_S_OPKTDIST:
if (is_port) {
(double)diff_stats.opackets/
} else {
return ("");
}
break;
}
return (buf);
err:
buf[0] = '\0';
return (buf);
}
static dladm_status_t
{
int i;
/* sum the ports statistics */
DLADM_OPT_ACTIVE)) != DLADM_STATUS_OK) {
goto done;
}
}
}
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];
MAXLINKNAMELEN)) != DLADM_STATUS_OK) {
return (status);
}
return (DLADM_STATUS_NOTFOUND);
if (status != DLADM_STATUS_OK)
return (status);
else if (state->gs_extended)
else {
}
done:
return (status);
}
static int
{
if (status != DLADM_STATUS_OK)
goto done;
done:
return (DLADM_WALK_CONTINUE);
}
static char *
{
static char buf[DLADM_STRSIZE];
case DEV_LINK:
break;
case DEV_STATE:
break;
case DEV_SPEED:
break;
case DEV_DUPLEX:
break;
default:
break;
}
return (buf);
}
static int
{
}
return (DLADM_WALK_CONTINUE);
}
static char *
{
static char buf[DLADM_STRSIZE];
case DEVS_LINK:
break;
case DEVS_IPKTS:
break;
case DEVS_RBYTES:
diff_stats->rbytes);
break;
case DEVS_IERRORS:
break;
case DEVS_OPKTS:
break;
case DEVS_OBYTES:
diff_stats->obytes);
break;
case DEVS_OERRORS:
break;
default:
die("invalid input");
break;
}
return (buf);
}
static int
{
if (state->ls_firstonly) {
if (state->ls_donefirst)
return (DLADM_WALK_CONTINUE);
} else {
}
print_dev_stats, &dargs);
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
int interval = 0;
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 'o':
fields_str = optarg;
break;
case 'i':
if (i_arg)
break;
default:
break;
}
}
die("the option -i can be used only with -s");
die("the option -P cannot be used with -s");
/* get link name (optional last argument) */
uint32_t f;
}
if (!(f & flags)) {
"a temporary link" : "temporarily removed");
}
usage();
}
die("-p requires -o");
die("\"-o all\" is invalid with -p");
if (s_arg)
else if (flags & DLADM_OPT_ACTIVE)
else
}
if (s_arg) {
return;
}
CMD_TYPE_ANY, &nfields);
die("invalid field(s) specified");
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static void
{
int option;
int interval = 0;
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";
int pfmax;
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;
}
&nfields);
die("invalid field(s) specified");
return;
}
if (s_arg) {
return;
}
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static void
{
int option;
int interval = 0;
char *fields_str = NULL;
char *all_fields = "link,state,speed,duplex";
static 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 '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");
if (!s_arg)
else
}
die("the option -s cannot be used with -p");
/* get dev name (optional last argument) */
NULL, 0) != DLADM_STATUS_OK) ||
!(flags & DLADM_OPT_ACTIVE)) {
}
usage();
}
if (s_arg) {
return;
}
CMD_TYPE_ANY, &nfields);
die("invalid field(s) specified");
return;
}
} else {
}
}
static dladm_status_t
{
char link[MAXLINKNAMELEN];
goto done;
}
if (class != DATALINK_CLASS_PHYS) {
goto done;
}
goto done;
}
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);
}
static int
{
if (status != DLADM_STATUS_OK)
goto done;
}
dladm_print_field, (void *)&pattr);
done:
return (DLADM_WALK_CONTINUE);
}
/*
* Print the active topology information.
*/
static dladm_status_t
{
goto done;
}
goto done;
}
sizeof (l->link_over))) != DLADM_STATUS_OK) {
goto done;
}
done:
return (status);
}
static int
{
if (status != DLADM_STATUS_OK)
goto done;
}
dladm_print_field, (void *)&lbuf);
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";
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;
}
}
die("-p requires -o");
die("\"-o all\" is invalid with -p");
/* get link name (optional last argument) */
}
usage();
}
else
}
die("invalid field(s) specified");
return;
}
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static void
{
int option;
char *fields_str = NULL;
char *all_fields = "link,vid,over,flags";
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;
}
}
die("-p requires -o");
die("\"-o all\" is invalid with -p");
/* get link name (optional last argument) */
}
usage();
}
CMD_TYPE_ANY, &nfields);
die("invalid field(s) specified");
return;
}
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static void
{
CMD_TYPE_ANY, &nfields);
die("invalid field(s) specified");
return;
}
/*
* If an interval is specified, continuously show the stats
* only for the first MAC port.
*/
if (!state->ls_parseable)
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;
}
}
static void
{
CMD_TYPE_ANY, &nfields);
die("invalid field(s) specified");
return;
}
/*
* If an interval is specified, continuously show the stats
* only for the first MAC port.
*/
for (;;) {
if (!state->ls_parseable)
else
if (interval == 0)
break;
}
}
/* accumulate stats (s1 += (s2 - s3)) */
static void
{
}
/* compute stats differences (s1 = s2 - s3) */
static void
{
}
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;
bail:
(void) kstat_close(kcp);
return;
}
static void
{
char module[DLPI_LINKNAME_MAX];
return;
}
static void
{
}
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);
}
}
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
{
if (cmdtype == WIFI_CMD_SCAN) {
} else if (cmdtype == WIFI_CMD_SHOW) {
} else {
return (-1);
}
return (0);
return (-1);
}
static print_field_t **
{
uint_t i, j;
return (NULL);
goto fail;
for (j = 0; j < max_fields; j++) {
break;
}
}
if (!good_match)
goto fail;
}
*countp = i;
return (pf);
fail:
return (NULL);
}
typedef struct print_wifi_state {
char *ws_link;
typedef struct wlan_scan_args_s {
void *ws_attr;
static void
{
/*
* Parsable fields are separated by ':'. If such a field contains
* a ':' or '\', this character is prefixed by a '\'.
*/
if (parseable) {
char c;
return;
}
while ((c = *value++) != '\0') {
if (c == ':' || c == '\\')
(void) putchar('\\');
(void) putchar(c);
}
if (!statep->ps_lastfield)
(void) putchar(':');
return;
} else {
if (value[0] == '\0')
if (statep->ps_lastfield) {
statep->ps_overflow = 0;
return;
}
}
}
if (!statep->ps_lastfield)
(void) putchar(' ');
}
static char *
{
static char buf[DLADM_STRSIZE];
wlan_scan_args_t *w = warg;
}
return ("");
}
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 (buf);
}
static boolean_t
{
if (!statep->ws_parseable)
}
print_wlan_attr, &warg);
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 char *
{
static char buf[DLADM_STRSIZE];
char *ptr;
(void) dladm_wlan_linkstatus2str(
return (buf);
}
return (ptr);
}
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)
if (!statep->ws_parseable)
}
print_link_attr, &warg);
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
char *fields_str = NULL;
int (*callback)(datalink_id_t, void *);
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();
}
die("invalid field(s) specified");
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
static void
{
}
static void
{
}
typedef struct wlan_count_attr {
static int
{
return (DLADM_WALK_CONTINUE);
}
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;
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
{
}
}
static int
{
int len, i;
return (-1);
goto fail;
/*
* buf is a string of form [<propname>=<value>][,<propname>=<value>]+
* where each <value> string itself could be a comma-separated array.
* The loop below will count the number of propname assignments
* in pl_count; for each property, there is a pip entry with
* pi_name == <propname>, pi_count == # of elements in <value> array.
* pi_val[] contains the actual values.
*
* This could really be a combination of calls to
* strtok (token delimiter is ",") and strchr (chr '=')
* with appropriate null/string-bound-checks.
*/
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
{
int i;
char buf[DLADM_STRSIZE];
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 (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_parseable) {
"%s", buf);
} else {
}
}
static char *
{
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_DEFAULT:
goto skip;
break;
case LINKPROP_POSSIBLE:
goto skip;
break;
default:
die("invalid input");
break;
}
return (ptr);
skip:
return (NULL);
else
return ("");
}
static int
{
if (!statep->ls_parseable)
}
linkprop_callback, (void *)&ls_arg);
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
char *fields_str = NULL;
char *all_fields =
"link,property,value,default,possible";
opterr = 0;
switch (option) {
case 'p':
die("invalid link properties specified");
break;
case 'c':
break;
case 'P':
break;
case 'o':
else
fields_str = optarg;
break;
default:
break;
}
}
die("-c requires -o");
die("\"-o all\" is invalid with -c");
}
usage();
}
die("invalid field(s) specified");
return;
}
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
static int
{
int i;
char *buf;
MAXLINKNAMELEN) != DLADM_STATUS_OK) {
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;
(void) show_linkprop(linkid,
}
} else {
}
dlpi_close(dh);
return (DLADM_WALK_CONTINUE);
}
static dladm_status_t
{
if (status != DLADM_STATUS_OK) {
}
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':
break;
default:
}
}
/* get link name (required last argument) */
usage();
die("link property must be specified");
}
if (status != DLADM_STATUS_OK)
if (status != DLADM_STATUS_OK) {
}
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) {
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;
}
s = dladm_get_linkprop(linkid,
&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);
}
/* 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, 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 (!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 boolean_t
{
char buf[DLADM_STRSIZE];
if (statep->ss_persist)
if (status != DLADM_STATUS_OK)
if (!statep->ss_parseable)
}
obj_name);
if (getuid() == 0) {
}
dladm_print_field, (void *)&sbuf);
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");
die("invalid field(s) specified");
return;
}
die("invalid secure object name(s): '%s'",
}
break;
}
return;
usage();
if (status != DLADM_STATUS_OK)
}
/*ARGSUSED*/
static int
{
return (DLADM_WALK_CONTINUE);
}
/*ARGSUSED*/
static 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;
}
}
NULL)) != DLADM_STATUS_OK)
usage();
}
if (linkid == DATALINK_ALL_LINKID) {
/*
* linkprops of links of other classes have been initialized as
* part of the dladm up-xxx operation.
*/
} else {
}
}
/* ARGSUSED */
static void
{
int option;
char *fields_str;
char *all_fields =
"link,ptype,state,auto,speed-duplex,pause,rem_fault";
char *default_fields =
"link,ptype,state,auto,speed-duplex,pause";
switch (option) {
case 'x':
break;
case 'p':
break;
case 'o':
else
fields_str = optarg;
break;
default:
break;
}
}
die("-p requires -o");
die("\"-o all\" is invalid with -p");
die("invalid field(s) specified");
}
} else {
die("invalid link specified");
}
}
}
static char *
{
char *value;
return (value);
}
static int
{
char buf[DLADM_STRSIZE];
int speed;
uint64_t s;
char speed_unit = 'M';
return (DLADM_WALK_CONTINUE);
}
}
"%s", "current");
KSTAT_DATA_UINT64, &s);
speed = (int)(s/1000000ull);
if (speed >= 1000) {
speed_unit = 'G';
}
"%s", buf);
if (statep->es_extended)
return (DLADM_WALK_CONTINUE);
}
/* ARGSUSED */
static void
{
status = dladm_init_secobj();
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];
}
/* 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;
}
}
static void
{
char buf[DLADM_STRSIZE];
/* capable */
"%s", "capable");
if (r1)
if (r1)
/* advertised */
"%s", "adv");
if (r1)
if (r1)
/* peeradv */
"%s", "peeradv");
if (r1)
if (r1)
}
static boolean_t
{
char mii_prop[DLADM_STRSIZE];
&speed);
if (speed) {
}
if (speed) {
}
if (ret) {
if (add_comma)
}
return (ret);
}
static void
{
int i;
char *value;
print_field_t **pf;
for (i = 0; i < statep->ps_nfields; i++) {
}
(void) putchar('\n');
}
static void
{
int i;
print_field_t **pf;
for (i = 0; i < ps->ps_nfields; i++) {
}
(void) putchar('\n');
}
static char *
{
if (pause == 1)
return ("bi");
if (asmpause == 1)
return ("tx");
return ("none");
}
static boolean_t
{
return (B_TRUE);
}
return (B_FALSE);
}