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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_server.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_func.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_msgq.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_htab.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_cache.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_obj.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_dd.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_pdu.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_qry.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * external variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
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 NUM_OF_CHILD[MAX_OBJ_TYPE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern const int TYPE_OF_CHILD[MAX_OBJ_TYPE][MAX_CHILD_TYPE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * global variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int TAG_RANGE[MAX_OBJ_TYPE][3] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ENTITY_KEY, LAST_TAG_ENTITY, ENTITY_END },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ISCSI_KEY, LAST_TAG_ISCSI, ISCSI_END },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { PORTAL_KEY1, LAST_TAG_PORTAL, PORTAL_END },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { PG_KEY1, LAST_TAG_PG, PG_END },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { DD_KEY, LAST_TAG_DD, DD_END },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { DDS_KEY, LAST_TAG_DDS, DDS_END }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * local variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef int (*qry_func_t)(lookup_ctrl_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Edge functions of each adjacent object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int qry_c2e(lookup_ctrl_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int qry_ds2m(lookup_ctrl_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int qry_slf(lookup_ctrl_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int qry_e2i(lookup_ctrl_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int qry_e2p(lookup_ctrl_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int qry_e2g(lookup_ctrl_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int qry_i2g(lookup_ctrl_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int qry_i2d(lookup_ctrl_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int qry_p2g(lookup_ctrl_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int qry_g2i(lookup_ctrl_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int qry_g2p(lookup_ctrl_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int qry_d2s(lookup_ctrl_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* The type of spanning tree of query graph. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct adjvex {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qry_func_t f;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct adjvex const *v;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} adjvex_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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
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 Forte
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 Forte
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 Forte
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 Forte
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 Forte
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* the vector of query graph */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const adjvex_t *qry_puzzle[MAX_OBJ_TYPE][MAX_OBJ_TYPE] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{ NULL },
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};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_qry_parent_uid(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_FUNC_ARG_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t puid = get_parent_uid((isns_obj_t *)p1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((int)puid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_qry_child_uids(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type = lcp->data[1].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *uidp = get_child_t(obj, type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t num = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uidp != NULL && *uidp > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num = *uidp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = malloc(num * sizeof (*p));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uidp ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(p, uidp, num * sizeof (*p));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[2] = num;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[2].ptr = (uchar_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_INTERNAL_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortee2c(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = lcp->curr_uid; /* last child */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t num_of_child;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *uids;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tmp_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first times of query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[1].ui = type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = cache_lookup(lcp, NULL, cb_qry_child_uids);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num_of_child = lcp->id[2];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uids = (uint32_t *)lcp->data[2].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (num_of_child > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*uids > uid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_uid = *uids;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uids ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num_of_child --;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = tmp_uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no more child, clean up memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[1].ui = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[2] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[2].ptr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free up the memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(uids);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save it for returning and querying next uid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteqry_c2e(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* child object has only one parent */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lcp->curr_uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = (uint32_t)cache_lookup(lcp, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cb_qry_parent_uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save the result for returnning */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteqry_ds2m(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = lcp->curr_uid; /* last member */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type = lcp->type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t ds_id = lcp->data[0].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tmp_uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first times of query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = (type == OBJ_DD) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte get_dd_matrix(ds_id, &p, &n) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte get_dds_matrix(ds_id, &p, &n);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[1] = n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[1].ptr = (uchar_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = lcp->id[1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = (bmp_t *)lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_MEMBER(p, n, tmp_uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_uid > uid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = tmp_uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no more member, clean up memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[1].ptr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free up the matrix */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteqry_slf(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lcp->curr_uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = lcp->data[0].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteqry_e2i(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (e2c(lcp, OBJ_ISCSI));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteqry_e2p(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (e2c(lcp, OBJ_PORTAL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteqry_e2g(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = lcp->curr_uid; /* last pg */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte htab_t *htab = cache_get_htab(OBJ_PG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t puid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_PG, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* this is a shortcut */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_ITEM(htab, uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ui = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte puid = (uint32_t)cache_lookup(&lc, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cb_qry_parent_uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (puid == lcp->data[0].ui) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* keep the current uid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteqry_i2g(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = lcp->curr_uid; /* last pg */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first times of query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[1] = ISNS_ISCSI_NAME_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = cache_lookup(lcp, NULL, cb_clone_attrs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lcp->data[1].ptr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pg lookup */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = OBJ_PG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_PG(ISNS_PG_ISCSI_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = is_obj_there(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no more pg, update lcp with pg object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clean up the memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lcp->data[1].ptr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(lcp->data[1].ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reset it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[1].ptr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save it for returning and querying next pg */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteqry_i2d(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dd_id = lcp->curr_uid; /* last dd_id */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = lcp->data[0].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd_id = get_dd_id(uid, dd_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save it for returning and getting next dd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = dd_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteqry_p2g(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = lcp->curr_uid; /* last pg */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first time of query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* use 1&2 for the portal ip address & port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[1] = ISNS_PORTAL_IP_ADDR_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[2] = ISNS_PORTAL_PORT_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = cache_lookup(lcp, NULL, cb_clone_attrs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lcp->data[1].ip != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pg lookup */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = OBJ_PG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_PG(ISNS_PG_PORTAL_IP_ADDR_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_MEMORY_IP6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ip = lcp->data[1].ip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[1] = ATTR_INDEX_PG(ISNS_PG_PORTAL_PORT_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = OP_INTEGER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ui = lcp->data[2].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[2] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = is_obj_there(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no more pg, clean up memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[2] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clean up the memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lcp->data[1].ip != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(lcp->data[1].ip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reset it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[1].ip = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[2].ui = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save it for returning and next query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteqry_g2i(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = lcp->curr_uid; /* last node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first time of query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* use slot 1 for the storage node name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[1] = ISNS_PG_ISCSI_NAME_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = cache_lookup(lcp, NULL, cb_clone_attrs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lcp->data[1].ptr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iscsi node lookup */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = OBJ_ISCSI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = is_obj_there(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no longer need it, clean it up */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(lcp->data[1].ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[1].ptr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no longer need it, reset it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* one pg has maximum number of one storage node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save it for returning and next query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteqry_g2p(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = lcp->curr_uid; /* last portal */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first times of query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* use 1&2 for the portal ip addr and port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[1] = ISNS_PG_PORTAL_IP_ADDR_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[2] = ISNS_PG_PORTAL_PORT_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = cache_lookup(lcp, NULL, cb_clone_attrs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lcp->data[1].ip != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* portal lookup */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = OBJ_PORTAL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_PORTAL(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PORTAL_IP_ADDR_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_MEMORY_IP6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ip = lcp->data[1].ip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[1] = ATTR_INDEX_PORTAL(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PORTAL_PORT_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = OP_INTEGER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ui = lcp->data[2].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[2] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = is_obj_there(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no longer need it, reset it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(lcp->data[1].ip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[1].ip = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no longer need it, reset it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[2] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[2].ui = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* one pg has maximum number of one portal */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save it for returning and next query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteqry_d2s(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dds_id = lcp->curr_uid; /* last dds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dd_id = lcp->data[0].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dds_id = get_dds_id(dd_id, dds_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save it for returning and for getting next dds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = dds_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevalidate_qry_key(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *key,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t key_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attrs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t min_tag, max_tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte min_tag = TAG_RANGE[type][0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte max_tag = TAG_RANGE[type][2];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (key_len != 0 && ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tag = key->attr_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tag < min_tag || tag > max_tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (key->attr_len > 0 && attrs != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &attrs[tag - min_tag]; /* ATTR_INDEX_xxx */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = extract_attr(attr, key, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == ISNS_RSP_INVALID_REGIS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(key, key_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic lookup_method_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_op_method(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_method_t method = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* OP_STRING */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_EID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_ALIAS_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_AUTH_METHOD_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte method = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* OP_MEMORY_IP6 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_MGMT_IP_ADDR_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_IP_ADDR_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_PORTAL_IP_ADDR_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte method = OP_MEMORY_IP6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* OP_INTEGER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ENTITY_PROTOCOL_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_VERSION_RANGE_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ENTITY_REG_PERIOD_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ENTITY_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_PORT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ESI_INTERVAL_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ESI_PORT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_SCN_PORT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_NODE_TYPE_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_SCN_BITMAP_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_NODE_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_PORTAL_PORT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_TAG_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_ID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_STATUS_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_ID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* all other attrs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte method = OP_INTEGER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (method);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_attrs_match(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attrs = (isns_attr_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((lookup_ctrl_t *)p2)->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int match = 1; /* 0: not match, otherwise: match */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; match != 0 && i < NUM_OF_ATTRS[obj->type]; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attrs->tag != 0 && attrs->len > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = get_op_method(attrs->tag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = attrs->value.ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte match = key_cmp(&lc, obj) == 0 ? 1 : 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attrs ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (match);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteattrs_match(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attrs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int match; /* 0: not match, otherwise: match */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, type, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ptr = (uchar_t *)attrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte match = cache_lookup(&lc, NULL, cb_attrs_match);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (match);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteinsert_uid(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t **pp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *np,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *sp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *p = *pp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t n = *np;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t s = *sp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t u;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check for duplication */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n > 0 && uid <= p[n - 1]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (n-- > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p[n] == uid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = *np;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte u = p[n - 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[n - 1] = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = u;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (s == n) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = (s == 0) ? 8 : s * 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = (uint32_t *)realloc(p, s * sizeof (uint32_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (t != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pp = p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *sp = s;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[n ++] = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *np = n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteqry_and_match(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t **obj_uids,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *num_of_objs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t src_uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t src_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attrs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc = { 0 }; /* !!! need to be empty */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const adjvex_t *vex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* circular list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *p[2], n[2], s[2];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *p1, n1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *p2, n2, s2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialize the circular list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[i] = *obj_uids;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n[i] = *num_of_objs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s[i] = *size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[j] = malloc(8 * sizeof (uint32_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[j][0] = src_uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n[j] = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s[j] = 8;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initial object type of being queried */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = src_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vex = qry_puzzle[src_type][type];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* shift one on the circular list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = (i + 1) & 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j = (j + 1) & 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p1 = p[i]; n1 = n[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p2 = p[j]; n2 = n[j]; s2 = s[j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup control */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = UID_ATTR_INDEX[t];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_INTEGER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* result object type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = vex->t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_OBJS(p1, n1, uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* start query */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ui = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = vex->f(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = lc.curr_uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ec == 0 && uid != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attrs == NULL ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attrs_match(type, uid, attrs) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = insert_uid(&p2, &n2, &s2, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = vex->f(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = lc.curr_uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n1 = n2 = 0; /* force break */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vex = vex->v;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vex = NULL; /* force break */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* push back */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[j] = p2; n[j] = n2; s[j] = s2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reset the number of objects */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n[i] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (vex != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clean up the memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(p1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(p2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p2 = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n2 = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s2 = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *obj_uids = p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *num_of_objs = n2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *size = s2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_qry_keys(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *nodes_bmp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t num_of_nodes,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t *type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *key,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t key_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t **obj_uids,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *num_of_objs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte union {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t o;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_entity_t e;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_iscsi_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_portal_t p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_pg_t g;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_dd_t d;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_dds_t s;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } an_obj = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attrs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte htab_t *htab;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t node_uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *obj_uids = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *num_of_objs = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the object type identified by the key */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *type = TLV2TYPE(key);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*type == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_INVALID_QRY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attrs = &an_obj.o.attrs[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 return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nodes_bmp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_MEMBER(nodes_bmp, num_of_nodes, node_uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = qry_and_match(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj_uids, num_of_objs, &size, *type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node_uid, OBJ_ISCSI, attrs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte htab = cache_get_htab(OBJ_ISCSI);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_ITEM(htab, node_uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = qry_and_match(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj_uids, num_of_objs, &size, *type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node_uid, OBJ_ISCSI, attrs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_qry_ops(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t src_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t op_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t **op_uids,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *num_of_ops,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *num_of_ops = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = qry_and_match(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte op_uids, num_of_ops, size, op_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid, src_type, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_qry_ops2(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *nodes_bmp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t num_of_nodes,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t op_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t **op_uids,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *num_of_ops,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t node_uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte htab_t *htab;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *num_of_ops = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nodes_bmp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_MEMBER(nodes_bmp, num_of_nodes, node_uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = qry_and_match(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte op_uids, num_of_ops, size, op_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node_uid, OBJ_ISCSI, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte htab = cache_get_htab(OBJ_ISCSI);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_ITEM(htab, node_uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = qry_and_match(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte op_uids, num_of_ops, size, op_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node_uid, OBJ_ISCSI, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_next_obj(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *tlv,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tlv_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *uids,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t num
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t old = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t min = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid, diff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t pre_diff = 0xFFFFFFFF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[2] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tlv_len > 8) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tag = tlv->attr_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value = tlv->attr_value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_EID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_ENTITY(ISNS_EID_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = (uchar_t *)value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = (uchar_t *)value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_NODE_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_ISCSI(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_ISCSI_NODE_INDEX_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_INTEGER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ui = ntohl(*(uint32_t *)value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_IP_ADDR_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_PORTAL(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PORTAL_IP_ADDR_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_MEMORY_IP6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ip = (in6_addr_t *)value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(tlv, tlv_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tlv_len > 8 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((tag = tlv->attr_id) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PORTAL_PORT_ATTR_ID)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value = tlv->attr_value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[1] = ATTR_INDEX_PORTAL(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PORTAL_PORT_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = OP_INTEGER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ui = ntohl(*(uint32_t *)value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_PORTAL(ISNS_PORTAL_INDEX_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_INTEGER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ui = ntohl(*(uint32_t *)value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_PG(ISNS_PG_INDEX_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_INTEGER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ui = ntohl(*(uint32_t *)value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte old = is_obj_there(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (old == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (num > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = uids[-- num];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid > old) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte diff = uid - old;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (diff < pre_diff) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte min = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pre_diff = diff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (min);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_qry_rsp(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t tlv_len = lcp->id[1];
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type = obj->type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t min_tag = TAG_RANGE[type][0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t mid_tag = TAG_RANGE[type][1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t max_tag = TAG_RANGE[type][2];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_pdu_t *rsp = conn->out_packet.pdu;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t pl = conn->out_packet.pl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t sz = conn->out_packet.sz;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tlv->attr_len == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tag = tlv->attr_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tag <= mid_tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id = ATTR_INDEX(tag, type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[id];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = attr->len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value = (void *)attr->value.ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = pdu_add_tlv(&rsp, &pl, &sz,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tag, len, value, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(tlv, tlv_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (ec == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tlv_len >= 8 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tlv->attr_id >= min_tag &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tlv->attr_id <= max_tag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte conn->out_packet.pdu = rsp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte conn->out_packet.pl = pl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte conn->out_packet.sz = sz;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_qry_attrs(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *tlv,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t tlv_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte conn_arg_t *conn
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, type, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[1] = tlv_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ptr = (uchar_t *)tlv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[2].ptr = (uchar_t *)conn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = cache_lookup(&lc, NULL, cb_qry_rsp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_qry_attrs1(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *tlv,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t tlv_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte conn_arg_t *conn
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *tmp = tlv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tmp_len = tlv_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clear the length of all of tlv */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (tmp_len > 8) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp->attr_len = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(tmp, tmp_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (get_qry_attrs(uid, type, tlv, tlv_len, conn));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}