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 * external variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern const int NUM_OF_ATTRS[MAX_OBJ_TYPE_FOR_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern const int UID_ATTR_INDEX[MAX_OBJ_TYPE_FOR_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern const int TYPE_OF_CHILD[MAX_OBJ_TYPE][MAX_CHILD_TYPE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * global variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * local variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Edge functions of each adjacent object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* The directed cyclic graph of query procedure. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* __|____e_________i_________p_________g_________d_________s____ */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* e | qry_slf...qry_e2i...qry_e2p...qry_e2g...NULL......NULL.... */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* i | qry_c2e...qry_slf...NULL......qry_i2g...qry_i2d...NULL.... */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* p | qry_c2e...NULL......qry_slf...qry_p2g...NULL......NULL.... */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* g | qry_c2e...qry_g2i...qry_g2p...qry_slf...NULL......NULL.... */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* d | NULL......qry_ds2m..NULL......NULL......qry_slf...qry_d2s. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* s | NULL......NULL......NULL......NULL......qry_ds2m..qry_slf. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* The type of spanning tree of query graph. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct adjvex const *v;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* The solid edges in the spanning tree. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_slf = { &qry_slf, 0, NULL };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_c2e = { &qry_c2e, OBJ_ENTITY, NULL };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_e2i = { &qry_e2i, OBJ_ISCSI, NULL };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_e2p = { &qry_e2p, OBJ_PORTAL, NULL };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_e2g = { &qry_e2g, OBJ_PG, NULL };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_i2g = { &qry_i2g, OBJ_PG, NULL };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_i2d = { &qry_i2d, OBJ_DD, NULL };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_p2g = { &qry_p2g, OBJ_PG, NULL };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_g2i = { &qry_g2i, OBJ_ISCSI, NULL };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_g2p = { &qry_g2p, OBJ_PORTAL, NULL };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_d2s = { &qry_d2s, OBJ_DDS, NULL };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_d2i = { &qry_ds2m, OBJ_ISCSI, NULL };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_s2d = { &qry_ds2m, OBJ_DD, NULL };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* The virtual edges in the spanning tree. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_i2p = { &qry_i2g, OBJ_PG, &v_g2p };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_i2s = { &qry_i2d, OBJ_DD, &v_d2s };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_g2d = { &qry_g2i, OBJ_ISCSI, &v_i2d };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_g2s = { &qry_g2i, OBJ_ISCSI, &v_i2s };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_p2i = { &qry_p2g, OBJ_PG, &v_g2i };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_p2d = { &qry_p2g, OBJ_PG, &v_g2d };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_p2s = { &qry_p2g, OBJ_PG, &v_g2s };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_e2d = { &qry_e2i, OBJ_ISCSI, &v_i2d };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_e2s = { &qry_e2i, OBJ_ISCSI, &v_i2s };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_d2e = { &qry_ds2m, OBJ_ISCSI, &v_c2e };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_d2p = { &qry_ds2m, OBJ_ISCSI, &v_i2p };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_d2g = { &qry_ds2m, OBJ_ISCSI, &v_i2g };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_s2e = { &qry_ds2m, OBJ_DD, &v_d2e };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_s2i = { &qry_ds2m, OBJ_DD, &v_d2i };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_s2p = { &qry_ds2m, OBJ_DD, &v_d2p };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t v_s2g = { &qry_ds2m, OBJ_DD, &v_d2g };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* the vector of query graph */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t *qry_puzzle[MAX_OBJ_TYPE][MAX_OBJ_TYPE] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{ NULL, &v_slf, &v_e2i, &v_e2p, &v_e2g, &v_e2d, &v_e2s },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{ NULL, &v_c2e, &v_slf, &v_i2p, &v_i2g, &v_i2d, &v_i2s },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{ NULL, &v_c2e, &v_p2i, &v_slf, &v_p2g, &v_p2d, &v_p2s },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{ NULL, &v_c2e, &v_g2i, &v_g2p, &v_slf, &v_g2d, &v_g2s },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{ NULL, &v_d2e, &v_d2i, &v_d2p, &v_d2g, &v_slf, &v_d2s },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{ NULL, &v_s2e, &v_s2i, &v_s2p, &v_s2g, &v_s2d, &v_slf }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_FUNC_ARG_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t puid = get_parent_uid((isns_obj_t *)p1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((int)puid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first times of query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no more child, clean up memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free up the memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save it for returning and querying next uid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* child object has only one parent */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save the result for returnning */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first times of query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no more member, clean up memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free up the matrix */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* this is a shortcut */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* keep the current uid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first times of query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pg lookup */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_PG(ISNS_PG_ISCSI_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no more pg, update lcp with pg object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clean up the memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reset it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save it for returning and querying next pg */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save it for returning and getting next dd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first time of query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* use 1&2 for the portal ip address & port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pg lookup */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_PG(ISNS_PG_PORTAL_IP_ADDR_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[1] = ATTR_INDEX_PG(ISNS_PG_PORTAL_PORT_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no more pg, clean up memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clean up the memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reset it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save it for returning and next query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first time of query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* use slot 1 for the storage node name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iscsi node lookup */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no longer need it, clean it up */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no longer need it, reset it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* one pg has maximum number of one storage node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save it for returning and next query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first times of query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* use 1&2 for the portal ip addr and port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* portal lookup */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no longer need it, reset it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no longer need it, reset it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* one pg has maximum number of one portal */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save it for returning and next query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save it for returning and for getting next dds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &attrs[tag - min_tag]; /* ATTR_INDEX_xxx */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* OP_STRING */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* OP_MEMORY_IP6 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* OP_INTEGER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all other attrs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int match = 1; /* 0: not match, otherwise: match */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; match != 0 && i < NUM_OF_ATTRS[obj->type]; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check for duplication */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (n-- > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p[n] == uid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte u = p[n - 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (s == n) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = (uint32_t *)realloc(p, s * sizeof (uint32_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc = { 0 }; /* !!! need to be empty */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* circular list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialize the circular list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initial object type of being queried */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* shift one on the circular list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup control */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* result object type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* start query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* push back */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reset the number of objects */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clean up the memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the object type identified by the key */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*type == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* validate the Message Key */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = validate_qry_key(*type, key, key_len, attrs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_MEMBER(nodes_bmp, num_of_nodes, node_uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_MEMBER(nodes_bmp, num_of_nodes, node_uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_PORTAL(ISNS_PORTAL_INDEX_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (num > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *tlv = (isns_tlv_t *)lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte conn_arg_t *conn = (conn_arg_t *)lcp->data[2].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (ec == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clear the length of all of tlv */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (get_qry_attrs(uid, type, tlv, tlv_len, conn));