/*
* 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 (c) 1990 Mentat Inc. */
#include <assert.h>
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <stdarg.h>
#include <fcntl.h>
#include <unistd.h>
#include <stropts.h>
#include <inet/tunables.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <libdllink.h>
#include <libintl.h>
#include <libipadm.h>
static void name_print(char *buf);
static void getset_interactive(int fd);
static int open_device(void);
" ndd [-get] device_name name [name ...]";
/*
* Maps old ndd_name to the new ipadm_name. Any ndd property that is moved to
* libipadm should have an entry here to ensure backward compatibility
*/
typedef struct ndd2ipadm_map {
char *ndd_name;
char *ipadm_name;
0, MOD_PROP_PERM_READ },
0, 0 },
0, 0 },
0, 0 },
0, MOD_PROP_PERM_READ },
0, 0 },
0, 0 },
0, 0 },
0, MOD_PROP_PERM_READ },
0, 0 },
0, 0 },
0, 0 },
};
static uint_t
{
return (MOD_PROTO_TCP);
return (MOD_PROTO_UDP);
return (MOD_PROTO_IP);
return (MOD_PROTO_RAWIP);
return (MOD_PROTO_SCTP);
}
return (MOD_PROTO_NONE);
}
static char *
{
switch (perm) {
case MOD_PROP_PERM_READ:
return ("read only");
case MOD_PROP_PERM_WRITE:
return ("write only");
case MOD_PROP_PERM_RW:
return ("read and write");
}
return (NULL);
}
/*
* Print all the protocol properties for the given protocol name. The kernel
* returns all the properties for the given protocol therefore we have to
* apply some filters before we print them.
*
* - convert any new ipadm name to old ndd name using the table.
* For example: `sack' --> `tcp_sack_permitted'.
*
* - replace leading underscores with protocol name.
* For example: `_strong_iss' --> `tcp_strong_iss'
*
* - don't print new public properties that are supported only by ipadm(1M)
* For example: `hostmodel' should be supported only from ipadm(1M).
* Such properties are identified by not having leading '_' and not
* being present in the mapping table.
*/
static void
{
;
*protostr++ = '\0';
/* protostr now points to protocol */
;
*rwtag++ = '\0';
/* rwtag now points to permissions */
continue;
ndd_perm2str(perm));
}
/*
* print only if it's a private property. We should
* not be printing any new public property in ndd(1M)
* output.
*/
int err;
ndd_perm2str(perm));
}
;
}
}
/*
* IPH_LEGACY flag is used by libipadm for special handling. For some
* properties, libipadm.so displays strings (for e.g., on/off,
* printed numberals. This flag will help in avoiding printing strings.
*/
static boolean_t
{
char *mod;
int i;
else
++mod;
return (B_FALSE);
goto fail;
break;
}
}
&proto) != 0) {
goto fail;
} else {
}
}
int err;
if (perm == MOD_PROP_PERM_WRITE)
fatal("operation failed: Permission denied");
} else {
}
if (status != IPADM_SUCCESS)
goto fail;
} else {
/*
* For backward compatibility if there are multiple
* values print each value in it's own line.
*/
while (*tmp != '\0') {
if (*tmp == ',')
*tmp = '\n';
tmp++;
}
}
} else {
if (perm == MOD_PROP_PERM_READ)
fatal("operation failed: Permission denied");
/* walk past the property name to find the property value */
for (i = 0; buf[i] != '\0'; i++)
;
}
fail:
if (status != IPADM_SUCCESS)
return (B_TRUE);
}
/*
* for administration of other datalink types, which makes it permissible
* to test for support of the flowctrl property.
*/
static void
{
char *link;
return;
return;
if (status == DLADM_STATUS_OK) {
if (status == DLADM_STATUS_OK) {
"WARNING: The ndd commands for datalink "
"administration are obsolete and may be "
"removed in a future release of Solaris. "
"Use dladm(1M) to manage datalink tunables.\n"));
}
}
}
/* ARGSUSED */
int
{
int cmd;
int fd = 0;
}
return (EXIT_SUCCESS);
}
if (cp[0] == '-') {
}
mod++;
else
}
return (EXIT_SUCCESS);
}
value, '\0');
return (EXIT_FAILURE);
} else {
do {
return (EXIT_FAILURE);
(void) putchar('\n');
} while (cp);
}
return (EXIT_SUCCESS);
}
static void
{
;
*rwtag++ = '\0';
rwtag++;
;
}
}
/*
* This function is vile, but it's better here than in the kernel.
*/
static boolean_t
{
"by IP Multipathing.\nPlease see the IP Network "
"Multipathing Administration Guide for details.\n", param);
return (B_TRUE);
}
return (B_FALSE);
}
static boolean_t
{
char *cp;
if (is_obsolete(buf))
return (B_TRUE);
/*
* See if libipadm can handle this request, i.e., properties on
* following modules arp, ip, ipv4, ipv6, tcp, udp and sctp
*/
return (B_TRUE);
(void) printf("name is non-existent for this module\n"
"for a list of valid names, use name '?'\n");
else
return (B_FALSE);
}
if (is_name_get)
}
return (B_TRUE);
}
static int
{
int len;
else
len++;
return (len);
}
static void
{
int cmd;
char *cp;
for (;;) {
return;
*cp = '\0';
}
if (gbuf[0] != '?' &&
(void) printf("invalid length\n");
continue;
}
} else
}
}
static void
{
(void) printf("*ERROR* ");
if (print_errno)
else
(void) printf("\n");
}
static int
{
char *mod;
for (;;) {
sizeof (modpath));
if (len <= 1 ||
return (-1);
mod++;
else
continue;
}
} else {
return (0);
}
return (fd);
}
}
static void
{
}
static char *
{
}