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
fb2a9bae0030340ad72b9c26ba1ffee2ee3cafecyi zhang - Sun Microsystems - Beijing China * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China#include <libsun_ima.h>
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#define OPTIONSTRING8 "<# sessions>|<IP Address>[,<IP Address>]*"
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China#define OPTIONSTRING9 "tunable-prop=value"
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China#define ISCSI_DEFAULT_RX_TIMEOUT_VALUE "60"
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China#define ISCSI_DEFAULT_CONN_DEFAULT_LOGIN_MAX "180"
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China#define ISCSI_DEFAULT_LOGIN_POLLING_DELAY "60"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* For listNode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (prop).defaultValue == IMA_TRUE ? gettext("yes") : \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((option) == PRINT_NEGOTIATED_PARAMS) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((prop).currentValue == IMA_TRUE) ? gettext("yes") : \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%d/", (prop).defaultValue); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%d\n", (prop).currentValue); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((prop).currentValueValid == IMA_FALSE) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((option) == PRINT_NEGOTIATED_PARAMS) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%d\n", (prop).currentValue); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((prop).currentValueValid == IMA_FALSE) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* forward declarations */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Utility functions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiSCSINameCheckStatusType iSCSINameStringProfileCheck(wchar_t *name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t isNaturalNumber(char *numberStr, uint32_t upperBound);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int parseAddress(char *address_port_str, uint16_t defaultPort,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing Chinastatic int chkConnLoginMaxPollingLoginDelay(IMA_OID oid,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China int key, int uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* subcommand functions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int addFunc(int, char **, int, cmdOptions_t *, void *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int listFunc(int, char **, int, cmdOptions_t *, void *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int modifyFunc(int, char **, int, cmdOptions_t *, void *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int removeFunc(int, char **, int, cmdOptions_t *, void *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* helper functions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *getExecBasename(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int getSecret(char *, int *, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int getTargetAddress(int, char *, IMA_TARGET_ADDRESS *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int printLoginParameters(char *, IMA_OID, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void printDiscoveryMethod(char *, IMA_UINT32);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void printSendTargets(SUN_IMA_DISC_ADDRESS_KEY_PROPERTIES *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void printDigestAlgorithm(SUN_IMA_DIGEST_ALGORITHM_VALUE *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int setLoginParameter(IMA_OID, int, char *);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing Chinastatic int setTunableParameters(IMA_OID, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINTED E_STATIC_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int getAuthMethodValue(char *, IMA_AUTHMETHOD *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int getLoginParam(char *);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing Chinastatic int getTunableParam(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void iSCSINameCheckStatusDisplay(iSCSINameCheckStatusType status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int modifyIndividualTargetParam(cmdOptions_t *optionList,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing Chinastatic int printTunableParameters(IMA_OID oid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* object functions per subcommand */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int addAddress(int, int, char *[], int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int addStaticConfig(int, char *[], int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int listDiscovery(int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int listDiscoveryAddress(int, char *[], cmdOptions_t *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int listISNSServerAddress(int, char *[], cmdOptions_t *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int listNode(int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int listStaticConfig(int, char *[], int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int listTarget(int, char *[], cmdOptions_t *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int listTargetParam(int, char *[], cmdOptions_t *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int modifyDiscovery(cmdOptions_t *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int modifyNodeAuthMethod(IMA_OID, char *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int modifyNodeAuthParam(IMA_OID oid, int, char *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int modifyNodeRadiusConfig(IMA_OID, char *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int modifyNodeRadiusAccess(IMA_OID, char *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int modifyNodeRadiusSharedSecret(IMA_OID, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int modifyTargetAuthMethod(IMA_OID, char *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int modifyTargetAuthParam(IMA_OID oid, int param, char *chapName, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int modifyTargetParam(cmdOptions_t *, char *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int removeAddress(int, int, char *[], int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int removeStaticConfig(int, char *[], int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int removeTargetParam(int, char *[], int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int modifyTargetBidirAuthFlag(IMA_OID, char *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int modifyConfiguredSessions(IMA_OID targetOid, char *optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINTED E_STATIC_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic IMA_STATUS getISCSINodeParameter(int paramType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINTED E_STATIC_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic IMA_STATUS setISCSINodeParameter(int paramType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINTED E_STATIC_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic IMA_STATUS getDigest(IMA_OID oid, int ioctlCmd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* globals */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Available option letters:
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng * befgijklmnoquwxyz
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China * DEFGHIJKLMOQUVWXYZ
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add new options here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"sendtargets", required_arg, 't', OPTIONSTRING4},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"headerdigest", required_arg, 'h', OPTIONSTRING6},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"datadigest", required_arg, 'd', OPTIONSTRING6},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"login-param", required_arg, 'p', OPTIONSTRING5},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"authentication", required_arg, 'a', "CHAP|none"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"bi-directional-authentication", required_arg, 'B', OPTIONSTRING4},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"node-alias", required_arg, 'A', OPTIONSTRING3},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"radius-server", required_arg, 'r', OPTIONVAL4},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"radius-access", required_arg, 'R', OPTIONSTRING4},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"configured-sessions", required_arg, 'c', OPTIONSTRING8},
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China {"tunable-param", required_arg, 'T', OPTIONSTRING9},
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing ChinaparameterTbl_t tunableParams[] = {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China {"recv-login-rsp-timeout", RECV_LOGIN_RSP_TIMEOUT},
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China {"conn-login-max", CONN_LOGIN_MAX},
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China {"polling-login-delay", POLLING_LOGIN_DELAY},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add new subcommands here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add objects here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Rules for subcommands and objects
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "target-name"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {TARGET_PARAM, MODIFY|REMOVE, LIST, 0, ADD, MODIFY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "target-name"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {DISCOVERY, 0, 0, LIST|MODIFY, ADD|REMOVE, 0, NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {STATIC_CONFIG, ADD|REMOVE, LIST, 0, MODIFY, ADD|REMOVE|LIST,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "target-name,target-address[:port-number][,tpgt]"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {ISNS_SERVER_ADDRESS, ADD|REMOVE, LIST, 0, MODIFY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {0, 0, 0, 0, 0, NULL}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * list of objects, subcommands, valid short options, required flag and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * exclusive option string
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If it's not here, there are no options for that object.
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China {NODE, MODIFY, "NAhdCaRrPHcT", B_TRUE, "CP"},
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China {TARGET_PARAM, MODIFY, "ahdBCpcHT", B_TRUE, "C"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {0, 0, 0, 0, 0}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Convert names to lower case and compare
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar1 = towctrans((wint_t)name1[i], wctrans("tolower"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar2 = towctrans((wint_t)name2[i], wctrans("tolower"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteipAddressesEqual(IMA_TARGET_ADDRESS addr1, IMA_TARGET_ADDRESS addr2)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (addr1.hostnameIpAddress.id.ipAddress.ipv4Address !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr2.hostnameIpAddress.id.ipAddress.ipv4Address) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (addr1.hostnameIpAddress.id.ipAddress.ipv4Address) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp(addr1.hostnameIpAddress.id.ipAddress.ipAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr2.hostnameIpAddress.id.ipAddress.ipAddress, compSize) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (paramp = loginParams; paramp->name; paramp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing ChinagetTunableParam(char *arg)
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China parameterTbl_t *paramp;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China for (paramp = tunableParams; paramp->name != NULL; paramp++) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China len = strlen(arg);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (len == strlen(paramp->name) &&
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China strncasecmp(arg, paramp->name, len) == 0) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (paramp->val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errorString = gettext("Invalid parameter specified");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Internal library error: Invalid oid type specified");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Internal library error: Incorrect oid type specified");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errorString = gettext("Internal library error: Oid not found");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n", cmdName, errorString);
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 * nodeProps - pointer to caller allocated IMA_NODE_PROPERTIES
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * zero on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status = IMA_GetSharedNodeOid(&sharedNodeOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetNodeProperties(sharedNodeOid, nodeProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sunInitiatorFind
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Finds the Sun iSCSI initiator (LHBA). This CLI currently supports only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one initiator.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * oid of initiator
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * zero on success with initiator found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * > 0 on success with no initiator found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * < 0 on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status = IMA_GetLhbaOidList(&lhbaList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
f5fc5c043551e3eab595da7d8b5a53479207738fJack Meng if ((lhbaList == NULL) || (lhbaList->oidCount == 0)) {
f5fc5c043551e3eab595da7d8b5a53479207738fJack Meng return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wcInput - wide character string containing discovery address
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * address - IMA_TARGET_ADDRESS structure containing valid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * discovery address
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * zero on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetTargetAddress(int addrType, char *ipStr, IMA_TARGET_ADDRESS *address)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *tmpStrPtr, tmpStr[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if this is a ipv6 address */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte address->hostnameIpAddress.id.ipAddress.ipv4Address = IMA_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set start position to beginning of input object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte address->hostnameIpAddress.id.ipAddress.ipv4Address = IMA_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* wcschr for ':'. If not there, use default port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte address->hostnameIpAddress.id.ipAddress.ipAddress);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* inet_pton returns 1 on success */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s: %s\n", cmdName, ipStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * convert port string to unsigned value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note: Don't remove errno = 0 as you may get false failures.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno != 0 || inputPort == 0 && errchr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* make sure it's in the range */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print results of send targets command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteprintSendTargets(SUN_IMA_DISC_ADDRESS_KEY_PROPERTIES *pList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pList->keys[i].address.ipAddress.ipv4Address == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("\tTarget name: %ws\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t\t%s: %15s:%d", "Target address",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inet_ntop(af, &(pList->keys[i].address.ipAddress.ipAddress),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outBuf, inetSize), pList->keys[i].address.portNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, ", %d", pList->keys[i].tpgt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print all login parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteprintLoginParameters(char *prefix, IMA_OID oid, int printOption)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(longString, 0, sizeof (longString));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Login Parameters (Default/Configured)"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetConnProperties(&pConnList->oids[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propBool.currentValueValid = connProps->valuesValid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValueValid = connProps->valuesValid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propBool.currentValue = connProps->dataSequenceInOrder;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetDataSequenceInOrderProperties(oid, &propBool);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propBool.currentValue = connProps->dataPduInOrder;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetDataPduInOrderProperties(oid, &propBool);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->defaultTime2Retain;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetDefaultTime2RetainProperties(oid, &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->defaultTime2Wait;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetDefaultTime2WaitProperties(oid, &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->errorRecoveryLevel;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetErrorRecoveryLevelProperties(oid, &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->firstBurstLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propBool.currentValue = connProps->immediateData;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetImmediateDataProperties(oid, &propBool);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ", prefix, gettext("Immediate Data"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetInitialR2TProperties(oid, &propBool);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->maxBurstLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetMaxBurstLengthProperties(oid, &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ", prefix, gettext("Max Burst Length"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->maxOutstandingR2T;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetMaxOutstandingR2TProperties(oid, &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->maxRecvDataSegmentLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetMaxRecvDataSegmentLengthProperties(oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->maxConnections;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetMaxConnectionsProperties(oid, &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ", prefix, gettext("Max Connections"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print discovery information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteprintDiscoveryMethod(char *prefix, IMA_UINT32 discoveryMethodFlags)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s%s: ", prefix, gettext("Discovery Method"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (discoveryMethodFlags == IMA_TARGET_DISCOVERY_METHOD_UNKNOWN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s ", gettext("Static"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s ", gettext("SendTargets"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * printConnectionList - Prints the conection list provided
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteprintConnectionList(char *prefix, IMA_OID_LIST *pConnList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte imaStatus = SUN_IMA_GetConnProperties(&pConnList->oids[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (connProps->local.ipAddress.ipv4Address == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s %s: %s:%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s %s: [%s]:%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (connProps->peer.ipAddress.ipv4Address == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s %s: %s:%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s %s: [%s]:%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set login parameters on a target or initiator
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortesetLoginParameter(IMA_OID oid, int optval, char *optarg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for clarity, there are two switch statements
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The first loads the variable and the second
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * calls the appropriate API
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* implement 'default'? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* implement 'default'? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegettext("value must be between 512 and 16777215"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetDataSequenceInOrder(oid, boolValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetDefaultTime2Retain(oid, uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetDefaultTime2Wait(oid, uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetFirstBurstLength(oid, uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this call fails check to see if it's because
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the requested value is > than maxBurstLength
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "be less than or equal to than " \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "maxBurstLength"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this call fails check to see if it's because
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the requested value is < than firstBurstLength
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "greater than or equal to " \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "firstBurstLength"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetMaxOutstandingR2T(oid, uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetErrorRecoveryLevel(oid, uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteprintDigestAlgorithm(SUN_IMA_DIGEST_ALGORITHM_VALUE *digestAlgorithms,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < digestAlgorithms->defaultAlgorithmCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (digestAlgorithms->defaultAlgorithms[i]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (digestAlgorithms->currentValid == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i < digestAlgorithms->currentAlgorithmCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (printOption == PRINT_NEGOTIATED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (digestAlgorithms->negotiatedValid == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((nameValueString = strdup(optarg)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Retrieve all login params from option argument
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Syntax <key=value,...>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sscanf(indexp, gettext("%[^=]=%s"), keyp, valp) != 2) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (nameValueString) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China free(nameValueString);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China nameValueString = NULL;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (nameValueString) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China free(nameValueString);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China nameValueString = NULL;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (nameValueString) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China free(nameValueString);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China nameValueString = NULL;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (nameValueString) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China free(nameValueString);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China nameValueString = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print logical unit information for a specific target
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetLuProperties(lunList->oids[j],
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng * The lun is valid though the os Device Name is not.
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng * Give this information to users for judgement.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lunProps.imaProps.osDeviceNameValid == IMA_TRUE) {
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng " Available\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Retrieve CHAP secret from input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetSecret(char *secret, int *secretLen, int minSecretLen, int maxSecretLen)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get password */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapSecret = getpassphrase(gettext("Enter secret:"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapSecret = getpassphrase(gettext("Re-enter secret:"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("secrets do not match, secret not changed"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Lists the discovery attributes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get discovery attributes from IMA */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetDiscoveryProperties(initiatorOid, &discProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discProps.sendTargetsDiscoveryEnabled == IMA_TRUE ? \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print all initiator node attributes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Begin output */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("Initiator node alias: "));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("%ws\n"), nodeProps.alias);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Login Parameters (Default/Configured)"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get Digest configuration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetHeaderDigest(initiatorOid, &digestAlgorithms);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t\t%s: ", gettext("Header Digest"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetDataDigest(initiatorOid, &digestAlgorithms);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t\t%s: ", gettext("Data Digest"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get authentication type for this lhba */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetInUseInitiatorAuthMethods(initiatorOid, &maxEntries,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t%s: ", gettext("Authentication Type"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No authentication method set - default is NONE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < maxEntries; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (methodList[i]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get RADIUS configuration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetInitiatorRadiusConfig(initiatorOid, &radiusConfig);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t%s: ", gettext("RADIUS Server"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(radiusConfig.hostnameIpAddress) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetInitiatorRadiusAccess(initiatorOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t%s: ", gettext("RADIUS Access"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s", gettext("enabled"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s", gettext("disabled"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (status == IMA_ERROR_OBJECT_NOT_FOUND) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s", gettext("disabled"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s", gettext("unknown"));
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China /* print tunable parameters information. */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ret = printTunableParameters(initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* print configured session information. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print discovery addresses
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistDiscoveryAddress(int objectLen, char *objects[], cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_DISC_ADDR_PROP_LIST *discoveryAddressPropertiesList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If there are multiple objects, execute outer 'for' loop that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * many times for each target detail, otherwise, execute it only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * once with summaries only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetDiscoveryAddressPropertiesList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < outerLoop; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if one or more objects were input,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the values
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j < discoveryAddressPropertiesList->discAddrCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the discovery address with the input if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one was input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Print summary - always */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Discovery Address: %s:%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "DiscoveryAddress: [%s]:%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue sendTargets only when an addr is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "targets."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we found the discovery address - break */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * There was an object entered but we didn't
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print ISNS Server addresses
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistISNSServerAddress(int objectLen, char *objects[], cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_DISC_ADDR_PROP_LIST *discoveryAddressPropertiesList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If there are multiple objects, execute outer 'for' loop that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * many times for each target detail, otherwise, execute it only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * once with summaries only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetISNSServerAddressPropertiesList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < outerLoop; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if one or more objects were input,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the values
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j < discoveryAddressPropertiesList->discAddrCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the discovery address with the input if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one was input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Print summary - always */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "iSNS Server IP Address: %s:%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue sendTargets only when an addr is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check if the discovery mode is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "discovery "\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "disabled. "\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "No targets "\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "to report."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "targets."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we found the discovery address - break */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * There was an object entered but we didn't
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print static configuration targets
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistStaticConfig(int operandLen, char *operand[], int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_STATIC_TARGET_PROPERTIES staticTargetProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t staticTargetName[MAX_ISCSI_NAME_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t staticTargetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t found; /* B_TRUE if a target name is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t matched; /* B_TRUE if a specific target is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t tmpTargetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If there are multiple objects, execute outer 'for' loop that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * many times for each static config detail, otherwise, execute it only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * once with summaries only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* convert ':' to wide char for wchar string search */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetStaticDiscoveryTargetOidList(initiatorOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < outerLoop; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (found = B_FALSE, j = 0; j < staticTargetList->oidCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stpgt = staticTargetProps.staticTarget.targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isIpv6 = !staticTargetProps.staticTarget.targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the static target name with the input if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one was input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* targetName found - found = B_TRUE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Since an object is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified, it should also
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * have a tpgt specified. If
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * not, that means the object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified is associated with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the default tpgt. In
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * either case, a tpgt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * comparison should be done
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * before claiming that a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * match is found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* print summary - always */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Static Configuration Target",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No details to display, but if there were:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if (object && found)...
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * There was an object entered but we didn't
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print targets
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistTarget(int objectLen, char *objects[], cmdOptions_t *options, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t targetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If there are multiple objects, execute outer 'for' loop that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * many times for each target detail, otherwise, execute it only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * once with summaries only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetSessionOidList(initiatorOid, &targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < outerLoop; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (found = B_FALSE, j = 0; j < targetList->oidCount; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the target name with the input if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one was input, if they match, print the target's info
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if no target name was input, continue printing this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tpgt does not match,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * move on to next
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * target name does not match, move on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to next target
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* print summary - always */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t%s: ", gettext("Alias"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wslen(targetProps.imaProps.alias) > (size_t)0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (targetProps.defaultTpgtConf != IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s%s: %02x%02x%02x%02x%02x%02x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get Digest configuration */
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng * Proceeds the listing
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng * but indicates the
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng * error in return value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * did we find the object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print configured session information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get configured session information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetConfigSessions(oid, &pConfigSessions);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* default binding */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%lu\n", pConfigSessions->out);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* hardcoded binding */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print target parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistTargetParam(int operandLen, char *operand[], cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t targetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If there are multiple operands, execute outer 'for' loop that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * many times to find each target parameter operand entered, otherwise,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * execute it only once for all target parameters returned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Ideally there should be an interface available for obtaining
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the list of target-param objects. Since the driver currently
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * creates a target OID and the associated session structure when
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a target-param object is created, we can leverage the target
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OID list and use it to manage the target-param objects. When
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we stop creating a session for target-param object in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * driver, we will switch to using a different interface to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obtain target-param objects.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetTargetOidList(initiatorOid, &targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < outerLoop; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the target name with the input if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one was input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For now, regardless of whether a target
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * address is specified, we return B_TRUE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * because IMA_TARGET_PROPERTIES does not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * have a field for specifying address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if no operand was entered OR
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an operand was entered and it was
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found, we want to print
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get bidirectional authentication flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get authentication type for this target */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No authentication method define
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NONE by default.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < maxEntries; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (methodList[i]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get Digest configuration */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China /* print tunable parameters infomation */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (printTunableParameters(
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China targetList->oids[j]) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* print configured session information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Modify discovery attributes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyDiscovery(cmdOptions_t *options, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check optarg and set bool accordingly */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcasecmp(optionList->optarg, ISCSIADM_ARG_ENABLE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strcasecmp(optionList->optarg, ISCSIADM_ARG_DISABLE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set static discovery */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set send targets discovery */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set iSNS discovery */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the initiator node's authentication method
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyNodeAuthParam(IMA_OID oid, int param, char *chapName, int *funcRet)
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China int nameLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Start with existing parameters and modify with the desired change
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * before passing along. We ignore any failures as they probably
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are caused by non-existence of auth params for the given node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetInitiatorAuthParms(oid, IMA_AUTHMETHOD_CHAP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "CHAP name cannot be NULL.\n");
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China nameLen = strlen(chapName);
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China if (nameLen == 0) {
129b3e6c5b0ac55b5021a4c38db6387b6acdaaf1Jack Meng (void) fprintf(stderr, "CHAP name cannot be empty.\n");
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China if (nameLen > ISCSI_MAX_C_USER_LEN) {
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China (void) fprintf(stderr, "CHAP name is too long.\n");
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China &chapName[0], nameLen);
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China authParams.chapParms.nameLength = nameLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = getSecret((char *)&chapSecret[0], &secretLen,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&authParams.chapParms.challengeSecret, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&authParams.chapParms.challengeSecret,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authParams.chapParms.challengeSecretLength = secretLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "Invalid auth parameter %d\n", param);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetInitiatorAuthParms(oid, IMA_AUTHMETHOD_CHAP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the target's authentication method
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyTargetAuthParam(IMA_OID oid, int param, char *chapName, int *funcRet)
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China int nameLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Start with existing parameters and modify with the desired change
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * before passing along. We ignore any get failures as they probably
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are caused by non-existence of auth params for the given target.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetTargetAuthParms(oid, IMA_AUTHMETHOD_CHAP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "CHAP name cannot be NULL.\n");
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China nameLen = strlen(chapName);
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China if (nameLen == 0) {
129b3e6c5b0ac55b5021a4c38db6387b6acdaaf1Jack Meng (void) fprintf(stderr, "CHAP name cannot be empty.\n");
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China if (nameLen > ISCSI_MAX_C_USER_LEN) {
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China (void) fprintf(stderr, "CHAP name is too long.\n");
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China &chapName[0], nameLen);
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China authParams.chapParms.nameLength = nameLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = getSecret((char *)&chapSecret[0], &secretLen,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&authParams.chapParms.challengeSecret, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&authParams.chapParms.challengeSecret,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authParams.chapParms.challengeSecretLength = secretLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "Invalid auth parameter %d\n", param);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetTargetAuthParams(oid, IMA_AUTHMETHOD_CHAP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyTargetBidirAuthFlag(IMA_OID targetOid, char *optarg, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcasecmp(optarg, ISCSIADM_ARG_ENABLE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strcasecmp(optarg, ISCSIADM_ARG_DISABLE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("invalid option argument"), optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetTargetBidirAuthFlag(targetOid, &boolValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyConfiguredSessions(IMA_OID targetOid, char *optarg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Strip the first int value from the string. If we sprintf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this back to a string and it matches the original string
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then this command is using default binding. If not a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * match we have hard coded binding or a usage error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* default binding */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allocate the required pConfigSessions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions = (SUN_IMA_CONFIG_SESSIONS *)calloc(1, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* setup pConfigSessions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* hardcoded binding */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * First we need to determine how many bindings
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are available. This can be done by scanning
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for the number of ',' + 1.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allocate the required pConfigSessions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = sizeof (SUN_IMA_CONFIG_SESSIONS) + ((sessions - 1) *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions = (SUN_IMA_CONFIG_SESSIONS *)calloc(1, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* setup pConfigSessions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now fill in the binding information. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Walk thru possible address strings
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stop once all strings are processed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check if there is another address after this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one. If so terminate the current address and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * keep a pointer to the next one.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Parse current address. If invalid abort
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * processing of addresses and free memory.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ADDRESS_LEN, &port, &isIpv6) != PARSE_ADDR_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Convert address into binary form */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* inet_pton found address invalid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* update addressPos to next address */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* issue SUN_IMA request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetAuthMethodValue(char *method, IMA_AUTHMETHOD *value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the authentication method
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Currently only supports CHAP and NONE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyNodeAuthMethod(IMA_OID oid, char *optarg, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * optarg will be a , delimited set of auth methods, in order
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of preference
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if any values here are incorrect, return without setting
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (commaPos && methodCount < MAX_AUTH_METHODS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should not find more method specified - if found, error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetInitiatorAuthMethods(oid, methodCount, &methodList[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyTargetAuthMethod(IMA_OID oid, char *optarg, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * optarg will be a , delimited set of auth methods, in order
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of preference
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if any values here are incorrect, return without setting
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (commaPos && methodCount < MAX_AUTH_METHODS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should not find more method specified - if found, error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetTargetAuthMethods(oid, &methodCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Modify the RADIUS configuration of the initiator node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return 0 on success.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyNodeRadiusConfig(IMA_OID oid, char *optarg, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&config, 0, sizeof (SUN_IMA_RADIUS_CONFIG));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &config.hostnameIpAddress[0], SUN_IMA_IP_ADDRESS_PORT_LEN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte config.isIpv6 = (isIpv6 == B_TRUE) ? IMA_TRUE : IMA_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Not setting shared secret here. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetInitiatorRadiusConfig(oid, &config);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Modify the RADIUS access flag of the initiator node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return 0 on success.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyNodeRadiusAccess(IMA_OID oid, char *optarg, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if Radius Config is there */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&radiusConfig, 0, sizeof (SUN_IMA_RADIUS_CONFIG));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetInitiatorRadiusConfig(initiatorOid, &radiusConfig);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("RADIUS server not configured yet"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if Radius Shared is set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (radiusConfig.sharedSecretValid == IMA_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("RADIUS server secret not configured yet"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcasecmp(optarg, ISCSIADM_ARG_ENABLE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strcasecmp(optarg, ISCSIADM_ARG_DISABLE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetInitiatorRadiusAccess(oid, radiusAccess);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Modify the RADIUS shared secret.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * zero on success.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * > 0 on failure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyNodeRadiusSharedSecret(IMA_OID oid, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_BYTE radiusSharedSecret[SUN_IMA_MAX_RADIUS_SECRET_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = getSecret((char *)&radiusSharedSecret[0], &secretLen,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First obtain existing RADIUS configuration (if any) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&radiusConfig, 0, sizeof (SUN_IMA_RADIUS_CONFIG));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetInitiatorRadiusConfig(initiatorOid, &radiusConfig);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("RADIUS server not configured yet"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Modify the shared secret only */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetInitiatorRadiusConfig(oid, &radiusConfig);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set initiator node attributes.
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China char *mb_name = NULL;
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China int prefixlen = 0;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* Get boot session's info */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " of root disk"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
f5fc5c043551e3eab595da7d8b5a53479207738fJack Meng if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte maximum length is:"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Take the first operand as node name. */
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China prefixlen = strlen(ISCSI_IQN_NAME_PREFIX);
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China mb_name = (char *)calloc(1, prefixlen + 1);
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China if (mb_name == NULL) {
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China if (wcstombs(mb_name, nodeName,
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China prefixlen) == (size_t)-1) {
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China (void) fprintf(stderr, "%s: %s\n",
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China gettext("conversion error"));
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China (void) IMA_FreeMemory(mb_name);
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China if (strncmp(mb_name, ISCSI_IQN_NAME_PREFIX,
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China prefixlen) == 0) {
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China * For iqn format, we should map
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China * the upper-case characters to
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China * their lower-case equivalents.
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China for (i = 0; nodeName[i] != 0; i++) {
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China tolower(nodeName[i]);
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China nodeName[i] = lowerCase;
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China (void) IMA_FreeMemory(mb_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Perform string profile checks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IMA_GetSharedNodeOid(&sharedNodeOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return (INF_ERROR);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " allowed to change"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " initiator's name"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " allowed to change"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " initiator's alias"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Take the first operand as node alias. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte length is:"),
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " allowed to change authentication"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " method"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " allowed to change CHAP secret"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " boot and MPxIO"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " is disabled, not allowed"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " to change number of"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " sessions to be"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " configured"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " fail to set configured"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " session"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " allowed to change CHAP name"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " boot and MPxIO"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " is disabled, not"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " allowed to"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " change initiator's"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " login params"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " boot and MPxIO"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " is disabled, not"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " allowed to"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " change initiator's"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " login params"));
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (setTunableParameters(oid,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China optionList->optarg) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Modify target parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyTargetParam(cmdOptions_t *options, char *targetName, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t targetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Perform string profile checks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nameCheckStatus = iSCSINameStringProfileCheck(wcInputObject);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " of root disk"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng status = SUN_IMA_GetBootTargetName(bootTargetName);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng status = SUN_IMA_GetBootTargetAuthParams(&bootTargetCHAP);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " auth param"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* find target oid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (found = B_FALSE, i = 0; i < targetList->oidCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetTargetProperties(targetList->oids[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the target name with the input name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((targetNamesEqual(wcInputObject, targetProps.imaProps.name)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For now, regardless of whether a target address
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is specified, we return B_TRUE because
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IMA_TARGET_PROPERTIES does not have a field for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specifying address.
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if ((targetNamesEqual(bootTargetName, wcInputObject)
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * iscsi booting, need changed target param is
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * booting target, for auth param, not allow
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * to change, for others dependent on mpxio
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * -C CHAP secret set
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * -H CHAP name set
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * -a authentication
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * -B bi-directional-authentication
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " not allowed to modify"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " authentication parameters"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " of boot target"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " MPxIO is disabled, not allowed"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " to modify boot target's"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " parameters"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyIndividualTargetParam(optionList, targetOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Even after finding a matched target, keep going
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * since there could be multiple target objects
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * associated with one target name in the system
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * because of different TPGTs.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If the target OID cannot be found create one */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_CreateTargetOid(wcInputObject, &targetOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyIndividualTargetParam(optionList, targetOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add one or more addresses
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteaddAddress(int addrType, int operandLen, char *operand[], int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Format of discovery address operand:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * <IP address|hostname>:<port>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < operandLen; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&wcInputObject[0], 0, sizeof (wcInputObject));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getTargetAddress(addrType, operand[i], &address.imaStruct)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add one or more static configuration targets
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteaddStaticConfig(int operandLen, char *operand[], int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t staticTargetName[MAX_ISCSI_NAME_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t staticTargetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Format of static config operand:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * <target-name>,<IP address|hostname>[:port][,tpgt]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < operandLen; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Perform string profile checks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nameCheckStatus = iSCSINameStringProfileCheck(staticTargetName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) wcsncpy(staticConfig.targetName, staticTargetName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) wcstombs(sAddr, staticTargetAddress, sizeof (sAddr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticConfig.targetAddress.imaStruct.hostnameIpAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticConfig.targetAddress.imaStruct.hostnameIpAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (inet_pton(addrType, sAddr, staticConfig.targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte imaStruct.hostnameIpAddress.id.ipAddress.ipAddress) != 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("static config conversion error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticConfig.targetAddress.imaStruct.portNumber = port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticConfig.targetAddress.defaultTpgt = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_AddStaticTarget(oid, staticConfig, &oid);
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove one or more addresses
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteremoveAddress(int addrType, int operandLen, char *operand[], int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < operandLen; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&wcInputObject[0], 0, sizeof (wcInputObject));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getTargetAddress(addrType, operand[i], &address.imaStruct)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_RemoveDiscoveryAddress(address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_RemoveISNSServerAddress(address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove one or more static configuration targets
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteremoveStaticConfig(int operandLen, char *operand[], int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_STATIC_TARGET_PROPERTIES staticTargetProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t staticTargetName[MAX_ISCSI_NAME_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t staticTargetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t tmpTargetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetStaticDiscoveryTargetOidList(initiatorOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < operandLen; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Perform string profile checks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nameCheckStatus = iSCSINameStringProfileCheck(staticTargetName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When removing multiple static-config
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * entries we need to expect get
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * failures. These failures occur when
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we are trying to get entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information we have just removed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Ignore the failure and continue.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.staticTarget.targetAddress.tpgt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the static target name with the input if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one was input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "conversion error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove one or more target params.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteremoveTargetParam(int operandLen, char *operand[], int *funcRet)
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* Get boot session's info */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " root disk"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng status = SUN_IMA_GetBootTargetName(bootTargetName);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " target's name"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetTargetOidList(initiatorOid, &targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < operandLen; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Ignore IP address. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&wcInputObject[0], 0, sizeof (wcInputObject));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (found = B_FALSE, j = 0; j < targetList->oidCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the target name with the input if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one was input
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * iscsi booting, need changed target
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * param is booting target, booting
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * session mpxio disabled, not
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * allow to update
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " with MPxIO disabled,"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " not allowed to remove"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " boot sess param"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Silently ignoring it? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteaddFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = addAddress(object, operandLen, operand, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = addStaticConfig(operandLen, operand, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = listDiscoveryAddress(operandLen, operand, options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = listISNSServerAddress(operandLen, operand, options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = listStaticConfig(operandLen, operand, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = listTarget(operandLen, operand, options, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = listTargetParam(operandLen, operand, options, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = modifyTargetParam(options, operand[i], funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteremoveFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = removeStaticConfig(operandLen, operand, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = removeTargetParam(operandLen, operand, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiSCSINameCheckStatusDisplay(iSCSINameCheckStatusType status)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " format is: YYYY-MM"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("missing subdomain after \":\""));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("missing reversed fully qualified"\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " domain name"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A convenient function to modify the target parameters of an individual
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return 0 if successful
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return 1 if failed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyIndividualTargetParam(cmdOptions_t *optionList, IMA_OID targetOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Login parameter */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Modify configure sessions */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (setTunableParameters(targetOid,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China optionList->optarg) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This helper function could go into a utility module for general use.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* IPv6 address */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close_bracket_pos = strchr(address_port_str, ']');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strlcpy(address_str, &address_port_str[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Extract the port number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Port number out of range */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Specified port out of range: %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* IPv4 address */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No port number specified. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Extract the port number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Port number out of range */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Specified port out of range: %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This helper function could go into a utility module for general use.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) wcstombs(mb_name, name, MAX_ISCSI_NAME_LEN + 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check for invalid characters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * According to RFC 3722 iSCSI name must be either a letter,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a digit or one of the following '-' '.' ':'
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If name is of type iqn, check date string and naming
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * authority.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Don't allow the string to end with a colon. If there is a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * colon then there must be a subdomain provided.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Date string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Date string should be in YYYY-MM format */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Validate year. Only validating that the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * year can be converted to a number. No
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * validation will be done on year's actual
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Validate month is valid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A reversed FQDN needs to be provided. We
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will only check for a "." followed by more
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * than two or more characters. The list of domains is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * too large and changes too frequently to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add validation for.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Name authority string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(mb_name, ISCSI_EUI_NAME_PREFIX,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If name is of type EUI, change its length */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (tmp = mb_name + strlen(ISCSI_EUI_NAME_PREFIX) + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This helper function could go into a utility module for general use.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * B_TRUE is the numberStr is an unsigned natural number and within the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified bound.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * B_FALSE otherwise.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteisNaturalNumber(char *numberStr, uint32_t upperBound)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < number_str_len; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This helper function could go into a utility module for general use.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It parses a target string in the format of:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * <target_name>,[<ip_address>[:port][,tpgt]]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and creates wchar strings for target name and target address. It
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * also populates port and tpgt if found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PARSE_TARGET_OK if parsing is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PARSE_TARGET_INVALID_TPGT if the specified tpgt is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PARSE_TARGET_INVALID_ADDR if the address specified is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Checking of tpgt makes sense only when
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the target address/port are specified.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isNaturalNumber(commaPos2, ISCSI_MAX_TPGT_VALUE) ==
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China (void) fprintf(stderr, "%s: %s\n", cmdName,
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China gettext("parse target invalid TPGT"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (parseAddress(commaPos, ISCSI_LISTEN_PORT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetAddress[0], MAX_ADDRESS_LEN + 1, port, isIpv6)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; targetAddressStr[i] != 0; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) mbstowcs(targetNameStr, targetStr, targetNameStrLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; targetNameStr[i] != 0; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get Chap Name depending upon oid object type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n\t\t%s: ", gettext("CHAP Name"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Default chap name will be the node name. The default will
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be set by the driver.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(chapName, authParams.chapParms.name,
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng " iSCSI initiator."),
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng " iscsi(7D)."));
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng " try 'svcadm enable network/iscsi/initiator' to"
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng " enable the service."),
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng " iscsi(7D)."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Prints out see manual page.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called out through atexit(3C) so is always last thing displayed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("For more information, please see"), cmdName);
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (geteuid() != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s\n", gettext("permission denied"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set global command name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(versionString, sizeof (versionString), "%s.%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call the CLI parser */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cmdParse(argc, argv, synTables, subcommandArgs, &funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("Unable to complete operation"));
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing ChinasetTunableParameters(IMA_OID oid, char *optarg)
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China char keyp[MAXOPTARGLEN];
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China char valp[MAXOPTARGLEN];
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China IMA_STATUS status;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China IMA_UINT uintValue;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ISCSI_TUNABLE_PARAM tunableObj;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China char *nameValueString, *endptr;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if ((nameValueString = strdup(optarg)) == NULL) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (errno == ENOMEM) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stderr, "%s: %s\n",
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China cmdName, strerror(errno));
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stderr, "%s: %s\n", cmdName,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China gettext("unknown error"));
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) memset(keyp, 0, sizeof (keyp));
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) memset(valp, 0, sizeof (valp));
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (sscanf(nameValueString, gettext("%[^=]=%s"), keyp, valp) != 2) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stderr, "%s: %s: %s\n", cmdName,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China gettext("Unknown param"), nameValueString);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (nameValueString) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China free(nameValueString);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China nameValueString = NULL;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if ((key = getTunableParam(keyp)) == -1) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stderr, "%s: %s: %s\n", cmdName,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China gettext("Unknown key"), keyp);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (nameValueString) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China free(nameValueString);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China nameValueString = NULL;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China case RECV_LOGIN_RSP_TIMEOUT:
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China case CONN_LOGIN_MAX:
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China case POLLING_LOGIN_DELAY:
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China uintValue = strtoul(valp, &endptr, 0);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (*endptr != '\0' || errno != 0) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stderr, "%s: %s - %s\n",
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China gettext("invalid option argument"),
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (nameValueString) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China free(nameValueString);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China nameValueString = NULL;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (uintValue > 3600) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stderr, "%s: %s\n",
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing Chinagettext("value must be between 0 and 3600"));
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (nameValueString) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China free(nameValueString);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China nameValueString = NULL;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (chkConnLoginMaxPollingLoginDelay(oid, key, uintValue) > 0) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (nameValueString) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China free(nameValueString);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China nameValueString = NULL;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (key == RECV_LOGIN_RSP_TIMEOUT) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China tunableObj.tunable_objectType =
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ISCSI_RX_TIMEOUT_VALUE;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China } else if (key == CONN_LOGIN_MAX) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China tunableObj.tunable_objectType =
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ISCSI_CONN_DEFAULT_LOGIN_MAX;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China } else if (key == POLLING_LOGIN_DELAY) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China tunableObj.tunable_objectType =
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ISCSI_LOGIN_POLLING_DELAY;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China tunableObj.tunable_objectValue = valp;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China status = SUN_IMA_SetTunableProperties(oid, &tunableObj);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stderr, "%s: %s: %s\n", cmdName,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China gettext("Unsupported key"), keyp);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (nameValueString) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China free(nameValueString);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China nameValueString = NULL;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (!IMA_SUCCESS(status)) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China printLibError(status);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (nameValueString) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China free(nameValueString);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China nameValueString = NULL;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (nameValueString) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China free(nameValueString);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China nameValueString = NULL;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China * Print tunable parameters information
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing ChinaprintTunableParameters(IMA_OID oid)
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ISCSI_TUNABLE_PARAM tunableObj;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China char value[MAXOPTARGLEN] = "\0";
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China IMA_STATUS status;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China tunableObj.tunable_objectValue = value;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stdout, "\t%s:\n",
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China gettext("Tunable Parameters (Default/Configured)"));
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China tunableObj.tunable_objectType = ISCSI_RX_TIMEOUT_VALUE;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China status = SUN_IMA_GetTunableProperties(oid, &tunableObj);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (!IMA_SUCCESS(status)) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China printLibError(status);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (value[0] == '\0') {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China value[1] = '\0';
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stdout, "\t\t%s: ",
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China gettext("Session Login Response Time"));
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stdout, "%s/%s\n", ISCSI_DEFAULT_RX_TIMEOUT_VALUE,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China tunableObj.tunable_objectValue);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China value[0] = '\0';
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China tunableObj.tunable_objectType = ISCSI_CONN_DEFAULT_LOGIN_MAX;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China status = SUN_IMA_GetTunableProperties(oid, &tunableObj);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (!IMA_SUCCESS(status)) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China printLibError(status);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (value[0] == '\0') {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China value[1] = '\0';
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stdout, "\t\t%s: ",
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China gettext("Maximum Connection Retry Time"));
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stdout, "%s/%s\n", ISCSI_DEFAULT_CONN_DEFAULT_LOGIN_MAX,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China tunableObj.tunable_objectValue);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China value[0] = '\0';
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China tunableObj.tunable_objectType = ISCSI_LOGIN_POLLING_DELAY;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China status = SUN_IMA_GetTunableProperties(oid, &tunableObj);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (!IMA_SUCCESS(status)) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China printLibError(status);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (value[0] == '\0') {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China value[1] = '\0';
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stdout, "\t\t%s: ",
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China gettext("Login Retry Time Interval"));
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stdout, "%s/%s\n", ISCSI_DEFAULT_LOGIN_POLLING_DELAY,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China tunableObj.tunable_objectValue);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China * This is helper function to check conn_login_max and polling_login_delay.
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing ChinachkConnLoginMaxPollingLoginDelay(IMA_OID oid, int key, int uintValue)
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China char valuep[MAXOPTARGLEN];
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China IMA_STATUS status;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China IMA_UINT getValue;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ISCSI_TUNABLE_PARAM getObj;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (key == CONN_LOGIN_MAX) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China getObj.tunable_objectType = ISCSI_LOGIN_POLLING_DELAY;
fb2a9bae0030340ad72b9c26ba1ffee2ee3cafecyi zhang - Sun Microsystems - Beijing China } else if (key == POLLING_LOGIN_DELAY) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China getObj.tunable_objectType = ISCSI_CONN_DEFAULT_LOGIN_MAX;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China valuep[0] = '\0';
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China getObj.tunable_objectValue = valuep;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China status = SUN_IMA_GetTunableProperties(oid, &getObj);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (!IMA_SUCCESS(status)) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China printLibError(status);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (valuep[0] == '\0') {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (key == CONN_LOGIN_MAX) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) strlcpy(valuep,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ISCSI_DEFAULT_LOGIN_POLLING_DELAY,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China strlen(ISCSI_DEFAULT_LOGIN_POLLING_DELAY) +1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) strlcpy(valuep,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ISCSI_DEFAULT_CONN_DEFAULT_LOGIN_MAX,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China strlen(ISCSI_DEFAULT_CONN_DEFAULT_LOGIN_MAX) +1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China getValue = strtoul(valuep, &endptr, 0);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (*endptr != '\0' || errno != 0) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stderr, "%s: %s - %s\n",
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China gettext("cannot convert tunable string"),
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (key == CONN_LOGIN_MAX) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (uintValue < getValue) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stderr, "%s: %s %ld\n",
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China cmdName, gettext("value must larger than"),
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (uintValue > getValue) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China (void) fprintf(stderr, "%s: %s %ld\n",
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China cmdName, gettext("value must smaller than"),