fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fb2a9bae0030340ad72b9c26ba1ffee2ee3cafecyi zhang - Sun Microsystems - Beijing China * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <wchar.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <widec.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/socket.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <arpa/inet.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <netdb.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libintl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <limits.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <strings.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <syslog.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <netinet/in.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/socket.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <arpa/inet.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <wctype.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <assert.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ima.h>
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China#include <libsun_ima.h>
1a1a84a324206b6b1f5f704ab166c4ebf78aed76Peter Dunlap#include <sys/iscsi_protocol.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/adapters/iscsi_if.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "cmdparse.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sun_ima.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "iscsiadm.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define VERSION_STRING_MAX_LEN 10
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAX_LONG_CHAR_LEN 19
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAX_AUTH_METHODS 5
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Version number:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MAJOR - This should only change when there is an incompatible change made
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the interfaces or the output.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MINOR - This should change whenever there is a new command or new feature
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * with no incompatible change.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define VERSION_STRING_MAJOR "1"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define VERSION_STRING_MINOR "0"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OPTIONSTRING1 "yes|no"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OPTIONSTRING2 "initiator node name"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OPTIONSTRING3 "initiator node alias"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OPTIONSTRING4 "enable|disable"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OPTIONSTRING5 "key=value,..."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OPTIONSTRING6 "none|CRC32"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OPTIONSTRING7 "CHAP name"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OPTIONSTRING8 "<# sessions>|<IP Address>[,<IP Address>]*"
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China#define OPTIONSTRING9 "tunable-prop=value"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OPTIONVAL1 "0 to 3600"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OPTIONVAL2 "512 to 2**24 - 1"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OPTIONVAL3 "1 to 65535"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define OPTIONVAL4 "<IP address>[:port]"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAX_ISCSI_NAME_LEN 223
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAX_ADDRESS_LEN 255
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MIN_CHAP_SECRET_LEN 12
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAX_CHAP_SECRET_LEN 16
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEFAULT_ISCSI_PORT 3260
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISNS_DEFAULT_SERVER_PORT 3205
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEFAULT_RADIUS_PORT 1812
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAX_CHAP_NAME_LEN 512
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* For listNode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define INF_ERROR 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define INVALID_NODE_NAME 2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IMABOOLPRINT(prop, option) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((option) == PRINT_CONFIGURED_PARAMS) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s/%s\n", \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (prop).defaultValue == IMA_TRUE ? gettext("yes") : \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("no"), \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (prop).currentValueValid == IMA_TRUE ? \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((prop).currentValue == IMA_TRUE ? \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("yes"): gettext("no")) : "-"); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((option) == PRINT_NEGOTIATED_PARAMS) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\n", \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (prop).currentValueValid == IMA_TRUE ? \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((prop).currentValue == IMA_TRUE) ? gettext("yes") : \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("no")) : "-"); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IMAMINMAXPRINT(prop, option) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((option) == PRINT_CONFIGURED_PARAMS) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%d/", (prop).defaultValue); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((prop).currentValueValid == IMA_TRUE) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%d\n", (prop).currentValue); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((prop).currentValueValid == IMA_FALSE) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\n", "-"); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((option) == PRINT_NEGOTIATED_PARAMS) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((prop).currentValueValid == IMA_TRUE) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%d\n", (prop).currentValue); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((prop).currentValueValid == IMA_FALSE) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\n", "-"); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* forward declarations */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PARSE_ADDR_OK 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PARSE_ADDR_MISSING_CLOSING_BRACKET 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PARSE_ADDR_PORT_OUT_OF_RANGE 2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PARSE_TARGET_OK 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PARSE_TARGET_INVALID_TPGT 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PARSE_TARGET_INVALID_ADDR 2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PRINT_CONFIGURED_PARAMS 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PRINT_NEGOTIATED_PARAMS 2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum iSCSINameCheckStatus {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameCheckOK,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameLenZero,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameLenExceededMax,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameUnknownType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameInvalidCharacter,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameIqnFormatError,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameEUIFormatError,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameIqnDateFormatError,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameIqnSubdomainFormatError,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameIqnInvalidYearError,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameIqnInvalidMonthError,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameIqnFQDNError
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iSCSINameCheckStatusType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *address_str, size_t address_str_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t *port, boolean_t *isIpv6);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint parseTarget(char *targetStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t *targetNameStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t targetNameStrLen,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t *targetAddressSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t *targetAddressStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t targetAddressStrLen,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t *port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t *tpgtSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t *tpgt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t *isIpv6);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing Chinastatic int chkConnLoginMaxPollingLoginDelay(IMA_OID oid,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China int key, int uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* helper functions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *getExecBasename(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int getNodeProps(IMA_NODE_PROPERTIES *);
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 printTargetLuns(IMA_OID_LIST *);
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 *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int setLoginParameters(IMA_OID, char *);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing Chinastatic int setTunableParameters(IMA_OID, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void printLibError(IMA_STATUS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINTED E_STATIC_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sunPluginChk(IMA_OID, boolean_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sunInitiatorFind(IMA_OID *);
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,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID targetOid, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void listCHAPName(IMA_OID oid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int printConfiguredSessions(IMA_OID);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing Chinastatic int printTunableParameters(IMA_OID oid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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 modifyNode(cmdOptions_t *, 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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINTED E_STATIC_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic IMA_STATUS getISCSINodeParameter(int paramType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID *oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pProps,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t paramIndex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINTED E_STATIC_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic IMA_STATUS setISCSINodeParameter(int paramType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID *oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pProps,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t paramIndex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINTED E_STATIC_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic IMA_STATUS getDigest(IMA_OID oid, int ioctlCmd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_DIGEST_ALGORITHM_VALUE *algorithm);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIMA_STATUS getNegotiatedDigest(int digestType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_DIGEST_ALGORITHM_VALUE *algorithm,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_CONN_PROPERTIES *connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* globals */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *cmdName;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Available option letters:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng * befgijklmnoquwxyz
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China * DEFGHIJKLMOQUVWXYZ
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add new options here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteoptionTbl_t longOptions[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"static", required_arg, 's', OPTIONSTRING4},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"sendtargets", required_arg, 't', OPTIONSTRING4},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"iSNS", required_arg, 'i', 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 {"CHAP-secret", no_arg, 'C', NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"CHAP-name", required_arg, 'H', OPTIONSTRING7},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"node-name", required_arg, 'N', OPTIONSTRING2},
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 {"radius-shared-secret", no_arg, 'P', NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"verbose", no_arg, 'v', NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"scsi-target", no_arg, 'S', NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"configured-sessions", required_arg, 'c', OPTIONSTRING8},
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China {"tunable-param", required_arg, 'T', OPTIONSTRING9},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {NULL, 0, 0, 0}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteparameterTbl_t loginParams[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"dataseqinorder", DATA_SEQ_IN_ORDER},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"defaulttime2retain", DEFAULT_TIME_2_RETAIN},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"defaulttime2wait", DEFAULT_TIME_2_WAIT},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"firstburstlength", FIRST_BURST_LENGTH},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"immediatedata", IMMEDIATE_DATA},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"initialr2t", INITIAL_R2T},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"maxburstlength", MAX_BURST_LENGTH},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"datapduinorder", DATA_PDU_IN_ORDER},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"maxoutstandingr2t", MAX_OUTSTANDING_R2T},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"maxrecvdataseglen", MAX_RECV_DATA_SEG_LEN},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"maxconnections", MAX_CONNECTIONS},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"errorrecoverylevel", ERROR_RECOVERY_LEVEL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {NULL, 0}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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},
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China {NULL, 0}
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China};
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add new subcommands here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesubcommand_t subcommands[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"add", ADD, addFunc},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"list", LIST, listFunc},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"modify", MODIFY, modifyFunc},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"remove", REMOVE, removeFunc},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {NULL, 0, NULL}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add objects here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteobject_t objects[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"discovery", DISCOVERY},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"discovery-address", DISCOVERY_ADDRESS},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"isns-server", ISNS_SERVER_ADDRESS},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"initiator-node", NODE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"static-config", STATIC_CONFIG},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"target", TARGET},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"target-param", TARGET_PARAM},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {NULL, 0}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Rules for subcommands and objects
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteobjectRules_t objectRules[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {TARGET, 0, LIST, 0, ADD|REMOVE|MODIFY, LIST,
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 {NODE, 0, 0, MODIFY|LIST, 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 {DISCOVERY_ADDRESS, ADD|REMOVE, LIST, 0, MODIFY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ADD|REMOVE|LIST, "IP-address[:port-number]"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {ISNS_SERVER_ADDRESS, ADD|REMOVE, LIST, 0, MODIFY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ADD|REMOVE|LIST, "IP-address[:port-number]"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {0, 0, 0, 0, 0, NULL}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * list of objects, subcommands, valid short options, required flag and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * exclusive option string
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If it's not here, there are no options for that object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteoptionRules_t optionRules[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {DISCOVERY, MODIFY, "sti", B_TRUE, NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {DISCOVERY_ADDRESS, LIST, "v", B_FALSE, NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {ISNS_SERVER_ADDRESS, LIST, "v", B_FALSE, NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {TARGET, LIST, "vS", B_FALSE, NULL},
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 {TARGET_PARAM, LIST, "v", B_FALSE, NULL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {0, 0, 0, 0, 0}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic boolean_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortetargetNamesEqual(wchar_t *name1, wchar_t *name2)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t wchar1, wchar2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (name1 == NULL || name2 == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (B_FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wcslen(name1) != wcslen(name2)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (B_FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Convert names to lower case and compare
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < wcslen(name1); i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar1 = towctrans((wint_t)name1[i], wctrans("tolower"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar2 = towctrans((wint_t)name2[i], wctrans("tolower"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wchar1 != wchar2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (B_FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (B_TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic boolean_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteipAddressesEqual(IMA_TARGET_ADDRESS addr1, IMA_TARGET_ADDRESS addr2)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IPV4_ADDR_BYTES 4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IPV6_ADDR_BYTES 16
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int compSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (addr1.hostnameIpAddress.id.ipAddress.ipv4Address !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr2.hostnameIpAddress.id.ipAddress.ipv4Address) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (B_FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte compSize = IPV6_ADDR_BYTES;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (addr1.hostnameIpAddress.id.ipAddress.ipv4Address) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte compSize = IPV4_ADDR_BYTES;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bcmp(addr1.hostnameIpAddress.id.ipAddress.ipAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr2.hostnameIpAddress.id.ipAddress.ipAddress, compSize) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (B_TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (B_FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetLoginParam(char *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parameterTbl_t *paramp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (paramp = loginParams; paramp->name; paramp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = strlen(arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (len == strlen(paramp->name) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncasecmp(arg, paramp->name, len) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (paramp->val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing Chinastatic int
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing ChinagetTunableParam(char *arg)
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China{
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China parameterTbl_t *paramp;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China int len;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
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);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (-1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China}
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteprintLibError(IMA_STATUS status)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *errorString;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (status) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMA_ERROR_NOT_SUPPORTED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errorString =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Operation currently not supported");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMA_ERROR_INSUFFICIENT_MEMORY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errorString = gettext("Insufficient memory");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMA_ERROR_UNEXPECTED_OS_ERROR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errorString = gettext("unexpected OS error");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMA_ERROR_UNKNOWN_ERROR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errorString = gettext("Unknown error");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMA_ERROR_LU_IN_USE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errorString = gettext("Logical unit in use");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMA_ERROR_INVALID_PARAMETER:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errorString = gettext("Invalid parameter specified");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMA_ERROR_INVALID_OBJECT_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errorString =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Internal library error: Invalid oid type specified");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMA_ERROR_INCORRECT_OBJECT_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errorString =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Internal library error: Incorrect oid type specified");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMA_ERROR_OBJECT_NOT_FOUND:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errorString = gettext("Internal library error: Oid not found");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMA_ERROR_NAME_TOO_LONG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errorString = gettext("Name too long");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errorString = gettext("Unknown error");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n", cmdName, errorString);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * execFullName - exec name of program (argv[0])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * command name portion of execFullName
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetExecBasename(char *execFullname)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *lastSlash, *execBasename;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* guard against '/' at end of command invocation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (;;) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lastSlash = strrchr(execFullname, '/');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lastSlash == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte execBasename = execFullname;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte execBasename = lastSlash + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*execBasename == '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *lastSlash = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (execBasename);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nodeProps - pointer to caller allocated IMA_NODE_PROPERTIES
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * zero on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetNodeProps(IMA_NODE_PROPERTIES *nodeProps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID sharedNodeOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status = IMA_GetSharedNodeOid(&sharedNodeOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(IMA_SUCCESS(status))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (INF_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetNodeProperties(sharedNodeOid, nodeProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (INF_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sunInitiatorFind
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Finds the Sun iSCSI initiator (LHBA). This CLI currently supports only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one initiator.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * output:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * oid of initiator
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * zero on success with initiator found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * > 0 on success with no initiator found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * < 0 on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortesunInitiatorFind(IMA_OID *oid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
f5fc5c043551e3eab595da7d8b5a53479207738fJack Meng IMA_OID_LIST *lhbaList = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status = IMA_GetLhbaOidList(&lhbaList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
f5fc5c043551e3eab595da7d8b5a53479207738fJack Meng if ((lhbaList == NULL) || (lhbaList->oidCount == 0)) {
f5fc5c043551e3eab595da7d8b5a53479207738fJack Meng printLibError(IMA_ERROR_OBJECT_NOT_FOUND);
f5fc5c043551e3eab595da7d8b5a53479207738fJack Meng if (lhbaList != NULL)
f5fc5c043551e3eab595da7d8b5a53479207738fJack Meng (void) IMA_FreeMemory(lhbaList);
f5fc5c043551e3eab595da7d8b5a53479207738fJack Meng return (-1);
f5fc5c043551e3eab595da7d8b5a53479207738fJack Meng }
f5fc5c043551e3eab595da7d8b5a53479207738fJack Meng
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *oid = lhbaList->oids[0];
f5fc5c043551e3eab595da7d8b5a53479207738fJack Meng (void) IMA_FreeMemory(lhbaList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * input:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wcInput - wide character string containing discovery address
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * output:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * address - IMA_TARGET_ADDRESS structure containing valid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * discovery address
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * zero on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetTargetAddress(int addrType, char *ipStr, IMA_TARGET_ADDRESS *address)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char cCol = ':';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char cBracketL = '['; /* Open Bracket '[' */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char cBracketR = ']'; /* Close Bracket ']' */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *colPos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *startPos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned long inputPort;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int addressType = AF_INET;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *tmpStrPtr, tmpStr[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if this is a ipv6 address */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ipStr[0] == cBracketL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addressType = AF_INET6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte startPos = strchr(ipStr, cBracketR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!startPos) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s: ']' %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, ipStr, gettext("missing"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strlcpy(tmpStr, ipStr+1, startPos-ipStr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte address->hostnameIpAddress.id.ipAddress.ipv4Address = IMA_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmpStrPtr = tmpStr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set start position to beginning of input object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addressType = AF_INET;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte startPos = ipStr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte address->hostnameIpAddress.id.ipAddress.ipv4Address = IMA_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmpStrPtr = ipStr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* wcschr for ':'. If not there, use default port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte colPos = strchr(startPos, cCol);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!colPos) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (addrType == DISCOVERY_ADDRESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inputPort = DEFAULT_ISCSI_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (addrType == ISNS_SERVER_ADDRESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inputPort = ISNS_DEFAULT_SERVER_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *colPos = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *colPos = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = inet_pton(addressType, tmpStrPtr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte address->hostnameIpAddress.id.ipAddress.ipAddress);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* inet_pton returns 1 on success */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rval != 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s: %s\n", cmdName, ipStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("invalid IP address"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (colPos) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *errchr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte colPos++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*colPos == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, ipStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("port number missing"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * convert port string to unsigned value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note: Don't remove errno = 0 as you may get false failures.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errno = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inputPort = strtol(colPos, &errchr, 10);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno != 0 || inputPort == 0 && errchr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s:%s %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, ipStr, colPos,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("port number invalid"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* make sure it's in the range */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (inputPort > USHRT_MAX) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, ipStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("port number out of range"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte address->portNumber = inputPort;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print results of send targets command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteprintSendTargets(SUN_IMA_DISC_ADDRESS_KEY_PROPERTIES *pList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char outBuf[INET6_ADDRSTRLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int inetSize;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int af;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < pList->keyCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pList->keys[i].address.ipAddress.ipv4Address == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte af = AF_INET;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inetSize = INET_ADDRSTRLEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte af = AF_INET6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inetSize = INET6_ADDRSTRLEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("\tTarget name: %ws\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pList->keys[i].name);
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 (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print all login parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteprintLoginParameters(char *prefix, IMA_OID oid, int printOption)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_BOOL_VALUE propBool;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_MIN_MAX_VALUE propMinMax;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char longString[MAX_LONG_CHAR_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_CONN_PROPERTIES *connProps = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID_LIST *pConnList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(longString, 0, sizeof (longString));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (printOption) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PRINT_CONFIGURED_PARAMS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s%s:\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Login Parameters (Default/Configured)"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PRINT_NEGOTIATED_PARAMS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s%s:\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Login Parameters (Negotiated)"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetConnOidList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &pConnList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetConnProperties(&pConnList->oids[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propBool.currentValueValid = connProps->valuesValid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValueValid = connProps->valuesValid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printOption == PRINT_NEGOTIATED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propBool.currentValue = connProps->dataSequenceInOrder;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetDataSequenceInOrderProperties(oid, &propBool);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ", prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Data Sequence In Order"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMABOOLPRINT(propBool, printOption);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printOption == PRINT_NEGOTIATED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propBool.currentValue = connProps->dataPduInOrder;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetDataPduInOrderProperties(oid, &propBool);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ", prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Data PDU In Order"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMABOOLPRINT(propBool, printOption);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printOption == PRINT_NEGOTIATED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->defaultTime2Retain;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetDefaultTime2RetainProperties(oid, &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ", prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Default Time To Retain"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMAMINMAXPRINT(propMinMax, printOption);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printOption == PRINT_NEGOTIATED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->defaultTime2Wait;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetDefaultTime2WaitProperties(oid, &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ", prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Default Time To Wait"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMAMINMAXPRINT(propMinMax, printOption);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printOption == PRINT_NEGOTIATED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->errorRecoveryLevel;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetErrorRecoveryLevelProperties(oid, &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ", prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Error Recovery Level"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMAMINMAXPRINT(propMinMax, printOption);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printOption == PRINT_NEGOTIATED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->firstBurstLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetFirstBurstLengthProperties(oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prefix, gettext("First Burst Length"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMAMINMAXPRINT(propMinMax, printOption);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printOption == PRINT_NEGOTIATED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propBool.currentValue = connProps->immediateData;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetImmediateDataProperties(oid, &propBool);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ", prefix, gettext("Immediate Data"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMABOOLPRINT(propBool, printOption);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printOption == PRINT_NEGOTIATED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propBool.currentValue = connProps->initialR2T;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetInitialR2TProperties(oid, &propBool);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ", prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Initial Ready To Transfer (R2T)"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMABOOLPRINT(propBool, printOption);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printOption == PRINT_NEGOTIATED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->maxBurstLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetMaxBurstLengthProperties(oid, &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ", prefix, gettext("Max Burst Length"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMAMINMAXPRINT(propMinMax, printOption);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printOption == PRINT_NEGOTIATED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->maxOutstandingR2T;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetMaxOutstandingR2TProperties(oid, &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ", prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Max Outstanding R2T"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMAMINMAXPRINT(propMinMax, printOption);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printOption == PRINT_NEGOTIATED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->maxRecvDataSegmentLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetMaxRecvDataSegmentLengthProperties(oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ", prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Max Receive Data Segment Length"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMAMINMAXPRINT(propMinMax, printOption);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printOption == PRINT_NEGOTIATED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte propMinMax.currentValue = connProps->maxConnections;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetMaxConnectionsProperties(oid, &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\t%s: ", prefix, gettext("Max Connections"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMAMINMAXPRINT(propMinMax, printOption);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print discovery information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteprintDiscoveryMethod(char *prefix, IMA_UINT32 discoveryMethodFlags)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
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\n", gettext("NA"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!((discoveryMethodFlags &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_TARGET_DISCOVERY_METHOD_STATIC) ^
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_TARGET_DISCOVERY_METHOD_STATIC)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s ", gettext("Static"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!((discoveryMethodFlags &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_TARGET_DISCOVERY_METHOD_SENDTARGETS) ^
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_TARGET_DISCOVERY_METHOD_SENDTARGETS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s ", gettext("SendTargets"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!((discoveryMethodFlags &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_TARGET_DISCOVERY_METHOD_ISNS) ^
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_TARGET_DISCOVERY_METHOD_ISNS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s ", gettext("iSNS"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * printConnectionList - Prints the conection list provided
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteprintConnectionList(char *prefix, IMA_OID_LIST *pConnList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS imaStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_CONN_PROPERTIES *connProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte union {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char ipv4[INET_ADDRSTRLEN+1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char ipv6[INET6_ADDRSTRLEN+1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < pConnList->oidCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte imaStatus = SUN_IMA_GetConnProperties(&pConnList->oids[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (imaStatus != IMA_STATUS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%sCID: %d\n", prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte connProps->connectionID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&tmp, 0, sizeof (tmp));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (connProps->local.ipAddress.ipv4Address == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (inet_ntop(AF_INET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &connProps->local.ipAddress.ipAddress[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tmp.ipv4[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte INET_ADDRSTRLEN)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s %s: %s:%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("IP address (Local)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tmp.ipv4[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ntohs(connProps->local.portNumber));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (inet_ntop(AF_INET6,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &connProps->local.ipAddress.ipAddress[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tmp.ipv6[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte INET6_ADDRSTRLEN)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s %s: [%s]:%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("IP address (Local)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tmp.ipv6[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ntohs(connProps->local.portNumber));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (connProps->peer.ipAddress.ipv4Address == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (inet_ntop(AF_INET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &connProps->peer.ipAddress.ipAddress[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tmp.ipv4[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte INET_ADDRSTRLEN)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s %s: %s:%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("IP address (Peer)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tmp.ipv4[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ntohs(connProps->peer.portNumber));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (inet_ntop(AF_INET6,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &connProps->peer.ipAddress.ipAddress[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tmp.ipv6[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte INET6_ADDRSTRLEN)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s %s: [%s]:%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prefix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("IP address (Peer)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tmp.ipv6[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ntohs(connProps->peer.portNumber));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set login parameters on a target or initiator
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortesetLoginParameter(IMA_OID oid, int optval, char *optarg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status = IMA_STATUS_SUCCESS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT uintValue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_BOOL boolValue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_DIGEST_ALGORITHM digestAlgList[1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_MIN_MAX_VALUE propMinMax;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *endptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (optval) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DATA_SEQ_IN_ORDER:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMMEDIATE_DATA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case INITIAL_R2T:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DATA_PDU_IN_ORDER:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* implement 'default'? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcasecmp(optarg, "yes") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolValue = IMA_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strcasecmp(optarg, "no") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolValue = IMA_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s - %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("invalid option argument"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DEFAULT_TIME_2_RETAIN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DEFAULT_TIME_2_WAIT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errno = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uintValue = strtoul(optarg, &endptr, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*endptr != '\0' || errno != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s - %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("invalid option argument"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uintValue > 3600) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegettext("value must be between 0 and 3600"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FIRST_BURST_LENGTH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MAX_BURST_LENGTH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MAX_RECV_DATA_SEG_LEN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errno = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* implement 'default'? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uintValue = strtoul(optarg, &endptr, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*endptr != '\0' || errno != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s - %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("invalid option argument"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uintValue < 512 || uintValue > 16777215) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegettext("value must be between 512 and 16777215"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MAX_OUTSTANDING_R2T:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errno = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uintValue = strtoul(optarg, &endptr, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*endptr != '\0' || errno != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s - %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("invalid option argument"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uintValue < 1 || uintValue > 65535) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegettext("value must be between 1 and 65535"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HEADER_DIGEST:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DATA_DIGEST:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcasecmp(optarg, "none") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte digestAlgList[0] = SUN_IMA_DIGEST_NONE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strcasecmp(optarg, "CRC32") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte digestAlgList[0] = SUN_IMA_DIGEST_CRC32;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s - %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("invalid option argument"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MAX_CONNECTIONS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errno = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uintValue = strtoul(optarg, &endptr, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*endptr != '\0' || errno != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s - %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("invalid option argument"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uintValue < 1 || uintValue > 256) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegettext("value must be between 1 and 256"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ERROR_RECOVERY_LEVEL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errno = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uintValue = strtoul(optarg, &endptr, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*endptr != '\0' || errno != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s - %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("invalid option argument"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uintValue > 2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegettext("value must be between 0 and 2"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %c: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, optval, gettext("unknown option"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (optval) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DATA_PDU_IN_ORDER:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetDataPduInOrder(oid, boolValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DATA_SEQ_IN_ORDER:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetDataSequenceInOrder(oid, boolValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DEFAULT_TIME_2_RETAIN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetDefaultTime2Retain(oid, uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DEFAULT_TIME_2_WAIT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetDefaultTime2Wait(oid, uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FIRST_BURST_LENGTH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetFirstBurstLength(oid, uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this call fails check to see if it's because
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the requested value is > than maxBurstLength
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetMaxBurstLengthProperties(oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uintValue > propMinMax.currentValue) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s: %s\n", cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("firstBurstLength must " \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "be less than or equal to than " \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "maxBurstLength"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMMEDIATE_DATA:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetImmediateData(oid, boolValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case INITIAL_R2T:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetInitialR2T(oid, boolValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MAX_BURST_LENGTH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetMaxBurstLength(oid, uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this call fails check to see if it's because
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the requested value is < than firstBurstLength
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetFirstBurstLengthProperties(oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &propMinMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uintValue < propMinMax.currentValue) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("maxBurstLength must be " \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "greater than or equal to " \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "firstBurstLength"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MAX_OUTSTANDING_R2T:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetMaxOutstandingR2T(oid, uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MAX_RECV_DATA_SEG_LEN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetMaxRecvDataSegmentLength(oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case HEADER_DIGEST:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetHeaderDigest(oid, 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &digestAlgList[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DATA_DIGEST:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetDataDigest(oid, 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &digestAlgList[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case MAX_CONNECTIONS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetMaxConnections(oid, uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ERROR_RECOVERY_LEVEL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetErrorRecoveryLevel(oid, uintValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteprintDigestAlgorithm(SUN_IMA_DIGEST_ALGORITHM_VALUE *digestAlgorithms,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int printOption)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printOption == PRINT_CONFIGURED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < digestAlgorithms->defaultAlgorithmCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "|");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (digestAlgorithms->defaultAlgorithms[i]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SUN_IMA_DIGEST_NONE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("NONE"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SUN_IMA_DIGEST_CRC32:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("CRC32"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Unknown"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "/");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (digestAlgorithms->currentValid == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i < digestAlgorithms->currentAlgorithmCount; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "|");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (digestAlgorithms->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte currentAlgorithms[i]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SUN_IMA_DIGEST_NONE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("NONE"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SUN_IMA_DIGEST_CRC32:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("CRC32"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Unknown"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "-");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (printOption == PRINT_NEGOTIATED_PARAMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (digestAlgorithms->negotiatedValid == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i < digestAlgorithms->negotiatedAlgorithmCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "|");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (digestAlgorithms->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte negotiatedAlgorithms[i]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SUN_IMA_DIGEST_NONE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("NONE"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SUN_IMA_DIGEST_CRC32:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("CRC32"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Unknown"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "-");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortesetLoginParameters(IMA_OID oid, char *optarg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char keyp[MAXOPTARGLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char valp[MAXOPTARGLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int key;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *nameValueString, *indexp, *delim = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((nameValueString = strdup(optarg)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno == ENOMEM) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n", cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unknown error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte indexp = nameValueString;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Retrieve all login params from option argument
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Syntax <key=value,...>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (indexp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (delim = strchr(indexp, ',')) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte delim[0] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(keyp, 0, sizeof (keyp));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(valp, 0, sizeof (valp));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sscanf(indexp, gettext("%[^=]=%s"), keyp, valp) != 2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s: %s\n", cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Unknown param"), indexp);
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 }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((key = getLoginParam(keyp)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s: %s\n", cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 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 }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (setLoginParameter(oid, key, valp) != 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 }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (delim) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte indexp = delim + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte indexp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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 }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print logical unit information for a specific target
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteprintTargetLuns(IMA_OID_LIST * lunList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_LU_PROPERTIES lunProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < lunList->oidCount; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetLuProperties(lunList->oids[j],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &lunProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng (void) fprintf(stdout, "\tLUN: %lld\n",
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng lunProps.imaProps.targetLun);
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng (void) fprintf(stdout, "\t Vendor: %s\n",
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng lunProps.vendorId);
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng (void) fprintf(stdout, "\t Product: %s\n",
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng lunProps.productId);
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng /*
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng * The lun is valid though the os Device Name is not.
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng * Give this information to users for judgement.
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lunProps.imaProps.osDeviceNameValid == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("\t OS Device Name: %ws\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lunProps.imaProps.osDeviceName);
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng } else {
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng (void) fprintf(stdout,
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng gettext("\t OS Device Name: Not"
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng " Available\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Retrieve CHAP secret from input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetSecret(char *secret, int *secretLen, int minSecretLen, int maxSecretLen)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *chapSecret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get password */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapSecret = getpassphrase(gettext("Enter secret:"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng if (chapSecret == NULL) {
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng (void) fprintf(stderr, "%s: %s\n", cmdName,
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng gettext("Unable to get secret"));
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng *secret = NULL;
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng return (1);
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng }
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(chapSecret) > maxSecretLen) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s %d\n", cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("secret too long, maximum length is"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte maxSecretLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *secret = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(chapSecret) < minSecretLen) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s %d\n", cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("secret too short, minimum length is"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte minSecretLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *secret = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(secret, chapSecret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chapSecret = getpassphrase(gettext("Re-enter secret:"));
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng if (chapSecret == NULL) {
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng (void) fprintf(stderr, "%s: %s\n", cmdName,
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng gettext("Unable to get secret"));
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng *secret = NULL;
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng return (1);
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng }
5279807d7e1818eac6f90ac640b7a89cdb37522dJack Meng
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(secret, chapSecret) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n", cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("secrets do not match, secret not changed"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *secret = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *secretLen = strlen(chapSecret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Lists the discovery attributes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistDiscovery(int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID initiatorOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_DISCOVERY_PROPERTIES discProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get discovery attributes from IMA */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetDiscoveryProperties(initiatorOid, &discProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s:\n", "Discovery");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\tStatic: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discProps.staticDiscoveryEnabled == IMA_TRUE ? \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("enabled") : gettext("disabled"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\tSend Targets: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discProps.sendTargetsDiscoveryEnabled == IMA_TRUE ? \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("enabled") : gettext("disabled"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\tiSNS: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discProps.iSnsDiscoveryEnabled == IMA_TRUE ? \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("enabled") : gettext("disabled"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print all initiator node attributes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistNode(int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID initiatorOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_NODE_PROPERTIES nodeProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT maxEntries = MAX_AUTH_METHODS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_AUTHMETHOD methodList[MAX_AUTH_METHODS];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_RADIUS_CONFIG radiusConfig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_DIGEST_ALGORITHM_VALUE digestAlgorithms;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_BOOL radiusAccess;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = getNodeProps(&nodeProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nodeProps.nameValid == IMA_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (INVALID_NODE_NAME);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Begin output */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("%s: %ws\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Initiator node name"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodeProps.name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("Initiator node alias: "));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nodeProps.aliasValid == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("%ws\n"), nodeProps.alias);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\n", "-");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t%s:\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Login Parameters (Default/Configured)"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get Digest configuration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetHeaderDigest(initiatorOid, &digestAlgorithms);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t\t%s: ", gettext("Header Digest"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printDigestAlgorithm(&digestAlgorithms,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PRINT_CONFIGURED_PARAMS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetDataDigest(initiatorOid, &digestAlgorithms);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t\t%s: ", gettext("Data Digest"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printDigestAlgorithm(&digestAlgorithms,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PRINT_CONFIGURED_PARAMS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get authentication type for this lhba */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetInUseInitiatorAuthMethods(initiatorOid, &maxEntries,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &methodList[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t%s: ", gettext("Authentication Type"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No authentication method set - default is NONE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("NONE"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < maxEntries; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "|");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (methodList[i]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMA_AUTHMETHOD_NONE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("NONE"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMA_AUTHMETHOD_CHAP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("CHAP"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte listCHAPName(initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unknown type"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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 (IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(radiusConfig.hostnameIpAddress) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s:%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte radiusConfig.hostnameIpAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte radiusConfig.port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s", gettext("NONE"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s", gettext("NONE"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetInitiatorRadiusAccess(initiatorOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &radiusAccess);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t%s: ", gettext("RADIUS Access"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (radiusAccess == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s", gettext("enabled"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s", gettext("disabled"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (status == IMA_ERROR_OBJECT_NOT_FOUND) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s", gettext("disabled"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s", gettext("unknown"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China /* print tunable parameters information. */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China ret = printTunableParameters(initiatorOid);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* print configured session information. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = printConfiguredSessions(initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print discovery addresses
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistDiscoveryAddress(int objectLen, char *objects[], cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID initiatorOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_DISC_ADDR_PROP_LIST *discoveryAddressPropertiesList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_DISCOVERY_ADDRESS_PROPERTIES discAddrProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_TARGET_ADDRESS address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_DISC_ADDRESS_KEY_PROPERTIES *pList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t wcInputObject[MAX_ADDRESS_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t object = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int outerLoop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t found;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t verbose = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdOptions_t *optionList = options;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char sAddr[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; optionList->optval; optionList++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (optionList->optval) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'v':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %c: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, optionList->optval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unknown option"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (objectLen > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outerLoop = objectLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outerLoop = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetDiscoveryAddressPropertiesList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &discoveryAddressPropertiesList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < outerLoop; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (object) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&wcInputObject[0], 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (wcInputObject));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&address, 0, sizeof (address));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbstowcs(wcInputObject, objects[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (MAX_ADDRESS_LEN + 1)) == (size_t)-1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("conversion error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if one or more objects were input,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the values
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getTargetAddress(DISCOVERY_ADDRESS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte objects[i], &address) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (found = B_FALSE, j = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j < discoveryAddressPropertiesList->discAddrCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discAddrProps =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discoveryAddressPropertiesList->props[j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the discovery address with the input if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one was input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (object &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipAddressesEqual(discAddrProps.discoveryAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte address) && (discAddrProps.discoveryAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portNumber == address.portNumber)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!object || found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Print summary - always */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (discAddrProps.discoveryAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hostnameIpAddress.id.ipAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipv4Address) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) inet_ntop(AF_INET, discAddrProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discoveryAddress.hostnameIpAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id.ipAddress.ipAddress, sAddr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (sAddr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Discovery Address: %s:%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sAddr, discAddrProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discoveryAddress.portNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) inet_ntop(AF_INET6,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discAddrProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discoveryAddress.hostnameIpAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id.ipAddress.ipAddress, sAddr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (sAddr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "DiscoveryAddress: [%s]:%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sAddr, discAddrProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discoveryAddress.portNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((!object || found) && verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_NODE_PROPERTIES nodeProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getNodeProps(&nodeProps) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue sendTargets only when an addr is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SendTargets(nodeProps.name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discAddrProps.discoveryAddress, &pList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("\tUnable to get "\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "targets."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printSendTargets(pList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we found the discovery address - break */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * There was an object entered but we didn't
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * find it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (object && !found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte objects[i], gettext("not found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print ISNS Server addresses
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistISNSServerAddress(int objectLen, char *objects[], cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID initiatorOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_DISC_ADDR_PROP_LIST *discoveryAddressPropertiesList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_DISCOVERY_ADDRESS_PROPERTIES discAddrProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_TARGET_ADDRESS address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_DISC_ADDRESS_KEY_PROPERTIES *pList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t wcInputObject[MAX_ADDRESS_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t object = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int outerLoop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t found;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t showTarget = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdOptions_t *optionList = options;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char sAddr[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; optionList->optval; optionList++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (optionList->optval) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'v':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte showTarget = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %c: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, optionList->optval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unknown option"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (objectLen > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outerLoop = objectLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outerLoop = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetISNSServerAddressPropertiesList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &discoveryAddressPropertiesList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < outerLoop; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (object) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&wcInputObject[0], 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (wcInputObject));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&address, 0, sizeof (address));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbstowcs(wcInputObject, objects[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (MAX_ADDRESS_LEN + 1)) == (size_t)-1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("conversion error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if one or more objects were input,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the values
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getTargetAddress(ISNS_SERVER_ADDRESS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte objects[i], &address) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (found = B_FALSE, j = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j < discoveryAddressPropertiesList->discAddrCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discAddrProps =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discoveryAddressPropertiesList->props[j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the discovery address with the input if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one was input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (object &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipAddressesEqual(discAddrProps.discoveryAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte address) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (discAddrProps.discoveryAddress.portNumber ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte address.portNumber)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!object || found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Print summary - always */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (discAddrProps.discoveryAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hostnameIpAddress.id.ipAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipv4Address) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) inet_ntop(AF_INET, discAddrProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discoveryAddress.hostnameIpAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id.ipAddress.ipAddress, sAddr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (sAddr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) inet_ntop(AF_INET6,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discAddrProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discoveryAddress.hostnameIpAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id.ipAddress.ipAddress, sAddr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (sAddr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "iSNS Server IP Address: %s:%u\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sAddr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discAddrProps.discoveryAddress.portNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((!object || found) && showTarget) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_NODE_PROPERTIES nodeProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getNodeProps(&nodeProps) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue sendTargets only when an addr is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_RetrieveISNSServerTargets(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discAddrProps.discoveryAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &pList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check if the discovery mode is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * disabled.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_ERROR_OBJECT_NOT_FOUND) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("\tiSNS "\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "discovery "\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "mode "\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "disabled. "\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "No targets "\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "to report."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("\tUnable "\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "to get "\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "targets."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printSendTargets(pList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we found the discovery address - break */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * There was an object entered but we didn't
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * find it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (object && !found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte objects[i], gettext("not found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print static configuration targets
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistStaticConfig(int operandLen, char *operand[], int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID initiatorOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID_LIST *staticTargetList;
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 wcCol;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char sAddr[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t object = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int outerLoop;
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 boolean_t targetAddressSpecified = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t tpgtSpecified = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t isIpv6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT16 port = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT16 tpgt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tmpStr[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t tmpTargetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (operandLen > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outerLoop = operandLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outerLoop = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* convert ':' to wide char for wchar string search */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbtowc(&wcCol, ":", sizeof (wcCol)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("conversion error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetStaticDiscoveryTargetOidList(initiatorOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &staticTargetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < outerLoop; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (object) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (parseTarget(operand[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &staticTargetName[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ISCSI_NAME_LEN + 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetAddressSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &staticTargetAddress[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_IP_ADDRESS_PORT_LEN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tpgtSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tpgt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &isIpv6) != PARSE_TARGET_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (found = B_FALSE, j = 0; j < staticTargetList->oidCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t isIpv6 = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT16 stpgt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_BOOL defaultTpgt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&staticTargetProps, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (staticTargetProps));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetStaticTargetProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetList->oids[j], &staticTargetProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(staticTargetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stpgt = staticTargetProps.staticTarget.targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tpgt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte defaultTpgt = staticTargetProps.staticTarget.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetAddress.defaultTpgt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isIpv6 = !staticTargetProps.staticTarget.targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte imaStruct.hostnameIpAddress.id.ipAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipv4Address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the static target name with the input if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one was input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (object &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (targetNamesEqual(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.staticTarget.targetName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetName) == B_TRUE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* targetName found - found = B_TRUE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (targetAddressSpecified == B_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (staticTargetProps.staticTarget.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetAddress.imaStruct.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hostnameIpAddress.id.ipAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipv4Address == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) inet_ntop(AF_INET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTarget.targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte imaStruct.hostnameIpAddress.id.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipAddress.ipAddress, tmpStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (tmpStr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) inet_ntop(AF_INET6,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTarget.targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte imaStruct.hostnameIpAddress.id.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipAddress.ipAddress, tmpStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (tmpStr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbstowcs(tmpTargetAddress, tmpStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_IP_ADDRESS_PORT_LEN) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (size_t)-1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("conversion error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wcsncmp(tmpTargetAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_IP_ADDRESS_PORT_LEN)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTarget.targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte imaStruct.portNumber == port) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((tpgt == stpgt &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tpgtSpecified == B_TRUE &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte defaultTpgt == IMA_FALSE) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (tpgt == stpgt &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tpgtSpecified == B_FALSE &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte defaultTpgt == IMA_TRUE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!object || matched) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* print summary - always */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("%s: %ws,"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Static Configuration Target",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.staticTarget.targetName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isIpv6 == B_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) inet_ntop(AF_INET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTarget.targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte imaStruct.hostnameIpAddress.id.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipAddress.ipAddress, sAddr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (sAddr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s:%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sAddr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.staticTarget.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetAddress.imaStruct.portNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) inet_ntop(AF_INET6,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTarget.targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte imaStruct.hostnameIpAddress.id.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipAddress.ipAddress, sAddr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (sAddr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "[%s]:%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sAddr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.staticTarget.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetAddress.imaStruct.portNumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (staticTargetProps.staticTarget.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte defaultTpgt == IMA_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, ",%d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTarget.targetAddress.tpgt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No details to display, but if there were:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if (object && found)...
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * There was an object entered but we didn't
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * find it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (object && !found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte operand[i], gettext("not found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1; /* DIY test fix */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print targets
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistTarget(int objectLen, char *objects[], cmdOptions_t *options, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID initiatorOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID_LIST *targetList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID_LIST *lunList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_TARGET_PROPERTIES targetProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID_LIST *pConnList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_CONN_PROPERTIES *connProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t targetName[MAX_ISCSI_NAME_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t targetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int outerLoop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t found;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t operandEntered = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t verbose = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t scsi_target = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t targetAddressSpecified = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t isIpv6 = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdOptions_t *optionList = options;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t tpgtSpecified = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT16 port = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t tpgt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; optionList->optval; optionList++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (optionList->optval) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'S':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_target = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'v':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %c: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, optionList->optval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unknown option"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (objectLen > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte operandEntered = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outerLoop = objectLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte operandEntered = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outerLoop = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetSessionOidList(initiatorOid, &targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < outerLoop; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tpgtSpecified = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (operandEntered) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (parseTarget(objects[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetName[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ISCSI_NAME_LEN + 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetAddressSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetAddress[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_IP_ADDRESS_PORT_LEN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tpgtSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tpgt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &isIpv6) != PARSE_TARGET_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (found = B_FALSE, j = 0; j < targetList->oidCount; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetTargetProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetList->oids[j],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if no target name was input, continue printing this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * target
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (operandEntered) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (targetNamesEqual(targetProps.imaProps.name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetName) == B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tpgtSpecified == B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (targetProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte defaultTpgtConf ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_FALSE &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tpgtConf == tpgt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tpgt does not match,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * move on to next
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * target
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * target name does not match, move on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to next target
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* print summary - always */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("%s: %ws\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Target"), targetProps.imaProps.name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Alias */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t%s: ", gettext("Alias"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wslen(targetProps.imaProps.alias) > (size_t)0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("%ws\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetProps.imaProps.alias);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\n", "-");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (targetProps.defaultTpgtNego != IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s%s: %d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t", gettext("TPGT"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetProps.tpgtNego);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (targetProps.defaultTpgtConf != IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s%s: %d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t", gettext("TPGT"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetProps.tpgtConf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s%s: %02x%02x%02x%02x%02x%02x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t", gettext("ISID"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetProps.isid[0], targetProps.isid[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetProps.isid[2], targetProps.isid[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetProps.isid[4], targetProps.isid[5]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConnList = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetConnOidList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetList->oids[j],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &pConnList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s%s: %lu\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Connections"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConnList->oidCount);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_DIGEST_ALGORITHM_VALUE digestAlgorithms;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printConnectionList("\t\t", pConnList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printDiscoveryMethod(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t\t ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetProps.imaProps.discoveryMethodFlags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printLoginParameters(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t\t ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetList->oids[j],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PRINT_NEGOTIATED_PARAMS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get Digest configuration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetConnProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &pConnList->oids[0], &connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) getNegotiatedDigest(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_LOGIN_PARAM_HEADER_DIGEST,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &digestAlgorithms, connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t\t \t%s: ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Header Digest"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printDigestAlgorithm(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &digestAlgorithms,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PRINT_NEGOTIATED_PARAMS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(pConnList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) getNegotiatedDigest(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_LOGIN_PARAM_DATA_DIGEST,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &digestAlgorithms, connProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t\t \t%s: ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Data Digest"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printDigestAlgorithm(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &digestAlgorithms,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PRINT_NEGOTIATED_PARAMS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(pConnList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scsi_target) {
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng status = SUN_IMA_ReEnumeration(
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng targetList->oids[j]);
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng if (!IMA_SUCCESS(status)) {
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng /*
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng * Proceeds the listing
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng * but indicates the
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng * error in return value
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng */
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng ret = 1;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng }
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetLuOidList(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetList->oids[j],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &lunList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lunList->oidCount != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printTargetLuns(lunList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(lunList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * did we find the object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (operandEntered && !found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte objects[i], gettext("not found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print configured session information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteprintConfiguredSessions(IMA_OID oid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *rtn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_CONFIG_SESSIONS *pConfigSessions;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char address[MAX_ADDRESS_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get configured session information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetConfigSessions(oid, &pConfigSessions);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t%s: ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Configured Sessions"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pConfigSessions->bound == IMA_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* default binding */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%lu\n", pConfigSessions->out);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* hardcoded binding */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (out = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte out < pConfigSessions->out; out++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pConfigSessions->bindings[out].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipAddress.ipv4Address == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rtn = inet_ntop(AF_INET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions->bindings[out].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipAddress.ipAddress, address,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ADDRESS_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rtn = inet_ntop(AF_INET6,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions->bindings[out].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipAddress.ipAddress, address,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ADDRESS_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rtn != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("%s ", address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pConfigSessions);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pConfigSessions);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print target parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistTargetParam(int operandLen, char *operand[], cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID initiatorOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID_LIST *targetList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_AUTHMETHOD methodList[MAX_AUTH_METHODS];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_TARGET_PROPERTIES targetProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT maxEntries = MAX_AUTH_METHODS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_BOOL bidirAuth;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t targetName[MAX_ISCSI_NAME_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t targetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t operandEntered = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t targetAddressSpecified = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t printObject = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t tpgtSpecified = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t isIpv6 = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int outerLoop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t found;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_DIGEST_ALGORITHM_VALUE digestAlgorithms;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t verbose = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdOptions_t *optionList = options;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT16 port = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT16 tpgt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; optionList->optval; optionList++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (optionList->optval) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'v':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte verbose = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %c: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, optionList->optval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unknown option"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (operandLen > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte operandEntered = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outerLoop = operandLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte operandEntered = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte outerLoop = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetTargetOidList(initiatorOid, &targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < outerLoop; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (operandEntered) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (parseTarget(operand[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetName[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ISCSI_NAME_LEN + 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetAddressSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetAddress[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_IP_ADDRESS_PORT_LEN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tpgtSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tpgt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &isIpv6) != PARSE_TARGET_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < targetList->oidCount; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printObject = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetTargetProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetList->oids[j],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the target name with the input if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one was input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (operandEntered &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (targetNamesEqual(targetProps.imaProps.name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetName) == B_TRUE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!operandEntered || found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printObject = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printObject) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("%s: %ws\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Target"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetProps.imaProps.name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t%s: ", gettext("Alias"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wslen(targetProps.imaProps.alias) >
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (size_t)0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%ws\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetProps.imaProps.alias);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s\n", "-");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printObject && verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get bidirectional authentication flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t%s: ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Bi-directional Authentication"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetTargetBidirAuthFlag(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetList->oids[j],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &bidirAuth);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bidirAuth == IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("enabled"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("disabled"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("disabled"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get authentication type for this target */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetTargetAuthMethods(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte initiatorOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetList->oids[j],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &maxEntries,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &methodList[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t%s: ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Authentication Type"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No authentication method define
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NONE by default.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, gettext("NONE"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < maxEntries; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "|");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (methodList[i]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMA_AUTHMETHOD_NONE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("NONE"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IMA_AUTHMETHOD_CHAP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("CHAP"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte listCHAPName(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetList->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte oids[j]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "unknown "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "type"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printLoginParameters("\t",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetList->oids[j],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PRINT_CONFIGURED_PARAMS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get Digest configuration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetHeaderDigest(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetList->oids[j],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &digestAlgorithms);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t\t%s: ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Header Digest"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printDigestAlgorithm(&digestAlgorithms,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PRINT_CONFIGURED_PARAMS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetDataDigest(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetList->oids[j],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &digestAlgorithms);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\t\t%s: ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Data Digest"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printDigestAlgorithm(&digestAlgorithms,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PRINT_CONFIGURED_PARAMS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China *funcRet = 1;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (ret);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* print configured session information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (printConfiguredSessions(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetList->oids[j]) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (operandEntered && !found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1; /* DIY message fix */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte operand[i], gettext("not found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Modify discovery attributes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyDiscovery(cmdOptions_t *options, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID oid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_BOOL setDiscovery;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_HOST_ID hostId;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdOptions_t *optionList = options;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&oid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; optionList->optval; optionList++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check optarg and set bool accordingly */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcasecmp(optionList->optarg, ISCSIADM_ARG_ENABLE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setDiscovery = IMA_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strcasecmp(optionList->optarg, ISCSIADM_ARG_DISABLE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setDiscovery = IMA_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("invalid option argument"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (optionList->optval) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 's':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set static discovery */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetStaticDiscovery(oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setDiscovery);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 't':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set send targets discovery */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetSendTargetsDiscovery(oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setDiscovery);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'i':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set iSNS discovery */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&hostId, 0, sizeof (hostId));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetIsnsDiscovery(oid, setDiscovery,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_ISNS_DISCOVERY_METHOD_STATIC, &hostId);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %c: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, optionList->optval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unknown option"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the initiator node's authentication method
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyNodeAuthParam(IMA_OID oid, int param, char *chapName, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_INITIATOR_AUTHPARMS authParams;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int secretLen = MAX_CHAP_SECRET_LEN;
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China int nameLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_BYTE chapSecret[MAX_CHAP_SECRET_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetInitiatorAuthParms(oid, IMA_AUTHMETHOD_CHAP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &authParams);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (param) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case AUTH_NAME:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (chapName == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "CHAP name cannot be NULL.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
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");
129b3e6c5b0ac55b5021a4c38db6387b6acdaaf1Jack Meng return (1);
129b3e6c5b0ac55b5021a4c38db6387b6acdaaf1Jack Meng }
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 return (1);
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&authParams.chapParms.name, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (authParams.chapParms.name));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&authParams.chapParms.name,
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China &chapName[0], nameLen);
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China authParams.chapParms.nameLength = nameLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case AUTH_PASSWORD :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = getSecret((char *)&chapSecret[0], &secretLen,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MIN_CHAP_SECRET_LEN, MAX_CHAP_SECRET_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&authParams.chapParms.challengeSecret, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (authParams.chapParms.challengeSecret));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&authParams.chapParms.challengeSecret,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &chapSecret[0], secretLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authParams.chapParms.challengeSecretLength = secretLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "Invalid auth parameter %d\n", param);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetInitiatorAuthParms(oid, IMA_AUTHMETHOD_CHAP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &authParams);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the target's authentication method
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyTargetAuthParam(IMA_OID oid, int param, char *chapName, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_INITIATOR_AUTHPARMS authParams;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int secretLen = MAX_CHAP_SECRET_LEN;
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China int nameLen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_BYTE chapSecret[MAX_CHAP_SECRET_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetTargetAuthParms(oid, IMA_AUTHMETHOD_CHAP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &authParams);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (param) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case AUTH_NAME:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (chapName == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "CHAP name cannot be NULL.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
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");
129b3e6c5b0ac55b5021a4c38db6387b6acdaaf1Jack Meng return (1);
129b3e6c5b0ac55b5021a4c38db6387b6acdaaf1Jack Meng }
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 return (1);
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&authParams.chapParms.name, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (authParams.chapParms.name));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&authParams.chapParms.name,
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China &chapName[0], nameLen);
2e0fe3efe5f9d579d4e44b3532d8e342c68b40cabing zhao - Sun Microsystems - Beijing China authParams.chapParms.nameLength = nameLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case AUTH_PASSWORD :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = getSecret((char *)&chapSecret[0], &secretLen,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 1, MAX_CHAP_SECRET_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&authParams.chapParms.challengeSecret, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (authParams.chapParms.challengeSecret));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&authParams.chapParms.challengeSecret,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &chapSecret[0], secretLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authParams.chapParms.challengeSecretLength = secretLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "Invalid auth parameter %d\n", param);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetTargetAuthParams(oid, IMA_AUTHMETHOD_CHAP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &authParams);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyTargetBidirAuthFlag(IMA_OID targetOid, char *optarg, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_BOOL boolValue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcasecmp(optarg, ISCSIADM_ARG_ENABLE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolValue = IMA_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strcasecmp(optarg, ISCSIADM_ARG_DISABLE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolValue = IMA_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("invalid option argument"), optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetTargetBidirAuthFlag(targetOid, &boolValue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyConfiguredSessions(IMA_OID targetOid, char *optarg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_CONFIG_SESSIONS *pConfigSessions;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sessions;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tmp[1024];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t isIpv6 = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char address[MAX_ADDRESS_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *commaPos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *addressPos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rtn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sessions = atoi(optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(tmp, "%d", sessions);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(optarg, tmp) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* default binding */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allocate the required pConfigSessions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = sizeof (SUN_IMA_CONFIG_SESSIONS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions = (SUN_IMA_CONFIG_SESSIONS *)calloc(1, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pConfigSessions == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* setup pConfigSessions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions->bound = IMA_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions->in = sessions;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions->out = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* hardcoded binding */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sessions = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commaPos = strchr(optarg, ',');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (commaPos != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sessions++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commaPos = strchr(++commaPos, ',');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allocate the required pConfigSessions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = sizeof (SUN_IMA_CONFIG_SESSIONS) + ((sessions - 1) *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (IMA_ADDRESS_KEY));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions = (SUN_IMA_CONFIG_SESSIONS *)calloc(1, size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pConfigSessions == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* setup pConfigSessions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions->bound = IMA_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions->in = sessions;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions->out = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now fill in the binding information. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sessions = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addressPos = optarg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Walk thru possible address strings
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stop once all strings are processed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (addressPos != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commaPos = strchr(addressPos, ',');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (commaPos != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *commaPos++ = 0x00;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Parse current address. If invalid abort
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * processing of addresses and free memory.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (parseAddress(addressPos, 0, address,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ADDRESS_LEN, &port, &isIpv6) != PARSE_ADDR_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pConfigSessions);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(IMA_ERROR_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Convert address into binary form */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isIpv6 == B_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions->bindings[sessions].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipAddress.ipv4Address = IMA_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rtn = inet_pton(AF_INET, address,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions->bindings[sessions].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipAddress.ipAddress);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions->bindings[sessions].ipAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipv4Address =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rtn = inet_pton(AF_INET6, address,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions->bindings[sessions].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ipAddress.ipAddress);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rtn == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* inet_pton found address invalid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pConfigSessions);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(IMA_ERROR_INVALID_PARAMETER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* update addressPos to next address */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sessions++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addressPos = commaPos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* issue SUN_IMA request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetConfigSessions(targetOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pConfigSessions);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pConfigSessions);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pConfigSessions);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetAuthMethodValue(char *method, IMA_AUTHMETHOD *value)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcasecmp(method, "chap") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *value = IMA_AUTHMETHOD_CHAP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcasecmp(method, "none") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *value = IMA_AUTHMETHOD_NONE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the authentication method
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Currently only supports CHAP and NONE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyNodeAuthMethod(IMA_OID oid, char *optarg, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_AUTHMETHOD methodList[MAX_AUTH_METHODS];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT methodCount = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_AUTHMETHOD value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *method;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *commaPos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 * anything.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte method = optarg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commaPos = strchr(optarg, ',');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (commaPos && methodCount < MAX_AUTH_METHODS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *commaPos = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAuthMethodValue(method, &value) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: a: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("invalid option argument"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte methodList[methodCount++] = value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commaPos++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte method = commaPos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commaPos = strchr(method, ',');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should not find more method specified - if found, error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (commaPos) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: -a: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("invalid option argument"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAuthMethodValue(method, &value) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: -a: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("invalid option argument"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte methodList[methodCount++] = value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetInitiatorAuthMethods(oid, methodCount, &methodList[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyTargetAuthMethod(IMA_OID oid, char *optarg, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_AUTHMETHOD methodList[MAX_AUTH_METHODS];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT methodCount = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_AUTHMETHOD value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *method;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *commaPos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 * anything.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte method = optarg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commaPos = strchr(optarg, ',');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (commaPos && methodCount < MAX_AUTH_METHODS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *commaPos = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAuthMethodValue(method, &value) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: a: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("invalid option argument"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte methodList[methodCount++] = value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commaPos++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte method = commaPos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commaPos = strchr(method, ',');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should not find more method specified - if found, error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (commaPos) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: -a: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("invalid option argument"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getAuthMethodValue(method, &value) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: -a: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("invalid option argument"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte methodList[methodCount++] = value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetTargetAuthMethods(oid, &methodCount,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &methodList[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Modify the RADIUS configuration of the initiator node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return 0 on success.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyNodeRadiusConfig(IMA_OID oid, char *optarg, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_RADIUS_CONFIG config;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t isIpv6 = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&config, 0, sizeof (SUN_IMA_RADIUS_CONFIG));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (parseAddress(optarg, DEFAULT_RADIUS_PORT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &config.hostnameIpAddress[0], SUN_IMA_IP_ADDRESS_PORT_LEN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &port, &isIpv6) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PARSE_ADDR_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte config.port = (IMA_UINT16)port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte config.isIpv6 = (isIpv6 == B_TRUE) ? IMA_TRUE : IMA_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Not setting shared secret here. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte config.sharedSecretValid = IMA_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetInitiatorRadiusConfig(oid, &config);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Modify the RADIUS access flag of the initiator node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return 0 on success.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyNodeRadiusAccess(IMA_OID oid, char *optarg, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_BOOL radiusAccess;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID initiatorOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_RADIUS_CONFIG radiusConfig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if Radius Config is there */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&radiusConfig, 0, sizeof (SUN_IMA_RADIUS_CONFIG));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetInitiatorRadiusConfig(initiatorOid, &radiusConfig);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("RADIUS server not configured yet"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if Radius Shared is set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (radiusConfig.sharedSecretValid == IMA_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n", cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("RADIUS server secret not configured yet"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcasecmp(optarg, ISCSIADM_ARG_ENABLE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte radiusAccess = IMA_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strcasecmp(optarg, ISCSIADM_ARG_DISABLE) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte radiusAccess = IMA_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("invalid option argument"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetInitiatorRadiusAccess(oid, radiusAccess);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Modify the RADIUS shared secret.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * zero on success.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * > 0 on failure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyNodeRadiusSharedSecret(IMA_OID oid, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_BYTE radiusSharedSecret[SUN_IMA_MAX_RADIUS_SECRET_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID initiatorOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_RADIUS_CONFIG radiusConfig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int secretLen = SUN_IMA_MAX_RADIUS_SECRET_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = getSecret((char *)&radiusSharedSecret[0], &secretLen,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, SUN_IMA_MAX_RADIUS_SECRET_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
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 if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("RADIUS server not configured yet"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Modify the shared secret only */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte radiusConfig.sharedSecretLength = secretLen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(&radiusConfig.sharedSecret,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &radiusSharedSecret[0], secretLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte radiusConfig.sharedSecretValid = IMA_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_SetInitiatorRadiusConfig(oid, &radiusConfig);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set initiator node attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyNode(cmdOptions_t *options, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_NODE_NAME nodeName;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_NODE_ALIAS nodeAlias;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID oid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdOptions_t *optionList = options;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameCheckStatusType nameCheckStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID sharedNodeOid;
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China int i;
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China int lowerCase;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng IMA_BOOL iscsiBoot = IMA_FALSE;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng IMA_BOOL mpxioEnabled = IMA_FALSE;
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China char *mb_name = NULL;
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China int prefixlen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* Get boot session's info */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) SUN_IMA_GetBootIscsi(&iscsiBoot);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiBoot == IMA_TRUE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng status = SUN_IMA_GetBootMpxio(&mpxioEnabled);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (!IMA_SUCCESS(status)) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr, "%s: %s\n",
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng cmdName, gettext("unable to get MPxIO info"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " of root disk"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng *funcRet = 1;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng return (1);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&oid);
f5fc5c043551e3eab595da7d8b5a53479207738fJack Meng if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; optionList->optval; optionList++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (optionList->optval) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'N':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(optionList->optarg) >=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ISCSI_NAME_LEN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s %d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("name too long, \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte maximum length is:"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ISCSI_NAME_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Take the first operand as node name. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&nodeName, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (IMA_NODE_NAME));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbstowcs(nodeName, optionList->optarg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_NODE_NAME_LEN) == (size_t)-1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("conversion error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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 return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China
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 cmdName,
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 return (1);
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China }
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 /*
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 */
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China for (i = 0; nodeName[i] != 0; i++) {
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China lowerCase =
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China tolower(nodeName[i]);
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China nodeName[i] = lowerCase;
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China }
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China }
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China (void) IMA_FreeMemory(mb_name);
7f848965aa84f3ffafe9b934c813f94048ea42f8bing zhao - Sun Microsystems - Beijing China
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Perform string profile checks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nameCheckStatus =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameStringProfileCheck(nodeName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameCheckStatusDisplay(nameCheckStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nameCheckStatus != iSCSINameCheckOK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1; /* DIY message fix */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IMA_GetSharedNodeOid(&sharedNodeOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return (INF_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiBoot == IMA_TRUE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr, "%s: %s\n",
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng cmdName, gettext("iscsi boot, not"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " allowed to change"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " initiator's name"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng return (1);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte oid.objectType = IMA_OBJECT_TYPE_NODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetNodeName(oid, nodeName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'A':
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiBoot == IMA_TRUE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr, "%s: %s\n",
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng cmdName, gettext("iscsi boot, not"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " allowed to change"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " initiator's alias"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng return (1);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Take the first operand as node alias. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(optionList->optarg) >=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ISCSI_NAME_LEN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s %d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("alias too long, maximum \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte length is:"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ISCSI_NAME_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&nodeAlias, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (IMA_NODE_ALIAS));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbstowcs(nodeAlias, optionList->optarg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_NODE_ALIAS_LEN) == (size_t)-1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("conversion error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetSharedNodeOid(&sharedNodeOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_SetNodeAlias(sharedNodeOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodeAlias);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'a':
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiBoot == IMA_TRUE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr, "%s: %s\n",
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng cmdName, gettext("iscsi boot, not"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " allowed to change authentication"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " method"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng return (1);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyNodeAuthMethod(oid, options->optarg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte funcRet) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'R':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyNodeRadiusAccess(oid, options->optarg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte funcRet) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'r':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyNodeRadiusConfig(oid, options->optarg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte funcRet) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'P':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyNodeRadiusSharedSecret(oid, funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'C':
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiBoot == IMA_TRUE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr, "%s: %s\n",
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng cmdName, gettext("iscsi boot, not"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " allowed to change CHAP secret"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng return (1);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyNodeAuthParam(oid, AUTH_PASSWORD,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, funcRet) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'c':
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiBoot == IMA_TRUE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (mpxioEnabled == IMA_FALSE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng "%s: %s\n", cmdName,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng gettext("iscsi"
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 return (1);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyConfiguredSessions(oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optionList->optarg) != 0) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiBoot == IMA_TRUE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng "%s: %s\n", cmdName,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng gettext("iscsi boot,"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " fail to set configured"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " session"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'H':
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiBoot == IMA_TRUE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr, "%s: %s\n",
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng cmdName, gettext("iscsi boot, not"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " allowed to change CHAP name"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng return (1);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyNodeAuthParam(oid, AUTH_NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optionList->optarg, funcRet) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'd':
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiBoot == IMA_TRUE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (mpxioEnabled == IMA_FALSE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng "%s: %s\n", cmdName,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng gettext("iscsi"
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 return (1);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (setLoginParameter(oid, DATA_DIGEST,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optionList->optarg) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'h':
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiBoot == IMA_TRUE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (mpxioEnabled == IMA_FALSE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng "%s: %s\n", cmdName,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng gettext("iscsi"
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 return (1);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (setLoginParameter(oid, HEADER_DIGEST,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optionList->optarg) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China case 'T':
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (setTunableParameters(oid,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China optionList->optarg) != 0) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %c: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, optionList->optval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unknown option"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Modify target parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyTargetParam(cmdOptions_t *options, char *targetName, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID oid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID targetOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID_LIST *targetList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_TARGET_PROPERTIES targetProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t wcInputObject[MAX_ISCSI_NAME_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t targetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t found;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t targetAddressSpecified = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t tpgtSpecified = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t isIpv6 = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameCheckStatusType nameCheckStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT16 port = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT16 tpgt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng IMA_NODE_NAME bootTargetName;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng IMA_INITIATOR_AUTHPARMS bootTargetCHAP;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng IMA_BOOL iscsiBoot;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng IMA_BOOL mpxioEnabled;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdOptions_t *optionList = options;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&oid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (parseTarget(targetName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &wcInputObject[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ISCSI_NAME_LEN + 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetAddressSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetAddress[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_IP_ADDRESS_PORT_LEN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tpgtSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tpgt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &isIpv6) != PARSE_TARGET_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Perform string profile checks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nameCheckStatus = iSCSINameStringProfileCheck(wcInputObject);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameCheckStatusDisplay(nameCheckStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nameCheckStatus != iSCSINameCheckOK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetTargetOidList(oid, &targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) SUN_IMA_GetBootIscsi(&iscsiBoot);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiBoot == IMA_TRUE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng status = SUN_IMA_GetBootMpxio(&mpxioEnabled);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (!IMA_SUCCESS(status)) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr, "%s: %s\n",
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng cmdName, gettext("unable to get MPxIO info"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " of root disk"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng *funcRet = 1;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng return (ret);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng status = SUN_IMA_GetBootTargetName(bootTargetName);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (!IMA_SUCCESS(status)) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr, "%s: %s\n",
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng cmdName, gettext("unable to get boot target's"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " name"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng *funcRet = 1;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng return (ret);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng status = SUN_IMA_GetBootTargetAuthParams(&bootTargetCHAP);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (!IMA_SUCCESS(status)) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr, "%s: %s\n",
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng cmdName, gettext("unable to get boot target's"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " auth param"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng *funcRet = 1;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng return (ret);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng
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 &targetProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the target name with the input name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((targetNamesEqual(wcInputObject, targetProps.imaProps.name)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == B_TRUE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetOid = targetList->oids[i];
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if ((targetNamesEqual(bootTargetName, wcInputObject)
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng == B_TRUE) && (iscsiBoot == IMA_TRUE)) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /*
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 */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if ((optionList->optval == 'C') ||
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (optionList->optval == 'H') ||
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (optionList->optval == 'B') ||
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (optionList->optval == 'a')) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /*
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * -C CHAP secret set
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * -H CHAP name set
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * -a authentication
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * -B bi-directional-authentication
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr, "%s: %s\n",
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng cmdName, gettext("iscsi boot,"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " not allowed to modify"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " authentication parameters"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " of boot target"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng return (1);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (mpxioEnabled == IMA_FALSE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr, "%s: %s\n",
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng cmdName, gettext("iscsi boot and"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " MPxIO is disabled, not allowed"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " to modify boot target's"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " parameters"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng return (1);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyIndividualTargetParam(optionList, targetOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte funcRet) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If the target OID cannot be found create one */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_CreateTargetOid(wcInputObject, &targetOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyIndividualTargetParam(optionList, targetOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte funcRet) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add one or more addresses
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteaddAddress(int addrType, int operandLen, char *operand[], int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID oid, addressOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_TARGET_ADDRESS address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t wcInputObject[MAX_ADDRESS_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&oid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Format of discovery address operand:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * <IP address|hostname>:<port>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < operandLen; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&wcInputObject[0], 0, sizeof (wcInputObject));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&address, 0, sizeof (address));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbstowcs(wcInputObject, operand[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (MAX_ADDRESS_LEN + 1)) == (size_t)-1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("conversion error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getTargetAddress(addrType, operand[i], &address.imaStruct)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (addrType == DISCOVERY_ADDRESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_AddDiscoveryAddress(oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte address.imaStruct, &addressOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (addrType == ISNS_SERVER_ADDRESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_AddISNSServerAddress(address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add one or more static configuration targets
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteaddStaticConfig(int operandLen, char *operand[], int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t targetAddressSpecified = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t tpgtSpecified = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t isIpv6 = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int addrType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID oid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_STATIC_DISCOVERY_TARGET staticConfig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT16 port = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT16 tpgt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t staticTargetName[MAX_ISCSI_NAME_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t staticTargetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameCheckStatusType nameCheckStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char sAddr[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&oid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Format of static config operand:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * <target-name>,<IP address|hostname>[:port][,tpgt]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < operandLen; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (parseTarget(operand[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &staticTargetName[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ISCSI_NAME_LEN + 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetAddressSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &staticTargetAddress[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_IP_ADDRESS_PORT_LEN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tpgtSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tpgt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &isIpv6) != PARSE_TARGET_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (targetAddressSpecified != B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("missing target address"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1; /* DIY message fix */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Perform string profile checks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nameCheckStatus = iSCSINameStringProfileCheck(staticTargetName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameCheckStatusDisplay(nameCheckStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nameCheckStatus != iSCSINameCheckOK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1; /* DIY message fix */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) wcsncpy(staticConfig.targetName, staticTargetName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ISCSI_NAME_LEN + 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) wcstombs(sAddr, staticTargetAddress, sizeof (sAddr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isIpv6 == B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticConfig.targetAddress.imaStruct.hostnameIpAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id.ipAddress.ipv4Address = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addrType = AF_INET6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticConfig.targetAddress.imaStruct.hostnameIpAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id.ipAddress.ipv4Address = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addrType = AF_INET;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (inet_pton(addrType, sAddr, staticConfig.targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte imaStruct.hostnameIpAddress.id.ipAddress.ipAddress) != 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("static config conversion error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticConfig.targetAddress.imaStruct.portNumber = port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tpgtSpecified == B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticConfig.targetAddress.defaultTpgt = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticConfig.targetAddress.tpgt = tpgt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticConfig.targetAddress.defaultTpgt = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticConfig.targetAddress.tpgt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_AddStaticTarget(oid, staticConfig, &oid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China if (ret != 0) {
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China *funcRet = 1;
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China }
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove one or more addresses
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteremoveAddress(int addrType, int operandLen, char *operand[], int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID initiatorOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_TARGET_ADDRESS address;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t wcInputObject[MAX_ADDRESS_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < operandLen; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&wcInputObject[0], 0, sizeof (wcInputObject));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&address, 0, sizeof (address));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbstowcs(wcInputObject, operand[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ADDRESS_LEN + 1) == (size_t)-1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("conversion error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getTargetAddress(addrType, operand[i], &address.imaStruct)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (addrType == DISCOVERY_ADDRESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_RemoveDiscoveryAddress(address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == IMA_ERROR_OBJECT_NOT_FOUND) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte operand[i], gettext("not found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_RemoveISNSServerAddress(address);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove one or more static configuration targets
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteremoveStaticConfig(int operandLen, char *operand[], int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID initiatorOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID_LIST *staticTargetList;
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 int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t atLeastFoundOne;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t matched;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t targetAddressSpecified = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t tpgtSpecified = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t isIpv6 = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT16 port = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT16 tpgt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameCheckStatusType nameCheckStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tmpStr[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t tmpTargetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetStaticDiscoveryTargetOidList(initiatorOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &staticTargetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < operandLen; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (parseTarget(operand[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &staticTargetName[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ISCSI_NAME_LEN + 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetAddressSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &staticTargetAddress[0],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_IP_ADDRESS_PORT_LEN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tpgtSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tpgt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &isIpv6) != PARSE_TARGET_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Perform string profile checks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nameCheckStatus = iSCSINameStringProfileCheck(staticTargetName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSINameCheckStatusDisplay(nameCheckStatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nameCheckStatus != iSCSINameCheckOK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (atLeastFoundOne = B_FALSE, j = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j < staticTargetList->oidCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_UINT16 stpgt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetStaticTargetProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetList->oids[j], &staticTargetProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == IMA_ERROR_OBJECT_NOT_FOUND) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(staticTargetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stpgt =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.staticTarget.targetAddress.tpgt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the static target name with the input if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one was input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((targetNamesEqual(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.staticTarget.targetName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetName) == B_TRUE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (targetAddressSpecified == B_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (staticTargetProps.staticTarget.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetAddress.imaStruct.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hostnameIpAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id.ipAddress.ipv4Address ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) inet_ntop(AF_INET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTarget.targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte imaStruct.hostnameIpAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id.ipAddress.ipAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmpStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (tmpStr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) inet_ntop(AF_INET6,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTarget.targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte imaStruct.hostnameIpAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id.ipAddress.ipAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmpStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (tmpStr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbstowcs(tmpTargetAddress, tmpStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_IP_ADDRESS_PORT_LEN) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (size_t)-1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "conversion error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((wcsncmp(tmpTargetAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_IP_ADDRESS_PORT_LEN) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0) && (staticTargetProps.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTarget.targetAddress.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte imaStruct.portNumber == port)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tpgtSpecified == B_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tpgt == stpgt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matched =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (matched) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_RemoveStaticDiscoveryTarget(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetList->oids[j]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte atLeastFoundOne = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!atLeastFoundOne) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%ws,%ws: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte staticTargetName, staticTargetAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("not found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove one or more target params.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteremoveTargetParam(int operandLen, char *operand[], int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *commaPos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID initiatorOid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_OID_LIST *targetList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUN_IMA_TARGET_PROPERTIES targetProps;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t wcInputObject[MAX_ISCSI_NAME_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t found;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng IMA_NODE_NAME bootTargetName;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng IMA_BOOL iscsiBoot = IMA_FALSE;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng IMA_BOOL mpxioEnabled = IMA_FALSE;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /* Get boot session's info */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) SUN_IMA_GetBootIscsi(&iscsiBoot);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (iscsiBoot == IMA_TRUE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng status = SUN_IMA_GetBootMpxio(&mpxioEnabled);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (!IMA_SUCCESS(status)) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr, "%s: %s\n",
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng cmdName, gettext("unable to get MPxIO info of"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " root disk"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng *funcRet = 1;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng return (1);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng status = SUN_IMA_GetBootTargetName(bootTargetName);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (!IMA_SUCCESS(status)) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr, "%s: %s\n",
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng cmdName, gettext("unable to get boot"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " target's name"));
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng *funcRet = 1;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng return (1);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find Sun initiator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = sunInitiatorFind(&initiatorOid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("no initiator found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetTargetOidList(initiatorOid, &targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < operandLen; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commaPos = strchr(operand[i], ',');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (commaPos) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Ignore IP address. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *commaPos = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&wcInputObject[0], 0, sizeof (wcInputObject));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mbstowcs(wcInputObject, operand[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ISCSI_NAME_LEN + 1) == (size_t)-1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n", cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("conversion error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (found = B_FALSE, j = 0; j < targetList->oidCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetTargetProperties(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetList->oids[j], &targetProps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the target name with the input if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one was input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (targetNamesEqual(targetProps.imaProps.name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wcInputObject) == B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = B_TRUE;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if ((targetNamesEqual(bootTargetName,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng wcInputObject) == B_TRUE) &&
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (iscsiBoot == IMA_TRUE)) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng /*
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 */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng if (mpxioEnabled == IMA_FALSE) {
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng (void) fprintf(stderr,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng "%s: %s\n", cmdName,
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng gettext("iscsi boot"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " with MPxIO disabled,"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " not allowed to remove"
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng " boot sess param"));
f03fb72c9f13560757b95b26631635b5d2a6d6c5yi zhang - Sun Microsystems - Beijing China ret = 1;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng continue;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng }
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_RemoveTargetParam(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetList->oids[j]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printLibError(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *funcRet = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Silently ignoring it? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%ws: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wcInputObject, gettext("not found"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) IMA_FreeMemory(targetList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteaddFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *addArgs, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (object) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DISCOVERY_ADDRESS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_SERVER_ADDRESS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = addAddress(object, operandLen, operand, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case STATIC_CONFIG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = addStaticConfig(operandLen, operand, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("unknown object"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *addArgs, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (object) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DISCOVERY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = listDiscovery(funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DISCOVERY_ADDRESS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = listDiscoveryAddress(operandLen, operand, options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_SERVER_ADDRESS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = listISNSServerAddress(operandLen, operand, options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case NODE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = listNode(funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case STATIC_CONFIG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = listStaticConfig(operandLen, operand, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case TARGET:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = listTarget(operandLen, operand, options, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case TARGET_PARAM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = listTargetParam(operandLen, operand, options, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("unknown object"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *addArgs, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret, i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (object) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DISCOVERY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = modifyDiscovery(options, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case NODE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = modifyNode(options, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case TARGET_PARAM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (operand[i]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = modifyTargetParam(options, operand[i], funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("modify failed"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte operand[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("unknown object"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteremoveFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *addArgs, int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (object) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DISCOVERY_ADDRESS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_SERVER_ADDRESS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = removeAddress(object, operandLen, operand,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case STATIC_CONFIG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = removeStaticConfig(operandLen, operand, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case TARGET_PARAM:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = removeTargetParam(operandLen, operand, funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("unknown object"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiSCSINameCheckStatusDisplay(iSCSINameCheckStatusType status)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (status) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iSCSINameLenZero:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("empty iSCSI name."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iSCSINameLenExceededMax:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n", cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("iSCSI name exceeded maximum length."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iSCSINameUnknownType:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n", cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unknown iSCSI name type."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iSCSINameInvalidCharacter:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("iSCSI name invalid character used"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iSCSINameIqnFormatError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n", cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("iqn formatting error."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iSCSINameIqnDateFormatError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("invalid iqn date." \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " format is: YYYY-MM"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iSCSINameIqnSubdomainFormatError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("missing subdomain after \":\""));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iSCSINameIqnInvalidYearError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("invalid year"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iSCSINameIqnInvalidMonthError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("invalid month"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iSCSINameIqnFQDNError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("missing reversed fully qualified"\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " domain name"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case iSCSINameEUIFormatError:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n", cmdName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("eui formatting error."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A convenient function to modify the target parameters of an individual
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * target.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return 0 if successful
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return 1 if failed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortemodifyIndividualTargetParam(cmdOptions_t *optionList, IMA_OID targetOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *funcRet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(funcRet != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; optionList->optval; optionList++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (optionList->optval) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'a':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyTargetAuthMethod(targetOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optionList->optarg, funcRet) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'B':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyTargetBidirAuthFlag(targetOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optionList->optarg, funcRet) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'C':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyTargetAuthParam(targetOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AUTH_PASSWORD, NULL, funcRet) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'd':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (setLoginParameter(targetOid, DATA_DIGEST,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optionList->optarg) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'h':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (setLoginParameter(targetOid, HEADER_DIGEST,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optionList->optarg) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'p':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Login parameter */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (setLoginParameters(targetOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optionList->optarg) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'c':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Modify configure sessions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyConfiguredSessions(targetOid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optionList->optarg) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'H':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (modifyTargetAuthParam(targetOid, AUTH_NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optionList->optarg, funcRet) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China case 'T':
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (setTunableParameters(targetOid,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China optionList->optarg) != 0) {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This helper function could go into a utility module for general use.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteparseAddress(char *address_port_str,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t defaultPort,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *address_str,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t address_str_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t *port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t *isIpv6)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char port_str[64];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int tmp_port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *errchr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (address_port_str[0] == '[') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* IPv6 address */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *close_bracket_pos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close_bracket_pos = strchr(address_port_str, ']');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!close_bracket_pos) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_USER|LOG_DEBUG,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "IP address format error: %s\n", address_str);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (PARSE_ADDR_MISSING_CLOSING_BRACKET);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *close_bracket_pos = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strlcpy(address_str, &address_port_str[1],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte address_str_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Extract the port number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close_bracket_pos++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*close_bracket_pos == ':') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close_bracket_pos++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*close_bracket_pos != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strlcpy(port_str, close_bracket_pos, 64);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port = strtol(port_str, &errchr, 10);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_port == 0 && errchr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s:%s %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, address_str,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close_bracket_pos,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("port number invalid"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (PARSE_ADDR_PORT_OUT_OF_RANGE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((tmp_port > 0) && (tmp_port > USHRT_MAX) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (tmp_port < 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Port number out of range */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_USER|LOG_DEBUG,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Specified port out of range: %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (PARSE_ADDR_PORT_OUT_OF_RANGE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *port = (uint16_t)tmp_port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *port = defaultPort;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *port = defaultPort;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *isIpv6 = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* IPv4 address */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *colon_pos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte colon_pos = strchr(address_port_str, ':');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!colon_pos) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No port number specified. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *port = defaultPort;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strlcpy(address_str, address_port_str,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte address_str_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *colon_pos = (char)NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strlcpy(address_str, address_port_str,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte address_str_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Extract the port number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte colon_pos++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*colon_pos != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strlcpy(port_str, colon_pos, 64);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port = strtol(port_str, &errchr, 10);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_port == 0 && errchr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s:%s %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, address_str, colon_pos,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("port number invalid"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (PARSE_ADDR_PORT_OUT_OF_RANGE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((tmp_port > 0) && (tmp_port > USHRT_MAX) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (tmp_port < 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Port number out of range */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_USER|LOG_DEBUG,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Specified port out of range: %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (PARSE_ADDR_PORT_OUT_OF_RANGE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *port = (uint16_t)tmp_port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *port = defaultPort;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *isIpv6 = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (PARSE_ADDR_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This helper function could go into a utility module for general use.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiSCSINameCheckStatusType
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiSCSINameStringProfileCheck(wchar_t *name)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char mb_name[MAX_ISCSI_NAME_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t name_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) wcstombs(mb_name, name, MAX_ISCSI_NAME_LEN + 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((name_len = strlen(mb_name)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameLenZero);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (name_len > MAX_ISCSI_NAME_LEN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameLenExceededMax);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (tmp = mb_name; *tmp != NULL; tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((isalnum(*tmp) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*tmp != '-') &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*tmp != '.') &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*tmp != ':')) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameInvalidCharacter);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(mb_name, ISCSI_IQN_NAME_PREFIX,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(ISCSI_IQN_NAME_PREFIX)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If name is of type iqn, check date string and naming
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * authority.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *strp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mb_name[strlen(mb_name) - 1] == ':') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameIqnSubdomainFormatError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Date string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strp = strtok(&mb_name[3], ".");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tmpYear[5], tmpMonth[3], *endPtr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int year, month;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Date string should be in YYYY-MM format */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(strp) != strlen("YYYY-MM") ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strp[4] != '-') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameIqnDateFormatError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 * value.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(tmpYear, strp, 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmpYear[4] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errno = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte year = strtol(tmpYear, &endPtr, 10);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno != 0 || *endPtr != '\0' ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte year < 0 || year > 9999) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameIqnInvalidYearError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Validate month is valid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(tmpMonth, &strp[5], 2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmpMonth[2] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errno = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte month = strtol(tmpMonth, &endPtr, 10);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno != 0 || *endPtr != '\0' ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte month < 1 || month > 12) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameIqnInvalidMonthError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strp = strtok(NULL, ".");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!strp || strlen(strp) < 2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameIqnFQDNError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Name authority string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strp = strtok(NULL, ":");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameCheckOK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameIqnFQDNError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameIqnFormatError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(mb_name, ISCSI_EUI_NAME_PREFIX,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(ISCSI_EUI_NAME_PREFIX)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If name is of type EUI, change its length */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(mb_name) != ISCSI_EUI_NAME_LEN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameEUIFormatError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (tmp = mb_name + strlen(ISCSI_EUI_NAME_PREFIX) + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *tmp != '\0'; tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isxdigit(*tmp)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameEUIFormatError);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameCheckOK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iSCSINameUnknownType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This helper function could go into a utility module for general use.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
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 Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteisNaturalNumber(char *numberStr, uint32_t upperBound)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int number_str_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((number_str_len = strlen(numberStr)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (B_FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < number_str_len; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (numberStr[i] < 060 || numberStr[i] > 071) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (B_FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (atoi(numberStr) > upperBound) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (B_FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (B_TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * <target_name>,[<ip_address>[:port][,tpgt]]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and creates wchar strings for target name and target address. It
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * also populates port and tpgt if found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PARSE_TARGET_OK if parsing is successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PARSE_TARGET_INVALID_TPGT if the specified tpgt is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * invalid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PARSE_TARGET_INVALID_ADDR if the address specified is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * invalid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteparseTarget(char *targetStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t *targetNameStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t targetNameStrLen,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t *targetAddressSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wchar_t *targetAddressStr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t targetAddressStrLen,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t *port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t *tpgtSpecified,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t *tpgt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t *isIpv6)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *commaPos;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *commaPos2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char targetAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int lowerCase;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(targetNameStr, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetNameStrLen * sizeof (wchar_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(targetAddressStr, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetAddressStrLen * sizeof (wchar_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commaPos = strchr(targetStr, ',');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (commaPos != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *commaPos = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commaPos++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *targetAddressSpecified = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Checking of tpgt makes sense only when
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the target address/port are specified.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commaPos2 = strchr(commaPos, ',');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (commaPos2 != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *commaPos2 = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commaPos2++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isNaturalNumber(commaPos2, ISCSI_MAX_TPGT_VALUE) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *tpgt = atoi(commaPos2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *tpgtSpecified = B_TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
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 return (PARSE_TARGET_INVALID_TPGT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (parseAddress(commaPos, ISCSI_LISTEN_PORT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &targetAddress[0], MAX_ADDRESS_LEN + 1, port, isIpv6)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PARSE_ADDR_PORT_OUT_OF_RANGE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (PARSE_TARGET_INVALID_ADDR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PARSE_ADDR_OK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("cannot parse target name"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (PARSE_TARGET_INVALID_ADDR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) mbstowcs(targetAddressStr, targetAddress,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetAddressStrLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; targetAddressStr[i] != 0; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lowerCase = tolower(targetAddressStr[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetAddressStr[i] = lowerCase;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *targetAddressSpecified = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *tpgtSpecified = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) mbstowcs(targetNameStr, targetStr, targetNameStrLen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; targetNameStr[i] != 0; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lowerCase = tolower(targetNameStr[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetNameStr[i] = lowerCase;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (PARSE_TARGET_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortelistCHAPName(IMA_OID oid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_INITIATOR_AUTHPARMS authParams;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_BYTE chapName [MAX_CHAP_NAME_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get Chap Name depending upon oid object type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (oid.objectType == IMA_OBJECT_TYPE_LHBA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = IMA_GetInitiatorAuthParms(oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_AUTHMETHOD_CHAP, &authParams);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = SUN_IMA_GetTargetAuthParms(oid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IMA_AUTHMETHOD_CHAP, &authParams);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "\n\t\t%s: ", gettext("CHAP Name"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IMA_SUCCESS(status)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Default chap name will be the node name. The default will
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be set by the driver.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (authParams.chapParms.nameLength != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(chapName, 0, sizeof (chapName));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(chapName, authParams.chapParms.name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte authParams.chapParms.nameLength);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s", chapName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s", "-");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s", "-");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Mengstatic boolean_t
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack MengcheckServiceStatus(void)
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng{
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng IMA_STATUS status = IMA_ERROR_UNKNOWN_ERROR;
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng IMA_BOOL enabled = 0;
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng status = SUN_IMA_GetSvcStatus(&enabled);
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng if (status != IMA_STATUS_SUCCESS) {
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng (void) fprintf(stdout, "%s\n%s\n",
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng gettext("Unable to query the service status of"
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng " iSCSI initiator."),
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng gettext("For more information, please refer to"
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng " iscsi(7D)."));
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng return (B_FALSE);
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng }
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng if (enabled == 0) {
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng (void) fprintf(stdout, "%s\n%s\n",
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng gettext("iSCSI Initiator Service is disabled,"
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng " try 'svcadm enable network/iscsi/initiator' to"
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng " enable the service."),
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng gettext("For more information, please refer to"
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng " iscsi(7D)."));
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng return (B_FALSE);
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng }
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng return (B_TRUE);
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng}
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Prints out see manual page.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called out through atexit(3C) so is always last thing displayed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteseeMan(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static int sent = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sent)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%s %s(1M)\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("For more information, please see"), cmdName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sent = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * main calls a parser that checks syntax of the input command against
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * various rules tables.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The parser provides usage feedback based upon same tables by calling
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * two usage functions, usage and subUsage, handling command and subcommand
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * usage respectively.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The parser handles all printing of usage syntactical errors
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When syntax is successfully validated, the parser calls the associated
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * function using the subcommands table functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Syntax is as follows:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * command subcommand [options] resource-type [<object>]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The return value from the function is placed in funcRet
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemain(int argc, char *argv[])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables_t synTables;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char versionString[VERSION_STRING_MAX_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int funcRet = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *subcommandArgs = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (geteuid() != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s\n", gettext("permission denied"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng if (checkServiceStatus() == B_FALSE) {
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng return (1);
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng }
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set global command name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName = getExecBasename(argv[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(versionString, sizeof (versionString), "%s.%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte VERSION_STRING_MAJOR, VERSION_STRING_MINOR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables.versionString = versionString;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables.longOptionTbl = &longOptions[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables.subcommandTbl = &subcommands[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables.objectTbl = &objects[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables.objectRulesTbl = &objectRules[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte synTables.optionRulesTbl = &optionRules[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* call the CLI parser */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cmdParse(argc, argv, synTables, subcommandArgs, &funcRet);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte perror(cmdName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (funcRet != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmdName, gettext("Unable to complete operation"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing Chinastatic int
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing ChinasetTunableParameters(IMA_OID oid, char *optarg)
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China{
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China char keyp[MAXOPTARGLEN];
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China char valp[MAXOPTARGLEN];
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China int key;
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
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 } else {
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 }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
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 }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
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 }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China switch (key) {
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 errno = 0;
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 cmdName,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China gettext("invalid option argument"),
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China optarg);
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 }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
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 China cmdName,
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 }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
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 }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
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 }
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 break;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China default:
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 }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
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 }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
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 }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (0);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China}
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China/*
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China * Print tunable parameters information
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing Chinastatic int
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing ChinaprintTunableParameters(IMA_OID oid)
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China{
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
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 return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (value[0] == '\0') {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China value[0] = '-';
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China value[1] = '\0';
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
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
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 return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (value[0] == '\0') {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China value[0] = '-';
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China value[1] = '\0';
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
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
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 return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China if (value[0] == '\0') {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China value[0] = '-';
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China value[1] = '\0';
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
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 return (0);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China}
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China/*
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China * This is helper function to check conn_login_max and polling_login_delay.
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing Chinastatic int
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing ChinachkConnLoginMaxPollingLoginDelay(IMA_OID oid, int key, int uintValue)
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China{
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 char *endptr;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
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;
fb2a9bae0030340ad72b9c26ba1ffee2ee3cafecyi zhang - Sun Microsystems - Beijing China } else {
fb2a9bae0030340ad72b9c26ba1ffee2ee3cafecyi zhang - Sun Microsystems - Beijing China return (0);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
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 return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
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 } else {
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 }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China errno = 0;
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 cmdName,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China gettext("cannot convert tunable string"),
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China valuep);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
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 getValue);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China } else {
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"),
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China getValue);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (1);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China }
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China return (0);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China}