fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTE: This routine is found in libnsl. There's apparently no prototype to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be found in any of the header files in /usr/include so defining a prototype
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * here to keep the compiler happy.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint getdomainname(char *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const char *iqn_template = "iqn.2004-02.%s";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ISCSI_LOGIN_PARAM_DATA_SEQUENCE_IN_ORDER, "Sequence In Order"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ISCSI_LOGIN_PARAM_IMMEDIATE_DATA, "Immediate Data"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ISCSI_LOGIN_PARAM_DATA_PDU_IN_ORDER, "Data PDU In Order"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ISCSI_LOGIN_PARAM_HEADER_DIGEST, "Header Digest"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ISCSI_LOGIN_PARAM_DEFAULT_TIME_2_RETAIN, "Default Time To Retain"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ISCSI_LOGIN_PARAM_DEFAULT_TIME_2_WAIT, "Default Time To Wait"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ISCSI_LOGIN_PARAM_MAX_RECV_DATA_SEGMENT_LENGTH,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Max Recv Data Segment Length"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ISCSI_LOGIN_PARAM_FIRST_BURST_LENGTH, "First Burst Length"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ISCSI_LOGIN_PARAM_MAX_BURST_LENGTH, "Max Burst Length"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ISCSI_LOGIN_PARAM_MAX_CONNECTIONS, "Max Connections"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ISCSI_LOGIN_PARAM_OUTSTANDING_R2T, "Outstanding R2T"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ISCSI_LOGIN_PARAM_ERROR_RECOVERY_LEVEL, "Error Recovery Level"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * utils_map_param -- Given a parameter return it's ascii name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This routine was created because previously an array contained in order
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the parameter names. Once or twice the parameters value changed which
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * changed the order, but not the array. To avoid further confusion we'll
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * do a simple lookup. This code is rarely called so it shouldn't be an
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * prt_bitmap -- print out ascii strings associated with bit numbers.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprt_bitmap(int bitmap, char *str, char *buf, int size)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The maximum space required will if the bitmap was all 1's which
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * would cause the octal characters to be replaced by '|'. So make
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sure the buffer has enough space.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ("No room");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*p < 0x20) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if we have been putting out stuff add separator
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ---- remove the last separator if it was added ---- */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse_addr_port_tpgt - Used to parse addr, port and tpgt from string
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function is used to parse addr, port and tpgt from a string. Callers
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of this function are the sendtargets and login redirection code. The
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caller must be aware that this function will modify the callers string
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to insert NULL terminators if required. Port and TPGT are optional.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteparse_addr_port_tpgt(char *in, char **addr, int *type, char **port, char **tpgt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* default return values if requested */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* extract ip or domain name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* IPV4 or domainname */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* extract port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* exact tpgt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * []--------------------------------------------------------------[]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | reverse_fqdn -- given a fully qualified domain name reverse it |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | The routine has the obvious problem that it can only handle a |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | name with 5 or less dots. This needs to be fixed by counting |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | the number of dots in the incoming name, calloc'ing an array |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | of the appropriate size and then handling the pointers. |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * []--------------------------------------------------------------[]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINTED E_FUNC_ARG_UNUSED for 3rd arg size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereverse_fqdn(const char *domain, char *buf, int size)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dp = dp1 = malloc(strlen(domain) + 1)) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (v < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (v++; v < 5; v++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * []------------------------------------------------------------------[]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | utils_iqn_create -- returns an iqn name for the machine |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | The information found in the iqn is not correct. The year and |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | date should be flexible. Currently this is hardwired to the |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | current year and month of this project. |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * []------------------------------------------------------------------[]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getdomainname(domainname, sizeof (domainname))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * getdomainname always returns something in the order of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * host.domainname so we need to skip over that portion of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * host name because we don't care about it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ---- Create Fully Qualified Domain Name ---- */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(temp, strlen(p), "%s.%s", uts_info.nodename, p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ---- According to the spec, names must be lower case ---- */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (p = temp; *p; p++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now use the template with the reversed domainname to create
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an iSCSI name using the IQN format. Only count it a success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if the number of characters formated is less than the buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (snprintf(iqn_buf, size, iqn_template, pmet) <= size)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* !_KERNEL */