fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <fcinfo.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define VERSION_STRING_MAX_LEN 10
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Version number:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MAJOR - This should only change when there is an incompatible change made
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the interfaces or the output.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MINOR - This should change whenever there is a new command or new feature
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * with no incompatible change.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define VERSION_STRING_MAJOR "1"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define VERSION_STRING_MINOR "0"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OPTIONSTRING1 "HBA Port WWN"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OPTIONSTRING2 "HBA Node WWN"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* forward declarations */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int listHbaPortFunc(int, char **, cmdOptions_t *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int listRemotePortFunc(int, char **, cmdOptions_t *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int listLogicalUnitFunc(int, char **, cmdOptions_t *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int npivCreatePortFunc(int, char **, cmdOptions_t *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int npivDeletePortFunc(int, char **, cmdOptions_t *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int npivCreatePortListFunc(int, char **, cmdOptions_t *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int npivListHbaPortFunc(int, char **, cmdOptions_t *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int npivListRemotePortFunc(int, char **, cmdOptions_t *, void *);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic int fcoeAdmCreatePortFunc(int, char **, cmdOptions_t *, void *);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic int fcoeListPortsFunc(int, char **, cmdOptions_t *, void *);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic int fcoeAdmDeletePortFunc(int, char **, cmdOptions_t *, void *);
a79493184c9332129c9c91500069322f6f3fafddReedstatic int fcadmForceLipFunc(int, char **, cmdOptions_t *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *getExecBasename(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add new options here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Optional option-arguments are not allowed by CLIP
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteoptionTbl_t fcinfolongOptions[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"port", required_argument, 'p', OPTIONSTRING1},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"target", no_argument, 't', NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"initiator", no_argument, 'i', NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"linkstat", no_argument, 'l', NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"scsi-target", no_argument, 's', NULL},
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang {"fcoe", no_argument, 'e', NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"verbose", no_argument, 'v', NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {NULL, 0, 0}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteoptionTbl_t fcadmlongOptions[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"port", required_argument, 'p', OPTIONSTRING1},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"node", required_argument, 'n', OPTIONSTRING2},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"linkstat", no_argument, 'l', NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"scsi-target", no_argument, 's', NULL},
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang {"fcoe-force-promisc", no_argument, 'f', NULL},
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang {"target", no_argument, 't', NULL},
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang {"initiator", no_argument, 'i', NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {NULL, 0, 0}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add new subcommands here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortesubCommandProps_t fcinfosubcommands[] = {
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang {"hba-port", listHbaPortFunc, "itel", NULL, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPERAND_OPTIONAL_MULTIPLE, "WWN"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"remote-port", listRemotePortFunc, "lsp", "p", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPERAND_OPTIONAL_MULTIPLE, "WWN"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"logical-unit", listLogicalUnitFunc, "v", NULL, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPERAND_OPTIONAL_MULTIPLE, "OS Device Path"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"lu", listLogicalUnitFunc, "v", NULL, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPERAND_OPTIONAL_MULTIPLE, "OS Device Path"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {NULL, 0, NULL, NULL, NULL, 0, NULL, NULL}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortesubCommandProps_t fcadmsubcommands[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"create-npiv-port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte npivCreatePortFunc, "pn", NULL, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPERAND_MANDATORY_SINGLE, "WWN"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"delete-npiv-port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte npivDeletePortFunc, "p", "p", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPERAND_MANDATORY_SINGLE, "WWN"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"hba-port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte npivListHbaPortFunc, "l", NULL, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPERAND_OPTIONAL_MULTIPLE, "WWN"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"remote-port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte npivListRemotePortFunc, "psl", "p", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPERAND_OPTIONAL_MULTIPLE, "WWN"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"create-port-list",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte npivCreatePortListFunc, NULL, NULL, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPERAND_NONE, NULL},
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang {"create-fcoe-port",
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang fcoeAdmCreatePortFunc, "itpnf", NULL, NULL,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang OPERAND_MANDATORY_SINGLE, "Network Interface Name"},
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang {"delete-fcoe-port",
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang fcoeAdmDeletePortFunc, NULL, NULL, NULL,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang OPERAND_MANDATORY_SINGLE, "Network Interface Name"},
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang {"list-fcoe-ports",
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang fcoeListPortsFunc, "it", NULL, NULL,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang OPERAND_NONE, NULL},
a79493184c9332129c9c91500069322f6f3fafddReed {"force-lip",
a79493184c9332129c9c91500069322f6f3fafddReed fcadmForceLipFunc, NULL, NULL, NULL,
a79493184c9332129c9c91500069322f6f3fafddReed OPERAND_MANDATORY_SINGLE, "WWN"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {NULL, 0, NULL, NULL, NULL, 0, NULL, NULL}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pass in options/arguments, rest of arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistHbaPortFunc(int objects, char *argv[], cmdOptions_t *options, void *addArgs)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_list_hbaport(objects, argv, options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pass in options/arguments, rest of arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistRemotePortFunc(int objects, char *argv[], cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *addArgs)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_list_remoteport(objects, argv, options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pass in options/arguments, rest of arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistLogicalUnitFunc(int objects, char *argv[], cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *addArgs)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_list_logicalunit(objects, argv, options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pass in options/arguments, rest of arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortenpivCreatePortFunc(int objects, char *argv[],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdOptions_t *options, void *addArgs) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_create_npivport(objects, argv, options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortenpivCreatePortListFunc(int objects, char *argv[],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdOptions_t *options, void *addArgs) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((objects == 0) && addArgs && options && argv) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte objects = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_create_portlist());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pass in options/arguments, rest of arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortenpivDeletePortFunc(int objects, char *argv[],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdOptions_t *options, void *addArgs) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_delete_npivport(objects, argv, options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pass in options/arguments, rest of arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortenpivListHbaPortFunc(int objects, char *argv[],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdOptions_t *options, void *addArgs) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_list_hbaport(objects, argv, options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pass in options/arguments, rest of arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortenpivListRemotePortFunc(int objects, char *argv[],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdOptions_t *options, void *addArgs) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_list_remoteport(objects, argv, options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/*
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Pass in options/arguments, rest of arguments
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/*ARGSUSED*/
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic int
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong WangfcoeAdmCreatePortFunc(int objects, char *argv[], cmdOptions_t *options,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang void *addArgs)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang{
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang return (fcoe_adm_create_port(objects, argv, options));
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang}
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/*
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Pass in options/arguments, rest of arguments
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/*ARGSUSED*/
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic int
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong WangfcoeAdmDeletePortFunc(int objects, char *argv[], cmdOptions_t *options,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang void *addArgs)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang{
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang return (fcoe_adm_delete_port(objects, argv));
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang}
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/*
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Pass in options/arguments, rest of arguments
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/*ARGSUSED*/
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangstatic int
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong WangfcoeListPortsFunc(int objects, char *argv[], cmdOptions_t *options,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang void *addArgs)
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang{
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang return (fcoe_adm_list_ports(options));
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang}
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang
a79493184c9332129c9c91500069322f6f3fafddReed/*
a79493184c9332129c9c91500069322f6f3fafddReed * Pass in options/arguments, rest of arguments
a79493184c9332129c9c91500069322f6f3fafddReed */
a79493184c9332129c9c91500069322f6f3fafddReed/*ARGSUSED*/
a79493184c9332129c9c91500069322f6f3fafddReedstatic int
a79493184c9332129c9c91500069322f6f3fafddReedfcadmForceLipFunc(int objects, char *argv[], cmdOptions_t *options,
a79493184c9332129c9c91500069322f6f3fafddReed void *addArgs)
a79493184c9332129c9c91500069322f6f3fafddReed{
a79493184c9332129c9c91500069322f6f3fafddReed return (fc_util_force_lip(objects, argv));
a79493184c9332129c9c91500069322f6f3fafddReed}
a79493184c9332129c9c91500069322f6f3fafddReed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * execFullName - exec name of program (argv[0])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * command name portion of execFullName
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetExecBasename(char *execFullname)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *lastSlash, *execBasename;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* guard against '/' at end of command invocation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (;;) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lastSlash = strrchr(execFullname, '/');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lastSlash == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte execBasename = execFullname;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte execBasename = lastSlash + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*execBasename == '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *lastSlash = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (execBasename);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * main calls a parser that checks syntax of the input command against
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * various rules tables.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The parser provides usage feedback based upon same tables by calling
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * two usage functions, usage and subUsage, handling command and subcommand
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * usage respectively.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The parser handles all printing of usage syntactical errors
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When syntax is successfully validated, the parser calls the associated
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * function using the subcommands table functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Syntax is as follows:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * command subcommand [options] resource-type [<object>]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The return value from the function is placed in funcRet
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemain(int argc, char *argv[])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables_t synTables;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char versionString[VERSION_STRING_MAX_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int funcRet;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *subcommandArgs = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang (void) setlocale(LC_ALL, "");
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#endif
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang (void) textdomain(TEXT_DOMAIN);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set global command name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName = getExecBasename(argv[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sprintf(versionString, "%s.%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte VERSION_STRING_MAJOR, VERSION_STRING_MINOR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables.versionString = versionString;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(cmdName, "fcadm") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables.longOptionTbl = &fcadmlongOptions[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables.subCommandPropsTbl = &fcadmsubcommands[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables.longOptionTbl = &fcinfolongOptions[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables.subCommandPropsTbl = &fcinfosubcommands[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call the CLI parser */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cmdParse(argc, argv, synTables, subcommandArgs, &funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stdout, "%s %s(1M)\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("For more information, please see"), cmdName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (ret == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte perror(cmdName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (funcRet != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}