fcinfo.c revision 7ff836697c120cb94bd30d5c2204eb9b74718e4c
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
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 * CDDL HEADER END
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
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 * MINOR - This should change whenever there is a new command or new feature
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * with no incompatible change.
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 *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *getExecBasename(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add new options here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Optional option-arguments are not allowed by CLIP
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add new subcommands here
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang {"hba-port", listHbaPortFunc, "itel", NULL, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"remote-port", listRemotePortFunc, "lsp", "p", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"logical-unit", listLogicalUnitFunc, "v", NULL, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"create-npiv-port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"delete-npiv-port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"hba-port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"remote-port",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"create-port-list",
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang {"create-fcoe-port",
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang OPERAND_MANDATORY_SINGLE, "Network Interface Name"},
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang {"delete-fcoe-port",
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang OPERAND_MANDATORY_SINGLE, "Network Interface Name"},
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang {"list-fcoe-ports",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pass in options/arguments, rest of arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistHbaPortFunc(int objects, char *argv[], cmdOptions_t *options, void *addArgs)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_list_hbaport(objects, argv, options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pass in options/arguments, rest of arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistRemotePortFunc(int objects, char *argv[], cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_list_remoteport(objects, argv, options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pass in options/arguments, rest of arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistLogicalUnitFunc(int objects, char *argv[], cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_list_logicalunit(objects, argv, options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pass in options/arguments, rest of arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_create_npivport(objects, argv, options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((objects == 0) && addArgs && options && argv) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pass in options/arguments, rest of arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_delete_npivport(objects, argv, options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pass in options/arguments, rest of arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_list_hbaport(objects, argv, options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pass in options/arguments, rest of arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (fc_util_list_remoteport(objects, argv, options));
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Pass in options/arguments, rest of arguments
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong WangfcoeAdmCreatePortFunc(int objects, char *argv[], cmdOptions_t *options,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang return (fcoe_adm_create_port(objects, argv, options));
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Pass in options/arguments, rest of arguments
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong WangfcoeAdmDeletePortFunc(int objects, char *argv[], cmdOptions_t *options,
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Pass in options/arguments, rest of arguments
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong WangfcoeListPortsFunc(int objects, char *argv[], cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * execFullName - exec name of program (argv[0])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * command name portion of execFullName
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* guard against '/' at end of command invocation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * main calls a parser that checks syntax of the input command against
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * various rules tables.
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 * The parser handles all printing of usage syntactical errors
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When syntax is successfully validated, the parser calls the associated
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * function using the subcommands table functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Syntax is as follows:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * command subcommand [options] resource-type [<object>]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The return value from the function is placed in funcRet
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set global command name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables.subCommandPropsTbl = &fcadmsubcommands[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables.subCommandPropsTbl = &fcinfosubcommands[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call the CLI parser */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cmdParse(argc, argv, synTables, subcommandArgs, &funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("For more information, please see"), cmdName);