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/*
530e2b59e3a1e24b97617608e33a1786f2875502wl * Copyright 2009 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#include <pthread.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/socket.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <netinet/in.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <arpa/inet.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_server.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_msgq.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_htab.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_cache.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_pdu.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_obj.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_dd.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_func.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_dseng.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_log.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_scn.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_utils.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_esi.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * external variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int verbose_mc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void print_object(char *, isns_obj_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern msg_queue_t *sys_q;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern msg_queue_t *scn_q;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern pthread_mutex_t el_mtx;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int cache_flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * global data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * local variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* type of parent object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int TYPE_OF_PARENT[MAX_OBJ_TYPE_FOR_SIZE] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_PARENT_TYPE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PORTAL_PARENT_TYPE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PG_PARENT_TYPE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DD */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DDS */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* MAX_OBJ_TYPE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY2 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY3 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY4 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSOC_ISCSI_PARENT_TYPE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSOC_DD_PARENT_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* number of children object type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int NUM_OF_CHILD[MAX_OBJ_TYPE] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ENTITY_CHILD,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_ISCSI_CHILD,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_PORTAL_CHILD,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_PG_CHILD,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* type of a child object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int TYPE_OF_CHILD[MAX_OBJ_TYPE][MAX_CHILD_TYPE] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { OBJ_ISCSI, OBJ_PORTAL },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* number of attributes of certain type of object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int NUM_OF_ATTRS[MAX_OBJ_TYPE_FOR_SIZE] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NUM_OF_ENTITY_ATTRS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NUM_OF_ISCSI_ATTRS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NUM_OF_PORTAL_ATTRS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NUM_OF_PG_ATTRS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NUM_OF_DD_ATTRS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NUM_OF_DDS_ATTRS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* MAX_OBJ_TYPE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY2 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY3 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY4 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NUM_OF_ASSOC_ISCSI_ATTRS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NUM_OF_ASSOC_DD_ATTRS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* the tag of UID of each type of object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int UID_TAG[MAX_OBJ_TYPE_FOR_SIZE] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_ENTITY_INDEX_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_ISCSI_NODE_INDEX_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PORTAL_INDEX_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PG_INDEX_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DD_ID_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DD_SET_ID_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* MAX_OBJ_TYPE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY2 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY3 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY4 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DD_ISCSI_INDEX_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DD_ID_ATTR_ID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* the index of UID of each type of object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int UID_ATTR_INDEX[MAX_OBJ_TYPE_FOR_SIZE] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_ENTITY(ISNS_ENTITY_INDEX_ATTR_ID),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_ISCSI(ISNS_ISCSI_NODE_INDEX_ATTR_ID),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PORTAL(ISNS_PORTAL_INDEX_ATTR_ID),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PG(ISNS_PG_INDEX_ATTR_ID),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_DD(ISNS_DD_ID_ATTR_ID),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_DDS(ISNS_DD_SET_ID_ATTR_ID),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* MAX_OBJ_TYPE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY2 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY3 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY4 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_ASSOC_ISCSI(ISNS_DD_ISCSI_INDEX_ATTR_ID),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_ASSOC_DD(ISNS_DD_ID_ATTR_ID)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* the index of the key attributes of each type of object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int KEY_ATTR_INDEX[MAX_OBJ_TYPE][MAX_KEY_ATTRS] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ATTR_INDEX_ENTITY(ISNS_EID_ATTR_ID), 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ATTR_INDEX_PORTAL(ISNS_PORTAL_IP_ADDR_ATTR_ID),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PORTAL(ISNS_PORTAL_PORT_ATTR_ID),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ATTR_INDEX_PG(ISNS_PG_ISCSI_NAME_ATTR_ID),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PG(ISNS_PG_PORTAL_IP_ADDR_ATTR_ID),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PG(ISNS_PG_PORTAL_PORT_ATTR_ID) },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID), 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID), 0 }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* the operating methods for key attributes of each type of object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int KEY_ATTR_OP[MAX_OBJ_TYPE][MAX_KEY_ATTRS] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { OP_STRING, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { OP_STRING, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { OP_MEMORY_IP6, OP_INTEGER, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { OP_STRING, OP_MEMORY_IP6, OP_INTEGER },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { OP_STRING, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { OP_STRING, 0 }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* the size of each type of object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int SIZEOF_OBJ[MAX_OBJ_TYPE_FOR_SIZE] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (isns_entity_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (isns_iscsi_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (isns_portal_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (isns_pg_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (isns_dd_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (isns_dds_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (isns_assoc_iscsi_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (isns_assoc_dd_t)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int NUM_OF_REF[MAX_OBJ_TYPE_FOR_SIZE] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int NUM_OF_REF[MAX_OBJ_TYPE_FOR_SIZE] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PG_REF_COUNT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* the type of the reference object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int TYPE_OF_REF[MAX_OBJ_TYPE][MAX_REF_COUNT + 1] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { OBJ_PG, OBJ_PORTAL, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { OBJ_PG, OBJ_ISCSI, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, OBJ_ISCSI, OBJ_PORTAL },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0 }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* the operating method for match operation of the reference object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAX_REF_MATCH (2)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int REF_MATCH_OPS[MAX_OBJ_TYPE][MAX_REF_MATCH] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { OP_STRING, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { OP_MEMORY_IP6, OP_INTEGER },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* the index of the attribute of being matched object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int REF_MATCH_ID1[MAX_OBJ_TYPE][MAX_REF_MATCH] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID), 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ATTR_INDEX_PORTAL(ISNS_PORTAL_IP_ADDR_ATTR_ID),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PORTAL(ISNS_PORTAL_PORT_ATTR_ID) },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* the index of the attribute of matching object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int REF_MATCH_ID2[MAX_OBJ_TYPE][MAX_REF_MATCH] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ATTR_INDEX_PG(ISNS_PG_ISCSI_NAME_ATTR_ID), 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { ATTR_INDEX_PG(ISNS_PG_PORTAL_IP_ADDR_ATTR_ID),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PG(ISNS_PG_PORTAL_PORT_ATTR_ID) },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { 0, 0 }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * local functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t get_reg_period();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *make_unique_name(int *, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic lookup_ctrl_t *set_lookup_ctrl(lookup_ctrl_t *, isns_obj_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int setup_ref_lcp(lookup_ctrl_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *, const isns_obj_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int setup_deref_lcp(lookup_ctrl_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *, isns_type_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int cb_get_parent(void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int cb_node_child(void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int cb_set_ref(void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int cb_clear_ref(void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int cb_add_child(void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int cb_remove_child(void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int cb_verify_ref(void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int cb_ref_new2old(void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int cb_new_ref(void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ref_new2old(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *, isns_type_t, uint32_t, const isns_obj_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ref_new2new(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *, const isns_obj_t *, const isns_obj_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int new_ref(const isns_obj_t *, const isns_obj_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t setup_parent_lcp(lookup_ctrl_t *, isns_obj_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int set_obj_offline(isns_obj_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int copy_attrs(isns_obj_t *, const isns_obj_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic isns_obj_t *make_default_pg(const isns_obj_t *, const isns_obj_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic isns_obj_t *(*const make_ref[MAX_OBJ_TYPE])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (const isns_obj_t *, const isns_obj_t *) = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &make_default_pg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &make_default_pg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t entity_hval(void *, uint16_t, uint32_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t iscsi_hval(void *, uint16_t, uint32_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t portal_hval(void *, uint16_t, uint32_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t pg_hval(void *, uint16_t, uint32_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t dd_hval(void *, uint16_t, uint32_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t dds_hval(void *, uint16_t, uint32_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t (*const hval_func[MAX_OBJ_TYPE])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *, uint16_t, uint32_t *) = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &entity_hval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &iscsi_hval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &portal_hval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &pg_hval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &dd_hval,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &dds_hval
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * entity_hval:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caculate the hash value of a network entity object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer pointers to network entity object or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the lookup control data, both have the key attribute
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of a network entity object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * chunk- which chunk of the hash table.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flags- pointer to flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the hash value.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteentity_hval(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_FUNC_ARG_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t chunk,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *key;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*flags & FLAGS_CTRL_MASK) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* p pointers to a network entity object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = (isns_obj_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte key = obj->attrs[ATTR_INDEX_ENTITY(ISNS_EID_ATTR_ID)].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value.ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* p is lookup control data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp = (lookup_ctrl_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte key = lcp->data[0].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (htab_compute_hval(key));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_hval:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caculate the hash value of an iscsi storage node object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer pointers to iscsi storage node object or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the lookup control data, both have the key attribute
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of an iscsi storage node object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * chunk- which chunk of the hash table.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flags- pointer to flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the hash value.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_hval(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_FUNC_ARG_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t chunk,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *key;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*flags & FLAGS_CTRL_MASK) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* p pointers to an iscsi storage node object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = (isns_obj_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte key = obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID)].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value.ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* p is lookup control data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp = (lookup_ctrl_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte key = lcp->data[0].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (htab_compute_hval(key));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * portal_hval:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caculate the hash value of a portal object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer pointers to a portal object or the lookup control
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * data, both have the key attributes of a portal object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * chunk- which chunk of the hash table.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flags- pointer to flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the hash value.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteportal_hval(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_FUNC_ARG_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t chunk,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buff[INET6_ADDRSTRLEN + 8] = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buff2[8] = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *key;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte in6_addr_t *ip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*flags & FLAGS_CTRL_MASK) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* p pointers to a portal object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = (isns_obj_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ip = obj->attrs[ATTR_INDEX_PORTAL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ISNS_PORTAL_IP_ADDR_ATTR_ID)].value.ip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = obj->attrs[ATTR_INDEX_PORTAL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ISNS_PORTAL_PORT_ATTR_ID)].value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* p is lookup control data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp = (lookup_ctrl_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ip = lcp->data[0].ip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = lcp->data[1].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte key = (uchar_t *)inet_ntop(AF_INET6, (void *)ip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buff, sizeof (buff));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(buff2, sizeof (buff2), "%d", port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat((char *)key, buff2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (htab_compute_hval(key));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pg_hval:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caculate the hash value of a portal group object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer pointers to a portal group object or the lookup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * control data, both have the key attributes of a portal object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * chunk- which chunk of the hash table.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flags- pointer to flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the hash value.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepg_hval(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t chunk,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buff[INET6_ADDRSTRLEN + 8] = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buff2[8] = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *key = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte in6_addr_t *ip = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*flags & FLAGS_CTRL_MASK) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* p is a portal group object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = (isns_obj_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (chunk == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first chunk */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte key = obj->attrs[ATTR_INDEX_PG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ISNS_PG_ISCSI_NAME_ATTR_ID)].value.ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* another chunk */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ip = obj->attrs[ATTR_INDEX_PG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ISNS_PG_PORTAL_IP_ADDR_ATTR_ID)].value.ip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = obj->attrs[ATTR_INDEX_PG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ISNS_PG_PORTAL_PORT_ATTR_ID)].value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* p is a lookup control data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp = (lookup_ctrl_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clear the chunk flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *flags &= ~FLAGS_CHUNK_MASK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lcp->op[0] == OP_STRING) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first chunk */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte key = lcp->data[0].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* another chunk */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ip = lcp->data[0].ip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = lcp->data[1].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *flags |= 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (key == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte key = (uchar_t *)inet_ntop(AF_INET6, (void *)ip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buff, sizeof (buff));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(buff2, sizeof (buff2), "%d", port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat((char *)key, buff2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (htab_compute_hval(key));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dd_hval:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caculate the hash value of a DD object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer pointers to a DD object or the lookup control data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * both have the key attributes of a DD object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * chunk- which chunk of the hash table.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flags- pointer to flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the hash value.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedd_hval(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_FUNC_ARG_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t chunk,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *key;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*flags & FLAGS_CTRL_MASK) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* p is a DD object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = (isns_obj_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte key = obj->attrs[ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID)].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value.ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* p is a lookup control data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp = (lookup_ctrl_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte key = lcp->data[0].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (htab_compute_hval(key));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dds_hval:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caculate the hash value of a DD-set object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer pointers to a DD-set object or the lookup control data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * both have the key attributes of a DD-set object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * chunk- which chunk of the hash table.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flags- pointer to flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the hash value.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedds_hval(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_FUNC_ARG_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t chunk,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *key;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*flags & FLAGS_CTRL_MASK) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* p is a DD-set object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = (isns_obj_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte key = obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID)].
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value.ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* p is lookup control data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp = (lookup_ctrl_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte key = lcp->data[0].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (htab_compute_hval(key));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj_hval:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caculate the hash value of an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer pointers to an object or lookup control data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * both has the object type and the key attributes of an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * chunk- which chunk of the hash table.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flags- pointer to flags.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the hash value.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteobj_hval(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t chunk,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type = ((isns_obj_t *)p)->type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (hval_func[type](p, chunk, flags));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_obj_uid:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the UID of an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer pointers to an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_obj_uid(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const void *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr = &obj->attrs[UID_ATTR_INDEX[obj->type]];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = attr->value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set_obj_uid:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set the UID of an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer pointers to an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid - the UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteset_obj_uid(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr = &obj->attrs[UID_ATTR_INDEX[obj->type]];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set the tag, len and value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = UID_TAG[obj->type];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj_cmp:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * compare between two objects or an object with a lookup control data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - the pointer points to an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - the pointer points to an object or a lookup control data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flags- 0: p2 is an object; otherwise p2 is a lookup control data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the comparsion result.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteobj_cmp(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t buff = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flags == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp = set_lookup_ctrl(&buff, (isns_obj_t *)p2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = get_obj_uid(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the object are linked with decending order by */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the object UID, if the object UID is greater than */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* or equal to the current UID, it needs to compare */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* for the next one. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lcp->curr_uid != 0 && uid >= lcp->curr_uid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (key_cmp(lcp, obj));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * replace_object:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * replace an existing object with the new one.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - the pointer points to an object being replaced.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - the pointer points to a new object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid_p- points to uid for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flag - 0: do not free the source object, otherwise free it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereplace_object(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *uid_p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef SKIP_SRC_AUTH
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *pp_dst, *pp_src, swap;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int online;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *dst = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *src = (isns_obj_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (src->type == OBJ_DD || src->type == OBJ_DDS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* replace not allowed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_NAME_IN_USE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte online = is_obj_online(dst);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set cache update flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_CACHE_UPDATED();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* update parent uid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef SKIP_SRC_AUTH
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pp_dst = get_parent_p(dst);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pp_dst != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pp_src = get_parent_p(src);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte swap = *pp_dst;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pp_dst = *pp_src;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (swap != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pp_src = swap;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* update all of attributes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (copy_attrs(dst, src) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_INTERNAL_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free up the src object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free_object(src);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (online == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) set_obj_uid(src, get_obj_uid(dst));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) set_obj_offline(src);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* update data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sys_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = write_data(DATA_UPDATE, dst);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we should never have duplicated entry in data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* trigger a scn */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scn_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) make_scn((online == 0) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_OBJECT_ADDED :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_OBJECT_UPDATED,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dst);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid_p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *uid_p = get_obj_uid(dst);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add_object:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * post function after adding a new object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - object which has been added.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadd_object(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* add the new object to data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sys_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = write_data(DATA_ADD, obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* trigger a scn */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 && scn_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) make_scn(ISNS_OBJECT_ADDED, obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj_tab_init:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initialize the object hash tables.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * c - points to the cache.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteobj_tab_init(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct cache *c
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte htab_t *t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte htab_init();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocate an array of pointer for the object hash tables.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c->t = (struct htab **)calloc(sizeof (struct htab *), MAX_OBJ_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (c->t == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hash table for network entity objects.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = htab_create(UID_FLAGS_SEQ, 8, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (t != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t->c = c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c->t[OBJ_ENTITY] = t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hash table for iscsi storage node objects.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = htab_create(UID_FLAGS_SEQ, 8, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (t != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t->c = c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c->t[OBJ_ISCSI] = t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hash table for portal objects.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = htab_create(UID_FLAGS_SEQ, 8, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (t != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t->c = c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c->t[OBJ_PORTAL] = t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hash table for portal group objects.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = htab_create(UID_FLAGS_SEQ, 8, 2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (t != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t->c = c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c->t[OBJ_PG] = t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hash table for discovery domain objects.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = htab_create(0, 6, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (t != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t->c = c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c->t[OBJ_DD] = t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hash table for discovery domain set objects.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = htab_create(0, 4, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (t != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t->c = c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c->t[OBJ_DDS] = t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_ref_np:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the ref pointer of the portal group object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - portal group object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - ref pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_ref_np(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int n
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *refp =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj->type == OBJ_PG ? &((isns_pg_t *)obj)->ref[n] : NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (refp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_ref_n(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int n
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (*get_ref_np(obj, n));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_ref_p(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t rt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t t = obj->type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < NUM_OF_REF[t]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rt == TYPE_OF_REF[t][i + 1]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (get_ref_np(obj, i));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_ref_t(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *refp = get_ref_p(obj, type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (refp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (*refp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_NOP_ELSE_STMT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_parent_p:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the pointer of the parent object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - parent object pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t *const
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_parent_p(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *pp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (obj->type) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case OBJ_ISCSI:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pp = &((isns_iscsi_t *)obj)->puid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case OBJ_PORTAL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pp = &((isns_portal_t *)obj)->puid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case OBJ_PG:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pp = &((isns_pg_t *)obj)->puid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case OBJ_ASSOC_ISCSI:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pp = &((isns_assoc_iscsi_t *)obj)->puid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case OBJ_ASSOC_DD:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pp = &((isns_assoc_dd_t *)obj)->puid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (pp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_parent_uid(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *pp = get_parent_p(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (*pp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_child_np:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the pointer of the UID array of the n'th child of an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * n - the child index.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the pointer of the UID array.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t **
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_child_np(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int n
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t **pp =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj->type == OBJ_ENTITY ? &((isns_entity_t *)obj)->cuid[n] : NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (pp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_child_n:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the UID array of the n'th child of an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * n - the child index.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the UID array.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_child_n(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int n
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t **pp = get_child_np(obj, n);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (*pp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_child_p:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the pointer of the UID array of the child matching the type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * base - an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * child_type - the child object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the pointer of the UID array.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t **
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_child_p(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *base,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int child_type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t **pp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < NUM_OF_CHILD[base->type]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (child_type == TYPE_OF_CHILD[base->type][i]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pp = get_child_np(base, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (pp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_child_t:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the UID array of the child object matching the type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * base - an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * child_type - the child object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the UID array.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_child_t(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *base,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int child_type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t **pp = get_child_p(base, child_type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (*pp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * key_cmp:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * compare the object against the lookup control data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lcp - the lookup control data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - comparison result.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortekey_cmp(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int match = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < MAX_LOOKUP_CTRL && lcp->op[i] > 0 && match) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr = &obj->attrs[lcp->id[i]];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (lcp->op[i]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case OP_STRING:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte match = (strcmp((const char *)lcp->data[i].ptr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (const char *)attr->value.ptr) == 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case OP_INTEGER:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte match = (lcp->data[i].ui == attr->value.ui);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case OP_MEMORY_IP6:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte match = !memcmp((void *)lcp->data[i].ip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)attr->value.ip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (in6_addr_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte match = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i && match) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set_lookup_ctrl:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fill in the lookup control data for an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lcp - the lookup control data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the lookup control data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic lookup_ctrl_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteset_lookup_ctrl(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type = obj->type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t id, op;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->type = type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < MAX_KEY_ATTRS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte op = KEY_ATTR_OP[type][i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (op != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id = KEY_ATTR_INDEX[type][i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[i] = id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->op[i] = op;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[i].ui = obj->attrs[id].value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (lcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * assign_attr:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * assign an attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * attr - the attribute being assigned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tmp - the attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteassign_attr(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_attr_t *tmp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (tmp->tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_EID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp->len == 0 && attr->len == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *name = make_unique_name(&len, tmp->tag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (name != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ptr = (uchar_t *)name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = tmp->tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* memory exhausted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_ALIAS_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_AUTH_METHOD_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp->len == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
530e2b59e3a1e24b97617608e33a1786f2875502wl } else if (tmp->len >= attr->len) {
530e2b59e3a1e24b97617608e33a1786f2875502wl attr->value.ptr = realloc(
530e2b59e3a1e24b97617608e33a1786f2875502wl attr->value.ptr, tmp->len + 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ptr != NULL) {
530e2b59e3a1e24b97617608e33a1786f2875502wl (void) strncpy((char *)attr->value.ptr,
530e2b59e3a1e24b97617608e33a1786f2875502wl (char *)tmp->value.ptr, tmp->len);
530e2b59e3a1e24b97617608e33a1786f2875502wl attr->value.ptr[tmp->len] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = tmp->tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = tmp->len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* memory exhausted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
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 if (attr->value.ip == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ip = (in6_addr_t *)calloc(1, tmp->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ip != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy((void *)attr->value.ip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)tmp->value.ip, tmp->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = tmp->tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = tmp->len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* memory exhausted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ENTITY_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_NODE_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_ID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_ID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ui != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ENTITY_PROTOCOL_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_VERSION_RANGE_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_PORT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ESI_PORT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_SCN_PORT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_NODE_TYPE_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_SCN_BITMAP_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_PORTAL_PORT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_TAG_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_STATUS_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_ISCSI_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = tmp->tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = tmp->len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = tmp->value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ENTITY_REG_PERIOD_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = tmp->tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = tmp->len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = tmp->value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = get_reg_period();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ui > t) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (attr->value.ui < ONE_DAY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = ONE_DAY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ESI_INTERVAL_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = tmp->tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = tmp->len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = tmp->value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ui > ONE_DAY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = ONE_DAY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (attr->value.ui < MIN_ESI_INTVAL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = MIN_ESI_INTVAL; /* 20 seconds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* don't assign the attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * copy_attrs:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * copy all of attributes from one object to another.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dst - the destination object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tmp - the source object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecopy_attrs(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *dst,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *src
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int n = NUM_OF_ATTRS[dst->type];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *dst_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_attr_t *src_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < n) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte src_attr = &(src->attrs[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (src_attr->tag != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dst_attr = &(dst->attrs[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (assign_attr(dst_attr, src_attr) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * extract_attr:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * extract an attribute from a TLV format data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * attr - the attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tlv - the TLV format data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextract_attr(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_tlv_t *tlv,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t min_len = 4, max_len = 224;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (tlv->attr_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_EID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte min_len = 0;
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 max_len = 256;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tlv->attr_len < min_len || tlv->attr_len > max_len) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = tlv->attr_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = tlv->attr_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ptr = (uchar_t *)&(tlv->attr_value[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_AUTH_METHOD_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = tlv->attr_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = tlv->attr_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ptr = (uchar_t *)&(tlv->attr_value[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
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 if (tlv->attr_len != 16) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = tlv->attr_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = tlv->attr_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ip = (void *)&(tlv->attr_value[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
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 /* fall throught */
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_SCN_PORT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fall throught */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_NODE_TYPE_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fall throught */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_PORTAL_PORT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fall throught */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_ID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_STATUS_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fall throught */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_ID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tlv->attr_len != 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_TAG_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = tlv->attr_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = tlv->attr_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tlv->attr_len == 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = ntohl(*(uint32_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(tlv->attr_value[0]));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_SCN_BITMAP_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ignore scn bitmap attribute during object registration, */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* it is registered by scn_reg message. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ENTITY_ISAKMP_P1_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ENTITY_CERT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_SEC_BMP_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_ISAKMP_P1_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_ISAKMP_P2_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_CERT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_NODE_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tlv->attr_len != 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = tlv->attr_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = tlv->attr_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = ntohl(*(uint32_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(tlv->attr_value[0]));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ENTITY_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_TIMESTAMP_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INVALID_QRY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INVALID_REGIS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * copy_attr:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * copy an attribute from a TLV format data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * attr - the attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tlv - the TLV format data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecopy_attr(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_tlv_t *tlv
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t tmp = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* extract the attribute first */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = extract_attr(&tmp, tlv, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* assign the attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 && tmp.tag != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (assign_attr(attr, &tmp) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_timestamp:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get current timestamp.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - current timestamp.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_timestamp(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* block the scheduler */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&el_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get most current time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sys_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* need to wakeup idle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = get_stopwatch(flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unblock it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&el_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_reg_period:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the longest registration period.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the longest registration period.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_reg_period(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t period;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get most current time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = get_timestamp();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* just one second before the end of the world */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte period = INFINITY - t - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (period);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj_calloc:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocate memory space for an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type - the object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - pointer of the object being allocated.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_obj_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteobj_calloc(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = (isns_obj_t *)calloc(1, SIZEOF_OBJ[type]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj->type = type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose_mc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf("object(%d) allocated\n", type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * make_default_entity:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * generate a default network entity object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - pointer of the default network entity object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_obj_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemake_default_entity(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = obj_calloc(OBJ_ENTITY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *eid = make_unique_name(&len, ISNS_EID_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!eid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ENTITY(ISNS_EID_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set default entity name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = ISNS_EID_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ptr = (uchar_t *)eid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set default registration period */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_ENTITY(ISNS_ENTITY_REG_PERIOD_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->tag == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = ISNS_ENTITY_REG_PERIOD_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = get_reg_period();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * make_default_pg:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * generate a default portal group object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi - the iscsi storage node object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * portal - the portal object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - pointer of the default portal group object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic isns_obj_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemake_default_pg(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *iscsi, *portal;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_attr_t *name, *addr, *port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *pg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *pg_name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte in6_addr_t *pg_addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *refp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p1->type == OBJ_ISCSI) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi = p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portal = p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi = p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portal = p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = &iscsi->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr = &portal->attrs[ATTR_INDEX_PORTAL(ISNS_PORTAL_IP_ADDR_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = &portal->attrs[ATTR_INDEX_PORTAL(ISNS_PORTAL_PORT_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg = obj_calloc(OBJ_PG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_name = (uchar_t *)malloc(name->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_addr = (in6_addr_t *)malloc(addr->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pg != NULL && pg_name != NULL && pg_addr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy((char *)pg_name, (char *)name->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &pg->attrs[ATTR_INDEX_PG(ISNS_PG_ISCSI_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = ISNS_PG_ISCSI_NAME_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = name->len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ptr = pg_name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy((void *)pg_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)addr->value.ip, addr->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &pg->attrs[ATTR_INDEX_PG(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PG_PORTAL_IP_ADDR_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = ISNS_PG_PORTAL_IP_ADDR_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = addr->len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ip = pg_addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &pg->attrs[ATTR_INDEX_PG(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PG_PORTAL_PORT_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = ISNS_PG_PORTAL_PORT_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = port->len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = port->value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &pg->attrs[ATTR_INDEX_PG(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PG_TAG_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = ISNS_PG_TAG_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = ISNS_DEFAULT_PGT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte refp = get_ref_p(pg, OBJ_ISCSI);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *refp = get_obj_uid(iscsi);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte refp = get_ref_p(pg, OBJ_PORTAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *refp = get_obj_uid(portal);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) set_parent_obj(pg, get_parent_uid(iscsi));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pg_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pg_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (pg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reg_get_entity:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse the Operating Attributes of the DevAttrReg message and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create the Network Entity object if it has one.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer of the object for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op - the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op_len - the length of the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereg_get_entity(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t **p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t **op,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t *op_len
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t tmp_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *entity = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp = *op;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_len = *op_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* parse the entity object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_len >= 8 && IS_ENTITY_KEY(tmp->attr_id)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entity = obj_calloc(OBJ_ENTITY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (entity != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &entity->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_ENTITY(tmp->attr_id)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = copy_attr(attr, tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(tmp, tmp_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (ec == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_len >= 8 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IS_ENTITY_ATTR(tmp->attr_id));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set default registration period */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &entity->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_ENTITY(ISNS_ENTITY_REG_PERIOD_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->tag == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = ISNS_ENTITY_REG_PERIOD_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = get_reg_period();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (entity != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(entity);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entity = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = entity;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *op = tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *op_len = tmp_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reg_get_iscsi:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse the Operating Attributes of the DevAttrReg message and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create an iSCSI Storage Node object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer of the object for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pg_key1 - the pointer of iscsi storage node name for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op - the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op_len - the length of the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereg_get_iscsi(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t **p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *pg_key1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t **op,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t *op_len
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t tmp_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp = *op;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_len = *op_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* keep the iscsi storage node name for */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* parsing a pg object which is immediately */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* followed with a PGT by the iscsi storage node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_key1->tag = PG_KEY1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_key1->len = tmp->attr_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_key1->value.ptr = (uchar_t *)&tmp->attr_value[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* parse one iscsi storage node object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = obj_calloc(OBJ_ISCSI);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* parse key & non-key attributes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_ISCSI(tmp->attr_id)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = copy_attr(attr, tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(tmp, tmp_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (ec == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_len >= 8 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IS_ISCSI_ATTR(tmp->attr_id));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *op = tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *op_len = tmp_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reg_get_portal:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse the Operating Attributes of the DevAttrReg message and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create a Portal object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer of the object for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pg_key1 - the pointer of portal ip addr for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pg_key2 - the pointer of portal port for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op - the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op_len - the length of the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereg_get_portal(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t **p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *pg_key1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *pg_key2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t **op,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t *op_len
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t tmp_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *ip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp = *op;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_len = *op_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* keep the portal ip addr */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_key1->tag = PG_KEY2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_key1->len = tmp->attr_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_key1->value.ip = (void *)&tmp->attr_value[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ip = tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(tmp, tmp_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_len > 8 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp->attr_id == PORTAL_KEY2 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp->attr_len == 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* keep the portal port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_key2->tag = PG_KEY3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_key2->len = tmp->attr_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_key2->value.ui = ntohl(*(uint32_t *)&tmp->attr_value[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* parse one portal object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = obj_calloc(OBJ_PORTAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy ip addr attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PORTAL(ip->attr_id)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = copy_attr(attr, ip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy port attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PORTAL(tmp->attr_id)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = copy_attr(attr, tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* parse non-key attributes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(tmp, tmp_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ec == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_len >= 8 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IS_PORTAL_ATTR(tmp->attr_id)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PORTAL(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp->attr_id)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = copy_attr(attr, tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(tmp, tmp_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ip address is not followed by port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *op = tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *op_len = tmp_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reg_get_pg:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse the Operating Attributes of the DevAttrReg message and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create a Portal Group object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer of the object for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op - the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op_len - the length of the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereg_get_pg(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t **p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t **op,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t *op_len
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t tmp_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp = *op;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_len = *op_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* parse a complete pg object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = obj_calloc(OBJ_PG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* parse attributes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PG(tmp->attr_id)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = copy_attr(attr, tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(tmp, tmp_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (ec == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_len >= 8 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IS_PG_ATTR(tmp->attr_id));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *op = tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *op_len = tmp_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reg_get_pg1:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse the Operating Attributes of the DevAttrReg message and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create a Portal Group object which is followed to a Portal object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer of the object for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pgt - the size-3 array of pointers which have the pg portal ip addr, port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and the pg tag attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op - the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op_len - the length of the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereg_get_pg1(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t **p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t const *pgt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t **op,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t *op_len
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t tmp_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp = *op;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_len = *op_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pgt[0].tag == PG_KEY2 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgt[1].tag == PG_KEY3) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the pg iscsi storage node name is */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* followed to a portal group tag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = obj_calloc(OBJ_PG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy pg iscsi storage node name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PG(tmp->attr_id)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = copy_attr(attr, tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy pg ip addr, pg port & pgt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ec == 0 && i < 3) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PG(pgt[i].tag)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = assign_attr(attr, &pgt[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(tmp, tmp_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *op = tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *op_len = tmp_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reg_get_pg2:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse the Operating Attributes of the DevAttrReg message and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create a Portal Group object which is followed to a iSCSI
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Storage Node object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer of the object for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pgt - the size-3 array of pointers which have the pg iscsi storage
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * node name and the pg tag attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op - the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op_len - the length of the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereg_get_pg2(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t **p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t const *pgt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t **op,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t *op_len
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t tmp_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *ip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp = *op;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_len = *op_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* keep ip address */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ip = tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(tmp, tmp_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_len > 8 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* expect pg portal port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp->attr_id == PG_KEY3 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp->attr_len == 4 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* expect pg tag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgt[2].tag == PG_PGT &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* expect pg iscsi storage node name only */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgt[1].tag == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgt[0].tag == PG_KEY1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the pg portal ip addr & port is followed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* to a pg tag and we have the iscsi storage */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* node parsed previously */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = obj_calloc(OBJ_PG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy the pg ip addr */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PG(ip->attr_id)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = copy_attr(attr, ip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy the pg port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PG(tmp->attr_id)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = copy_attr(attr, tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy pg iscsi storage node name & pgt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ec == 0 && i < 3) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_PG(pgt[i].tag)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = assign_attr(attr, &pgt[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i += 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(tmp, tmp_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *op = tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *op_len = tmp_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reg_get_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse and create one object from the rest of Operating Attributes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of the DevAttrReg message, the object can be iSCSI Storage Node,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Portal or Portal Group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer of the object for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pgt - an attribute array with size 3, the elements are:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0: the first pg key attribute, it is either the name of an
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi storage node object or the ip addr of a portal object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1: the second pg key attribute, i.e. the portal port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 2: the portal group tag attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op - the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op_len - the length of the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereg_get_obj(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t **p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *pgt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t **op,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t *op_len
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int derefd = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t pg_tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*op_len == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch ((*op)->attr_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISCSI_KEY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = reg_get_iscsi(p, &pgt[0], op, op_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgt[1].tag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgt[2].tag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PORTAL_KEY1:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = reg_get_portal(p, &pgt[0], &pgt[1], op, op_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgt[2].tag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PG_KEY1:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pgt[2].tag == PG_PGT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pg iscsi storage node name is */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* followed to a pgt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = reg_get_pg1(p, pgt, op, op_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* a complete pg object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = reg_get_pg(p, op, op_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgt[0].tag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgt[1].tag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgt[2].tag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PG_KEY2:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pg portal ip addr is followed to a pgt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = reg_get_pg2(p, pgt, op, op_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PG_PGT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (pgt[0].tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* portal group tag does not follow */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iscsi storage node or portal object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PG_KEY1:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PG_KEY2:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgt[2].tag = PG_PGT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgt[2].len = (*op)->attr_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_tag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch ((*op)->attr_len) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 4:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_tag = ntohl(*(uint32_t *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(*op)->attr_value[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pgt[2].value.ui = pg_tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte derefd = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(*op, *op_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = reg_get_obj(p, pgt, op, op_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* should never happen */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 && derefd == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = update_deref_obj(*p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0 && *p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_one_object(*p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reg_auth_src:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Authorize the source attribute the DevAttrReg message.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The update can only performed by the node who has the owenership.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer of the object for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pgt - an attribute array with size 3, the elements are:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0: the first pg key attribute, it is either the name of an
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi storage node object or the ip addr of a portal object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1: the second pg key attribute, i.e. the portal port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 2: the portal group tag attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op - the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * op_len - the length of the operating attributes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereg_auth_src(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *src
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t puid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte puid = is_parent_there(src);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (TYPE_OF_PARENT[type] != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, type, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = cache_lookup(&lc, NULL, cb_get_parent);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte type = TYPE_OF_PARENT[type];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid != 0 && puid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, type, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = cache_lookup(&lc, NULL, cb_node_child);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (puid != uid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is_obj_online:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * determine if the object is currently registered with the server.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the object being checked.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 0: not registered, otherwise registered.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteis_obj_online(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int online = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (obj->type) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case OBJ_ISCSI:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte online = obj->attrs[ATTR_INDEX_ISCSI(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_ISCSI_NODE_TYPE_ATTR_ID)].value.ui == 0 ? 0 : 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (online);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteset_obj_offline(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (obj->type) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case OBJ_ISCSI:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj->attrs[ATTR_INDEX_ISCSI(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_ISCSI_NODE_TYPE_ATTR_ID)].value.ui = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * assoc_clone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * clone the association object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the object being cloned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * clone_flag - 0: the object is being removed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1: only the association is being removed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the clone object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteassoc_clone(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int clone_flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *clone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_attr_t *src_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *dst_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t id, op;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dd_flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int online;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = (isns_obj_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj->type != OBJ_ISCSI) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd_flag = (get_dd_id(get_obj_uid(obj), ISNS_DEFAULT_DD_ID) == 0) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0 : 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte online = is_obj_online(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state = (clone_flag << 2) | (dd_flag << 1) | online;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clone_flag dd_flag online action */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 0 0 0 ASSERT(0) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 0 0 1 NULL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 0 1 0 itself */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 0 1 1 clone it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 1 0 0 NULL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 1 0 1 itself */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 1 1 0 itself */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 1 1 1 itself */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (state) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 1:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 4:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 2:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 5:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 6:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 7:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 3:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte type = obj->type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clone = obj_calloc(type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (clone != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id = UID_ATTR_INDEX[type];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte src_attr = &(obj->attrs[id]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dst_attr = &(clone->attrs[id]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (assign_attr(dst_attr, src_attr) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_one_object(clone);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < MAX_KEY_ATTRS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte op = KEY_ATTR_OP[type][i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (op != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id = KEY_ATTR_INDEX[type][i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte src_attr = &(obj->attrs[id]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dst_attr = &(clone->attrs[id]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (assign_attr(dst_attr, src_attr) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_one_object(clone);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((void *)clone);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * free_one_object:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * free up one object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the object being freed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefree_one_object(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *cuid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < NUM_OF_ATTRS[obj->type]; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr = &obj->attrs[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (attr->tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_EID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_ALIAS_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_AUTH_METHOD_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_IP_ADDR_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_PORTAL_IP_ADDR_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_FC_PORT_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_PORTAL_IP_ADDR_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose_mc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf("memory(%d) deallocated\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ptr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free child uids */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < NUM_OF_CHILD[obj->type]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cuid = get_child_n(obj, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(cuid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* at last, free the object itself */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose_mc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf("object(%d) deallocated\n", obj->type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * free_object:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * free up one object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the object being freed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefree_object(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_one_object(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set_parent_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set the parent object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the child object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * puid- the parent object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteset_parent_obj(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t puid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *const p = get_parent_p(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = puid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * buff_child_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add a child object UID to the child object array.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the parent object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * child_type - the type of the child object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * number - the number of the child object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the length of the child object UID array.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortebuff_child_obj(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_type_t ptype,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_type_t ctype,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const void *c,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void const ***child
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void const ***pp, **p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t num, new_num;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the pointer of the array which the child belongs to */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < NUM_OF_CHILD[ptype]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (TYPE_OF_CHILD[ptype][i] == ctype) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pp = &child[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the child type is not applicable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = *pp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get an empty slot from the uid array for this child */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num = (uint32_t)*p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < num) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p[++i] == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* found it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[i] = c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = *pp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new_num = num + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new_num = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the array is full, enlarge the child uid array */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = (void const **)realloc(p, (new_num + 1) * sizeof (void *));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pp = p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = (void *)new_num;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p[new_num] = c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * update_child_object:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * update the child object of a network entity object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * puid - the UID of the parent object, i.e. the network entity object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * child_type - the type of the child object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * child_uid - the uid of the child object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_child_obj(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_type_t ptype,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t puid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void const ***child,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int child_flag
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, ptype, puid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ptr = (uchar_t *)child;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[2].ui = child_flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = cache_lookup(&lc, NULL, cb_add_child);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_ref_obj(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = obj->type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (TYPE_OF_REF[t][0] != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) setup_ref_lcp(&lc, obj, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[2] = t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[2].ui = get_obj_uid(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_lookup(&lc, &uid, cb_set_ref);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (uid != 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * verify_ref_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * update the reference bit of a portal group object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the object being ref'ed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteverify_ref_obj(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_type_t ptype,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t puid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void const ***child
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, ptype, puid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ptr = (uchar_t *)child;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = cache_lookup(&lc, NULL, cb_verify_ref);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_deref_obj(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t t, rt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, ref_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid, *refp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = obj->type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = ref_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < NUM_OF_REF[t]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rt = TYPE_OF_REF[t][i + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) setup_deref_lcp(&lc, obj, rt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = is_obj_there(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte refp = get_ref_p(obj, lc.type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *refp = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ref_count ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0 && ref_count == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INVALID_REGIS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * register_object:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add one object to the object container.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the object being added.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid_p- the pointer for returning object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * update_p- the pointer for returning flag which indicates if the object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is newly registered or updated with an existing one.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteregister_object(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *uid_p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *update_p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cache_add(obj, 0, uid_p, update_p));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * register_assoc:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add one association object to the object container, the association
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * object has only the information for discovery domain membership, i.e.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a name and UID only.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the association object being added.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid_p- the pointer for returning object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteregister_assoc(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *uid_p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cache_add(obj, 1, uid_p, NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is_obj_there:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check if the object is registered or not.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lcp - the lookup control data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteis_obj_there(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_lookup(lcp, &uid, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteis_parent_there(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *src
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
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 = src;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cache_lookup(&lc, NULL, cb_get_parent));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * setup_ref_lcp:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * prepare the lookup control data for looking up a portal group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * object which references to a iscsi stroage node and/or a portal
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lcp - the lookup control data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi- the ref'ed iscsi storage node object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * portal- the ref'ed portal object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesetup_ref_lcp(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *iscsi,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *portal
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0, j = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->type = TYPE_OF_REF[iscsi->type][0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* extrace the matching attributes from iscsi storage node object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iscsi != NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i < MAX_REF_MATCH &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REF_MATCH_OPS[iscsi->type][i] > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[i] = REF_MATCH_ID2[iscsi->type][i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->op[i] = REF_MATCH_OPS[iscsi->type][i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[i].ptr = iscsi->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REF_MATCH_ID1[iscsi->type][i]].value.ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* extrace the matching attributes from portal object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (portal != NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i < MAX_LOOKUP_CTRL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j < MAX_REF_MATCH &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REF_MATCH_OPS[portal->type][j] > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[i] = REF_MATCH_ID2[portal->type][j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->op[i] = REF_MATCH_OPS[portal->type][j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[i].ptr = portal->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REF_MATCH_ID1[portal->type][j]].value.ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i < MAX_LOOKUP_CTRL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->op[i] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesetup_deref_lcp(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *pg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->type = t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* extrace the matching attributes from iscsi storage node object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < MAX_REF_MATCH &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REF_MATCH_OPS[t][i] > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[i] = REF_MATCH_ID1[t][i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->op[i] = REF_MATCH_OPS[t][i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[i].ptr = pg->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte REF_MATCH_ID2[t][i]].value.ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i < MAX_LOOKUP_CTRL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->op[i] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * setup_parent_lcp:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * prepare the lookup control data for looking up parent object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * with a child object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lcp - the lookup control data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the child object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - parent object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesetup_parent_lcp(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t ptype;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t puid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte puid = get_parent_uid(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (puid != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ptype = TYPE_OF_PARENT[obj->type];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(lcp, ptype, puid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[1].ui = obj->type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[2].ui = get_obj_uid(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (puid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_get_parent(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_FUNC_ARG_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (get_parent_uid(p1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_node_child(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_FUNC_ARG_UNUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t num, uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *cuid = get_child_t(obj, OBJ_ISCSI);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cuid != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num = *cuid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (num > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = *++cuid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num --;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_set_ref:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * callback function which sets the reference bit to 1 according to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the type of object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - the object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - the lcp.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_set_ref(
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t u;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *refp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = lcp->id[2];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte u = lcp->data[2].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte refp = get_ref_p(obj, t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *refp = u;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successful */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_clear_ref:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * callback function which clears the reference bit according to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the type of object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - the object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - the lcp.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 1: the object is no longer ref'ed, 0: otherwise.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_clear_ref(
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *refp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t ref;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = lcp->data[2].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte refp = get_ref_p(obj, t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *refp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < NUM_OF_REF[obj->type]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ref = get_ref_n(obj, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ref != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_add_child(
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const void ***child;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const void **vpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t vnum;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int child_flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t **upp, *up;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t num;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *o;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte child = (const void ***)lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte child_flag = lcp->data[2].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < NUM_OF_CHILD[obj->type]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vpp = child[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vpp != NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (vnum = (uint32_t)*vpp) > 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *(vpp + 1) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte upp = get_child_np(obj, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*upp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (child_flag == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (typeof (**upp)) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (typeof (**child))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *upp = (uint32_t *)vpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vpp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte child[i] = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num = vnum;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num = **upp + vnum;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vpp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy required */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte up = (uint32_t *)realloc(*upp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (num + 1) * sizeof (uint32_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (up == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_INTERNAL_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *upp = up;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *up = num;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte up += num;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vpp += vnum;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (vnum > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*vpp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *up = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (child_flag == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *up = (uint32_t)*vpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *vpp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte o = (isns_obj_t *)*vpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *up = get_obj_uid(o);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_obj_online(o) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_object(o);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *vpp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte up --;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vpp --;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vnum --;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_remove_child:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * callback function which removes a child object UID from the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * children objet UID array of the parent object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - the object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - the lcp.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 1: no more such type of child object, 0: otherwise.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_remove_child(
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 uint32_t child_type = lcp->data[1].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t child_uid = lcp->data[2].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *cuidp, cuid, num_of_child = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the children object UID array */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cuidp = get_child_t(obj, child_type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cuidp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num_of_child = *cuidp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (num_of_child > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cuid = *++cuidp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cuid == child_uid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *cuidp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num_of_child --;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check if all of child object UIDs are removed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < NUM_OF_CHILD[obj->type]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cuidp = get_child_n(obj, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cuidp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num_of_child = *cuidp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (num_of_child > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cuid = *++cuidp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cuid != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num_of_child --;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_verify_ref(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *parent = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const void ***child;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const void **vpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const void *vp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t vnum;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const void **evpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const void *evp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t evnum;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t pt; /* parent object type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t ct; /* child object type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t rt; /* ref object type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t et; /* peer object type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *up;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t u;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t unum;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t flag[MAX_OBJ_TYPE + 1] = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j, k;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pt = parent->type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte child = (const void ***)lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < NUM_OF_CHILD[pt]; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ct = TYPE_OF_CHILD[pt][i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rt = TYPE_OF_REF[ct][0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rt == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte et = TYPE_OF_REF[ct][1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vpp = child[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vpp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vnum = (uint32_t)*vpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte up = get_child_t(parent, et);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (up != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unum = *up;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unum = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vnum = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j = vnum;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (j > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vp = vpp[j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) setup_ref_lcp(&lc, vp, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte k = unum;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (k > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte u = up[k];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (u != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ref_new2old(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &lc, et, u, vp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte k --;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of while each unum */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j --;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of while each vnum */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag[ct] != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte evnum = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (j < NUM_OF_CHILD[pt]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (TYPE_OF_CHILD[pt][j] == et) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte evpp = child[j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (evpp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte evnum = (uint32_t)*evpp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j = vnum;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (j > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vp = vpp[j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte k = evnum;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (k > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte evp = evpp[k];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vp != NULL && evp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) setup_ref_lcp(&lc, vp, evp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ref_new2new(&lc, vp, evp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte k --;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j --;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of while each vnum */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag[et] = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of for each type of child */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_ref_new2old(
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t et;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uu;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t ref;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int match;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte et = lcp->id[2];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uu = lcp->data[2].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ref = get_ref_t(obj, et);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ref == uu) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte match = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte match = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (match);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_new_ref(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *a = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *b = (isns_obj_t *)lcp->data[2].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = new_ref(a, b);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteref_new2old(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t et,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uu,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *vp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int match;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[2] = et;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[2].ui = uu;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte match = cache_lookup(lcp, &uid, cb_ref_new2old);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (match == 0 && uid != 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (match == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no such ref, create a default one */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, et, uu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[2].ptr = (uchar_t *)vp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = cache_lookup(&lc, NULL, cb_new_ref);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteref_new2new(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_obj_there(lcp) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = new_ref(p1, p2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenew_ref(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = make_ref[p1->type](p1, p2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = register_object(obj, NULL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * do_dereg:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Physically remove an object along with the children objects,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the reference object and the parent object recursively.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Apporiate SCN is triggered.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lcp - the lookup control for the object being removed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parent_flag - 1: the object being removed is the parent object;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0: otherwise.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * child_flag - 1: the object being removed is a child object;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0: otherwise.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pending - 1: do not remove the ESI entry immediately;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0: remove the ESI entry without any delay.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedo_dereg(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int parent_flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int child_flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int pending
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *cuidp, num;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove the object from object container */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = cache_remove(lcp, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* trigger a scn */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scn_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) make_scn(ISNS_OBJECT_REMOVED, obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* dereg children */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ec == 0 && !parent_flag &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i < NUM_OF_CHILD[obj->type]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte type = TYPE_OF_CHILD[obj->type][i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cuidp = get_child_n(obj, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cuidp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num = *cuidp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ec == 0 && num > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = cuidp[num];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(lcp, type, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = do_dereg(lcp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parent_flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pending);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num --;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clear the ref bit on the ref'd object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 && TYPE_OF_REF[obj->type][0] > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) setup_ref_lcp(lcp, obj, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[2].ui = obj->type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cache_lookup(lcp, &uid, cb_clear_ref) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UPDATE_LCP_UID(lcp, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = do_dereg(lcp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parent_flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte child_flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pending);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (uid != 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove it from the parent */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 && !child_flag &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TYPE_OF_PARENT[obj->type] > 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uid = setup_parent_lcp(lcp, obj)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cache_lookup(lcp, NULL, cb_remove_child) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UPDATE_LCP_UID(lcp, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = do_dereg(lcp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte child_flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 && !child_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove it from persistent data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sys_q) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = write_data(DATA_DELETE, obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove esi event entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) esi_remove_obj(obj, pending);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save the parent uid for caller */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (TYPE_OF_PARENT[obj->type] != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = get_parent_uid(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* it's the parent itself */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->curr_uid = get_obj_uid(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove this portal from scn registry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj->type == OBJ_PORTAL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) remove_scn_portal(get_obj_uid(obj));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free the object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) free_object(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dereg_assoc:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove one association object from object container.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lcp - the lookup control for the object being removed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedereg_assoc(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = cache_remove(lcp, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free the object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_object(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dereg_object:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove one object from object container.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lcp - the lookup control for the object being removed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedereg_object(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int pending
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (do_dereg(lcp, 0, 0, pending));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * data_sync:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Synchronize the cache with persistent data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Flush the cache data to data store if the input ec is zero,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * retreat the changes in cache and ignore data store update
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if there is an error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ec - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedata_sync(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cache is updated successfully, commit the data to data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_CACHE_UPDATED()) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = write_data(DATA_COMMIT, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successful, trigger the SCN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) queue_msg_set(scn_q, SCN_TRIGGER, (void *)NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte shutdown_server();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ignore all SCNs which have been generated */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) queue_msg_set(scn_q, SCN_IGNORE, (void *)NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) write_data(DATA_RETREAT, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic pthread_mutex_t name_mtx[3] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PTHREAD_MUTEX_INITIALIZER,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PTHREAD_MUTEX_INITIALIZER,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PTHREAD_MUTEX_INITIALIZER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const char *name_pattern[3] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ENTITY_ID_%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "DD_%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "DD-Set_%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t name_count[3] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * make_unique_name:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * make a default unique name for a newly registered network entity,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * discovery domain or discovery domain set object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * len - pointer of the length of the new name for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tag - which attribute of the new name is for.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the name being made.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemake_unique_name(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char name[32] = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_EID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = OBJ_ENTITY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_ENTITY(ISNS_EID_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = OBJ_DD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = OBJ_DDS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&name_mtx[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = ++ name_count[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&name_mtx[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no more space, failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (count == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(name, name_pattern[i], count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = (uchar_t *)name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (is_obj_there(&lc) != 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 4-bytes aligned length */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *len = strlen(name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *len = *len + (4 - *len % 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = (char *)malloc(*len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(p, name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteobj_dump(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_object(NULL, (isns_obj_t *)p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif