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/*
5fbbe9c6367b156920d72becff64235e6274db32wl * 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 <libxml/xmlreader.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libxml/xmlwriter.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libxml/tree.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#include <pthread.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_server.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_cfg.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_htab.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_cache.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_obj.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_dd.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_utils.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_mgmt.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_protocol.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "admintf.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern const int UID_ATTR_INDEX[MAX_OBJ_TYPE_FOR_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic isns_type_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_lc_type(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object_type obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case Node:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte type = OBJ_ISCSI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DiscoveryDomain:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DiscoveryDomainMember:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte type = OBJ_DD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DiscoveryDomainSet:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DiscoveryDomainSetMember:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte type = OBJ_DDS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_lc_id(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object_type obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case Node:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id = ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DiscoveryDomain:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DiscoveryDomainMember:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DiscoveryDomainSet:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DiscoveryDomainSetMember:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id = 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 return (id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_get_node_info: callback for get_node_op
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine process matching node and add a Node object elements
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the response doc.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - matching node object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - lookup control data that was used for node look up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * returns parent index(newtork entity) in look up control.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_get_node_info(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_obj, n_node, sub_node, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlAttrPtr n_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddChild(root, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewNode(NULL, (xmlChar *)NODEOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlAddChild(n_obj, n_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get node name, alias, type and generate xml info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)NAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_NODE_TYPE_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (attr->value.ui) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_CONTROL_NODE_TYPE | ISNS_INITIATOR_NODE_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)CONTROLNODEINITIATORTYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_CONTROL_NODE_TYPE | ISNS_TARGET_NODE_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)CONTROLNODETARGETTYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_TARGET_NODE_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)TARGETTYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_INITIATOR_NODE_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)INITIATORTYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_CONTROL_NODE_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)CONTROLNODETYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)UNKNOWNTYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_ALIAS_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)ALIASATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A node can have all or no SCN subsribtion.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * May avoid redundant code with scsusrciption table.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_SCN_BITMAP_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_SCN_INIT_SELF_INFO_ONLY(attr->value.ui)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)SCNINITSELFONLY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_SCN_TARGET_SELF_INFO_ONLY(attr->value.ui)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)SCNTARGETSELFONLY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_SCN_MGMT_REG(attr->value.ui)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)SCNTARGETSELFONLY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_SCN_OBJ_REMOVED(attr->value.ui)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)SCNOBJECTREMOVED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_SCN_OBJ_ADDED(attr->value.ui)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)SCNOBJECTADDED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_SCN_OBJ_UPDATED(attr->value.ui)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)SCNOBJECTUPDATED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_SCN_MEMBER_REMOVED(attr->value.ui)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)SCNMEMBERREMOVED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (IS_SCN_MEMBER_ADDED(attr->value.ui)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)SCNMEMBERADDED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set the parent object id, i.e. the network entity object id */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[2] = get_parent_uid(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pass back the node object element to add entity, portal info to it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[2].ptr = (uchar_t *)n_node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successful */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_get_entity_info: callback for get_node_op
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine process matching network entity and add children elements
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to a Node object for given entity.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - matching entity object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - lookup control data that was used for node look up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * returns parent index(newtork entity) in look up control.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_get_entity_info(
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 xmlNodePtr n_node = (xmlNodePtr)lcp->data[2].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr sub_node, subchild_node, subgrandchild_node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char numbuf[32];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buff[INET6_ADDRSTRLEN + 1] = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL, (xmlChar *)NETWORKENTITY, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ENTITY(ISNS_EID_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewChild(sub_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)ENTITYID, (xmlChar *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ENTITY(ISNS_ENTITY_PROTOCOL_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%u", attr->value.ui);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewChild(sub_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)ENTITYPROTOCOL, (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ENTITY(ISNS_MGMT_IP_ADDR_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ip) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* convert the ipv6 to ipv4 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((int *)attr->value.ip)[0] == 0x00 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((int *)attr->value.ip)[1] == 0x00 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((uchar_t *)attr->value.ip)[8] == 0x00 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((uchar_t *)attr->value.ip)[9] == 0x00 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((uchar_t *)attr->value.ip)[10] == 0xFF &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((uchar_t *)attr->value.ip)[11] == 0xFF) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewChild(sub_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)MANAGEMENTIPADDR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)inet_ntop(AF_INET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&(((uint32_t *)attr->value.ip)[3]),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buff, sizeof (buff)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewChild(sub_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)MANAGEMENTIPADDR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)inet_ntop(AF_INET6,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)attr->value.ip, buff, sizeof (buff)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ENTITY(ISNS_TIMESTAMP_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ui) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%u", attr->value.ui);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewChild(sub_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)ENTITYREGTIMESTAMP, (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ENTITY(ISNS_VERSION_RANGE_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ui) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewNode(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)PROTOCOLVERSIONRANGE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlAddChild(sub_node, subchild_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%u",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (attr->value.ui >> ISNS_VER_SHIFT) & ISNS_VERSION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subgrandchild_node = xmlNewChild(subchild_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)PROTOCOLMAXVERSION, (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subgrandchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%u", attr->value.ui & ISNS_VERSION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subgrandchild_node = xmlNewChild(subchild_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)PROTOCOLMINVERSION, (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subgrandchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &obj->attrs[ATTR_INDEX_ENTITY(ISNS_ENTITY_REG_PERIOD_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ui) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%u", attr->value.ui);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewChild(sub_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)REGISTRATIONPERIOD, (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successful */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_get_pg_info: callback for get_node_op
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine process matching portal group and returns ip address
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and port number for further portal processing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - matching portal group object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - lookup control data that was used for portal group look up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * returns portal ip address, port and group tag in look up control.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_get_pg_info(
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_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get pg portal ip address and port attributes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PG(ISNS_PG_PORTAL_IP_ADDR_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(lcp->data[1].ip, attr->value.ip, sizeof (in6_addr_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PG(ISNS_PG_PORTAL_PORT_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[2].ui = attr->value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PG(ISNS_PG_TAG_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[2] = attr->value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successful */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_get_portal_info: callback for get_node_op
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine process matching portal and add portal object info to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the node object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - matching portal object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - lookup control data that was used for portal look up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_get_portal_info(
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 xmlNodePtr n_node = (xmlNodePtr)lcp->data[2].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tag = lcp->id[2];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr sub_node, subchild_node, subgrandchild_node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char numbuf[32];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buff[INET6_ADDRSTRLEN + 1] = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL, (xmlChar *)PORTAL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get portal object attributes. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PORTAL(ISNS_PORTAL_IP_ADDR_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ip) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* convert the ipv6 to ipv4 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((int *)attr->value.ip)[0] == 0x00 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((int *)attr->value.ip)[1] == 0x00 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((uchar_t *)attr->value.ip)[8] == 0x00 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((uchar_t *)attr->value.ip)[9] == 0x00 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((uchar_t *)attr->value.ip)[10] == 0xFF &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((uchar_t *)attr->value.ip)[11] == 0xFF) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewChild(sub_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)IPADDR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)inet_ntop(AF_INET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&(((uint32_t *)attr->value.ip)[3]),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buff, sizeof (buff)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewChild(sub_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)IPADDR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)inet_ntop(AF_INET6,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)attr->value.ip, buff, sizeof (buff)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewChild(sub_node, NULL, (xmlChar *)UDPTCPPORT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subchild_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PORTAL(ISNS_PORTAL_PORT_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subgrandchild_node = xmlNewChild(subchild_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)PORTTYPE, IS_PORT_UDP(attr->value.ui) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)UDPPORT : (xmlChar *)TCPPORT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subgrandchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%u", PORT_NUMBER(attr->value.ui));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subgrandchild_node = xmlNewChild(subchild_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)PORTNUMBER, (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subgrandchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%u", tag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewChild(sub_node, NULL, (xmlChar *)GROUPTAG,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PORTAL(ISNS_PORTAL_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ptr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewChild(sub_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)SYMBOLICNAME, (xmlChar *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PORTAL(ISNS_ESI_INTERVAL_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ui) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%u", attr->value.ui);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewChild(sub_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)ESIINTERVAL, (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PORTAL(ISNS_ESI_PORT_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ui) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewChild(sub_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)ESIPORT, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subchild_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subgrandchild_node = xmlNewChild(subchild_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)PORTTYPE, IS_PORT_UDP(attr->value.ui) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)UDPPORT : (xmlChar *)TCPPORT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subgrandchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%u", PORT_NUMBER(attr->value.ui));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subgrandchild_node = xmlNewChild(subchild_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)PORTNUMBER, (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subgrandchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PORTAL(ISNS_SCN_PORT_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ui) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subchild_node = xmlNewChild(sub_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)SCNPORT, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subchild_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subgrandchild_node = xmlNewChild(subchild_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)PORTTYPE, IS_PORT_UDP(attr->value.ui) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)UDPPORT : (xmlChar *)TCPPORT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%u", PORT_NUMBER(attr->value.ui));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subgrandchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte subgrandchild_node = xmlNewChild(subchild_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)PORTNUMBER, (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (subgrandchild_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successful */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_get_dd_info: callback for get_dd_op
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine process matching dd object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - matching dd object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - lookup control data that was used for dd look up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_get_dd_info(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_obj, n_node, sub_node, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlAttrPtr n_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char numbuf[32];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddChild(root, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewNode(NULL, (xmlChar *)DDOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlAddChild(n_obj, n_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)NAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_ID_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%u", attr->value.ui);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)IDATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_FEATURES_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DD_BOOTLIST_ENABLED(attr->value.ui)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL, (xmlChar *)BOOTLISTENABLEDELEM,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)XMLTRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL, (xmlChar *)BOOTLISTENABLEDELEM,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)XMLFALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successful */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_get_ddset_info: callback for get_ddset_op
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine process matching dd object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - matching dds object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - lookup control data that was used for dd set look up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_get_ddset_info(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_obj, n_node, sub_node, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlAttrPtr n_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char numbuf[32];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddChild(root, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewNode(NULL, (xmlChar *)DDSETOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlAddChild(n_obj, n_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get node name, alias, type and generate xml info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)NAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_ID_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%u", attr->value.ui);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)IDATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_STATUS_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DDS_ENABLED(attr->value.ui)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL, (xmlChar *)ENABLEDELEM,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)XMLTRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL, (xmlChar *)ENABLEDELEM,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)XMLFALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successful */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_enumerate_node_info: callback for enumerate_node_op
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine is invoked for each node object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - node object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - lookup control data that was used for node look up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_enumerate_node_info(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_obj, n_node, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlAttrPtr n_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddChild(root, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewNode(NULL, (xmlChar *)NODEOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlAddChild(n_obj, n_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get node name, alias, type and generate xml info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)NAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_NODE_TYPE_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (attr->value.ui) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_CONTROL_NODE_TYPE | ISNS_INITIATOR_NODE_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)CONTROLNODEINITIATORTYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_CONTROL_NODE_TYPE | ISNS_TARGET_NODE_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)CONTROLNODETARGETTYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_TARGET_NODE_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)TARGETTYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_INITIATOR_NODE_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)INITIATORTYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_CONTROL_NODE_TYPE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)CONTROLNODETYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)UNKNOWNTYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_ALIAS_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)ALIASATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successful */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * i_enumerate_dd_dds_info:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine is implemnetation for enumerate dd and enumerate dds.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - dd or dd set object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - lookup control data that was used for dd and dd set look up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortei_enumerate_dd_dds_info(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t obj_type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_obj, n_node, sub_node, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlAttrPtr n_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char numbuf[32];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddChild(root, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj_type == OBJ_DD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewNode(NULL, (xmlChar *)DDOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewNode(NULL, (xmlChar *)DDSETOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlAddChild(n_obj, n_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj_type == OBJ_DD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get name, id, feaure and generate xml info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)NAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_ID_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%u", attr->value.ui);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)IDATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_FEATURES_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DD_BOOTLIST_ENABLED(attr->value.ui)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)BOOTLISTENABLEDELEM, (xmlChar *)XMLTRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)BOOTLISTENABLEDELEM, (xmlChar *)XMLFALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get name, id, status and generate xml info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)NAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_ID_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%u", attr->value.ui);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)IDATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_STATUS_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DDS_ENABLED(attr->value.ui)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)ENABLEDELEM, (xmlChar *)XMLTRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sub_node = xmlNewChild(n_node, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)ENABLEDELEM, (xmlChar *)XMLFALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sub_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successful */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_enumerate_dd_info: callback for enumerate_dd_op
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine is invoked for each dd object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - dd object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - lookup control data that was used for dd look up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_enumerate_dd_info(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (i_enumerate_dd_dds_info(p1, p2, OBJ_DD));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_enumerate_ddset_info: callback for enumerate_dd_op
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine is invoked for each dd object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - dd object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - lookup control data that was used for dd set look up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_enumerate_ddset_info(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (i_enumerate_dd_dds_info(p1, p2, OBJ_DDS));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_getAssociated_node_info:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine is implemnetation for enumerate dd and enumerate dds.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - dd or dd set object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - lookup control data that was used for dd and dd set look up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_getAssociated_node_info(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_obj, n_node, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlAttrPtr n_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *ddname = lcp->data[2].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ASSOCIATION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddChild(root, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewNode(NULL, (xmlChar *)DDOBJECTMEMBER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlAddChild(n_obj, n_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get node name, alias, type and generate xml info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)NODENAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)ddname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successful */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_getAssociated_node_to_dd_info:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine is implemnetation for enumerate dd and enumerate dds.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - dd or dd set object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - lookup control data that was used for dd and dd set look up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_getAssociated_node_to_dd_info(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_obj, n_node, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlAttrPtr n_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *nodename = lcp->data[2].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ASSOCIATION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddChild(root, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewNode(NULL, (xmlChar *)DDOBJECTMEMBER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlAddChild(n_obj, n_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get node name, alias, type and generate xml info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)NODENAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)nodename);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successful */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_getAssociated_dd_info:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine is implemnetation for getting dds membership.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - dd or dd set object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - lookup control data that was used for dd and dd set look up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_getAssociated_dd_info(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_obj, n_node, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlAttrPtr n_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *ddsetname = lcp->data[2].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ASSOCIATION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddChild(root, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewNode(NULL, (xmlChar *)DDSETOBJECTMEMBER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlAddChild(n_obj, n_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get node name, alias, type and generate xml info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)DDSETNAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)ddsetname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successful */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_getAssociated_dd_to_ddset_info:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine is implemnetation for enumerate dd and enumerate dds.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - dd or dd set object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - lookup control data that was used for dd and dd set look up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_getAssociated_dd_to_ddset_info(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_obj, n_node, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlAttrPtr n_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *ddname = lcp->data[2].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ASSOCIATION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddChild(root, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewNode(NULL, (xmlChar *)DDSETOBJECTMEMBER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlAddChild(n_obj, n_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get node name, alias, type and generate xml info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)ddname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)DDSETNAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successful */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * handle_partial_success:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ret - return code from the caller.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortehandle_partial_success(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_obj, n_node, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char numbuf[32];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)RESULTELEMENT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root->children) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddPrevSibling(root->children, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%d", (ret != 0) ? PARTIAL_SUCCESS : 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewChild(n_obj, NULL, (xmlChar *)STATUSELEMENT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewChild(n_obj, NULL, (xmlChar *)MESSAGEELEMENT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)result_code_to_str((ret != 0) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PARTIAL_SUCCESS : 0));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddChild(root, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%d", ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewChild(n_obj, NULL, (xmlChar *)STATUSELEMENT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewChild(n_obj, NULL, (xmlChar *)MESSAGEELEMENT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)result_code_to_str(ret));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * handle_partial_failure:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ret - return code from the caller.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortehandle_partial_failure(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t all_failed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_obj, n_node, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char numbuf[32];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)RESULTELEMENT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root->children) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* some or all associations failed to create */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddPrevSibling(root->children, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* capture last error. should come up with all failed?? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte all_failed ? ret : PARTIAL_FAILURE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewChild(n_obj, NULL, (xmlChar *)STATUSELEMENT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewChild(n_obj, NULL, (xmlChar *)MESSAGEELEMENT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)result_code_to_str(all_failed ? ret :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PARTIAL_FAILURE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddChild(root, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%d", (ret != 0) ? ret : 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewChild(n_obj, NULL, (xmlChar *)STATUSELEMENT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)numbuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = xmlNewChild(n_obj, NULL, (xmlChar *)MESSAGEELEMENT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)result_code_to_str((ret != 0) ? ret : 0));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_serverconfig_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The routine process server administrative setting.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_serverconfig_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte extern uint64_t esi_threshold;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte extern uint8_t mgmt_scn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte extern ctrl_node_t *control_nodes;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte extern pthread_mutex_t ctrl_node_mtx;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte extern char data_store[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_obj, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char numbuf[32];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ctrl_node_t *ctrl_node_p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ISNSSERVER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddChild(root, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlNewChild(n_obj, NULL, (xmlChar *)DATASTORELOCATION,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)data_store) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(numbuf, "%llu", esi_threshold);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlNewChild(n_obj, NULL, (xmlChar *)ESIRETRYTHRESHOLD,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)numbuf) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlNewChild(n_obj, NULL, (xmlChar *)MANAGEMENTSCNENABLED,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (mgmt_scn) ? (uchar_t *)XMLTRUE : (uchar_t *)XMLFALSE) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&ctrl_node_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (control_nodes == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlNewChild(n_obj, NULL, (xmlChar *)CONTROLNODENAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)NULL) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&ctrl_node_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ctrl_node_p = control_nodes;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ctrl_node_p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlNewChild(n_obj, NULL, (xmlChar *)CONTROLNODENAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)ctrl_node_p->name) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&ctrl_node_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ctrl_node_p = ctrl_node_p->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&ctrl_node_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_success(doc, ret));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_node_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * service get operation on a given node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains all info for a request.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_node_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret = 0, ret_save = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc, lc2, lc3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buff2[INET6_ADDRSTRLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup ctrl data for looking for the node object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = get_lc_type(req->op_info.obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = get_lc_id(req->op_info.obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ptr = (uchar_t *)doc; /* xml writer descriptor */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < req->count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_lookup(&lc, &uid, cb_get_node_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_MATCHING_ISCSI_NODE_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* generate network entity object information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret == 0 && lc.id[2] != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * !!! there might be no entity and portal info for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * !!! the node if it is not a registered node
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup ctrl data for looking for entity */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc2, OBJ_ENTITY, lc.id[2]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[1].ptr = (uchar_t *)doc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cb_get_node_info callback returned Node object. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[2].ptr = lc.data[2].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_lookup(&lc2, &uid, cb_get_entity_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_MATCHING_NETWORK_ENTITY_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* generate portal information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret == 0 && lc.id[2] != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup ctrl data for looking for pg */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.type = OBJ_PG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.id[0] = ATTR_INDEX_PG(ISNS_PG_ISCSI_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* lc.data[0].ptr contains node name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[0].ptr = lc.data[0].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[1].ip = (in6_addr_t *)buff2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup ctrl data for looking for portal */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc3.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc3.type = OBJ_PORTAL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc3.id[0] = ATTR_INDEX_PORTAL(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PORTAL_IP_ADDR_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc3.op[0] = OP_MEMORY_IP6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc3.id[1] = ATTR_INDEX_PORTAL(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PORTAL_PORT_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc3.op[1] = OP_INTEGER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc3.op[2] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cb_get_node_info callback returned Node object. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc3.data[2].ptr = lc.data[2].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (;;) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_lookup(&lc2, &uid, cb_get_pg_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we found a portal group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.curr_uid = uid;
5fbbe9c6367b156920d72becff64235e6274db32wl /* it is a null pg if pgt is zero. */
5fbbe9c6367b156920d72becff64235e6274db32wl if (lc2.id[2] != 0) {
5fbbe9c6367b156920d72becff64235e6274db32wl /* pass ip addr */
5fbbe9c6367b156920d72becff64235e6274db32wl lc3.data[0].ip = lc2.data[1].ip;
5fbbe9c6367b156920d72becff64235e6274db32wl /* pass port num */
5fbbe9c6367b156920d72becff64235e6274db32wl lc3.data[1].ui = lc2.data[2].ui;
5fbbe9c6367b156920d72becff64235e6274db32wl /* pass pgt */
5fbbe9c6367b156920d72becff64235e6274db32wl lc3.id[2] = lc2.id[2];
5fbbe9c6367b156920d72becff64235e6274db32wl ret = cache_lookup(&lc3, &uid,
5fbbe9c6367b156920d72becff64235e6274db32wl cb_get_portal_info);
5fbbe9c6367b156920d72becff64235e6274db32wl }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * no more portal group which is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tied to this stroage node object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save error for this iteration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_success(doc, ret_save));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * i_get_dd_dds_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * serves get operatrion on dd or dds.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains all info for a request.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj_type - object type(either dd or dd set)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortei_get_dd_dds_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t obj_type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result_code_t ret = 0, ret_save = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((obj_type != OBJ_DD) && (obj_type != OBJ_DDS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_INVALID_MGMT_REQUEST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup ctrl data for looking for the node object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = obj_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = get_lc_id(req->op_info.obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ptr = (uchar_t *)doc; /* xml writer descriptor */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < req->count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj_type == OBJ_DD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_lookup(&lc, &uid, cb_get_dd_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set an error and continue. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_MATCHING_DD_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_lookup(&lc, &uid, cb_get_ddset_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set an error and continue. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_MATCHING_DDSET_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save error for this iteration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_success(doc, ret_save));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * i_delete_ddmember_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * serves delete member operatrion on dd.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * container - dd name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * member - node name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortei_delete_ddmember_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *container,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *member
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_assoc_iscsi_t aiscsi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *assoc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dd_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup ctrl data for looking for the dd object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = OBJ_DD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = container;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dd_id = is_obj_there(&lc)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aiscsi.type = OBJ_ASSOC_ISCSI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aiscsi.puid = dd_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = strlen((char *)member) + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len += 4 - (len % 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &aiscsi.attrs[ATTR_INDEX_ASSOC_ISCSI(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DD_ISCSI_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = ISNS_DD_ISCSI_NAME_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ptr = (uchar_t *)member;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &aiscsi.attrs[ATTR_INDEX_ASSOC_ISCSI(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DD_ISCSI_INDEX_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = 0; /* clear it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assoc = (isns_obj_t *)&aiscsi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = remove_dd_member(assoc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_MATCHING_DD_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * i_delete_ddsetmember_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * serves delete member operatrion on dd set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * container - dd set name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * member - dd name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortei_delete_ddsetmember_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *container,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *member
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc, lc2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t container_id, member_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup ctrl data for looking for the dd-set object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = OBJ_DDS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = container;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup ctrl data for looking for the dd object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.type = OBJ_DD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.id[0] = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[0].ptr = member;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((container_id = is_obj_there(&lc)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((member_id = is_obj_there(&lc2)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = remove_dds_member(container_id, member_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_MATCHING_DD_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_MATCHING_DDSET_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_dd_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * service get operation on given dd(s).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains all info for a request.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_dd_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (i_get_dd_dds_op(req, doc, OBJ_DD));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_ddset_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * service get operation on given dd set(s).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains all info for a request.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_ddset_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (i_get_dd_dds_op(req, doc, OBJ_DDS));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * enumerate_node_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * services enumerate node op.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains enumerate request info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteenumerate_node_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte htab_t *htab = cache_get_htab(OBJ_ISCSI);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret = 0, ret_save = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_ISCSI, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ptr = (uchar_t *)doc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[2].ui = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_ITEM(htab, uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ui = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_lookup(&lc, NULL, cb_enumerate_node_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_success(doc, ret_save));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * enumerate_dd_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * services enumerate discovery domain op.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains enumerate request info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteenumerate_dd_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte htab_t *htab = cache_get_htab(OBJ_DD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret = 0, ret_save = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_DD, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ptr = (uchar_t *)doc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[2].ui = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_ITEM(htab, uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ui = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_lookup(&lc, NULL, cb_enumerate_dd_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_success(doc, ret_save));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * enumerate_ddset_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * services enumerate discovery domain set op.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains enumerate request info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteenumerate_ddset_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte htab_t *htab = cache_get_htab(OBJ_DDS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret = 0, ret_save = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_DDS, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ptr = (uchar_t *)doc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[2].ui = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_ITEM(htab, uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ui = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_lookup(&lc, NULL, cb_enumerate_ddset_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_success(doc, ret_save));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * getassociated_dd_to_node_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * construct a list of node that is associated with a given Discovery
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Domain.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains getAssociated request info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetAssociated_dd_to_node_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = 0, n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc, lc2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0, ret = 0, ret_save = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = OBJ_DD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc2, OBJ_ISCSI, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[1].ptr = (uchar_t *)doc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < req->count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((uid = is_obj_there(&lc)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = get_dd_matrix(uid, &p, &n);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_MEMBER(p, n, uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[0].ui = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[2].ptr = (uchar_t *)req->req_data.data[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_lookup(&lc2, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cb_getAssociated_node_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_MATCHING_DD_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save error for this iteration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_success(doc, ret_save));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * getassociated_node_to_dd_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * construct a list of Discovery Doamins that is associated with a given
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains getAssociated request info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetAssociated_node_to_dd_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = 0, dd_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc, lc2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0, ret = 0, ret_save = 0;
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.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc2, OBJ_DD, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[1].ptr = (uchar_t *)doc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < req->count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((uid = is_obj_there(&lc)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dd_id = get_dd_id(uid, 0)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_NO_ASSOCIATED_DD_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[0].ui = dd_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[2].ptr = (uchar_t *)req->req_data.data[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_lookup(&lc2, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cb_getAssociated_node_to_dd_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd_id = get_dd_id(uid, dd_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (dd_id != 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_MATCHING_NODE_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save error for this iteration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_success(doc, ret_save));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * getassociated_ddset_to_dd_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * construct a list of Discovery Doamins that is associated with a given
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Discover Domain set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains getAssociated request info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetAssociated_ddset_to_dd_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = 0, n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc, lc2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0, ret = 0, ret_save = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = OBJ_DDS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc2, OBJ_DD, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[1].ptr = (uchar_t *)doc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < req->count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((uid = is_obj_there(&lc)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = get_dds_matrix(uid, &p, &n);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_MEMBER(p, n, uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[0].ui = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[2].ptr = (uchar_t *)req->req_data.data[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_lookup(&lc2, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cb_getAssociated_dd_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_MATCHING_DDSET_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save error for this iteration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_success(doc, ret_save));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * getassociated_dd_to_ddset_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * construct a list of Discovery Doamin sets that is associated with a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * given Discovery Domain.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains getAssociated request info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetAssociated_dd_to_ddset_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid = 0, ddset_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc, lc2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0, ret = 0, ret_save = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = OBJ_DD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc2, OBJ_DDS, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[1].ptr = (uchar_t *)doc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < req->count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((uid = is_obj_there(&lc)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[2].ui = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ddset_id = get_dds_id(uid, 0)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_NO_ASSOCIATED_DDSET_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[0].ui = ddset_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[2].ptr = (uchar_t *)req->req_data.data[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_lookup(&lc2, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cb_getAssociated_dd_to_ddset_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ddset_id = get_dds_id(uid, ddset_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (ddset_id != 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_MATCHING_DD_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_success(doc, ret_save));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * delete_dd_ddset_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * removes a list of dd or dd set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains delete request info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj_type - object type(either dd or dd set)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedelete_dd_ddset_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object_type type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result_code_t ret = 0, ret_save = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t lc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0, err_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_obj, n_node, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlAttrPtr n_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int different_err = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc_type = get_lc_type(type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((lc_type != OBJ_DD) && (lc_type != OBJ_DDS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_INVALID_MGMT_REQUEST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup ctrl data for looking for the node object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = lc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = get_lc_id(req->op_info.obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ptr = (uchar_t *)doc; /* xml writer descriptor */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < req->count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* lock the cache for writing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_lock_write();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((uid = is_obj_there(&lc)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove the dd/ddset */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = (lc_type == OBJ_DD) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte remove_dd_object(uid) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte remove_dds_object(uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock the cache and sync the data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_unlock_sync(ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock the cache and no need to sync data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_unlock_nosync();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set an error and continue. */
5fbbe9c6367b156920d72becff64235e6274db32wl ret = (lc_type == OBJ_DD) ? ERR_MATCHING_DD_NOT_FOUND :
5fbbe9c6367b156920d72becff64235e6274db32wl ERR_MATCHING_DDSET_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* keep track if there are different errors encountered. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret_save != 0 && ret != ret_save) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte different_err++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((n_obj = xmlAddChild(root, n_obj)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = (lc_type == OBJ_DD) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNewNode(NULL, (xmlChar *)DDOBJECT) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNewNode(NULL, (xmlChar *)DDSETOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((n_node = xmlAddChild(n_obj, n_node)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)NAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)req->req_data.data[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_failure(doc, ret_save,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (req->count == err_count && !different_err) ? B_TRUE : B_FALSE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * delete_ddmember_ddsetmember_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * removes a list of dd memeber or dd seti member.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains delete request info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type - object type(either dd or dd set)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedelete_ddmember_ddsetmember_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object_type type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result_code_t ret = 0, ret_save = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t lc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0, err_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc, lc2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t container_id, member_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_node, n_obj, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlAttrPtr n_attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int different_err = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int is_a_member;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc_type = get_lc_type(type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((lc_type != OBJ_DD) && (lc_type != OBJ_DDS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_INVALID_MGMT_REQUEST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup ctrl data for looking for the node object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = lc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = get_lc_id(req->op_info.obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lc_type == OBJ_DD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.type = OBJ_ISCSI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.id[0] = ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.type = OBJ_DD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.id[0] = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < req->count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = (uchar_t *)req->req_data.pair[i]->container;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the dd_id/dds_id */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_lock_write();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte container_id = is_obj_there(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (container_id != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[0].ptr = (uchar_t *)req->req_data.pair[i]->member;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte member_id = is_obj_there(&lc2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (member_id != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte is_a_member =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (container_id ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((lc_type == OBJ_DD) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte get_dd_id(member_id, container_id - 1) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte get_dds_id(member_id, container_id - 1)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (member_id != 0 && is_a_member != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* delete the dd member */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = (lc_type == OBJ_DD) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i_delete_ddmember_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)req->req_data.pair[i]->container,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)req->req_data.pair[i]->member) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i_delete_ddsetmember_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)req->req_data.pair[i]->container,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)req->req_data.pair[i]->member);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock the cache and sync the data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_unlock_sync(ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock the cache and no need to sync */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_unlock_nosync();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_NO_SUCH_ASSOCIATION;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock the cache and no need to sync */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_unlock_nosync();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = (lc_type == OBJ_DD) ? ERR_MATCHING_DD_NOT_FOUND :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ERR_MATCHING_DDSET_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* keep track if there are different errors encountered. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret_save != 0 && ret != ret_save) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte different_err++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ASSOCIATION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddChild(root, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lc_type == OBJ_DD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNewNode(NULL, (xmlChar *)DDOBJECTMEMBER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)NODENAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)req->req_data.pair[i]->member);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)req->req_data.pair[i]->container);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNewNode(NULL, (xmlChar *)DDSETOBJECTMEMBER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)req->req_data.pair[i]->member);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_attr = xmlSetProp(n_node, (xmlChar *)DDSETNAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)req->req_data.pair[i]->container);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_attr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlAddChild(n_obj, n_node) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_failure(doc, ret_save,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (req->count == err_count && !different_err) ? B_TRUE : B_FALSE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create_ddmember_ddsetmember_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * removes a list of dd memeber or dd seti member.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains delete request info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type - object type(either dd or dd set)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecreate_ddmember_ddsetmember_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object_type type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result_code_t ret = 0, ret_save = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t lc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0, err_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc, lc2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t container_id, member_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_node, n_obj, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_assoc_iscsi_t aiscsi = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_assoc_dd_t add = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *assoc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int different_err = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc_type = get_lc_type(type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((lc_type != OBJ_DD) && (lc_type != OBJ_DDS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_INVALID_MGMT_REQUEST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup ctrl data for looking for the node object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = lc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = get_lc_id(req->op_info.obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lc_type == OBJ_DD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.type = OBJ_ISCSI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.id[0] = ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.type = OBJ_DD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.id[0] = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < req->count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = (uchar_t *)req->req_data.pair[i]->container;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the dd_id/dds_id */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_lock_write();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte container_id = is_obj_there(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (container_id != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&aiscsi, 0, sizeof (aiscsi));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lc_type == OBJ_DD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aiscsi.puid = container_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aiscsi.type = OBJ_ASSOC_ISCSI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &aiscsi.attrs[ATTR_INDEX_ASSOC_ISCSI(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DD_ISCSI_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = ISNS_DD_ISCSI_NAME_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = xmlStrlen(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)req->req_data.pair[i]->member) + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len += 4 - (len % 4); /* on 4 bytes aligned */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ptr =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)req->req_data.pair[i]->member;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assoc = (isns_obj_t *)&aiscsi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* add the dd member */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = add_dd_member(assoc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock the cache and sync the data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_unlock_sync(ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc2.data[0].ptr =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)req->req_data.pair[i]->member;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((member_id = is_obj_there(&lc2)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte add.puid = container_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte add.type = OBJ_ASSOC_DD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &add.attrs[ATTR_INDEX_ASSOC_DD(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DD_ID_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = ISNS_DD_ID_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = member_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assoc = (isns_obj_t *)&add;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* add the dd-set member */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = add_dds_member(assoc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock the cache and sync the data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_unlock_sync(ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock the cache and no need to sync */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_unlock_nosync();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_MATCHING_DD_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock the cache and no need to sync */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_unlock_nosync();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = (lc_type == OBJ_DD) ? ERR_MATCHING_DD_NOT_FOUND :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ERR_MATCHING_DDSET_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* keep track if there are different errors encountered. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret_save != 0 && ret != ret_save) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte different_err++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ASSOCIATION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlAddChild(root, n_obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lc_type == OBJ_DD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNewNode(NULL, (xmlChar *)DDOBJECTMEMBER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlSetProp(n_node, (xmlChar *)NODENAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)req->req_data.pair[i]->member) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)req->req_data.pair[i]->container) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNewNode(NULL, (xmlChar *)DDSETOBJECTMEMBER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)req->req_data.pair[i]->member) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlSetProp(n_node, (xmlChar *)DDSETNAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)req->req_data.pair[i]->container) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlAddChild(n_obj, n_node) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_failure(doc, ret_save,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (req->count == err_count && !different_err) ? B_TRUE : B_FALSE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rename_dd_ddset_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * removes a list of dd memeber or dd seti member.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains delete request info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type - object type(either dd or dd set)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterename_dd_ddset_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object_type type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result_code_t ret = 0, ret_save = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t lc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0, err_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t container_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_node, n_obj, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int different_err = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc_type = get_lc_type(type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((lc_type != OBJ_DD) && (lc_type != OBJ_DDS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_INVALID_MGMT_REQUEST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup ctrl data for looking for the node object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, lc_type, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < req->count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* id is checked to be not NULL before calling this routine. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ui = *(req->req_data.attrlist[i]->id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the dd_id/dds_id */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_lock_write();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((container_id = is_obj_there(&lc)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = (uchar_t *)req->req_data.attrlist[i]->name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the length of the name need to include the */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* null terminator and be on 4 bytes aligned */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = xmlStrlen(name) + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len += 4 - (len % 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* rename the dd/dds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = (lc_type == OBJ_DD) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte update_dd_name(container_id, len, name) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte update_dds_name(container_id, len, name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* release the lock and sync the data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_unlock_sync(ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* release the lock and no need to sync */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_unlock_nosync();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = (lc_type == OBJ_DD) ? ERR_MATCHING_DD_NOT_FOUND :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ERR_MATCHING_DDSET_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* keep track if there are different errors encountered. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret_save != 0 && ret != ret_save) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte different_err++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((n_obj = xmlAddChild(root, n_obj)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = (lc_type == OBJ_DD) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNewNode(NULL, (xmlChar *)DDOBJECT) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNewNode(NULL, (xmlChar *)DDSETOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((n_node = xmlAddChild(n_obj, n_node)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlSetProp(n_node, (xmlChar *)NAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)req->req_data.attrlist[i]->name) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_failure(doc, ret_save,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (req->count == err_count && !different_err) ? B_TRUE : B_FALSE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * update_dd_ddset_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * removes a list of dd memeber or dd seti member.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains delete request info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type - object type(either dd or dd set)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_dd_ddset_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object_type type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result_code_t ret = 0, ret_save = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t lc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0, err_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t container_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_node, n_obj, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int different_err = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc_type = get_lc_type(type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((lc_type != OBJ_DD) && (lc_type != OBJ_DDS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_INVALID_MGMT_REQUEST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup ctrl data for looking for the node object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = lc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = get_lc_id(req->op_info.obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < req->count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = req->req_data.attrlist[i]->name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* lock the cache for writing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_lock_write();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((container_id = is_obj_there(&lc)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = (lc_type == OBJ_DD) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* enabled is checked to be not NULL before calling. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte update_dd_features(container_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *(req->req_data.attrlist[i]->enabled) ? 1 : 0):
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte update_dds_status(container_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *(req->req_data.attrlist[i]->enabled) ? 1 : 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock the cache and sync the data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_unlock_sync(ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_unlock_nosync();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = (lc_type == OBJ_DD) ? ERR_MATCHING_DD_NOT_FOUND :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ERR_MATCHING_DDSET_NOT_FOUND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* keep track if there are different errors encountered. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret_save != 0 && ret != ret_save) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte different_err++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((n_obj = xmlAddChild(root, n_obj)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = (lc_type == OBJ_DD) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNewNode(NULL, (xmlChar *)DDOBJECT) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNewNode(NULL, (xmlChar *)DDSETOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((n_node = xmlAddChild(n_obj, n_node)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlSetProp(n_node, (xmlChar *)NAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)req->req_data.attrlist[i]->name) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_failure(doc, ret_save,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (req->count == err_count && !different_err) ? B_TRUE : B_FALSE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * createModify_dd_ddset_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * removes a list of dd memeber or dd seti member.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains delete request info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecreate_dd_ddset_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object_type type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result_code_t ret = 0, ret_save = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t lc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0, err_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr n_obj, n_node, root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int different_err = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc_type = get_lc_type(type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((lc_type != OBJ_DD) && (lc_type != OBJ_DDS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_INVALID_MGMT_REQUEST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_SYNTAX_MISSING_ROOT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc_type = get_lc_type(type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((lc_type != OBJ_DD) && (lc_type != OBJ_DDS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_INVALID_MGMT_REQUEST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare lookup ctrl data for looking for the node object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = lc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = get_lc_id(req->op_info.obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ptr = (uchar_t *)doc; /* xml writer descriptor */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < req->count) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = req->req_data.attrlist[i]->name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* grab the write lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_lock_write();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = is_obj_there(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = (lc_type == OBJ_DD) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adm_create_dd(&obj, req->req_data.attrlist[i]->name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, 0) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adm_create_dds(&obj, req->req_data.attrlist[i]->name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = register_object(obj, NULL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_object(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* release the lock and sync the cache and data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = cache_unlock_sync(ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* release the lock and no need to sync the data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_unlock_nosync();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ERR_NAME_IN_USE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* keep track if there are different errors encountered. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret_save != 0 && ret != ret_save) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte different_err++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret_save = ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_obj) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((n_obj = xmlAddChild(root, n_obj)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n_node = (lc_type == OBJ_DD) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNewNode(NULL, (xmlChar *)DDOBJECT) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNewNode(NULL, (xmlChar *)DDSETOBJECT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n_node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((n_node = xmlAddChild(n_obj, n_node)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_ADDCHILD_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlSetProp(n_node, (xmlChar *)NAMEATTR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)req->req_data.attrlist[i]->name) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_SETPROP_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ERR_XML_NEWNODE_FAILED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (handle_partial_failure(doc, ret_save,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (req->count == err_count && !different_err) ? B_TRUE : B_FALSE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * createModify_dd_ddset_op:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * removes a list of dd memeber or dd seti member.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * req - contains delete request info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - response doc to fill up
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortecreateModify_dd_ddset_op(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte request_t *req,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* any additional arguments go here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result_code_t ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (req->req_data.attrlist[0]->id != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = rename_dd_ddset_op(req, doc, req->op_info.obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (req->req_data.attrlist[0]->enabled != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = update_dd_ddset_op(req, doc, req->op_info.obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = create_dd_ddset_op(req, doc, req->op_info.obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}