5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2017 Nexenta Systems, Inc.
25 */
26
27 #include <arpa/inet.h>
28 #include <errno.h>
29 #include <getopt.h>
30 #include <inet/ip.h>
31 #include <inet/iptun.h>
32 #include <inet/tunables.h>
33 #include <libdladm.h>
34 #include <libdliptun.h>
35 #include <libdllink.h>
36 #include <libinetutil.h>
37 #include <libipadm.h>
38 #include <locale.h>
39 #include <netdb.h>
40 #include <netinet/in.h>
41 #include <ofmt.h>
42 #include <stdarg.h>
43 #include <stddef.h>
44 #include <stdio.h>
490 if (flags & IPADM_OPT_PERSIST)
491 die("persistent operation not supported for disable-if");
492 status = ipadm_disable_if(iph, argv[index], flags);
493 if (status != IPADM_SUCCESS) {
494 die("Could not disable %s: %s",
495 argv[optind], ipadm_status2str(status));
496 }
497 }
498
499 /*
500 * Print individual columns for the show-*prop subcommands.
501 */
502 static void
503 print_prop(show_prop_state_t *statep, uint_t flags, char *buf, size_t bufsize)
504 {
505 const char *prop_name = statep->sps_pname;
506 char *ifname = statep->sps_ifname;
507 char *propval = statep->sps_propval;
508 uint_t proto = statep->sps_proto;
509 size_t propsize = MAXPROPVALLEN;
510 char *object;
511 ipadm_status_t status;
512
513 if (statep->sps_ifprop) {
514 status = ipadm_get_ifprop(iph, ifname, prop_name, propval,
515 &propsize, proto, flags);
516 object = ifname;
517 } else if (statep->sps_modprop) {
518 status = ipadm_get_prop(iph, prop_name, propval, &propsize,
519 proto, flags);
520 object = ipadm_proto2str(proto);
521 } else {
522 status = ipadm_get_addrprop(iph, prop_name, propval, &propsize,
523 statep->sps_aobjname, flags);
524 object = statep->sps_aobjname;
525 }
526
527 if (status != IPADM_SUCCESS) {
528 if ((status == IPADM_NOTFOUND && (flags & IPADM_OPT_PERSIST)) ||
529 status == IPADM_ENXIO) {
530 propval[0] = '\0';
531 goto cont;
532 }
533 statep->sps_status = status;
534 statep->sps_retstatus = status;
535 return;
536 }
537 cont:
538 statep->sps_status = IPADM_SUCCESS;
539 (void) snprintf(buf, bufsize, "%s", propval);
540 }
541
542 /*
543 * Callback function for show-*prop subcommands.
544 */
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2017 Nexenta Systems, Inc.
25 * Copyright 2017 Gary Mills
26 */
27
28 #include <arpa/inet.h>
29 #include <errno.h>
30 #include <getopt.h>
31 #include <inet/ip.h>
32 #include <inet/iptun.h>
33 #include <inet/tunables.h>
34 #include <libdladm.h>
35 #include <libdliptun.h>
36 #include <libdllink.h>
37 #include <libinetutil.h>
38 #include <libipadm.h>
39 #include <locale.h>
40 #include <netdb.h>
41 #include <netinet/in.h>
42 #include <ofmt.h>
43 #include <stdarg.h>
44 #include <stddef.h>
45 #include <stdio.h>
491 if (flags & IPADM_OPT_PERSIST)
492 die("persistent operation not supported for disable-if");
493 status = ipadm_disable_if(iph, argv[index], flags);
494 if (status != IPADM_SUCCESS) {
495 die("Could not disable %s: %s",
496 argv[optind], ipadm_status2str(status));
497 }
498 }
499
500 /*
501 * Print individual columns for the show-*prop subcommands.
502 */
503 static void
504 print_prop(show_prop_state_t *statep, uint_t flags, char *buf, size_t bufsize)
505 {
506 const char *prop_name = statep->sps_pname;
507 char *ifname = statep->sps_ifname;
508 char *propval = statep->sps_propval;
509 uint_t proto = statep->sps_proto;
510 size_t propsize = MAXPROPVALLEN;
511 ipadm_status_t status;
512
513 if (statep->sps_ifprop) {
514 status = ipadm_get_ifprop(iph, ifname, prop_name, propval,
515 &propsize, proto, flags);
516 } else if (statep->sps_modprop) {
517 status = ipadm_get_prop(iph, prop_name, propval, &propsize,
518 proto, flags);
519 } else {
520 status = ipadm_get_addrprop(iph, prop_name, propval, &propsize,
521 statep->sps_aobjname, flags);
522 }
523
524 if (status != IPADM_SUCCESS) {
525 if ((status == IPADM_NOTFOUND && (flags & IPADM_OPT_PERSIST)) ||
526 status == IPADM_ENXIO) {
527 propval[0] = '\0';
528 goto cont;
529 }
530 statep->sps_status = status;
531 statep->sps_retstatus = status;
532 return;
533 }
534 cont:
535 statep->sps_status = IPADM_SUCCESS;
536 (void) snprintf(buf, bufsize, "%s", propval);
537 }
538
539 /*
540 * Callback function for show-*prop subcommands.
541 */
|