17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM * CDDL HEADER START
37836SJohn.Forte@Sun.COM *
47836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM *
87836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM * and limitations under the License.
127836SJohn.Forte@Sun.COM *
137836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM *
197836SJohn.Forte@Sun.COM * CDDL HEADER END
207836SJohn.Forte@Sun.COM */
217836SJohn.Forte@Sun.COM
227836SJohn.Forte@Sun.COM /*
23*8854Swl202157@icefox * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
247836SJohn.Forte@Sun.COM * Use is subject to license terms.
257836SJohn.Forte@Sun.COM */
267836SJohn.Forte@Sun.COM
277836SJohn.Forte@Sun.COM #include <stdio.h>
287836SJohn.Forte@Sun.COM #include <stdlib.h>
297836SJohn.Forte@Sun.COM #include <string.h>
307836SJohn.Forte@Sun.COM #include <libxml/xmlreader.h>
317836SJohn.Forte@Sun.COM #include <libxml/xmlwriter.h>
327836SJohn.Forte@Sun.COM #include <libxml/tree.h>
337836SJohn.Forte@Sun.COM #include <sys/types.h>
347836SJohn.Forte@Sun.COM #include <sys/socket.h>
357836SJohn.Forte@Sun.COM #include <netinet/in.h>
367836SJohn.Forte@Sun.COM #include <arpa/inet.h>
377836SJohn.Forte@Sun.COM #include <pthread.h>
387836SJohn.Forte@Sun.COM
397836SJohn.Forte@Sun.COM #include "isns_server.h"
407836SJohn.Forte@Sun.COM #include "isns_cfg.h"
417836SJohn.Forte@Sun.COM #include "isns_htab.h"
427836SJohn.Forte@Sun.COM #include "isns_cache.h"
437836SJohn.Forte@Sun.COM #include "isns_obj.h"
447836SJohn.Forte@Sun.COM #include "isns_dd.h"
457836SJohn.Forte@Sun.COM #include "isns_utils.h"
467836SJohn.Forte@Sun.COM #include "isns_mgmt.h"
477836SJohn.Forte@Sun.COM #include "isns_protocol.h"
487836SJohn.Forte@Sun.COM #include "admintf.h"
497836SJohn.Forte@Sun.COM
507836SJohn.Forte@Sun.COM extern const int UID_ATTR_INDEX[MAX_OBJ_TYPE_FOR_SIZE];
517836SJohn.Forte@Sun.COM
527836SJohn.Forte@Sun.COM static isns_type_t
get_lc_type(object_type obj)537836SJohn.Forte@Sun.COM get_lc_type(
547836SJohn.Forte@Sun.COM object_type obj
557836SJohn.Forte@Sun.COM )
567836SJohn.Forte@Sun.COM {
577836SJohn.Forte@Sun.COM isns_type_t type;
587836SJohn.Forte@Sun.COM
597836SJohn.Forte@Sun.COM switch (obj) {
607836SJohn.Forte@Sun.COM case Node:
617836SJohn.Forte@Sun.COM type = OBJ_ISCSI;
627836SJohn.Forte@Sun.COM break;
637836SJohn.Forte@Sun.COM case DiscoveryDomain:
647836SJohn.Forte@Sun.COM case DiscoveryDomainMember:
657836SJohn.Forte@Sun.COM type = OBJ_DD;
667836SJohn.Forte@Sun.COM break;
677836SJohn.Forte@Sun.COM case DiscoveryDomainSet:
687836SJohn.Forte@Sun.COM case DiscoveryDomainSetMember:
697836SJohn.Forte@Sun.COM type = OBJ_DDS;
707836SJohn.Forte@Sun.COM break;
717836SJohn.Forte@Sun.COM default:
727836SJohn.Forte@Sun.COM ASSERT(0);
737836SJohn.Forte@Sun.COM break;
747836SJohn.Forte@Sun.COM }
757836SJohn.Forte@Sun.COM
767836SJohn.Forte@Sun.COM return (type);
777836SJohn.Forte@Sun.COM }
787836SJohn.Forte@Sun.COM
797836SJohn.Forte@Sun.COM static uint32_t
get_lc_id(object_type obj)807836SJohn.Forte@Sun.COM get_lc_id(
817836SJohn.Forte@Sun.COM object_type obj
827836SJohn.Forte@Sun.COM )
837836SJohn.Forte@Sun.COM {
847836SJohn.Forte@Sun.COM uint32_t id;
857836SJohn.Forte@Sun.COM
867836SJohn.Forte@Sun.COM switch (obj) {
877836SJohn.Forte@Sun.COM case Node:
887836SJohn.Forte@Sun.COM id = ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID);
897836SJohn.Forte@Sun.COM break;
907836SJohn.Forte@Sun.COM case DiscoveryDomain:
917836SJohn.Forte@Sun.COM case DiscoveryDomainMember:
927836SJohn.Forte@Sun.COM id = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
937836SJohn.Forte@Sun.COM break;
947836SJohn.Forte@Sun.COM case DiscoveryDomainSet:
957836SJohn.Forte@Sun.COM case DiscoveryDomainSetMember:
967836SJohn.Forte@Sun.COM id = ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID);
977836SJohn.Forte@Sun.COM break;
987836SJohn.Forte@Sun.COM default:
997836SJohn.Forte@Sun.COM ASSERT(0);
1007836SJohn.Forte@Sun.COM break;
1017836SJohn.Forte@Sun.COM }
1027836SJohn.Forte@Sun.COM
1037836SJohn.Forte@Sun.COM return (id);
1047836SJohn.Forte@Sun.COM }
1057836SJohn.Forte@Sun.COM
1067836SJohn.Forte@Sun.COM /*
1077836SJohn.Forte@Sun.COM * ****************************************************************************
1087836SJohn.Forte@Sun.COM *
1097836SJohn.Forte@Sun.COM * cb_get_node_info: callback for get_node_op
1107836SJohn.Forte@Sun.COM * The routine process matching node and add a Node object elements
1117836SJohn.Forte@Sun.COM * to the response doc.
1127836SJohn.Forte@Sun.COM *
1137836SJohn.Forte@Sun.COM * p1 - matching node object
1147836SJohn.Forte@Sun.COM * p2 - lookup control data that was used for node look up
1157836SJohn.Forte@Sun.COM * returns parent index(newtork entity) in look up control.
1167836SJohn.Forte@Sun.COM * return - error code
1177836SJohn.Forte@Sun.COM *
1187836SJohn.Forte@Sun.COM * ****************************************************************************
1197836SJohn.Forte@Sun.COM */
1207836SJohn.Forte@Sun.COM static int
cb_get_node_info(void * p1,void * p2)1217836SJohn.Forte@Sun.COM cb_get_node_info(
1227836SJohn.Forte@Sun.COM void *p1,
1237836SJohn.Forte@Sun.COM void *p2
1247836SJohn.Forte@Sun.COM )
1257836SJohn.Forte@Sun.COM {
1267836SJohn.Forte@Sun.COM xmlNodePtr n_obj, n_node, sub_node, root;
1277836SJohn.Forte@Sun.COM xmlAttrPtr n_attr;
1287836SJohn.Forte@Sun.COM isns_attr_t *attr;
1297836SJohn.Forte@Sun.COM
1307836SJohn.Forte@Sun.COM isns_obj_t *obj = (isns_obj_t *)p1;
1317836SJohn.Forte@Sun.COM lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
1327836SJohn.Forte@Sun.COM xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
1337836SJohn.Forte@Sun.COM
1347836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
1357836SJohn.Forte@Sun.COM if (root == NULL) {
1367836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
1377836SJohn.Forte@Sun.COM }
1387836SJohn.Forte@Sun.COM
1397836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
1407836SJohn.Forte@Sun.COM if (n_obj) {
1417836SJohn.Forte@Sun.COM n_obj = xmlAddChild(root, n_obj);
1427836SJohn.Forte@Sun.COM if (n_obj == NULL) {
1437836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
1447836SJohn.Forte@Sun.COM }
1457836SJohn.Forte@Sun.COM } else {
1467836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
1477836SJohn.Forte@Sun.COM }
1487836SJohn.Forte@Sun.COM
1497836SJohn.Forte@Sun.COM n_node = xmlNewNode(NULL, (xmlChar *)NODEOBJECT);
1507836SJohn.Forte@Sun.COM if (n_node) {
1517836SJohn.Forte@Sun.COM n_node = xmlAddChild(n_obj, n_node);
1527836SJohn.Forte@Sun.COM if (n_node == NULL) {
1537836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
1547836SJohn.Forte@Sun.COM }
1557836SJohn.Forte@Sun.COM } else {
1567836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
1577836SJohn.Forte@Sun.COM }
1587836SJohn.Forte@Sun.COM
1597836SJohn.Forte@Sun.COM /* get node name, alias, type and generate xml info */
1607836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID)];
1617836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)NAMEATTR,
1627836SJohn.Forte@Sun.COM (xmlChar *)attr->value.ptr);
1637836SJohn.Forte@Sun.COM if (n_attr == NULL) {
1647836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
1657836SJohn.Forte@Sun.COM }
1667836SJohn.Forte@Sun.COM
1677836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_NODE_TYPE_ATTR_ID)];
1687836SJohn.Forte@Sun.COM switch (attr->value.ui) {
1697836SJohn.Forte@Sun.COM case ISNS_CONTROL_NODE_TYPE | ISNS_INITIATOR_NODE_TYPE:
1707836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
1717836SJohn.Forte@Sun.COM (xmlChar *)CONTROLNODEINITIATORTYPE);
1727836SJohn.Forte@Sun.COM break;
1737836SJohn.Forte@Sun.COM case ISNS_CONTROL_NODE_TYPE | ISNS_TARGET_NODE_TYPE:
1747836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
1757836SJohn.Forte@Sun.COM (xmlChar *)CONTROLNODETARGETTYPE);
1767836SJohn.Forte@Sun.COM break;
1777836SJohn.Forte@Sun.COM case ISNS_TARGET_NODE_TYPE:
1787836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
1797836SJohn.Forte@Sun.COM (xmlChar *)TARGETTYPE);
1807836SJohn.Forte@Sun.COM break;
1817836SJohn.Forte@Sun.COM case ISNS_INITIATOR_NODE_TYPE:
1827836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
1837836SJohn.Forte@Sun.COM (xmlChar *)INITIATORTYPE);
1847836SJohn.Forte@Sun.COM break;
1857836SJohn.Forte@Sun.COM case ISNS_CONTROL_NODE_TYPE:
1867836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
1877836SJohn.Forte@Sun.COM (xmlChar *)CONTROLNODETYPE);
1887836SJohn.Forte@Sun.COM break;
1897836SJohn.Forte@Sun.COM default:
1907836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
1917836SJohn.Forte@Sun.COM (xmlChar *)UNKNOWNTYPE);
1927836SJohn.Forte@Sun.COM }
1937836SJohn.Forte@Sun.COM if (n_attr == NULL) {
1947836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
1957836SJohn.Forte@Sun.COM }
1967836SJohn.Forte@Sun.COM
1977836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_ALIAS_ATTR_ID)];
1987836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)ALIASATTR,
1997836SJohn.Forte@Sun.COM (xmlChar *)attr->value.ptr);
2007836SJohn.Forte@Sun.COM if (n_attr == NULL) {
2017836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
2027836SJohn.Forte@Sun.COM }
2037836SJohn.Forte@Sun.COM
2047836SJohn.Forte@Sun.COM /*
2057836SJohn.Forte@Sun.COM * A node can have all or no SCN subsribtion.
2067836SJohn.Forte@Sun.COM * May avoid redundant code with scsusrciption table.
2077836SJohn.Forte@Sun.COM */
2087836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_SCN_BITMAP_ATTR_ID)];
2097836SJohn.Forte@Sun.COM if (IS_SCN_INIT_SELF_INFO_ONLY(attr->value.ui)) {
2107836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
2117836SJohn.Forte@Sun.COM (xmlChar *)SCNINITSELFONLY);
2127836SJohn.Forte@Sun.COM if (sub_node == NULL) {
2137836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
2147836SJohn.Forte@Sun.COM }
2157836SJohn.Forte@Sun.COM }
2167836SJohn.Forte@Sun.COM if (IS_SCN_TARGET_SELF_INFO_ONLY(attr->value.ui)) {
2177836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
2187836SJohn.Forte@Sun.COM (xmlChar *)SCNTARGETSELFONLY);
2197836SJohn.Forte@Sun.COM if (sub_node == NULL) {
2207836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
2217836SJohn.Forte@Sun.COM }
2227836SJohn.Forte@Sun.COM }
2237836SJohn.Forte@Sun.COM if (IS_SCN_MGMT_REG(attr->value.ui)) {
2247836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
2257836SJohn.Forte@Sun.COM (xmlChar *)SCNTARGETSELFONLY);
2267836SJohn.Forte@Sun.COM if (sub_node == NULL) {
2277836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
2287836SJohn.Forte@Sun.COM }
2297836SJohn.Forte@Sun.COM }
2307836SJohn.Forte@Sun.COM if (IS_SCN_OBJ_REMOVED(attr->value.ui)) {
2317836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
2327836SJohn.Forte@Sun.COM (xmlChar *)SCNOBJECTREMOVED);
2337836SJohn.Forte@Sun.COM if (sub_node == NULL) {
2347836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
2357836SJohn.Forte@Sun.COM }
2367836SJohn.Forte@Sun.COM }
2377836SJohn.Forte@Sun.COM if (IS_SCN_OBJ_ADDED(attr->value.ui)) {
2387836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
2397836SJohn.Forte@Sun.COM (xmlChar *)SCNOBJECTADDED);
2407836SJohn.Forte@Sun.COM if (sub_node == NULL) {
2417836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
2427836SJohn.Forte@Sun.COM }
2437836SJohn.Forte@Sun.COM }
2447836SJohn.Forte@Sun.COM if (IS_SCN_OBJ_UPDATED(attr->value.ui)) {
2457836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
2467836SJohn.Forte@Sun.COM (xmlChar *)SCNOBJECTUPDATED);
2477836SJohn.Forte@Sun.COM if (sub_node == NULL) {
2487836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
2497836SJohn.Forte@Sun.COM }
2507836SJohn.Forte@Sun.COM }
2517836SJohn.Forte@Sun.COM if (IS_SCN_MEMBER_REMOVED(attr->value.ui)) {
2527836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
2537836SJohn.Forte@Sun.COM (xmlChar *)SCNMEMBERREMOVED);
2547836SJohn.Forte@Sun.COM if (sub_node == NULL) {
2557836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
2567836SJohn.Forte@Sun.COM }
2577836SJohn.Forte@Sun.COM }
2587836SJohn.Forte@Sun.COM if (IS_SCN_MEMBER_ADDED(attr->value.ui)) {
2597836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL, (xmlChar *)SCNSUBSCRIPTION,
2607836SJohn.Forte@Sun.COM (xmlChar *)SCNMEMBERADDED);
2617836SJohn.Forte@Sun.COM if (sub_node == NULL) {
2627836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
2637836SJohn.Forte@Sun.COM }
2647836SJohn.Forte@Sun.COM }
2657836SJohn.Forte@Sun.COM
2667836SJohn.Forte@Sun.COM /* set the parent object id, i.e. the network entity object id */
2677836SJohn.Forte@Sun.COM lcp->id[2] = get_parent_uid(obj);
2687836SJohn.Forte@Sun.COM /* pass back the node object element to add entity, portal info to it */
2697836SJohn.Forte@Sun.COM lcp->data[2].ptr = (uchar_t *)n_node;
2707836SJohn.Forte@Sun.COM
2717836SJohn.Forte@Sun.COM /* successful */
2727836SJohn.Forte@Sun.COM return (0);
2737836SJohn.Forte@Sun.COM }
2747836SJohn.Forte@Sun.COM
2757836SJohn.Forte@Sun.COM /*
2767836SJohn.Forte@Sun.COM * ****************************************************************************
2777836SJohn.Forte@Sun.COM *
2787836SJohn.Forte@Sun.COM * cb_get_entity_info: callback for get_node_op
2797836SJohn.Forte@Sun.COM * The routine process matching network entity and add children elements
2807836SJohn.Forte@Sun.COM * to a Node object for given entity.
2817836SJohn.Forte@Sun.COM *
2827836SJohn.Forte@Sun.COM * p1 - matching entity object
2837836SJohn.Forte@Sun.COM * p2 - lookup control data that was used for node look up
2847836SJohn.Forte@Sun.COM * returns parent index(newtork entity) in look up control.
2857836SJohn.Forte@Sun.COM * return - error code
2867836SJohn.Forte@Sun.COM *
2877836SJohn.Forte@Sun.COM * ****************************************************************************
2887836SJohn.Forte@Sun.COM */
2897836SJohn.Forte@Sun.COM static int
cb_get_entity_info(void * p1,void * p2)2907836SJohn.Forte@Sun.COM cb_get_entity_info(
2917836SJohn.Forte@Sun.COM void *p1,
2927836SJohn.Forte@Sun.COM void *p2
2937836SJohn.Forte@Sun.COM )
2947836SJohn.Forte@Sun.COM {
2957836SJohn.Forte@Sun.COM isns_obj_t *obj = (isns_obj_t *)p1;
2967836SJohn.Forte@Sun.COM lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
2977836SJohn.Forte@Sun.COM xmlNodePtr n_node = (xmlNodePtr)lcp->data[2].ptr;
2987836SJohn.Forte@Sun.COM xmlNodePtr sub_node, subchild_node, subgrandchild_node;
2997836SJohn.Forte@Sun.COM char numbuf[32];
3007836SJohn.Forte@Sun.COM char buff[INET6_ADDRSTRLEN + 1] = { 0 };
3017836SJohn.Forte@Sun.COM isns_attr_t *attr;
3027836SJohn.Forte@Sun.COM
3037836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL, (xmlChar *)NETWORKENTITY, NULL);
3047836SJohn.Forte@Sun.COM
3057836SJohn.Forte@Sun.COM if (sub_node) {
3067836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_ENTITY(ISNS_EID_ATTR_ID)];
3077836SJohn.Forte@Sun.COM subchild_node = xmlNewChild(sub_node, NULL,
3087836SJohn.Forte@Sun.COM (xmlChar *)ENTITYID, (xmlChar *)attr->value.ptr);
3097836SJohn.Forte@Sun.COM if (subchild_node == NULL) {
3107836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
3117836SJohn.Forte@Sun.COM }
3127836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_ENTITY(ISNS_ENTITY_PROTOCOL_ATTR_ID)];
3137836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%u", attr->value.ui);
3147836SJohn.Forte@Sun.COM subchild_node = xmlNewChild(sub_node, NULL,
3157836SJohn.Forte@Sun.COM (xmlChar *)ENTITYPROTOCOL, (xmlChar *)numbuf);
3167836SJohn.Forte@Sun.COM if (subchild_node == NULL) {
3177836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
3187836SJohn.Forte@Sun.COM }
3197836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_ENTITY(ISNS_MGMT_IP_ADDR_ATTR_ID)];
3207836SJohn.Forte@Sun.COM if (attr->value.ip) {
3217836SJohn.Forte@Sun.COM /* convert the ipv6 to ipv4 */
3227836SJohn.Forte@Sun.COM if (((int *)attr->value.ip)[0] == 0x00 &&
3237836SJohn.Forte@Sun.COM ((int *)attr->value.ip)[1] == 0x00 &&
3247836SJohn.Forte@Sun.COM ((uchar_t *)attr->value.ip)[8] == 0x00 &&
3257836SJohn.Forte@Sun.COM ((uchar_t *)attr->value.ip)[9] == 0x00 &&
3267836SJohn.Forte@Sun.COM ((uchar_t *)attr->value.ip)[10] == 0xFF &&
3277836SJohn.Forte@Sun.COM ((uchar_t *)attr->value.ip)[11] == 0xFF) {
3287836SJohn.Forte@Sun.COM subchild_node = xmlNewChild(sub_node, NULL,
3297836SJohn.Forte@Sun.COM (xmlChar *)MANAGEMENTIPADDR,
3307836SJohn.Forte@Sun.COM (xmlChar *)inet_ntop(AF_INET,
3317836SJohn.Forte@Sun.COM (void *)&(((uint32_t *)attr->value.ip)[3]),
3327836SJohn.Forte@Sun.COM buff, sizeof (buff)));
3337836SJohn.Forte@Sun.COM } else {
3347836SJohn.Forte@Sun.COM subchild_node = xmlNewChild(sub_node, NULL,
3357836SJohn.Forte@Sun.COM (xmlChar *)MANAGEMENTIPADDR,
3367836SJohn.Forte@Sun.COM (xmlChar *)inet_ntop(AF_INET6,
3377836SJohn.Forte@Sun.COM (void *)attr->value.ip, buff, sizeof (buff)));
3387836SJohn.Forte@Sun.COM }
3397836SJohn.Forte@Sun.COM if (subchild_node == NULL) {
3407836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
3417836SJohn.Forte@Sun.COM }
3427836SJohn.Forte@Sun.COM }
3437836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_ENTITY(ISNS_TIMESTAMP_ATTR_ID)];
3447836SJohn.Forte@Sun.COM if (attr->value.ui) {
3457836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%u", attr->value.ui);
3467836SJohn.Forte@Sun.COM subchild_node = xmlNewChild(sub_node, NULL,
3477836SJohn.Forte@Sun.COM (xmlChar *)ENTITYREGTIMESTAMP, (xmlChar *)numbuf);
3487836SJohn.Forte@Sun.COM if (subchild_node == NULL) {
3497836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
3507836SJohn.Forte@Sun.COM }
3517836SJohn.Forte@Sun.COM }
3527836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_ENTITY(ISNS_VERSION_RANGE_ATTR_ID)];
3537836SJohn.Forte@Sun.COM if (attr->value.ui) {
3547836SJohn.Forte@Sun.COM subchild_node = xmlNewNode(NULL,
3557836SJohn.Forte@Sun.COM (xmlChar *)PROTOCOLVERSIONRANGE);
3567836SJohn.Forte@Sun.COM subchild_node = xmlAddChild(sub_node, subchild_node);
3577836SJohn.Forte@Sun.COM if (subchild_node == NULL) {
3587836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
3597836SJohn.Forte@Sun.COM }
3607836SJohn.Forte@Sun.COM
3617836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%u",
3627836SJohn.Forte@Sun.COM (attr->value.ui >> ISNS_VER_SHIFT) & ISNS_VERSION);
3637836SJohn.Forte@Sun.COM subgrandchild_node = xmlNewChild(subchild_node, NULL,
3647836SJohn.Forte@Sun.COM (xmlChar *)PROTOCOLMAXVERSION, (xmlChar *)numbuf);
3657836SJohn.Forte@Sun.COM if (subgrandchild_node == NULL) {
3667836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
3677836SJohn.Forte@Sun.COM }
3687836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%u", attr->value.ui & ISNS_VERSION);
3697836SJohn.Forte@Sun.COM subgrandchild_node = xmlNewChild(subchild_node, NULL,
3707836SJohn.Forte@Sun.COM (xmlChar *)PROTOCOLMINVERSION, (xmlChar *)numbuf);
3717836SJohn.Forte@Sun.COM if (subgrandchild_node == NULL) {
3727836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
3737836SJohn.Forte@Sun.COM }
3747836SJohn.Forte@Sun.COM }
3757836SJohn.Forte@Sun.COM attr =
3767836SJohn.Forte@Sun.COM &obj->attrs[ATTR_INDEX_ENTITY(ISNS_ENTITY_REG_PERIOD_ATTR_ID)];
3777836SJohn.Forte@Sun.COM if (attr->value.ui) {
3787836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%u", attr->value.ui);
3797836SJohn.Forte@Sun.COM subchild_node = xmlNewChild(sub_node, NULL,
3807836SJohn.Forte@Sun.COM (xmlChar *)REGISTRATIONPERIOD, (xmlChar *)numbuf);
3817836SJohn.Forte@Sun.COM if (subchild_node == NULL) {
3827836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
3837836SJohn.Forte@Sun.COM }
3847836SJohn.Forte@Sun.COM }
3857836SJohn.Forte@Sun.COM } else {
3867836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
3877836SJohn.Forte@Sun.COM }
3887836SJohn.Forte@Sun.COM
3897836SJohn.Forte@Sun.COM /* successful */
3907836SJohn.Forte@Sun.COM return (0);
3917836SJohn.Forte@Sun.COM }
3927836SJohn.Forte@Sun.COM
3937836SJohn.Forte@Sun.COM /*
3947836SJohn.Forte@Sun.COM * ****************************************************************************
3957836SJohn.Forte@Sun.COM *
3967836SJohn.Forte@Sun.COM * cb_get_pg_info: callback for get_node_op
3977836SJohn.Forte@Sun.COM * The routine process matching portal group and returns ip address
3987836SJohn.Forte@Sun.COM * and port number for further portal processing.
3997836SJohn.Forte@Sun.COM *
4007836SJohn.Forte@Sun.COM * p1 - matching portal group object
4017836SJohn.Forte@Sun.COM * p2 - lookup control data that was used for portal group look up
4027836SJohn.Forte@Sun.COM * returns portal ip address, port and group tag in look up control.
4037836SJohn.Forte@Sun.COM * return - error code
4047836SJohn.Forte@Sun.COM *
4057836SJohn.Forte@Sun.COM * ****************************************************************************
4067836SJohn.Forte@Sun.COM */
4077836SJohn.Forte@Sun.COM static int
cb_get_pg_info(void * p1,void * p2)4087836SJohn.Forte@Sun.COM cb_get_pg_info(
4097836SJohn.Forte@Sun.COM void *p1,
4107836SJohn.Forte@Sun.COM void *p2
4117836SJohn.Forte@Sun.COM )
4127836SJohn.Forte@Sun.COM {
4137836SJohn.Forte@Sun.COM isns_obj_t *obj = (isns_obj_t *)p1;
4147836SJohn.Forte@Sun.COM lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
4157836SJohn.Forte@Sun.COM
4167836SJohn.Forte@Sun.COM isns_attr_t *attr;
4177836SJohn.Forte@Sun.COM
4187836SJohn.Forte@Sun.COM /* get pg portal ip address and port attributes */
4197836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_PG(ISNS_PG_PORTAL_IP_ADDR_ATTR_ID)];
4207836SJohn.Forte@Sun.COM (void) memcpy(lcp->data[1].ip, attr->value.ip, sizeof (in6_addr_t));
4217836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_PG(ISNS_PG_PORTAL_PORT_ATTR_ID)];
4227836SJohn.Forte@Sun.COM lcp->data[2].ui = attr->value.ui;
4237836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_PG(ISNS_PG_TAG_ATTR_ID)];
4247836SJohn.Forte@Sun.COM lcp->id[2] = attr->value.ui;
4257836SJohn.Forte@Sun.COM
4267836SJohn.Forte@Sun.COM /* successful */
4277836SJohn.Forte@Sun.COM return (0);
4287836SJohn.Forte@Sun.COM }
4297836SJohn.Forte@Sun.COM
4307836SJohn.Forte@Sun.COM /*
4317836SJohn.Forte@Sun.COM * ****************************************************************************
4327836SJohn.Forte@Sun.COM *
4337836SJohn.Forte@Sun.COM * cb_get_portal_info: callback for get_node_op
4347836SJohn.Forte@Sun.COM * The routine process matching portal and add portal object info to
4357836SJohn.Forte@Sun.COM * the node object.
4367836SJohn.Forte@Sun.COM *
4377836SJohn.Forte@Sun.COM * p1 - matching portal object
4387836SJohn.Forte@Sun.COM * p2 - lookup control data that was used for portal look up
4397836SJohn.Forte@Sun.COM * return - error code
4407836SJohn.Forte@Sun.COM *
4417836SJohn.Forte@Sun.COM * ****************************************************************************
4427836SJohn.Forte@Sun.COM */
4437836SJohn.Forte@Sun.COM static int
cb_get_portal_info(void * p1,void * p2)4447836SJohn.Forte@Sun.COM cb_get_portal_info(
4457836SJohn.Forte@Sun.COM void *p1,
4467836SJohn.Forte@Sun.COM void *p2
4477836SJohn.Forte@Sun.COM )
4487836SJohn.Forte@Sun.COM {
4497836SJohn.Forte@Sun.COM isns_obj_t *obj = (isns_obj_t *)p1;
4507836SJohn.Forte@Sun.COM lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
4517836SJohn.Forte@Sun.COM xmlNodePtr n_node = (xmlNodePtr)lcp->data[2].ptr;
4527836SJohn.Forte@Sun.COM uint32_t tag = lcp->id[2];
4537836SJohn.Forte@Sun.COM xmlNodePtr sub_node, subchild_node, subgrandchild_node;
4547836SJohn.Forte@Sun.COM char numbuf[32];
4557836SJohn.Forte@Sun.COM char buff[INET6_ADDRSTRLEN + 1] = { 0 };
4567836SJohn.Forte@Sun.COM isns_attr_t *attr;
4577836SJohn.Forte@Sun.COM
4587836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL, (xmlChar *)PORTAL, NULL);
4597836SJohn.Forte@Sun.COM
4607836SJohn.Forte@Sun.COM /* get portal object attributes. */
4617836SJohn.Forte@Sun.COM if (sub_node) {
4627836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_PORTAL(ISNS_PORTAL_IP_ADDR_ATTR_ID)];
4637836SJohn.Forte@Sun.COM if (attr->value.ip) {
4647836SJohn.Forte@Sun.COM /* convert the ipv6 to ipv4 */
4657836SJohn.Forte@Sun.COM if (((int *)attr->value.ip)[0] == 0x00 &&
4667836SJohn.Forte@Sun.COM ((int *)attr->value.ip)[1] == 0x00 &&
4677836SJohn.Forte@Sun.COM ((uchar_t *)attr->value.ip)[8] == 0x00 &&
4687836SJohn.Forte@Sun.COM ((uchar_t *)attr->value.ip)[9] == 0x00 &&
4697836SJohn.Forte@Sun.COM ((uchar_t *)attr->value.ip)[10] == 0xFF &&
4707836SJohn.Forte@Sun.COM ((uchar_t *)attr->value.ip)[11] == 0xFF) {
4717836SJohn.Forte@Sun.COM subchild_node = xmlNewChild(sub_node, NULL,
4727836SJohn.Forte@Sun.COM (xmlChar *)IPADDR,
4737836SJohn.Forte@Sun.COM (xmlChar *)inet_ntop(AF_INET,
4747836SJohn.Forte@Sun.COM (void *)&(((uint32_t *)attr->value.ip)[3]),
4757836SJohn.Forte@Sun.COM buff, sizeof (buff)));
4767836SJohn.Forte@Sun.COM } else {
4777836SJohn.Forte@Sun.COM subchild_node = xmlNewChild(sub_node, NULL,
4787836SJohn.Forte@Sun.COM (xmlChar *)IPADDR,
4797836SJohn.Forte@Sun.COM (xmlChar *)inet_ntop(AF_INET6,
4807836SJohn.Forte@Sun.COM (void *)attr->value.ip, buff, sizeof (buff)));
4817836SJohn.Forte@Sun.COM }
4827836SJohn.Forte@Sun.COM if (subchild_node == NULL) {
4837836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
4847836SJohn.Forte@Sun.COM }
4857836SJohn.Forte@Sun.COM }
4867836SJohn.Forte@Sun.COM subchild_node = xmlNewChild(sub_node, NULL, (xmlChar *)UDPTCPPORT,
4877836SJohn.Forte@Sun.COM NULL);
4887836SJohn.Forte@Sun.COM if (subchild_node) {
4897836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_PORTAL(ISNS_PORTAL_PORT_ATTR_ID)];
4907836SJohn.Forte@Sun.COM subgrandchild_node = xmlNewChild(subchild_node, NULL,
4917836SJohn.Forte@Sun.COM (xmlChar *)PORTTYPE, IS_PORT_UDP(attr->value.ui) ?
4927836SJohn.Forte@Sun.COM (xmlChar *)UDPPORT : (xmlChar *)TCPPORT);
4937836SJohn.Forte@Sun.COM if (subgrandchild_node == NULL) {
4947836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
4957836SJohn.Forte@Sun.COM }
4967836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%u", PORT_NUMBER(attr->value.ui));
4977836SJohn.Forte@Sun.COM subgrandchild_node = xmlNewChild(subchild_node, NULL,
4987836SJohn.Forte@Sun.COM (xmlChar *)PORTNUMBER, (xmlChar *)numbuf);
4997836SJohn.Forte@Sun.COM if (subgrandchild_node == NULL) {
5007836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
5017836SJohn.Forte@Sun.COM }
5027836SJohn.Forte@Sun.COM } else {
5037836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
5047836SJohn.Forte@Sun.COM }
5057836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%u", tag);
5067836SJohn.Forte@Sun.COM subchild_node = xmlNewChild(sub_node, NULL, (xmlChar *)GROUPTAG,
5077836SJohn.Forte@Sun.COM (xmlChar *)numbuf);
5087836SJohn.Forte@Sun.COM if (subchild_node == NULL) {
5097836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
5107836SJohn.Forte@Sun.COM }
5117836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_PORTAL(ISNS_PORTAL_NAME_ATTR_ID)];
5127836SJohn.Forte@Sun.COM if (attr->value.ptr) {
5137836SJohn.Forte@Sun.COM subchild_node = xmlNewChild(sub_node, NULL,
5147836SJohn.Forte@Sun.COM (xmlChar *)SYMBOLICNAME, (xmlChar *)attr->value.ptr);
5157836SJohn.Forte@Sun.COM if (subchild_node == NULL) {
5167836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
5177836SJohn.Forte@Sun.COM }
5187836SJohn.Forte@Sun.COM }
5197836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_PORTAL(ISNS_ESI_INTERVAL_ATTR_ID)];
5207836SJohn.Forte@Sun.COM if (attr->value.ui) {
5217836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%u", attr->value.ui);
5227836SJohn.Forte@Sun.COM subchild_node = xmlNewChild(sub_node, NULL,
5237836SJohn.Forte@Sun.COM (xmlChar *)ESIINTERVAL, (xmlChar *)numbuf);
5247836SJohn.Forte@Sun.COM if (subchild_node == NULL) {
5257836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
5267836SJohn.Forte@Sun.COM }
5277836SJohn.Forte@Sun.COM }
5287836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_PORTAL(ISNS_ESI_PORT_ATTR_ID)];
5297836SJohn.Forte@Sun.COM if (attr->value.ui) {
5307836SJohn.Forte@Sun.COM subchild_node = xmlNewChild(sub_node, NULL,
5317836SJohn.Forte@Sun.COM (xmlChar *)ESIPORT, NULL);
5327836SJohn.Forte@Sun.COM if (subchild_node) {
5337836SJohn.Forte@Sun.COM subgrandchild_node = xmlNewChild(subchild_node, NULL,
5347836SJohn.Forte@Sun.COM (xmlChar *)PORTTYPE, IS_PORT_UDP(attr->value.ui) ?
5357836SJohn.Forte@Sun.COM (xmlChar *)UDPPORT : (xmlChar *)TCPPORT);
5367836SJohn.Forte@Sun.COM if (subgrandchild_node == NULL) {
5377836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
5387836SJohn.Forte@Sun.COM }
5397836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%u", PORT_NUMBER(attr->value.ui));
5407836SJohn.Forte@Sun.COM subgrandchild_node = xmlNewChild(subchild_node, NULL,
5417836SJohn.Forte@Sun.COM (xmlChar *)PORTNUMBER, (xmlChar *)numbuf);
5427836SJohn.Forte@Sun.COM if (subgrandchild_node == NULL) {
5437836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
5447836SJohn.Forte@Sun.COM }
5457836SJohn.Forte@Sun.COM } else {
5467836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
5477836SJohn.Forte@Sun.COM }
5487836SJohn.Forte@Sun.COM }
5497836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_PORTAL(ISNS_SCN_PORT_ATTR_ID)];
5507836SJohn.Forte@Sun.COM if (attr->value.ui) {
5517836SJohn.Forte@Sun.COM subchild_node = xmlNewChild(sub_node, NULL,
5527836SJohn.Forte@Sun.COM (xmlChar *)SCNPORT, NULL);
5537836SJohn.Forte@Sun.COM if (subchild_node) {
5547836SJohn.Forte@Sun.COM subgrandchild_node = xmlNewChild(subchild_node, NULL,
5557836SJohn.Forte@Sun.COM (xmlChar *)PORTTYPE, IS_PORT_UDP(attr->value.ui) ?
5567836SJohn.Forte@Sun.COM (xmlChar *)UDPPORT : (xmlChar *)TCPPORT);
5577836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%u", PORT_NUMBER(attr->value.ui));
5587836SJohn.Forte@Sun.COM if (subgrandchild_node == NULL) {
5597836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
5607836SJohn.Forte@Sun.COM }
5617836SJohn.Forte@Sun.COM subgrandchild_node = xmlNewChild(subchild_node, NULL,
5627836SJohn.Forte@Sun.COM (xmlChar *)PORTNUMBER, (xmlChar *)numbuf);
5637836SJohn.Forte@Sun.COM if (subgrandchild_node == NULL) {
5647836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
5657836SJohn.Forte@Sun.COM }
5667836SJohn.Forte@Sun.COM } else {
5677836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
5687836SJohn.Forte@Sun.COM }
5697836SJohn.Forte@Sun.COM }
5707836SJohn.Forte@Sun.COM } else if (sub_node == NULL) {
5717836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
5727836SJohn.Forte@Sun.COM }
5737836SJohn.Forte@Sun.COM
5747836SJohn.Forte@Sun.COM /* successful */
5757836SJohn.Forte@Sun.COM return (0);
5767836SJohn.Forte@Sun.COM }
5777836SJohn.Forte@Sun.COM
5787836SJohn.Forte@Sun.COM /*
5797836SJohn.Forte@Sun.COM * ****************************************************************************
5807836SJohn.Forte@Sun.COM *
5817836SJohn.Forte@Sun.COM * cb_get_dd_info: callback for get_dd_op
5827836SJohn.Forte@Sun.COM * The routine process matching dd object
5837836SJohn.Forte@Sun.COM *
5847836SJohn.Forte@Sun.COM * p1 - matching dd object
5857836SJohn.Forte@Sun.COM * p2 - lookup control data that was used for dd look up
5867836SJohn.Forte@Sun.COM * return - error code
5877836SJohn.Forte@Sun.COM *
5887836SJohn.Forte@Sun.COM * ****************************************************************************
5897836SJohn.Forte@Sun.COM */
5907836SJohn.Forte@Sun.COM static int
cb_get_dd_info(void * p1,void * p2)5917836SJohn.Forte@Sun.COM cb_get_dd_info(
5927836SJohn.Forte@Sun.COM void *p1,
5937836SJohn.Forte@Sun.COM void *p2
5947836SJohn.Forte@Sun.COM )
5957836SJohn.Forte@Sun.COM {
5967836SJohn.Forte@Sun.COM xmlNodePtr n_obj, n_node, sub_node, root;
5977836SJohn.Forte@Sun.COM xmlAttrPtr n_attr;
5987836SJohn.Forte@Sun.COM isns_attr_t *attr;
5997836SJohn.Forte@Sun.COM char numbuf[32];
6007836SJohn.Forte@Sun.COM
6017836SJohn.Forte@Sun.COM isns_obj_t *obj = (isns_obj_t *)p1;
6027836SJohn.Forte@Sun.COM lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
6037836SJohn.Forte@Sun.COM xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
6047836SJohn.Forte@Sun.COM
6057836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
6067836SJohn.Forte@Sun.COM if (root == NULL) {
6077836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
6087836SJohn.Forte@Sun.COM }
6097836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
6107836SJohn.Forte@Sun.COM if (n_obj) {
6117836SJohn.Forte@Sun.COM n_obj = xmlAddChild(root, n_obj);
6127836SJohn.Forte@Sun.COM if (n_obj == NULL) {
6137836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
6147836SJohn.Forte@Sun.COM }
6157836SJohn.Forte@Sun.COM } else {
6167836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
6177836SJohn.Forte@Sun.COM }
6187836SJohn.Forte@Sun.COM
6197836SJohn.Forte@Sun.COM n_node = xmlNewNode(NULL, (xmlChar *)DDOBJECT);
6207836SJohn.Forte@Sun.COM if (n_node) {
6217836SJohn.Forte@Sun.COM n_node = xmlAddChild(n_obj, n_node);
6227836SJohn.Forte@Sun.COM if (n_node == NULL) {
6237836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
6247836SJohn.Forte@Sun.COM }
6257836SJohn.Forte@Sun.COM } else {
6267836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
6277836SJohn.Forte@Sun.COM }
6287836SJohn.Forte@Sun.COM
6297836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID)];
6307836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)NAMEATTR,
6317836SJohn.Forte@Sun.COM (xmlChar *)attr->value.ptr);
6327836SJohn.Forte@Sun.COM if (n_attr == NULL) {
6337836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
6347836SJohn.Forte@Sun.COM }
6357836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_ID_ATTR_ID)];
6367836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%u", attr->value.ui);
6377836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)IDATTR,
6387836SJohn.Forte@Sun.COM (xmlChar *)numbuf);
6397836SJohn.Forte@Sun.COM if (n_attr == NULL) {
6407836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
6417836SJohn.Forte@Sun.COM }
6427836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_FEATURES_ATTR_ID)];
6437836SJohn.Forte@Sun.COM if (DD_BOOTLIST_ENABLED(attr->value.ui)) {
6447836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL, (xmlChar *)BOOTLISTENABLEDELEM,
6457836SJohn.Forte@Sun.COM (xmlChar *)XMLTRUE);
6467836SJohn.Forte@Sun.COM if (sub_node == NULL) {
6477836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
6487836SJohn.Forte@Sun.COM }
6497836SJohn.Forte@Sun.COM } else {
6507836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL, (xmlChar *)BOOTLISTENABLEDELEM,
6517836SJohn.Forte@Sun.COM (xmlChar *)XMLFALSE);
6527836SJohn.Forte@Sun.COM if (sub_node == NULL) {
6537836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
6547836SJohn.Forte@Sun.COM }
6557836SJohn.Forte@Sun.COM }
6567836SJohn.Forte@Sun.COM
6577836SJohn.Forte@Sun.COM /* successful */
6587836SJohn.Forte@Sun.COM return (0);
6597836SJohn.Forte@Sun.COM }
6607836SJohn.Forte@Sun.COM
6617836SJohn.Forte@Sun.COM /*
6627836SJohn.Forte@Sun.COM * ****************************************************************************
6637836SJohn.Forte@Sun.COM *
6647836SJohn.Forte@Sun.COM * cb_get_ddset_info: callback for get_ddset_op
6657836SJohn.Forte@Sun.COM * The routine process matching dd object
6667836SJohn.Forte@Sun.COM *
6677836SJohn.Forte@Sun.COM * p1 - matching dds object
6687836SJohn.Forte@Sun.COM * p2 - lookup control data that was used for dd set look up
6697836SJohn.Forte@Sun.COM * return - error code
6707836SJohn.Forte@Sun.COM *
6717836SJohn.Forte@Sun.COM * ****************************************************************************
6727836SJohn.Forte@Sun.COM */
6737836SJohn.Forte@Sun.COM static int
cb_get_ddset_info(void * p1,void * p2)6747836SJohn.Forte@Sun.COM cb_get_ddset_info(
6757836SJohn.Forte@Sun.COM void *p1,
6767836SJohn.Forte@Sun.COM void *p2
6777836SJohn.Forte@Sun.COM )
6787836SJohn.Forte@Sun.COM {
6797836SJohn.Forte@Sun.COM xmlNodePtr n_obj, n_node, sub_node, root;
6807836SJohn.Forte@Sun.COM xmlAttrPtr n_attr;
6817836SJohn.Forte@Sun.COM isns_attr_t *attr;
6827836SJohn.Forte@Sun.COM char numbuf[32];
6837836SJohn.Forte@Sun.COM
6847836SJohn.Forte@Sun.COM isns_obj_t *obj = (isns_obj_t *)p1;
6857836SJohn.Forte@Sun.COM lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
6867836SJohn.Forte@Sun.COM xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
6877836SJohn.Forte@Sun.COM
6887836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
6897836SJohn.Forte@Sun.COM if (root == NULL) {
6907836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
6917836SJohn.Forte@Sun.COM }
6927836SJohn.Forte@Sun.COM
6937836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
6947836SJohn.Forte@Sun.COM if (n_obj) {
6957836SJohn.Forte@Sun.COM n_obj = xmlAddChild(root, n_obj);
6967836SJohn.Forte@Sun.COM if (n_obj == NULL) {
6977836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
6987836SJohn.Forte@Sun.COM }
6997836SJohn.Forte@Sun.COM } else {
7007836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
7017836SJohn.Forte@Sun.COM }
7027836SJohn.Forte@Sun.COM
7037836SJohn.Forte@Sun.COM n_node = xmlNewNode(NULL, (xmlChar *)DDSETOBJECT);
7047836SJohn.Forte@Sun.COM if (n_node) {
7057836SJohn.Forte@Sun.COM n_node = xmlAddChild(n_obj, n_node);
7067836SJohn.Forte@Sun.COM if (n_node == NULL) {
7077836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
7087836SJohn.Forte@Sun.COM }
7097836SJohn.Forte@Sun.COM } else {
7107836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
7117836SJohn.Forte@Sun.COM }
7127836SJohn.Forte@Sun.COM
7137836SJohn.Forte@Sun.COM /* get node name, alias, type and generate xml info */
7147836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID)];
7157836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)NAMEATTR,
7167836SJohn.Forte@Sun.COM (xmlChar *)attr->value.ptr);
7177836SJohn.Forte@Sun.COM if (n_attr == NULL) {
7187836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
7197836SJohn.Forte@Sun.COM }
7207836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_ID_ATTR_ID)];
7217836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%u", attr->value.ui);
7227836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)IDATTR,
7237836SJohn.Forte@Sun.COM (xmlChar *)numbuf);
7247836SJohn.Forte@Sun.COM if (n_attr == NULL) {
7257836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
7267836SJohn.Forte@Sun.COM }
7277836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_STATUS_ATTR_ID)];
7287836SJohn.Forte@Sun.COM if (DDS_ENABLED(attr->value.ui)) {
7297836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL, (xmlChar *)ENABLEDELEM,
7307836SJohn.Forte@Sun.COM (xmlChar *)XMLTRUE);
7317836SJohn.Forte@Sun.COM if (sub_node == NULL) {
7327836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
7337836SJohn.Forte@Sun.COM }
7347836SJohn.Forte@Sun.COM } else {
7357836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL, (xmlChar *)ENABLEDELEM,
7367836SJohn.Forte@Sun.COM (xmlChar *)XMLFALSE);
7377836SJohn.Forte@Sun.COM if (sub_node == NULL) {
7387836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
7397836SJohn.Forte@Sun.COM }
7407836SJohn.Forte@Sun.COM }
7417836SJohn.Forte@Sun.COM
7427836SJohn.Forte@Sun.COM /* successful */
7437836SJohn.Forte@Sun.COM return (0);
7447836SJohn.Forte@Sun.COM }
7457836SJohn.Forte@Sun.COM
7467836SJohn.Forte@Sun.COM /*
7477836SJohn.Forte@Sun.COM * ****************************************************************************
7487836SJohn.Forte@Sun.COM *
7497836SJohn.Forte@Sun.COM * cb_enumerate_node_info: callback for enumerate_node_op
7507836SJohn.Forte@Sun.COM * The routine is invoked for each node object.
7517836SJohn.Forte@Sun.COM *
7527836SJohn.Forte@Sun.COM * p1 - node object
7537836SJohn.Forte@Sun.COM * p2 - lookup control data that was used for node look up
7547836SJohn.Forte@Sun.COM * return - error code
7557836SJohn.Forte@Sun.COM *
7567836SJohn.Forte@Sun.COM * ****************************************************************************
7577836SJohn.Forte@Sun.COM */
7587836SJohn.Forte@Sun.COM static int
cb_enumerate_node_info(void * p1,void * p2)7597836SJohn.Forte@Sun.COM cb_enumerate_node_info(
7607836SJohn.Forte@Sun.COM void *p1,
7617836SJohn.Forte@Sun.COM void *p2
7627836SJohn.Forte@Sun.COM )
7637836SJohn.Forte@Sun.COM {
7647836SJohn.Forte@Sun.COM xmlNodePtr n_obj, n_node, root;
7657836SJohn.Forte@Sun.COM xmlAttrPtr n_attr;
7667836SJohn.Forte@Sun.COM isns_attr_t *attr;
7677836SJohn.Forte@Sun.COM
7687836SJohn.Forte@Sun.COM isns_obj_t *obj = (isns_obj_t *)p1;
7697836SJohn.Forte@Sun.COM lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
7707836SJohn.Forte@Sun.COM xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
7717836SJohn.Forte@Sun.COM
7727836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
7737836SJohn.Forte@Sun.COM if (root == NULL) {
7747836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
7757836SJohn.Forte@Sun.COM }
7767836SJohn.Forte@Sun.COM
7777836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
7787836SJohn.Forte@Sun.COM if (n_obj) {
7797836SJohn.Forte@Sun.COM n_obj = xmlAddChild(root, n_obj);
7807836SJohn.Forte@Sun.COM if (n_obj == NULL) {
7817836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
7827836SJohn.Forte@Sun.COM }
7837836SJohn.Forte@Sun.COM } else {
7847836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
7857836SJohn.Forte@Sun.COM }
7867836SJohn.Forte@Sun.COM
7877836SJohn.Forte@Sun.COM n_node = xmlNewNode(NULL, (xmlChar *)NODEOBJECT);
7887836SJohn.Forte@Sun.COM if (n_node) {
7897836SJohn.Forte@Sun.COM n_node = xmlAddChild(n_obj, n_node);
7907836SJohn.Forte@Sun.COM if (n_node == NULL) {
7917836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
7927836SJohn.Forte@Sun.COM }
7937836SJohn.Forte@Sun.COM } else {
7947836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
7957836SJohn.Forte@Sun.COM }
7967836SJohn.Forte@Sun.COM
7977836SJohn.Forte@Sun.COM /* get node name, alias, type and generate xml info */
7987836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID)];
7997836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)NAMEATTR,
8007836SJohn.Forte@Sun.COM (xmlChar *)attr->value.ptr);
8017836SJohn.Forte@Sun.COM if (n_attr == NULL) {
8027836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
8037836SJohn.Forte@Sun.COM }
8047836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_NODE_TYPE_ATTR_ID)];
8057836SJohn.Forte@Sun.COM switch (attr->value.ui) {
8067836SJohn.Forte@Sun.COM case ISNS_CONTROL_NODE_TYPE | ISNS_INITIATOR_NODE_TYPE:
8077836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
8087836SJohn.Forte@Sun.COM (xmlChar *)CONTROLNODEINITIATORTYPE);
8097836SJohn.Forte@Sun.COM break;
8107836SJohn.Forte@Sun.COM case ISNS_CONTROL_NODE_TYPE | ISNS_TARGET_NODE_TYPE:
8117836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
8127836SJohn.Forte@Sun.COM (xmlChar *)CONTROLNODETARGETTYPE);
8137836SJohn.Forte@Sun.COM break;
8147836SJohn.Forte@Sun.COM case ISNS_TARGET_NODE_TYPE:
8157836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
8167836SJohn.Forte@Sun.COM (xmlChar *)TARGETTYPE);
8177836SJohn.Forte@Sun.COM break;
8187836SJohn.Forte@Sun.COM case ISNS_INITIATOR_NODE_TYPE:
8197836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
8207836SJohn.Forte@Sun.COM (xmlChar *)INITIATORTYPE);
8217836SJohn.Forte@Sun.COM break;
8227836SJohn.Forte@Sun.COM case ISNS_CONTROL_NODE_TYPE:
8237836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
8247836SJohn.Forte@Sun.COM (xmlChar *)CONTROLNODETYPE);
8257836SJohn.Forte@Sun.COM break;
8267836SJohn.Forte@Sun.COM default:
8277836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)TYPEATTR,
8287836SJohn.Forte@Sun.COM (xmlChar *)UNKNOWNTYPE);
8297836SJohn.Forte@Sun.COM }
8307836SJohn.Forte@Sun.COM if (n_attr == NULL) {
8317836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
8327836SJohn.Forte@Sun.COM }
8337836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_ALIAS_ATTR_ID)];
8347836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)ALIASATTR,
8357836SJohn.Forte@Sun.COM (xmlChar *)attr->value.ptr);
8367836SJohn.Forte@Sun.COM if (n_attr == NULL) {
8377836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
8387836SJohn.Forte@Sun.COM }
8397836SJohn.Forte@Sun.COM
8407836SJohn.Forte@Sun.COM /* successful */
8417836SJohn.Forte@Sun.COM return (0);
8427836SJohn.Forte@Sun.COM }
8437836SJohn.Forte@Sun.COM
8447836SJohn.Forte@Sun.COM /*
8457836SJohn.Forte@Sun.COM * ****************************************************************************
8467836SJohn.Forte@Sun.COM *
8477836SJohn.Forte@Sun.COM * i_enumerate_dd_dds_info:
8487836SJohn.Forte@Sun.COM * The routine is implemnetation for enumerate dd and enumerate dds.
8497836SJohn.Forte@Sun.COM *
8507836SJohn.Forte@Sun.COM * p1 - dd or dd set object
8517836SJohn.Forte@Sun.COM * p2 - lookup control data that was used for dd and dd set look up
8527836SJohn.Forte@Sun.COM * return - error code
8537836SJohn.Forte@Sun.COM *
8547836SJohn.Forte@Sun.COM * ****************************************************************************
8557836SJohn.Forte@Sun.COM */
8567836SJohn.Forte@Sun.COM static int
i_enumerate_dd_dds_info(void * p1,void * p2,isns_type_t obj_type)8577836SJohn.Forte@Sun.COM i_enumerate_dd_dds_info(
8587836SJohn.Forte@Sun.COM void *p1,
8597836SJohn.Forte@Sun.COM void *p2,
8607836SJohn.Forte@Sun.COM isns_type_t obj_type
8617836SJohn.Forte@Sun.COM )
8627836SJohn.Forte@Sun.COM {
8637836SJohn.Forte@Sun.COM xmlNodePtr n_obj, n_node, sub_node, root;
8647836SJohn.Forte@Sun.COM xmlAttrPtr n_attr;
8657836SJohn.Forte@Sun.COM isns_attr_t *attr;
8667836SJohn.Forte@Sun.COM char numbuf[32];
8677836SJohn.Forte@Sun.COM
8687836SJohn.Forte@Sun.COM isns_obj_t *obj = (isns_obj_t *)p1;
8697836SJohn.Forte@Sun.COM lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
8707836SJohn.Forte@Sun.COM xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
8717836SJohn.Forte@Sun.COM
8727836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
8737836SJohn.Forte@Sun.COM if (root == NULL) {
8747836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
8757836SJohn.Forte@Sun.COM }
8767836SJohn.Forte@Sun.COM
8777836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
8787836SJohn.Forte@Sun.COM if (n_obj) {
8797836SJohn.Forte@Sun.COM n_obj = xmlAddChild(root, n_obj);
8807836SJohn.Forte@Sun.COM if (n_obj == NULL) {
8817836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
8827836SJohn.Forte@Sun.COM }
8837836SJohn.Forte@Sun.COM } else {
8847836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
8857836SJohn.Forte@Sun.COM }
8867836SJohn.Forte@Sun.COM
8877836SJohn.Forte@Sun.COM if (obj_type == OBJ_DD) {
8887836SJohn.Forte@Sun.COM n_node = xmlNewNode(NULL, (xmlChar *)DDOBJECT);
8897836SJohn.Forte@Sun.COM } else {
8907836SJohn.Forte@Sun.COM n_node = xmlNewNode(NULL, (xmlChar *)DDSETOBJECT);
8917836SJohn.Forte@Sun.COM }
8927836SJohn.Forte@Sun.COM
8937836SJohn.Forte@Sun.COM if (n_node) {
8947836SJohn.Forte@Sun.COM n_node = xmlAddChild(n_obj, n_node);
8957836SJohn.Forte@Sun.COM if (n_node == NULL) {
8967836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
8977836SJohn.Forte@Sun.COM }
8987836SJohn.Forte@Sun.COM } else {
8997836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
9007836SJohn.Forte@Sun.COM }
9017836SJohn.Forte@Sun.COM
9027836SJohn.Forte@Sun.COM if (obj_type == OBJ_DD) {
9037836SJohn.Forte@Sun.COM /* get name, id, feaure and generate xml info */
9047836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID)];
9057836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)NAMEATTR,
9067836SJohn.Forte@Sun.COM (xmlChar *)attr->value.ptr);
9077836SJohn.Forte@Sun.COM if (n_attr == NULL) {
9087836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
9097836SJohn.Forte@Sun.COM }
9107836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_ID_ATTR_ID)];
9117836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%u", attr->value.ui);
9127836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)IDATTR,
9137836SJohn.Forte@Sun.COM (xmlChar *)numbuf);
9147836SJohn.Forte@Sun.COM if (n_attr == NULL) {
9157836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
9167836SJohn.Forte@Sun.COM }
9177836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_FEATURES_ATTR_ID)];
9187836SJohn.Forte@Sun.COM if (DD_BOOTLIST_ENABLED(attr->value.ui)) {
9197836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL,
9207836SJohn.Forte@Sun.COM (xmlChar *)BOOTLISTENABLEDELEM, (xmlChar *)XMLTRUE);
9217836SJohn.Forte@Sun.COM if (sub_node == NULL) {
9227836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
9237836SJohn.Forte@Sun.COM }
9247836SJohn.Forte@Sun.COM } else {
9257836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL,
9267836SJohn.Forte@Sun.COM (xmlChar *)BOOTLISTENABLEDELEM, (xmlChar *)XMLFALSE);
9277836SJohn.Forte@Sun.COM if (sub_node == NULL) {
9287836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
9297836SJohn.Forte@Sun.COM }
9307836SJohn.Forte@Sun.COM }
9317836SJohn.Forte@Sun.COM } else {
9327836SJohn.Forte@Sun.COM /* get name, id, status and generate xml info */
9337836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID)];
9347836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)NAMEATTR,
9357836SJohn.Forte@Sun.COM (xmlChar *)attr->value.ptr);
9367836SJohn.Forte@Sun.COM if (n_attr == NULL) {
9377836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
9387836SJohn.Forte@Sun.COM }
9397836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_ID_ATTR_ID)];
9407836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%u", attr->value.ui);
9417836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)IDATTR,
9427836SJohn.Forte@Sun.COM (xmlChar *)numbuf);
9437836SJohn.Forte@Sun.COM if (n_attr == NULL) {
9447836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
9457836SJohn.Forte@Sun.COM }
9467836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_STATUS_ATTR_ID)];
9477836SJohn.Forte@Sun.COM if (DDS_ENABLED(attr->value.ui)) {
9487836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL,
9497836SJohn.Forte@Sun.COM (xmlChar *)ENABLEDELEM, (xmlChar *)XMLTRUE);
9507836SJohn.Forte@Sun.COM if (sub_node == NULL) {
9517836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
9527836SJohn.Forte@Sun.COM }
9537836SJohn.Forte@Sun.COM } else {
9547836SJohn.Forte@Sun.COM sub_node = xmlNewChild(n_node, NULL,
9557836SJohn.Forte@Sun.COM (xmlChar *)ENABLEDELEM, (xmlChar *)XMLFALSE);
9567836SJohn.Forte@Sun.COM if (sub_node == NULL) {
9577836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
9587836SJohn.Forte@Sun.COM }
9597836SJohn.Forte@Sun.COM }
9607836SJohn.Forte@Sun.COM }
9617836SJohn.Forte@Sun.COM
9627836SJohn.Forte@Sun.COM /* successful */
9637836SJohn.Forte@Sun.COM return (0);
9647836SJohn.Forte@Sun.COM }
9657836SJohn.Forte@Sun.COM
9667836SJohn.Forte@Sun.COM /*
9677836SJohn.Forte@Sun.COM * ****************************************************************************
9687836SJohn.Forte@Sun.COM *
9697836SJohn.Forte@Sun.COM * cb_enumerate_dd_info: callback for enumerate_dd_op
9707836SJohn.Forte@Sun.COM * The routine is invoked for each dd object.
9717836SJohn.Forte@Sun.COM *
9727836SJohn.Forte@Sun.COM * p1 - dd object
9737836SJohn.Forte@Sun.COM * p2 - lookup control data that was used for dd look up
9747836SJohn.Forte@Sun.COM * return - error code
9757836SJohn.Forte@Sun.COM *
9767836SJohn.Forte@Sun.COM * ****************************************************************************
9777836SJohn.Forte@Sun.COM */
9787836SJohn.Forte@Sun.COM static int
cb_enumerate_dd_info(void * p1,void * p2)9797836SJohn.Forte@Sun.COM cb_enumerate_dd_info(
9807836SJohn.Forte@Sun.COM void *p1,
9817836SJohn.Forte@Sun.COM void *p2
9827836SJohn.Forte@Sun.COM )
9837836SJohn.Forte@Sun.COM {
9847836SJohn.Forte@Sun.COM return (i_enumerate_dd_dds_info(p1, p2, OBJ_DD));
9857836SJohn.Forte@Sun.COM }
9867836SJohn.Forte@Sun.COM
9877836SJohn.Forte@Sun.COM /*
9887836SJohn.Forte@Sun.COM * ****************************************************************************
9897836SJohn.Forte@Sun.COM *
9907836SJohn.Forte@Sun.COM * cb_enumerate_ddset_info: callback for enumerate_dd_op
9917836SJohn.Forte@Sun.COM * The routine is invoked for each dd object.
9927836SJohn.Forte@Sun.COM *
9937836SJohn.Forte@Sun.COM * p1 - dd object
9947836SJohn.Forte@Sun.COM * p2 - lookup control data that was used for dd set look up
9957836SJohn.Forte@Sun.COM * return - error code
9967836SJohn.Forte@Sun.COM *
9977836SJohn.Forte@Sun.COM * ****************************************************************************
9987836SJohn.Forte@Sun.COM */
9997836SJohn.Forte@Sun.COM static int
cb_enumerate_ddset_info(void * p1,void * p2)10007836SJohn.Forte@Sun.COM cb_enumerate_ddset_info(
10017836SJohn.Forte@Sun.COM void *p1,
10027836SJohn.Forte@Sun.COM void *p2
10037836SJohn.Forte@Sun.COM )
10047836SJohn.Forte@Sun.COM {
10057836SJohn.Forte@Sun.COM return (i_enumerate_dd_dds_info(p1, p2, OBJ_DDS));
10067836SJohn.Forte@Sun.COM }
10077836SJohn.Forte@Sun.COM
10087836SJohn.Forte@Sun.COM /*
10097836SJohn.Forte@Sun.COM * ****************************************************************************
10107836SJohn.Forte@Sun.COM *
10117836SJohn.Forte@Sun.COM * cb_getAssociated_node_info:
10127836SJohn.Forte@Sun.COM * The routine is implemnetation for enumerate dd and enumerate dds.
10137836SJohn.Forte@Sun.COM *
10147836SJohn.Forte@Sun.COM * p1 - dd or dd set object
10157836SJohn.Forte@Sun.COM * p2 - lookup control data that was used for dd and dd set look up
10167836SJohn.Forte@Sun.COM * return - error code
10177836SJohn.Forte@Sun.COM *
10187836SJohn.Forte@Sun.COM * ****************************************************************************
10197836SJohn.Forte@Sun.COM */
10207836SJohn.Forte@Sun.COM static int
cb_getAssociated_node_info(void * p1,void * p2)10217836SJohn.Forte@Sun.COM cb_getAssociated_node_info(
10227836SJohn.Forte@Sun.COM void *p1,
10237836SJohn.Forte@Sun.COM void *p2
10247836SJohn.Forte@Sun.COM )
10257836SJohn.Forte@Sun.COM {
10267836SJohn.Forte@Sun.COM xmlNodePtr n_obj, n_node, root;
10277836SJohn.Forte@Sun.COM xmlAttrPtr n_attr;
10287836SJohn.Forte@Sun.COM isns_attr_t *attr;
10297836SJohn.Forte@Sun.COM
10307836SJohn.Forte@Sun.COM isns_obj_t *obj = (isns_obj_t *)p1;
10317836SJohn.Forte@Sun.COM lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
10327836SJohn.Forte@Sun.COM xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
10337836SJohn.Forte@Sun.COM uchar_t *ddname = lcp->data[2].ptr;
10347836SJohn.Forte@Sun.COM
10357836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
10367836SJohn.Forte@Sun.COM if (root == NULL) {
10377836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
10387836SJohn.Forte@Sun.COM }
10397836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ASSOCIATION);
10407836SJohn.Forte@Sun.COM if (n_obj) {
10417836SJohn.Forte@Sun.COM n_obj = xmlAddChild(root, n_obj);
10427836SJohn.Forte@Sun.COM if (n_obj == NULL) {
10437836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
10447836SJohn.Forte@Sun.COM }
10457836SJohn.Forte@Sun.COM } else {
10467836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
10477836SJohn.Forte@Sun.COM }
10487836SJohn.Forte@Sun.COM
10497836SJohn.Forte@Sun.COM n_node = xmlNewNode(NULL, (xmlChar *)DDOBJECTMEMBER);
10507836SJohn.Forte@Sun.COM if (n_node) {
10517836SJohn.Forte@Sun.COM n_node = xmlAddChild(n_obj, n_node);
10527836SJohn.Forte@Sun.COM if (n_node == NULL) {
10537836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
10547836SJohn.Forte@Sun.COM }
10557836SJohn.Forte@Sun.COM } else {
10567836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
10577836SJohn.Forte@Sun.COM }
10587836SJohn.Forte@Sun.COM
10597836SJohn.Forte@Sun.COM /* get node name, alias, type and generate xml info */
10607836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID)];
10617836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)NODENAMEATTR,
10627836SJohn.Forte@Sun.COM (xmlChar *)attr->value.ptr);
10637836SJohn.Forte@Sun.COM if (n_attr == NULL) {
10647836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
10657836SJohn.Forte@Sun.COM }
10667836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
10677836SJohn.Forte@Sun.COM (xmlChar *)ddname);
10687836SJohn.Forte@Sun.COM if (n_attr == NULL) {
10697836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
10707836SJohn.Forte@Sun.COM }
10717836SJohn.Forte@Sun.COM
10727836SJohn.Forte@Sun.COM /* successful */
10737836SJohn.Forte@Sun.COM return (0);
10747836SJohn.Forte@Sun.COM }
10757836SJohn.Forte@Sun.COM
10767836SJohn.Forte@Sun.COM /*
10777836SJohn.Forte@Sun.COM * ****************************************************************************
10787836SJohn.Forte@Sun.COM *
10797836SJohn.Forte@Sun.COM * cb_getAssociated_node_to_dd_info:
10807836SJohn.Forte@Sun.COM * The routine is implemnetation for enumerate dd and enumerate dds.
10817836SJohn.Forte@Sun.COM *
10827836SJohn.Forte@Sun.COM * p1 - dd or dd set object
10837836SJohn.Forte@Sun.COM * p2 - lookup control data that was used for dd and dd set look up
10847836SJohn.Forte@Sun.COM * return - error code
10857836SJohn.Forte@Sun.COM *
10867836SJohn.Forte@Sun.COM * ****************************************************************************
10877836SJohn.Forte@Sun.COM */
10887836SJohn.Forte@Sun.COM static int
cb_getAssociated_node_to_dd_info(void * p1,void * p2)10897836SJohn.Forte@Sun.COM cb_getAssociated_node_to_dd_info(
10907836SJohn.Forte@Sun.COM void *p1,
10917836SJohn.Forte@Sun.COM void *p2
10927836SJohn.Forte@Sun.COM )
10937836SJohn.Forte@Sun.COM {
10947836SJohn.Forte@Sun.COM xmlNodePtr n_obj, n_node, root;
10957836SJohn.Forte@Sun.COM xmlAttrPtr n_attr;
10967836SJohn.Forte@Sun.COM isns_attr_t *attr;
10977836SJohn.Forte@Sun.COM
10987836SJohn.Forte@Sun.COM isns_obj_t *obj = (isns_obj_t *)p1;
10997836SJohn.Forte@Sun.COM lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
11007836SJohn.Forte@Sun.COM xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
11017836SJohn.Forte@Sun.COM uchar_t *nodename = lcp->data[2].ptr;
11027836SJohn.Forte@Sun.COM
11037836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
11047836SJohn.Forte@Sun.COM if (root == NULL) {
11057836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
11067836SJohn.Forte@Sun.COM }
11077836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ASSOCIATION);
11087836SJohn.Forte@Sun.COM if (n_obj) {
11097836SJohn.Forte@Sun.COM n_obj = xmlAddChild(root, n_obj);
11107836SJohn.Forte@Sun.COM if (n_obj == NULL) {
11117836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
11127836SJohn.Forte@Sun.COM }
11137836SJohn.Forte@Sun.COM } else {
11147836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
11157836SJohn.Forte@Sun.COM }
11167836SJohn.Forte@Sun.COM
11177836SJohn.Forte@Sun.COM n_node = xmlNewNode(NULL, (xmlChar *)DDOBJECTMEMBER);
11187836SJohn.Forte@Sun.COM if (n_node) {
11197836SJohn.Forte@Sun.COM n_node = xmlAddChild(n_obj, n_node);
11207836SJohn.Forte@Sun.COM if (n_node == NULL) {
11217836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
11227836SJohn.Forte@Sun.COM }
11237836SJohn.Forte@Sun.COM } else {
11247836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
11257836SJohn.Forte@Sun.COM }
11267836SJohn.Forte@Sun.COM
11277836SJohn.Forte@Sun.COM /* get node name, alias, type and generate xml info */
11287836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)NODENAMEATTR,
11297836SJohn.Forte@Sun.COM (xmlChar *)nodename);
11307836SJohn.Forte@Sun.COM if (n_attr == NULL) {
11317836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
11327836SJohn.Forte@Sun.COM }
11337836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID)];
11347836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
11357836SJohn.Forte@Sun.COM (xmlChar *)attr->value.ptr);
11367836SJohn.Forte@Sun.COM if (n_attr == NULL) {
11377836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
11387836SJohn.Forte@Sun.COM }
11397836SJohn.Forte@Sun.COM
11407836SJohn.Forte@Sun.COM /* successful */
11417836SJohn.Forte@Sun.COM return (0);
11427836SJohn.Forte@Sun.COM }
11437836SJohn.Forte@Sun.COM
11447836SJohn.Forte@Sun.COM /*
11457836SJohn.Forte@Sun.COM * ****************************************************************************
11467836SJohn.Forte@Sun.COM *
11477836SJohn.Forte@Sun.COM * cb_getAssociated_dd_info:
11487836SJohn.Forte@Sun.COM * The routine is implemnetation for getting dds membership.
11497836SJohn.Forte@Sun.COM *
11507836SJohn.Forte@Sun.COM * p1 - dd or dd set object
11517836SJohn.Forte@Sun.COM * p2 - lookup control data that was used for dd and dd set look up
11527836SJohn.Forte@Sun.COM * return - error code
11537836SJohn.Forte@Sun.COM *
11547836SJohn.Forte@Sun.COM * ****************************************************************************
11557836SJohn.Forte@Sun.COM */
11567836SJohn.Forte@Sun.COM static int
cb_getAssociated_dd_info(void * p1,void * p2)11577836SJohn.Forte@Sun.COM cb_getAssociated_dd_info(
11587836SJohn.Forte@Sun.COM void *p1,
11597836SJohn.Forte@Sun.COM void *p2
11607836SJohn.Forte@Sun.COM )
11617836SJohn.Forte@Sun.COM {
11627836SJohn.Forte@Sun.COM xmlNodePtr n_obj, n_node, root;
11637836SJohn.Forte@Sun.COM xmlAttrPtr n_attr;
11647836SJohn.Forte@Sun.COM isns_attr_t *attr;
11657836SJohn.Forte@Sun.COM
11667836SJohn.Forte@Sun.COM isns_obj_t *obj = (isns_obj_t *)p1;
11677836SJohn.Forte@Sun.COM lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
11687836SJohn.Forte@Sun.COM xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
11697836SJohn.Forte@Sun.COM uchar_t *ddsetname = lcp->data[2].ptr;
11707836SJohn.Forte@Sun.COM
11717836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
11727836SJohn.Forte@Sun.COM if (root == NULL) {
11737836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
11747836SJohn.Forte@Sun.COM }
11757836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ASSOCIATION);
11767836SJohn.Forte@Sun.COM if (n_obj) {
11777836SJohn.Forte@Sun.COM n_obj = xmlAddChild(root, n_obj);
11787836SJohn.Forte@Sun.COM if (n_obj == NULL) {
11797836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
11807836SJohn.Forte@Sun.COM }
11817836SJohn.Forte@Sun.COM } else {
11827836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
11837836SJohn.Forte@Sun.COM }
11847836SJohn.Forte@Sun.COM
11857836SJohn.Forte@Sun.COM n_node = xmlNewNode(NULL, (xmlChar *)DDSETOBJECTMEMBER);
11867836SJohn.Forte@Sun.COM if (n_node) {
11877836SJohn.Forte@Sun.COM n_node = xmlAddChild(n_obj, n_node);
11887836SJohn.Forte@Sun.COM if (n_node == NULL) {
11897836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
11907836SJohn.Forte@Sun.COM }
11917836SJohn.Forte@Sun.COM } else {
11927836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
11937836SJohn.Forte@Sun.COM }
11947836SJohn.Forte@Sun.COM
11957836SJohn.Forte@Sun.COM /* get node name, alias, type and generate xml info */
11967836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID)];
11977836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
11987836SJohn.Forte@Sun.COM (xmlChar *)attr->value.ptr);
11997836SJohn.Forte@Sun.COM if (n_attr == NULL) {
12007836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
12017836SJohn.Forte@Sun.COM }
12027836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)DDSETNAMEATTR,
12037836SJohn.Forte@Sun.COM (xmlChar *)ddsetname);
12047836SJohn.Forte@Sun.COM if (n_attr == NULL) {
12057836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
12067836SJohn.Forte@Sun.COM }
12077836SJohn.Forte@Sun.COM
12087836SJohn.Forte@Sun.COM /* successful */
12097836SJohn.Forte@Sun.COM return (0);
12107836SJohn.Forte@Sun.COM }
12117836SJohn.Forte@Sun.COM
12127836SJohn.Forte@Sun.COM /*
12137836SJohn.Forte@Sun.COM * ****************************************************************************
12147836SJohn.Forte@Sun.COM *
12157836SJohn.Forte@Sun.COM * cb_getAssociated_dd_to_ddset_info:
12167836SJohn.Forte@Sun.COM * The routine is implemnetation for enumerate dd and enumerate dds.
12177836SJohn.Forte@Sun.COM *
12187836SJohn.Forte@Sun.COM * p1 - dd or dd set object
12197836SJohn.Forte@Sun.COM * p2 - lookup control data that was used for dd and dd set look up
12207836SJohn.Forte@Sun.COM * return - error code
12217836SJohn.Forte@Sun.COM *
12227836SJohn.Forte@Sun.COM * ****************************************************************************
12237836SJohn.Forte@Sun.COM */
12247836SJohn.Forte@Sun.COM static int
cb_getAssociated_dd_to_ddset_info(void * p1,void * p2)12257836SJohn.Forte@Sun.COM cb_getAssociated_dd_to_ddset_info(
12267836SJohn.Forte@Sun.COM void *p1,
12277836SJohn.Forte@Sun.COM void *p2
12287836SJohn.Forte@Sun.COM )
12297836SJohn.Forte@Sun.COM {
12307836SJohn.Forte@Sun.COM xmlNodePtr n_obj, n_node, root;
12317836SJohn.Forte@Sun.COM xmlAttrPtr n_attr;
12327836SJohn.Forte@Sun.COM isns_attr_t *attr;
12337836SJohn.Forte@Sun.COM
12347836SJohn.Forte@Sun.COM isns_obj_t *obj = (isns_obj_t *)p1;
12357836SJohn.Forte@Sun.COM lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
12367836SJohn.Forte@Sun.COM xmlDocPtr doc = (xmlDocPtr)lcp->data[1].ptr;
12377836SJohn.Forte@Sun.COM uchar_t *ddname = lcp->data[2].ptr;
12387836SJohn.Forte@Sun.COM
12397836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
12407836SJohn.Forte@Sun.COM if (root == NULL) {
12417836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
12427836SJohn.Forte@Sun.COM }
12437836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ASSOCIATION);
12447836SJohn.Forte@Sun.COM if (n_obj) {
12457836SJohn.Forte@Sun.COM n_obj = xmlAddChild(root, n_obj);
12467836SJohn.Forte@Sun.COM if (n_obj == NULL) {
12477836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
12487836SJohn.Forte@Sun.COM }
12497836SJohn.Forte@Sun.COM } else {
12507836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
12517836SJohn.Forte@Sun.COM }
12527836SJohn.Forte@Sun.COM
12537836SJohn.Forte@Sun.COM n_node = xmlNewNode(NULL, (xmlChar *)DDSETOBJECTMEMBER);
12547836SJohn.Forte@Sun.COM if (n_node) {
12557836SJohn.Forte@Sun.COM n_node = xmlAddChild(n_obj, n_node);
12567836SJohn.Forte@Sun.COM if (n_node == NULL) {
12577836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
12587836SJohn.Forte@Sun.COM }
12597836SJohn.Forte@Sun.COM } else {
12607836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
12617836SJohn.Forte@Sun.COM }
12627836SJohn.Forte@Sun.COM
12637836SJohn.Forte@Sun.COM /* get node name, alias, type and generate xml info */
12647836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
12657836SJohn.Forte@Sun.COM (xmlChar *)ddname);
12667836SJohn.Forte@Sun.COM if (n_attr == NULL) {
12677836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
12687836SJohn.Forte@Sun.COM }
12697836SJohn.Forte@Sun.COM attr = &obj->attrs[ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID)];
12707836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)DDSETNAMEATTR,
12717836SJohn.Forte@Sun.COM (xmlChar *)attr->value.ptr);
12727836SJohn.Forte@Sun.COM if (n_attr == NULL) {
12737836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
12747836SJohn.Forte@Sun.COM }
12757836SJohn.Forte@Sun.COM
12767836SJohn.Forte@Sun.COM /* successful */
12777836SJohn.Forte@Sun.COM return (0);
12787836SJohn.Forte@Sun.COM }
12797836SJohn.Forte@Sun.COM
12807836SJohn.Forte@Sun.COM /*
12817836SJohn.Forte@Sun.COM * ****************************************************************************
12827836SJohn.Forte@Sun.COM *
12837836SJohn.Forte@Sun.COM * handle_partial_success:
12847836SJohn.Forte@Sun.COM *
12857836SJohn.Forte@Sun.COM * doc - response doc to fill up
12867836SJohn.Forte@Sun.COM * ret - return code from the caller.
12877836SJohn.Forte@Sun.COM *
12887836SJohn.Forte@Sun.COM * ****************************************************************************
12897836SJohn.Forte@Sun.COM */
12907836SJohn.Forte@Sun.COM static int
handle_partial_success(xmlDocPtr doc,int ret)12917836SJohn.Forte@Sun.COM handle_partial_success(
12927836SJohn.Forte@Sun.COM xmlDocPtr doc,
12937836SJohn.Forte@Sun.COM int ret
12947836SJohn.Forte@Sun.COM )
12957836SJohn.Forte@Sun.COM {
12967836SJohn.Forte@Sun.COM xmlNodePtr n_obj, n_node, root;
12977836SJohn.Forte@Sun.COM char numbuf[32];
12987836SJohn.Forte@Sun.COM
12997836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
13007836SJohn.Forte@Sun.COM if (root == NULL) {
13017836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
13027836SJohn.Forte@Sun.COM }
13037836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)RESULTELEMENT);
13047836SJohn.Forte@Sun.COM if (n_obj) {
13057836SJohn.Forte@Sun.COM if (root->children) {
13067836SJohn.Forte@Sun.COM n_obj = xmlAddPrevSibling(root->children, n_obj);
13077836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%d", (ret != 0) ? PARTIAL_SUCCESS : 0);
13087836SJohn.Forte@Sun.COM n_node = xmlNewChild(n_obj, NULL, (xmlChar *)STATUSELEMENT,
13097836SJohn.Forte@Sun.COM (xmlChar *)numbuf);
13107836SJohn.Forte@Sun.COM if (n_node == NULL) {
13117836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
13127836SJohn.Forte@Sun.COM }
13137836SJohn.Forte@Sun.COM n_node = xmlNewChild(n_obj, NULL, (xmlChar *)MESSAGEELEMENT,
13147836SJohn.Forte@Sun.COM (xmlChar *)result_code_to_str((ret != 0) ?
13157836SJohn.Forte@Sun.COM PARTIAL_SUCCESS : 0));
13167836SJohn.Forte@Sun.COM if (n_node == NULL) {
13177836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
13187836SJohn.Forte@Sun.COM }
13197836SJohn.Forte@Sun.COM } else {
13207836SJohn.Forte@Sun.COM n_obj = xmlAddChild(root, n_obj);
13217836SJohn.Forte@Sun.COM if (n_obj == NULL) {
13227836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
13237836SJohn.Forte@Sun.COM }
13247836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%d", ret);
13257836SJohn.Forte@Sun.COM n_node = xmlNewChild(n_obj, NULL, (xmlChar *)STATUSELEMENT,
13267836SJohn.Forte@Sun.COM (xmlChar *)numbuf);
13277836SJohn.Forte@Sun.COM if (n_node == NULL) {
13287836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
13297836SJohn.Forte@Sun.COM }
13307836SJohn.Forte@Sun.COM n_node = xmlNewChild(n_obj, NULL, (xmlChar *)MESSAGEELEMENT,
13317836SJohn.Forte@Sun.COM (xmlChar *)result_code_to_str(ret));
13327836SJohn.Forte@Sun.COM if (n_node == NULL) {
13337836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
13347836SJohn.Forte@Sun.COM }
13357836SJohn.Forte@Sun.COM }
13367836SJohn.Forte@Sun.COM } else {
13377836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
13387836SJohn.Forte@Sun.COM }
13397836SJohn.Forte@Sun.COM
13407836SJohn.Forte@Sun.COM return (0);
13417836SJohn.Forte@Sun.COM }
13427836SJohn.Forte@Sun.COM
13437836SJohn.Forte@Sun.COM /*
13447836SJohn.Forte@Sun.COM * ****************************************************************************
13457836SJohn.Forte@Sun.COM *
13467836SJohn.Forte@Sun.COM * handle_partial_failure:
13477836SJohn.Forte@Sun.COM *
13487836SJohn.Forte@Sun.COM * doc - response doc to fill up
13497836SJohn.Forte@Sun.COM * ret - return code from the caller.
13507836SJohn.Forte@Sun.COM *
13517836SJohn.Forte@Sun.COM * ****************************************************************************
13527836SJohn.Forte@Sun.COM */
13537836SJohn.Forte@Sun.COM static int
handle_partial_failure(xmlDocPtr doc,int ret,boolean_t all_failed)13547836SJohn.Forte@Sun.COM handle_partial_failure(
13557836SJohn.Forte@Sun.COM xmlDocPtr doc,
13567836SJohn.Forte@Sun.COM int ret,
13577836SJohn.Forte@Sun.COM boolean_t all_failed
13587836SJohn.Forte@Sun.COM )
13597836SJohn.Forte@Sun.COM {
13607836SJohn.Forte@Sun.COM xmlNodePtr n_obj, n_node, root;
13617836SJohn.Forte@Sun.COM char numbuf[32];
13627836SJohn.Forte@Sun.COM
13637836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
13647836SJohn.Forte@Sun.COM if (root == NULL) {
13657836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
13667836SJohn.Forte@Sun.COM }
13677836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)RESULTELEMENT);
13687836SJohn.Forte@Sun.COM if (n_obj) {
13697836SJohn.Forte@Sun.COM if (root->children) {
13707836SJohn.Forte@Sun.COM /* some or all associations failed to create */
13717836SJohn.Forte@Sun.COM n_obj = xmlAddPrevSibling(root->children, n_obj);
13727836SJohn.Forte@Sun.COM /* capture last error. should come up with all failed?? */
13737836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%d",
13747836SJohn.Forte@Sun.COM all_failed ? ret : PARTIAL_FAILURE);
13757836SJohn.Forte@Sun.COM n_node = xmlNewChild(n_obj, NULL, (xmlChar *)STATUSELEMENT,
13767836SJohn.Forte@Sun.COM (xmlChar *)numbuf);
13777836SJohn.Forte@Sun.COM if (n_node == NULL) {
13787836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
13797836SJohn.Forte@Sun.COM }
13807836SJohn.Forte@Sun.COM n_node = xmlNewChild(n_obj, NULL, (xmlChar *)MESSAGEELEMENT,
13817836SJohn.Forte@Sun.COM (xmlChar *)result_code_to_str(all_failed ? ret :
13827836SJohn.Forte@Sun.COM PARTIAL_FAILURE));
13837836SJohn.Forte@Sun.COM if (n_node == NULL) {
13847836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
13857836SJohn.Forte@Sun.COM }
13867836SJohn.Forte@Sun.COM } else {
13877836SJohn.Forte@Sun.COM n_obj = xmlAddChild(root, n_obj);
13887836SJohn.Forte@Sun.COM if (n_obj == NULL) {
13897836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
13907836SJohn.Forte@Sun.COM }
13917836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%d", (ret != 0) ? ret : 0);
13927836SJohn.Forte@Sun.COM n_node = xmlNewChild(n_obj, NULL, (xmlChar *)STATUSELEMENT,
13937836SJohn.Forte@Sun.COM (xmlChar *)numbuf);
13947836SJohn.Forte@Sun.COM if (n_node == NULL) {
13957836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
13967836SJohn.Forte@Sun.COM }
13977836SJohn.Forte@Sun.COM n_node = xmlNewChild(n_obj, NULL, (xmlChar *)MESSAGEELEMENT,
13987836SJohn.Forte@Sun.COM (xmlChar *)result_code_to_str((ret != 0) ? ret : 0));
13997836SJohn.Forte@Sun.COM if (n_node == NULL) {
14007836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
14017836SJohn.Forte@Sun.COM }
14027836SJohn.Forte@Sun.COM }
14037836SJohn.Forte@Sun.COM } else {
14047836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
14057836SJohn.Forte@Sun.COM }
14067836SJohn.Forte@Sun.COM
14077836SJohn.Forte@Sun.COM return (0);
14087836SJohn.Forte@Sun.COM }
14097836SJohn.Forte@Sun.COM
14107836SJohn.Forte@Sun.COM /*
14117836SJohn.Forte@Sun.COM * ****************************************************************************
14127836SJohn.Forte@Sun.COM *
14137836SJohn.Forte@Sun.COM * get_serverconfig_op:
14147836SJohn.Forte@Sun.COM * The routine process server administrative setting.
14157836SJohn.Forte@Sun.COM *
14167836SJohn.Forte@Sun.COM * doc - response doc to fill up.
14177836SJohn.Forte@Sun.COM *
14187836SJohn.Forte@Sun.COM * ****************************************************************************
14197836SJohn.Forte@Sun.COM */
14207836SJohn.Forte@Sun.COM int
get_serverconfig_op(xmlDocPtr doc)14217836SJohn.Forte@Sun.COM get_serverconfig_op(
14227836SJohn.Forte@Sun.COM xmlDocPtr doc
14237836SJohn.Forte@Sun.COM )
14247836SJohn.Forte@Sun.COM {
14257836SJohn.Forte@Sun.COM extern uint64_t esi_threshold;
14267836SJohn.Forte@Sun.COM extern uint8_t mgmt_scn;
14277836SJohn.Forte@Sun.COM extern ctrl_node_t *control_nodes;
14287836SJohn.Forte@Sun.COM extern pthread_mutex_t ctrl_node_mtx;
14297836SJohn.Forte@Sun.COM extern char data_store[MAXPATHLEN];
14307836SJohn.Forte@Sun.COM
14317836SJohn.Forte@Sun.COM xmlNodePtr n_obj, root;
14327836SJohn.Forte@Sun.COM char numbuf[32];
14337836SJohn.Forte@Sun.COM ctrl_node_t *ctrl_node_p;
14347836SJohn.Forte@Sun.COM int ret = 0;
14357836SJohn.Forte@Sun.COM
14367836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
14377836SJohn.Forte@Sun.COM if (root == NULL) {
14387836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
14397836SJohn.Forte@Sun.COM }
14407836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ISNSSERVER);
14417836SJohn.Forte@Sun.COM if (n_obj) {
14427836SJohn.Forte@Sun.COM n_obj = xmlAddChild(root, n_obj);
14437836SJohn.Forte@Sun.COM if (n_obj == NULL) {
14447836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
14457836SJohn.Forte@Sun.COM }
14467836SJohn.Forte@Sun.COM } else {
14477836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
14487836SJohn.Forte@Sun.COM }
14497836SJohn.Forte@Sun.COM
14507836SJohn.Forte@Sun.COM if (xmlNewChild(n_obj, NULL, (xmlChar *)DATASTORELOCATION,
14517836SJohn.Forte@Sun.COM (xmlChar *)data_store) == NULL) {
14527836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
14537836SJohn.Forte@Sun.COM }
14547836SJohn.Forte@Sun.COM
14557836SJohn.Forte@Sun.COM (void) sprintf(numbuf, "%llu", esi_threshold);
14567836SJohn.Forte@Sun.COM if (xmlNewChild(n_obj, NULL, (xmlChar *)ESIRETRYTHRESHOLD,
14577836SJohn.Forte@Sun.COM (xmlChar *)numbuf) == NULL) {
14587836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
14597836SJohn.Forte@Sun.COM }
14607836SJohn.Forte@Sun.COM if (xmlNewChild(n_obj, NULL, (xmlChar *)MANAGEMENTSCNENABLED,
14617836SJohn.Forte@Sun.COM (mgmt_scn) ? (uchar_t *)XMLTRUE : (uchar_t *)XMLFALSE) == NULL) {
14627836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
14637836SJohn.Forte@Sun.COM }
14647836SJohn.Forte@Sun.COM
14657836SJohn.Forte@Sun.COM (void) pthread_mutex_lock(&ctrl_node_mtx);
14667836SJohn.Forte@Sun.COM if (control_nodes == NULL) {
14677836SJohn.Forte@Sun.COM if (xmlNewChild(n_obj, NULL, (xmlChar *)CONTROLNODENAME,
14687836SJohn.Forte@Sun.COM (xmlChar *)NULL) == NULL) {
14697836SJohn.Forte@Sun.COM (void) pthread_mutex_unlock(&ctrl_node_mtx);
14707836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
14717836SJohn.Forte@Sun.COM }
14727836SJohn.Forte@Sun.COM } else {
14737836SJohn.Forte@Sun.COM ctrl_node_p = control_nodes;
14747836SJohn.Forte@Sun.COM while (ctrl_node_p != NULL) {
14757836SJohn.Forte@Sun.COM if (xmlNewChild(n_obj, NULL, (xmlChar *)CONTROLNODENAME,
14767836SJohn.Forte@Sun.COM (xmlChar *)ctrl_node_p->name) == NULL) {
14777836SJohn.Forte@Sun.COM (void) pthread_mutex_unlock(&ctrl_node_mtx);
14787836SJohn.Forte@Sun.COM return (ERR_XML_NEWCHILD_FAILED);
14797836SJohn.Forte@Sun.COM }
14807836SJohn.Forte@Sun.COM ctrl_node_p = ctrl_node_p->next;
14817836SJohn.Forte@Sun.COM }
14827836SJohn.Forte@Sun.COM }
14837836SJohn.Forte@Sun.COM (void) pthread_mutex_unlock(&ctrl_node_mtx);
14847836SJohn.Forte@Sun.COM
14857836SJohn.Forte@Sun.COM return (handle_partial_success(doc, ret));
14867836SJohn.Forte@Sun.COM }
14877836SJohn.Forte@Sun.COM
14887836SJohn.Forte@Sun.COM /*
14897836SJohn.Forte@Sun.COM * ****************************************************************************
14907836SJohn.Forte@Sun.COM *
14917836SJohn.Forte@Sun.COM * get_node_op:
14927836SJohn.Forte@Sun.COM * service get operation on a given node.
14937836SJohn.Forte@Sun.COM *
14947836SJohn.Forte@Sun.COM * req - contains all info for a request.
14957836SJohn.Forte@Sun.COM * doc - response doc to fill up
14967836SJohn.Forte@Sun.COM *
14977836SJohn.Forte@Sun.COM * ****************************************************************************
14987836SJohn.Forte@Sun.COM */
14997836SJohn.Forte@Sun.COM int
get_node_op(request_t * req,xmlDocPtr doc)15007836SJohn.Forte@Sun.COM get_node_op(
15017836SJohn.Forte@Sun.COM request_t *req,
15027836SJohn.Forte@Sun.COM xmlDocPtr doc
15037836SJohn.Forte@Sun.COM /* any additional arguments go here */
15047836SJohn.Forte@Sun.COM )
15057836SJohn.Forte@Sun.COM {
15067836SJohn.Forte@Sun.COM int ret = 0, ret_save = 0;
15077836SJohn.Forte@Sun.COM int i = 0;
15087836SJohn.Forte@Sun.COM lookup_ctrl_t lc, lc2, lc3;
15097836SJohn.Forte@Sun.COM uint32_t uid;
15107836SJohn.Forte@Sun.COM char buff2[INET6_ADDRSTRLEN];
15117836SJohn.Forte@Sun.COM
15127836SJohn.Forte@Sun.COM /* prepare lookup ctrl data for looking for the node object */
15137836SJohn.Forte@Sun.COM lc.curr_uid = 0;
15147836SJohn.Forte@Sun.COM lc.type = get_lc_type(req->op_info.obj);
15157836SJohn.Forte@Sun.COM lc.id[0] = get_lc_id(req->op_info.obj);
15167836SJohn.Forte@Sun.COM lc.op[0] = OP_STRING;
15177836SJohn.Forte@Sun.COM lc.op[1] = 0;
15187836SJohn.Forte@Sun.COM lc.data[1].ptr = (uchar_t *)doc; /* xml writer descriptor */
15197836SJohn.Forte@Sun.COM while (i < req->count) {
15207836SJohn.Forte@Sun.COM lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
15217836SJohn.Forte@Sun.COM ret = cache_lookup(&lc, &uid, cb_get_node_info);
15227836SJohn.Forte@Sun.COM if (uid == 0) {
15237836SJohn.Forte@Sun.COM ret = ERR_MATCHING_ISCSI_NODE_NOT_FOUND;
15247836SJohn.Forte@Sun.COM }
15257836SJohn.Forte@Sun.COM
15267836SJohn.Forte@Sun.COM /* generate network entity object information */
15277836SJohn.Forte@Sun.COM if (ret == 0 && lc.id[2] != 0) {
15287836SJohn.Forte@Sun.COM /*
15297836SJohn.Forte@Sun.COM * !!! there might be no entity and portal info for
15307836SJohn.Forte@Sun.COM * !!! the node if it is not a registered node
15317836SJohn.Forte@Sun.COM */
15327836SJohn.Forte@Sun.COM /* prepare lookup ctrl data for looking for entity */
15337836SJohn.Forte@Sun.COM SET_UID_LCP(&lc2, OBJ_ENTITY, lc.id[2]);
15347836SJohn.Forte@Sun.COM
15357836SJohn.Forte@Sun.COM lc2.data[1].ptr = (uchar_t *)doc;
15367836SJohn.Forte@Sun.COM /* cb_get_node_info callback returned Node object. */
15377836SJohn.Forte@Sun.COM lc2.data[2].ptr = lc.data[2].ptr;
15387836SJohn.Forte@Sun.COM ret = cache_lookup(&lc2, &uid, cb_get_entity_info);
15397836SJohn.Forte@Sun.COM if (uid == 0) {
15407836SJohn.Forte@Sun.COM ret = ERR_MATCHING_NETWORK_ENTITY_NOT_FOUND;
15417836SJohn.Forte@Sun.COM }
15427836SJohn.Forte@Sun.COM }
15437836SJohn.Forte@Sun.COM
15447836SJohn.Forte@Sun.COM /* generate portal information */
15457836SJohn.Forte@Sun.COM if (ret == 0 && lc.id[2] != 0) {
15467836SJohn.Forte@Sun.COM /* prepare lookup ctrl data for looking for pg */
15477836SJohn.Forte@Sun.COM lc2.curr_uid = 0;
15487836SJohn.Forte@Sun.COM lc2.type = OBJ_PG;
15497836SJohn.Forte@Sun.COM lc2.id[0] = ATTR_INDEX_PG(ISNS_PG_ISCSI_NAME_ATTR_ID);
15507836SJohn.Forte@Sun.COM lc2.op[0] = OP_STRING;
15517836SJohn.Forte@Sun.COM /* lc.data[0].ptr contains node name */
15527836SJohn.Forte@Sun.COM lc2.data[0].ptr = lc.data[0].ptr;
15537836SJohn.Forte@Sun.COM lc2.op[1] = 0;
15547836SJohn.Forte@Sun.COM lc2.data[1].ip = (in6_addr_t *)buff2;
15557836SJohn.Forte@Sun.COM
15567836SJohn.Forte@Sun.COM /* prepare lookup ctrl data for looking for portal */
15577836SJohn.Forte@Sun.COM lc3.curr_uid = 0;
15587836SJohn.Forte@Sun.COM lc3.type = OBJ_PORTAL;
15597836SJohn.Forte@Sun.COM lc3.id[0] = ATTR_INDEX_PORTAL(
15607836SJohn.Forte@Sun.COM ISNS_PORTAL_IP_ADDR_ATTR_ID);
15617836SJohn.Forte@Sun.COM lc3.op[0] = OP_MEMORY_IP6;
15627836SJohn.Forte@Sun.COM lc3.id[1] = ATTR_INDEX_PORTAL(
15637836SJohn.Forte@Sun.COM ISNS_PORTAL_PORT_ATTR_ID);
15647836SJohn.Forte@Sun.COM lc3.op[1] = OP_INTEGER;
15657836SJohn.Forte@Sun.COM lc3.op[2] = 0;
15667836SJohn.Forte@Sun.COM /* cb_get_node_info callback returned Node object. */
15677836SJohn.Forte@Sun.COM lc3.data[2].ptr = lc.data[2].ptr;
15687836SJohn.Forte@Sun.COM for (;;) {
15697836SJohn.Forte@Sun.COM ret = cache_lookup(&lc2, &uid, cb_get_pg_info);
15707836SJohn.Forte@Sun.COM if (uid != 0) {
15717836SJohn.Forte@Sun.COM /* we found a portal group */
15727836SJohn.Forte@Sun.COM lc2.curr_uid = uid;
1573*8854Swl202157@icefox /* it is a null pg if pgt is zero. */
1574*8854Swl202157@icefox if (lc2.id[2] != 0) {
1575*8854Swl202157@icefox /* pass ip addr */
1576*8854Swl202157@icefox lc3.data[0].ip = lc2.data[1].ip;
1577*8854Swl202157@icefox /* pass port num */
1578*8854Swl202157@icefox lc3.data[1].ui = lc2.data[2].ui;
1579*8854Swl202157@icefox /* pass pgt */
1580*8854Swl202157@icefox lc3.id[2] = lc2.id[2];
1581*8854Swl202157@icefox ret = cache_lookup(&lc3, &uid,
1582*8854Swl202157@icefox cb_get_portal_info);
1583*8854Swl202157@icefox }
15847836SJohn.Forte@Sun.COM } else {
15857836SJohn.Forte@Sun.COM /*
15867836SJohn.Forte@Sun.COM * no more portal group which is
15877836SJohn.Forte@Sun.COM * tied to this stroage node object.
15887836SJohn.Forte@Sun.COM */
15897836SJohn.Forte@Sun.COM break;
15907836SJohn.Forte@Sun.COM }
15917836SJohn.Forte@Sun.COM }
15927836SJohn.Forte@Sun.COM }
15937836SJohn.Forte@Sun.COM /* save error for this iteration */
15947836SJohn.Forte@Sun.COM if (ret != 0) {
15957836SJohn.Forte@Sun.COM ret_save = ret;
15967836SJohn.Forte@Sun.COM }
15977836SJohn.Forte@Sun.COM ret = 0;
15987836SJohn.Forte@Sun.COM i++;
15997836SJohn.Forte@Sun.COM }
16007836SJohn.Forte@Sun.COM
16017836SJohn.Forte@Sun.COM return (handle_partial_success(doc, ret_save));
16027836SJohn.Forte@Sun.COM }
16037836SJohn.Forte@Sun.COM
16047836SJohn.Forte@Sun.COM /*
16057836SJohn.Forte@Sun.COM * ****************************************************************************
16067836SJohn.Forte@Sun.COM *
16077836SJohn.Forte@Sun.COM * i_get_dd_dds_op:
16087836SJohn.Forte@Sun.COM * serves get operatrion on dd or dds.
16097836SJohn.Forte@Sun.COM *
16107836SJohn.Forte@Sun.COM * req - contains all info for a request.
16117836SJohn.Forte@Sun.COM * doc - response doc to fill up
16127836SJohn.Forte@Sun.COM * obj_type - object type(either dd or dd set)
16137836SJohn.Forte@Sun.COM *
16147836SJohn.Forte@Sun.COM * ****************************************************************************
16157836SJohn.Forte@Sun.COM */
16167836SJohn.Forte@Sun.COM static int
i_get_dd_dds_op(request_t * req,xmlDocPtr doc,isns_type_t obj_type)16177836SJohn.Forte@Sun.COM i_get_dd_dds_op(
16187836SJohn.Forte@Sun.COM request_t *req,
16197836SJohn.Forte@Sun.COM xmlDocPtr doc,
16207836SJohn.Forte@Sun.COM isns_type_t obj_type
16217836SJohn.Forte@Sun.COM /* any additional arguments go here */
16227836SJohn.Forte@Sun.COM )
16237836SJohn.Forte@Sun.COM {
16247836SJohn.Forte@Sun.COM result_code_t ret = 0, ret_save = 0;
16257836SJohn.Forte@Sun.COM int i = 0;
16267836SJohn.Forte@Sun.COM lookup_ctrl_t lc;
16277836SJohn.Forte@Sun.COM uint32_t uid;
16287836SJohn.Forte@Sun.COM
16297836SJohn.Forte@Sun.COM if ((obj_type != OBJ_DD) && (obj_type != OBJ_DDS)) {
16307836SJohn.Forte@Sun.COM return (ERR_INVALID_MGMT_REQUEST);
16317836SJohn.Forte@Sun.COM }
16327836SJohn.Forte@Sun.COM
16337836SJohn.Forte@Sun.COM /* prepare lookup ctrl data for looking for the node object */
16347836SJohn.Forte@Sun.COM lc.curr_uid = 0;
16357836SJohn.Forte@Sun.COM lc.type = obj_type;
16367836SJohn.Forte@Sun.COM lc.id[0] = get_lc_id(req->op_info.obj);
16377836SJohn.Forte@Sun.COM lc.op[0] = OP_STRING;
16387836SJohn.Forte@Sun.COM lc.op[1] = 0;
16397836SJohn.Forte@Sun.COM lc.data[1].ptr = (uchar_t *)doc; /* xml writer descriptor */
16407836SJohn.Forte@Sun.COM while (i < req->count) {
16417836SJohn.Forte@Sun.COM if (obj_type == OBJ_DD) {
16427836SJohn.Forte@Sun.COM lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
16437836SJohn.Forte@Sun.COM ret = cache_lookup(&lc, &uid, cb_get_dd_info);
16447836SJohn.Forte@Sun.COM if (uid == 0) {
16457836SJohn.Forte@Sun.COM /* set an error and continue. */
16467836SJohn.Forte@Sun.COM ret = ERR_MATCHING_DD_NOT_FOUND;
16477836SJohn.Forte@Sun.COM }
16487836SJohn.Forte@Sun.COM } else {
16497836SJohn.Forte@Sun.COM lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
16507836SJohn.Forte@Sun.COM ret = cache_lookup(&lc, &uid, cb_get_ddset_info);
16517836SJohn.Forte@Sun.COM if (uid == 0) {
16527836SJohn.Forte@Sun.COM /* set an error and continue. */
16537836SJohn.Forte@Sun.COM ret = ERR_MATCHING_DDSET_NOT_FOUND;
16547836SJohn.Forte@Sun.COM }
16557836SJohn.Forte@Sun.COM }
16567836SJohn.Forte@Sun.COM /* save error for this iteration */
16577836SJohn.Forte@Sun.COM if (ret != 0) {
16587836SJohn.Forte@Sun.COM ret_save = ret;
16597836SJohn.Forte@Sun.COM }
16607836SJohn.Forte@Sun.COM ret = 0;
16617836SJohn.Forte@Sun.COM i++;
16627836SJohn.Forte@Sun.COM }
16637836SJohn.Forte@Sun.COM
16647836SJohn.Forte@Sun.COM return (handle_partial_success(doc, ret_save));
16657836SJohn.Forte@Sun.COM }
16667836SJohn.Forte@Sun.COM
16677836SJohn.Forte@Sun.COM /*
16687836SJohn.Forte@Sun.COM * ****************************************************************************
16697836SJohn.Forte@Sun.COM *
16707836SJohn.Forte@Sun.COM * i_delete_ddmember_op:
16717836SJohn.Forte@Sun.COM * serves delete member operatrion on dd.
16727836SJohn.Forte@Sun.COM *
16737836SJohn.Forte@Sun.COM * container - dd name
16747836SJohn.Forte@Sun.COM * member - node name
16757836SJohn.Forte@Sun.COM *
16767836SJohn.Forte@Sun.COM * ****************************************************************************
16777836SJohn.Forte@Sun.COM */
16787836SJohn.Forte@Sun.COM static int
i_delete_ddmember_op(uchar_t * container,uchar_t * member)16797836SJohn.Forte@Sun.COM i_delete_ddmember_op(
16807836SJohn.Forte@Sun.COM uchar_t *container,
16817836SJohn.Forte@Sun.COM uchar_t *member
16827836SJohn.Forte@Sun.COM )
16837836SJohn.Forte@Sun.COM {
16847836SJohn.Forte@Sun.COM int ret = 0;
16857836SJohn.Forte@Sun.COM
16867836SJohn.Forte@Sun.COM isns_assoc_iscsi_t aiscsi;
16877836SJohn.Forte@Sun.COM isns_obj_t *assoc;
16887836SJohn.Forte@Sun.COM isns_attr_t *attr;
16897836SJohn.Forte@Sun.COM int len;
16907836SJohn.Forte@Sun.COM
16917836SJohn.Forte@Sun.COM lookup_ctrl_t lc;
16927836SJohn.Forte@Sun.COM uint32_t dd_id;
16937836SJohn.Forte@Sun.COM
16947836SJohn.Forte@Sun.COM /* prepare lookup ctrl data for looking for the dd object */
16957836SJohn.Forte@Sun.COM lc.curr_uid = 0;
16967836SJohn.Forte@Sun.COM lc.type = OBJ_DD;
16977836SJohn.Forte@Sun.COM lc.id[0] = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
16987836SJohn.Forte@Sun.COM lc.op[0] = OP_STRING;
16997836SJohn.Forte@Sun.COM lc.data[0].ptr = container;
17007836SJohn.Forte@Sun.COM lc.op[1] = 0;
17017836SJohn.Forte@Sun.COM
17027836SJohn.Forte@Sun.COM if ((dd_id = is_obj_there(&lc)) != 0) {
17037836SJohn.Forte@Sun.COM aiscsi.type = OBJ_ASSOC_ISCSI;
17047836SJohn.Forte@Sun.COM aiscsi.puid = dd_id;
17057836SJohn.Forte@Sun.COM
17067836SJohn.Forte@Sun.COM len = strlen((char *)member) + 1;
17077836SJohn.Forte@Sun.COM len += 4 - (len % 4);
17087836SJohn.Forte@Sun.COM
17097836SJohn.Forte@Sun.COM attr = &aiscsi.attrs[ATTR_INDEX_ASSOC_ISCSI(
17107836SJohn.Forte@Sun.COM ISNS_DD_ISCSI_NAME_ATTR_ID)];
17117836SJohn.Forte@Sun.COM attr->tag = ISNS_DD_ISCSI_NAME_ATTR_ID;
17127836SJohn.Forte@Sun.COM attr->len = len;
17137836SJohn.Forte@Sun.COM attr->value.ptr = (uchar_t *)member;
17147836SJohn.Forte@Sun.COM attr = &aiscsi.attrs[ATTR_INDEX_ASSOC_ISCSI(
17157836SJohn.Forte@Sun.COM ISNS_DD_ISCSI_INDEX_ATTR_ID)];
17167836SJohn.Forte@Sun.COM attr->tag = 0; /* clear it */
17177836SJohn.Forte@Sun.COM assoc = (isns_obj_t *)&aiscsi;
17187836SJohn.Forte@Sun.COM ret = remove_dd_member(assoc);
17197836SJohn.Forte@Sun.COM } else {
17207836SJohn.Forte@Sun.COM ret = ERR_MATCHING_DD_NOT_FOUND;
17217836SJohn.Forte@Sun.COM }
17227836SJohn.Forte@Sun.COM
17237836SJohn.Forte@Sun.COM return (ret);
17247836SJohn.Forte@Sun.COM }
17257836SJohn.Forte@Sun.COM
17267836SJohn.Forte@Sun.COM /*
17277836SJohn.Forte@Sun.COM * ****************************************************************************
17287836SJohn.Forte@Sun.COM *
17297836SJohn.Forte@Sun.COM * i_delete_ddsetmember_op:
17307836SJohn.Forte@Sun.COM * serves delete member operatrion on dd set.
17317836SJohn.Forte@Sun.COM *
17327836SJohn.Forte@Sun.COM * container - dd set name
17337836SJohn.Forte@Sun.COM * member - dd name
17347836SJohn.Forte@Sun.COM *
17357836SJohn.Forte@Sun.COM * ****************************************************************************
17367836SJohn.Forte@Sun.COM */
17377836SJohn.Forte@Sun.COM static int
i_delete_ddsetmember_op(uchar_t * container,uchar_t * member)17387836SJohn.Forte@Sun.COM i_delete_ddsetmember_op(
17397836SJohn.Forte@Sun.COM uchar_t *container,
17407836SJohn.Forte@Sun.COM uchar_t *member
17417836SJohn.Forte@Sun.COM )
17427836SJohn.Forte@Sun.COM {
17437836SJohn.Forte@Sun.COM int ret = 0;
17447836SJohn.Forte@Sun.COM
17457836SJohn.Forte@Sun.COM lookup_ctrl_t lc, lc2;
17467836SJohn.Forte@Sun.COM uint32_t container_id, member_id;
17477836SJohn.Forte@Sun.COM
17487836SJohn.Forte@Sun.COM /* prepare lookup ctrl data for looking for the dd-set object */
17497836SJohn.Forte@Sun.COM lc.curr_uid = 0;
17507836SJohn.Forte@Sun.COM lc.type = OBJ_DDS;
17517836SJohn.Forte@Sun.COM lc.id[0] = ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID);
17527836SJohn.Forte@Sun.COM lc.op[0] = OP_STRING;
17537836SJohn.Forte@Sun.COM lc.data[0].ptr = container;
17547836SJohn.Forte@Sun.COM lc.op[1] = 0;
17557836SJohn.Forte@Sun.COM
17567836SJohn.Forte@Sun.COM /* prepare lookup ctrl data for looking for the dd object */
17577836SJohn.Forte@Sun.COM lc2.curr_uid = 0;
17587836SJohn.Forte@Sun.COM lc2.type = OBJ_DD;
17597836SJohn.Forte@Sun.COM lc2.id[0] = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
17607836SJohn.Forte@Sun.COM lc2.op[0] = OP_STRING;
17617836SJohn.Forte@Sun.COM lc2.data[0].ptr = member;
17627836SJohn.Forte@Sun.COM lc2.op[1] = 0;
17637836SJohn.Forte@Sun.COM
17647836SJohn.Forte@Sun.COM if ((container_id = is_obj_there(&lc)) != 0) {
17657836SJohn.Forte@Sun.COM if ((member_id = is_obj_there(&lc2)) != 0) {
17667836SJohn.Forte@Sun.COM ret = remove_dds_member(container_id, member_id);
17677836SJohn.Forte@Sun.COM } else {
17687836SJohn.Forte@Sun.COM ret = ERR_MATCHING_DD_NOT_FOUND;
17697836SJohn.Forte@Sun.COM }
17707836SJohn.Forte@Sun.COM } else {
17717836SJohn.Forte@Sun.COM ret = ERR_MATCHING_DDSET_NOT_FOUND;
17727836SJohn.Forte@Sun.COM }
17737836SJohn.Forte@Sun.COM
17747836SJohn.Forte@Sun.COM return (ret);
17757836SJohn.Forte@Sun.COM }
17767836SJohn.Forte@Sun.COM
17777836SJohn.Forte@Sun.COM /*
17787836SJohn.Forte@Sun.COM * ****************************************************************************
17797836SJohn.Forte@Sun.COM *
17807836SJohn.Forte@Sun.COM * get_dd_op:
17817836SJohn.Forte@Sun.COM * service get operation on given dd(s).
17827836SJohn.Forte@Sun.COM *
17837836SJohn.Forte@Sun.COM * req - contains all info for a request.
17847836SJohn.Forte@Sun.COM * doc - response doc to fill up
17857836SJohn.Forte@Sun.COM *
17867836SJohn.Forte@Sun.COM * ****************************************************************************
17877836SJohn.Forte@Sun.COM */
17887836SJohn.Forte@Sun.COM int
get_dd_op(request_t * req,xmlDocPtr doc)17897836SJohn.Forte@Sun.COM get_dd_op(
17907836SJohn.Forte@Sun.COM request_t *req,
17917836SJohn.Forte@Sun.COM xmlDocPtr doc
17927836SJohn.Forte@Sun.COM /* any additional arguments go here */
17937836SJohn.Forte@Sun.COM )
17947836SJohn.Forte@Sun.COM {
17957836SJohn.Forte@Sun.COM return (i_get_dd_dds_op(req, doc, OBJ_DD));
17967836SJohn.Forte@Sun.COM }
17977836SJohn.Forte@Sun.COM
17987836SJohn.Forte@Sun.COM /*
17997836SJohn.Forte@Sun.COM * ****************************************************************************
18007836SJohn.Forte@Sun.COM *
18017836SJohn.Forte@Sun.COM * get_ddset_op:
18027836SJohn.Forte@Sun.COM * service get operation on given dd set(s).
18037836SJohn.Forte@Sun.COM *
18047836SJohn.Forte@Sun.COM * req - contains all info for a request.
18057836SJohn.Forte@Sun.COM * doc - response doc to fill up
18067836SJohn.Forte@Sun.COM *
18077836SJohn.Forte@Sun.COM * ****************************************************************************
18087836SJohn.Forte@Sun.COM */
18097836SJohn.Forte@Sun.COM int
get_ddset_op(request_t * req,xmlDocPtr doc)18107836SJohn.Forte@Sun.COM get_ddset_op(
18117836SJohn.Forte@Sun.COM request_t *req,
18127836SJohn.Forte@Sun.COM xmlDocPtr doc
18137836SJohn.Forte@Sun.COM /* any additional arguments go here */
18147836SJohn.Forte@Sun.COM )
18157836SJohn.Forte@Sun.COM {
18167836SJohn.Forte@Sun.COM return (i_get_dd_dds_op(req, doc, OBJ_DDS));
18177836SJohn.Forte@Sun.COM }
18187836SJohn.Forte@Sun.COM
18197836SJohn.Forte@Sun.COM /*
18207836SJohn.Forte@Sun.COM * ****************************************************************************
18217836SJohn.Forte@Sun.COM *
18227836SJohn.Forte@Sun.COM * enumerate_node_op:
18237836SJohn.Forte@Sun.COM * services enumerate node op.
18247836SJohn.Forte@Sun.COM *
18257836SJohn.Forte@Sun.COM * req - contains enumerate request info.
18267836SJohn.Forte@Sun.COM * doc - response doc to fill up
18277836SJohn.Forte@Sun.COM *
18287836SJohn.Forte@Sun.COM * ****************************************************************************
18297836SJohn.Forte@Sun.COM */
18307836SJohn.Forte@Sun.COM int
enumerate_node_op(xmlDocPtr doc)18317836SJohn.Forte@Sun.COM enumerate_node_op(
18327836SJohn.Forte@Sun.COM xmlDocPtr doc
18337836SJohn.Forte@Sun.COM /* any additional arguments go here */
18347836SJohn.Forte@Sun.COM )
18357836SJohn.Forte@Sun.COM {
18367836SJohn.Forte@Sun.COM htab_t *htab = cache_get_htab(OBJ_ISCSI);
18377836SJohn.Forte@Sun.COM uint32_t uid = 0;
18387836SJohn.Forte@Sun.COM lookup_ctrl_t lc;
18397836SJohn.Forte@Sun.COM int ret = 0, ret_save = 0;
18407836SJohn.Forte@Sun.COM
18417836SJohn.Forte@Sun.COM SET_UID_LCP(&lc, OBJ_ISCSI, 0);
18427836SJohn.Forte@Sun.COM
18437836SJohn.Forte@Sun.COM lc.data[1].ptr = (uchar_t *)doc;
18447836SJohn.Forte@Sun.COM lc.data[2].ui = 0;
18457836SJohn.Forte@Sun.COM
18467836SJohn.Forte@Sun.COM FOR_EACH_ITEM(htab, uid, {
18477836SJohn.Forte@Sun.COM lc.data[0].ui = uid;
18487836SJohn.Forte@Sun.COM ret = cache_lookup(&lc, NULL, cb_enumerate_node_info);
18497836SJohn.Forte@Sun.COM if (ret != 0) {
18507836SJohn.Forte@Sun.COM ret_save = ret;
18517836SJohn.Forte@Sun.COM }
18527836SJohn.Forte@Sun.COM });
18537836SJohn.Forte@Sun.COM
18547836SJohn.Forte@Sun.COM return (handle_partial_success(doc, ret_save));
18557836SJohn.Forte@Sun.COM }
18567836SJohn.Forte@Sun.COM
18577836SJohn.Forte@Sun.COM /*
18587836SJohn.Forte@Sun.COM * ****************************************************************************
18597836SJohn.Forte@Sun.COM *
18607836SJohn.Forte@Sun.COM * enumerate_dd_op:
18617836SJohn.Forte@Sun.COM * services enumerate discovery domain op.
18627836SJohn.Forte@Sun.COM *
18637836SJohn.Forte@Sun.COM * req - contains enumerate request info.
18647836SJohn.Forte@Sun.COM * doc - response doc to fill up
18657836SJohn.Forte@Sun.COM *
18667836SJohn.Forte@Sun.COM * ****************************************************************************
18677836SJohn.Forte@Sun.COM */
18687836SJohn.Forte@Sun.COM int
enumerate_dd_op(xmlDocPtr doc)18697836SJohn.Forte@Sun.COM enumerate_dd_op(
18707836SJohn.Forte@Sun.COM xmlDocPtr doc
18717836SJohn.Forte@Sun.COM /* any additional arguments go here */
18727836SJohn.Forte@Sun.COM )
18737836SJohn.Forte@Sun.COM {
18747836SJohn.Forte@Sun.COM
18757836SJohn.Forte@Sun.COM htab_t *htab = cache_get_htab(OBJ_DD);
18767836SJohn.Forte@Sun.COM uint32_t uid = 0;
18777836SJohn.Forte@Sun.COM lookup_ctrl_t lc;
18787836SJohn.Forte@Sun.COM int ret = 0, ret_save = 0;
18797836SJohn.Forte@Sun.COM
18807836SJohn.Forte@Sun.COM SET_UID_LCP(&lc, OBJ_DD, 0);
18817836SJohn.Forte@Sun.COM
18827836SJohn.Forte@Sun.COM lc.data[1].ptr = (uchar_t *)doc;
18837836SJohn.Forte@Sun.COM lc.data[2].ui = 0;
18847836SJohn.Forte@Sun.COM
18857836SJohn.Forte@Sun.COM FOR_EACH_ITEM(htab, uid, {
18867836SJohn.Forte@Sun.COM lc.data[0].ui = uid;
18877836SJohn.Forte@Sun.COM ret = cache_lookup(&lc, NULL, cb_enumerate_dd_info);
18887836SJohn.Forte@Sun.COM if (ret != 0) {
18897836SJohn.Forte@Sun.COM ret_save = ret;
18907836SJohn.Forte@Sun.COM }
18917836SJohn.Forte@Sun.COM });
18927836SJohn.Forte@Sun.COM
18937836SJohn.Forte@Sun.COM return (handle_partial_success(doc, ret_save));
18947836SJohn.Forte@Sun.COM }
18957836SJohn.Forte@Sun.COM
18967836SJohn.Forte@Sun.COM /*
18977836SJohn.Forte@Sun.COM * ****************************************************************************
18987836SJohn.Forte@Sun.COM *
18997836SJohn.Forte@Sun.COM * enumerate_ddset_op:
19007836SJohn.Forte@Sun.COM * services enumerate discovery domain set op.
19017836SJohn.Forte@Sun.COM *
19027836SJohn.Forte@Sun.COM * req - contains enumerate request info.
19037836SJohn.Forte@Sun.COM * doc - response doc to fill up
19047836SJohn.Forte@Sun.COM *
19057836SJohn.Forte@Sun.COM * ****************************************************************************
19067836SJohn.Forte@Sun.COM */
19077836SJohn.Forte@Sun.COM int
enumerate_ddset_op(xmlDocPtr doc)19087836SJohn.Forte@Sun.COM enumerate_ddset_op(
19097836SJohn.Forte@Sun.COM xmlDocPtr doc
19107836SJohn.Forte@Sun.COM /* any additional arguments go here */
19117836SJohn.Forte@Sun.COM )
19127836SJohn.Forte@Sun.COM {
19137836SJohn.Forte@Sun.COM htab_t *htab = cache_get_htab(OBJ_DDS);
19147836SJohn.Forte@Sun.COM uint32_t uid = 0;
19157836SJohn.Forte@Sun.COM lookup_ctrl_t lc;
19167836SJohn.Forte@Sun.COM int ret = 0, ret_save = 0;
19177836SJohn.Forte@Sun.COM
19187836SJohn.Forte@Sun.COM SET_UID_LCP(&lc, OBJ_DDS, 0);
19197836SJohn.Forte@Sun.COM
19207836SJohn.Forte@Sun.COM lc.data[1].ptr = (uchar_t *)doc;
19217836SJohn.Forte@Sun.COM lc.data[2].ui = 0;
19227836SJohn.Forte@Sun.COM
19237836SJohn.Forte@Sun.COM FOR_EACH_ITEM(htab, uid, {
19247836SJohn.Forte@Sun.COM lc.data[0].ui = uid;
19257836SJohn.Forte@Sun.COM ret = cache_lookup(&lc, NULL, cb_enumerate_ddset_info);
19267836SJohn.Forte@Sun.COM if (ret != 0) {
19277836SJohn.Forte@Sun.COM ret_save = ret;
19287836SJohn.Forte@Sun.COM }
19297836SJohn.Forte@Sun.COM });
19307836SJohn.Forte@Sun.COM
19317836SJohn.Forte@Sun.COM return (handle_partial_success(doc, ret_save));
19327836SJohn.Forte@Sun.COM }
19337836SJohn.Forte@Sun.COM
19347836SJohn.Forte@Sun.COM /*
19357836SJohn.Forte@Sun.COM * ****************************************************************************
19367836SJohn.Forte@Sun.COM *
19377836SJohn.Forte@Sun.COM * getassociated_dd_to_node_op:
19387836SJohn.Forte@Sun.COM * construct a list of node that is associated with a given Discovery
19397836SJohn.Forte@Sun.COM * Domain.
19407836SJohn.Forte@Sun.COM *
19417836SJohn.Forte@Sun.COM * req - contains getAssociated request info.
19427836SJohn.Forte@Sun.COM * doc - response doc to fill up
19437836SJohn.Forte@Sun.COM *
19447836SJohn.Forte@Sun.COM * ****************************************************************************
19457836SJohn.Forte@Sun.COM */
19467836SJohn.Forte@Sun.COM int
getAssociated_dd_to_node_op(request_t * req,xmlDocPtr doc)19477836SJohn.Forte@Sun.COM getAssociated_dd_to_node_op(
19487836SJohn.Forte@Sun.COM request_t *req,
19497836SJohn.Forte@Sun.COM xmlDocPtr doc
19507836SJohn.Forte@Sun.COM /* any additional arguments go here */
19517836SJohn.Forte@Sun.COM )
19527836SJohn.Forte@Sun.COM {
19537836SJohn.Forte@Sun.COM uint32_t uid = 0, n;
19547836SJohn.Forte@Sun.COM lookup_ctrl_t lc, lc2;
19557836SJohn.Forte@Sun.COM int i = 0, ret = 0, ret_save = 0;
19567836SJohn.Forte@Sun.COM bmp_t *p;
19577836SJohn.Forte@Sun.COM
19587836SJohn.Forte@Sun.COM lc.curr_uid = 0;
19597836SJohn.Forte@Sun.COM lc.type = OBJ_DD;
19607836SJohn.Forte@Sun.COM lc.id[0] = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
19617836SJohn.Forte@Sun.COM lc.op[0] = OP_STRING;
19627836SJohn.Forte@Sun.COM lc.op[1] = 0;
19637836SJohn.Forte@Sun.COM
19647836SJohn.Forte@Sun.COM SET_UID_LCP(&lc2, OBJ_ISCSI, 0);
19657836SJohn.Forte@Sun.COM
19667836SJohn.Forte@Sun.COM lc2.data[1].ptr = (uchar_t *)doc;
19677836SJohn.Forte@Sun.COM
19687836SJohn.Forte@Sun.COM while (i < req->count) {
19697836SJohn.Forte@Sun.COM lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
19707836SJohn.Forte@Sun.COM if ((uid = is_obj_there(&lc)) != 0) {
19717836SJohn.Forte@Sun.COM ret = get_dd_matrix(uid, &p, &n);
19727836SJohn.Forte@Sun.COM FOR_EACH_MEMBER(p, n, uid, {
19737836SJohn.Forte@Sun.COM lc2.data[0].ui = uid;
19747836SJohn.Forte@Sun.COM lc2.data[2].ptr = (uchar_t *)req->req_data.data[i];
19757836SJohn.Forte@Sun.COM ret = cache_lookup(&lc2, NULL,
19767836SJohn.Forte@Sun.COM cb_getAssociated_node_info);
19777836SJohn.Forte@Sun.COM });
19787836SJohn.Forte@Sun.COM free(p);
19797836SJohn.Forte@Sun.COM } else {
19807836SJohn.Forte@Sun.COM ret = ERR_MATCHING_DD_NOT_FOUND;
19817836SJohn.Forte@Sun.COM }
19827836SJohn.Forte@Sun.COM /* save error for this iteration */
19837836SJohn.Forte@Sun.COM if (ret != 0) {
19847836SJohn.Forte@Sun.COM ret_save = ret;
19857836SJohn.Forte@Sun.COM }
19867836SJohn.Forte@Sun.COM ret = 0;
19877836SJohn.Forte@Sun.COM i++;
19887836SJohn.Forte@Sun.COM }
19897836SJohn.Forte@Sun.COM
19907836SJohn.Forte@Sun.COM return (handle_partial_success(doc, ret_save));
19917836SJohn.Forte@Sun.COM }
19927836SJohn.Forte@Sun.COM
19937836SJohn.Forte@Sun.COM /*
19947836SJohn.Forte@Sun.COM * ****************************************************************************
19957836SJohn.Forte@Sun.COM *
19967836SJohn.Forte@Sun.COM * getassociated_node_to_dd_op:
19977836SJohn.Forte@Sun.COM * construct a list of Discovery Doamins that is associated with a given
19987836SJohn.Forte@Sun.COM * node.
19997836SJohn.Forte@Sun.COM *
20007836SJohn.Forte@Sun.COM * req - contains getAssociated request info.
20017836SJohn.Forte@Sun.COM * doc - response doc to fill up
20027836SJohn.Forte@Sun.COM *
20037836SJohn.Forte@Sun.COM * ****************************************************************************
20047836SJohn.Forte@Sun.COM */
20057836SJohn.Forte@Sun.COM int
getAssociated_node_to_dd_op(request_t * req,xmlDocPtr doc)20067836SJohn.Forte@Sun.COM getAssociated_node_to_dd_op(
20077836SJohn.Forte@Sun.COM request_t *req,
20087836SJohn.Forte@Sun.COM xmlDocPtr doc
20097836SJohn.Forte@Sun.COM /* any additional arguments go here */
20107836SJohn.Forte@Sun.COM )
20117836SJohn.Forte@Sun.COM {
20127836SJohn.Forte@Sun.COM uint32_t uid = 0, dd_id;
20137836SJohn.Forte@Sun.COM lookup_ctrl_t lc, lc2;
20147836SJohn.Forte@Sun.COM int i = 0, ret = 0, ret_save = 0;
20157836SJohn.Forte@Sun.COM
20167836SJohn.Forte@Sun.COM lc.curr_uid = 0;
20177836SJohn.Forte@Sun.COM lc.type = OBJ_ISCSI;
20187836SJohn.Forte@Sun.COM lc.id[0] = ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID);
20197836SJohn.Forte@Sun.COM lc.op[0] = OP_STRING;
20207836SJohn.Forte@Sun.COM lc.op[1] = 0;
20217836SJohn.Forte@Sun.COM
20227836SJohn.Forte@Sun.COM SET_UID_LCP(&lc2, OBJ_DD, 0);
20237836SJohn.Forte@Sun.COM
20247836SJohn.Forte@Sun.COM lc2.data[1].ptr = (uchar_t *)doc;
20257836SJohn.Forte@Sun.COM
20267836SJohn.Forte@Sun.COM while (i < req->count) {
20277836SJohn.Forte@Sun.COM lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
20287836SJohn.Forte@Sun.COM if ((uid = is_obj_there(&lc)) != 0) {
20297836SJohn.Forte@Sun.COM if ((dd_id = get_dd_id(uid, 0)) == 0) {
20307836SJohn.Forte@Sun.COM ret = ERR_NO_ASSOCIATED_DD_FOUND;
20317836SJohn.Forte@Sun.COM i++;
20327836SJohn.Forte@Sun.COM continue;
20337836SJohn.Forte@Sun.COM } else {
20347836SJohn.Forte@Sun.COM do {
20357836SJohn.Forte@Sun.COM lc2.data[0].ui = dd_id;
20367836SJohn.Forte@Sun.COM lc2.data[2].ptr = (uchar_t *)req->req_data.data[i];
20377836SJohn.Forte@Sun.COM ret = cache_lookup(&lc2, NULL,
20387836SJohn.Forte@Sun.COM cb_getAssociated_node_to_dd_info);
20397836SJohn.Forte@Sun.COM dd_id = get_dd_id(uid, dd_id);
20407836SJohn.Forte@Sun.COM } while (dd_id != 0);
20417836SJohn.Forte@Sun.COM };
20427836SJohn.Forte@Sun.COM } else {
20437836SJohn.Forte@Sun.COM ret = ERR_MATCHING_NODE_NOT_FOUND;
20447836SJohn.Forte@Sun.COM }
20457836SJohn.Forte@Sun.COM /* save error for this iteration */
20467836SJohn.Forte@Sun.COM if (ret != 0) {
20477836SJohn.Forte@Sun.COM ret_save = ret;
20487836SJohn.Forte@Sun.COM }
20497836SJohn.Forte@Sun.COM ret = 0;
20507836SJohn.Forte@Sun.COM i++;
20517836SJohn.Forte@Sun.COM }
20527836SJohn.Forte@Sun.COM
20537836SJohn.Forte@Sun.COM return (handle_partial_success(doc, ret_save));
20547836SJohn.Forte@Sun.COM }
20557836SJohn.Forte@Sun.COM
20567836SJohn.Forte@Sun.COM /*
20577836SJohn.Forte@Sun.COM * ****************************************************************************
20587836SJohn.Forte@Sun.COM *
20597836SJohn.Forte@Sun.COM * getassociated_ddset_to_dd_op:
20607836SJohn.Forte@Sun.COM * construct a list of Discovery Doamins that is associated with a given
20617836SJohn.Forte@Sun.COM * Discover Domain set.
20627836SJohn.Forte@Sun.COM *
20637836SJohn.Forte@Sun.COM * req - contains getAssociated request info.
20647836SJohn.Forte@Sun.COM * doc - response doc to fill up
20657836SJohn.Forte@Sun.COM *
20667836SJohn.Forte@Sun.COM * ****************************************************************************
20677836SJohn.Forte@Sun.COM */
20687836SJohn.Forte@Sun.COM int
getAssociated_ddset_to_dd_op(request_t * req,xmlDocPtr doc)20697836SJohn.Forte@Sun.COM getAssociated_ddset_to_dd_op(
20707836SJohn.Forte@Sun.COM request_t *req,
20717836SJohn.Forte@Sun.COM xmlDocPtr doc
20727836SJohn.Forte@Sun.COM /* any additional arguments go here */
20737836SJohn.Forte@Sun.COM )
20747836SJohn.Forte@Sun.COM {
20757836SJohn.Forte@Sun.COM uint32_t uid = 0, n;
20767836SJohn.Forte@Sun.COM lookup_ctrl_t lc, lc2;
20777836SJohn.Forte@Sun.COM int i = 0, ret = 0, ret_save = 0;
20787836SJohn.Forte@Sun.COM bmp_t *p;
20797836SJohn.Forte@Sun.COM
20807836SJohn.Forte@Sun.COM lc.curr_uid = 0;
20817836SJohn.Forte@Sun.COM lc.type = OBJ_DDS;
20827836SJohn.Forte@Sun.COM lc.id[0] = ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID);
20837836SJohn.Forte@Sun.COM lc.op[0] = OP_STRING;
20847836SJohn.Forte@Sun.COM lc.op[1] = 0;
20857836SJohn.Forte@Sun.COM
20867836SJohn.Forte@Sun.COM SET_UID_LCP(&lc2, OBJ_DD, 0);
20877836SJohn.Forte@Sun.COM
20887836SJohn.Forte@Sun.COM lc2.data[1].ptr = (uchar_t *)doc;
20897836SJohn.Forte@Sun.COM
20907836SJohn.Forte@Sun.COM while (i < req->count) {
20917836SJohn.Forte@Sun.COM lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
20927836SJohn.Forte@Sun.COM if ((uid = is_obj_there(&lc)) != 0) {
20937836SJohn.Forte@Sun.COM ret = get_dds_matrix(uid, &p, &n);
20947836SJohn.Forte@Sun.COM FOR_EACH_MEMBER(p, n, uid, {
20957836SJohn.Forte@Sun.COM lc2.data[0].ui = uid;
20967836SJohn.Forte@Sun.COM lc2.data[2].ptr = (uchar_t *)req->req_data.data[i];
20977836SJohn.Forte@Sun.COM ret = cache_lookup(&lc2, NULL,
20987836SJohn.Forte@Sun.COM cb_getAssociated_dd_info);
20997836SJohn.Forte@Sun.COM });
21007836SJohn.Forte@Sun.COM free(p);
21017836SJohn.Forte@Sun.COM } else {
21027836SJohn.Forte@Sun.COM ret = ERR_MATCHING_DDSET_NOT_FOUND;
21037836SJohn.Forte@Sun.COM }
21047836SJohn.Forte@Sun.COM /* save error for this iteration */
21057836SJohn.Forte@Sun.COM if (ret != 0) {
21067836SJohn.Forte@Sun.COM ret_save = ret;
21077836SJohn.Forte@Sun.COM }
21087836SJohn.Forte@Sun.COM ret = 0;
21097836SJohn.Forte@Sun.COM i++;
21107836SJohn.Forte@Sun.COM }
21117836SJohn.Forte@Sun.COM
21127836SJohn.Forte@Sun.COM return (handle_partial_success(doc, ret_save));
21137836SJohn.Forte@Sun.COM }
21147836SJohn.Forte@Sun.COM
21157836SJohn.Forte@Sun.COM /*
21167836SJohn.Forte@Sun.COM * ****************************************************************************
21177836SJohn.Forte@Sun.COM *
21187836SJohn.Forte@Sun.COM * getassociated_dd_to_ddset_op:
21197836SJohn.Forte@Sun.COM * construct a list of Discovery Doamin sets that is associated with a
21207836SJohn.Forte@Sun.COM * given Discovery Domain.
21217836SJohn.Forte@Sun.COM *
21227836SJohn.Forte@Sun.COM * req - contains getAssociated request info.
21237836SJohn.Forte@Sun.COM * doc - response doc to fill up
21247836SJohn.Forte@Sun.COM *
21257836SJohn.Forte@Sun.COM * ****************************************************************************
21267836SJohn.Forte@Sun.COM */
21277836SJohn.Forte@Sun.COM int
getAssociated_dd_to_ddset_op(request_t * req,xmlDocPtr doc)21287836SJohn.Forte@Sun.COM getAssociated_dd_to_ddset_op(
21297836SJohn.Forte@Sun.COM request_t *req,
21307836SJohn.Forte@Sun.COM xmlDocPtr doc
21317836SJohn.Forte@Sun.COM /* any additional arguments go here */
21327836SJohn.Forte@Sun.COM )
21337836SJohn.Forte@Sun.COM {
21347836SJohn.Forte@Sun.COM uint32_t uid = 0, ddset_id;
21357836SJohn.Forte@Sun.COM lookup_ctrl_t lc, lc2;
21367836SJohn.Forte@Sun.COM int i = 0, ret = 0, ret_save = 0;
21377836SJohn.Forte@Sun.COM
21387836SJohn.Forte@Sun.COM lc.curr_uid = 0;
21397836SJohn.Forte@Sun.COM lc.type = OBJ_DD;
21407836SJohn.Forte@Sun.COM lc.id[0] = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
21417836SJohn.Forte@Sun.COM lc.op[0] = OP_STRING;
21427836SJohn.Forte@Sun.COM lc.op[1] = 0;
21437836SJohn.Forte@Sun.COM
21447836SJohn.Forte@Sun.COM SET_UID_LCP(&lc2, OBJ_DDS, 0);
21457836SJohn.Forte@Sun.COM
21467836SJohn.Forte@Sun.COM lc2.data[1].ptr = (uchar_t *)doc;
21477836SJohn.Forte@Sun.COM
21487836SJohn.Forte@Sun.COM while (i < req->count) {
21497836SJohn.Forte@Sun.COM lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
21507836SJohn.Forte@Sun.COM if ((uid = is_obj_there(&lc)) != 0) {
21517836SJohn.Forte@Sun.COM lc2.data[2].ui = 0;
21527836SJohn.Forte@Sun.COM if ((ddset_id = get_dds_id(uid, 0)) == 0) {
21537836SJohn.Forte@Sun.COM ret = ERR_NO_ASSOCIATED_DDSET_FOUND;
21547836SJohn.Forte@Sun.COM i++;
21557836SJohn.Forte@Sun.COM continue;
21567836SJohn.Forte@Sun.COM } else {
21577836SJohn.Forte@Sun.COM do {
21587836SJohn.Forte@Sun.COM lc2.data[0].ui = ddset_id;
21597836SJohn.Forte@Sun.COM lc2.data[2].ptr = (uchar_t *)req->req_data.data[i];
21607836SJohn.Forte@Sun.COM ret = cache_lookup(&lc2, NULL,
21617836SJohn.Forte@Sun.COM cb_getAssociated_dd_to_ddset_info);
21627836SJohn.Forte@Sun.COM ddset_id = get_dds_id(uid, ddset_id);
21637836SJohn.Forte@Sun.COM } while (ddset_id != 0);
21647836SJohn.Forte@Sun.COM };
21657836SJohn.Forte@Sun.COM } else {
21667836SJohn.Forte@Sun.COM ret = ERR_MATCHING_DD_NOT_FOUND;
21677836SJohn.Forte@Sun.COM }
21687836SJohn.Forte@Sun.COM if (ret != 0) {
21697836SJohn.Forte@Sun.COM ret_save = ret;
21707836SJohn.Forte@Sun.COM }
21717836SJohn.Forte@Sun.COM i++;
21727836SJohn.Forte@Sun.COM }
21737836SJohn.Forte@Sun.COM
21747836SJohn.Forte@Sun.COM return (handle_partial_success(doc, ret_save));
21757836SJohn.Forte@Sun.COM }
21767836SJohn.Forte@Sun.COM
21777836SJohn.Forte@Sun.COM /*
21787836SJohn.Forte@Sun.COM * ****************************************************************************
21797836SJohn.Forte@Sun.COM *
21807836SJohn.Forte@Sun.COM * delete_dd_ddset_op:
21817836SJohn.Forte@Sun.COM * removes a list of dd or dd set.
21827836SJohn.Forte@Sun.COM *
21837836SJohn.Forte@Sun.COM * req - contains delete request info.
21847836SJohn.Forte@Sun.COM * doc - response doc to fill up
21857836SJohn.Forte@Sun.COM * obj_type - object type(either dd or dd set)
21867836SJohn.Forte@Sun.COM *
21877836SJohn.Forte@Sun.COM * ****************************************************************************
21887836SJohn.Forte@Sun.COM */
21897836SJohn.Forte@Sun.COM int
delete_dd_ddset_op(request_t * req,xmlDocPtr doc,object_type type)21907836SJohn.Forte@Sun.COM delete_dd_ddset_op(
21917836SJohn.Forte@Sun.COM request_t *req,
21927836SJohn.Forte@Sun.COM xmlDocPtr doc,
21937836SJohn.Forte@Sun.COM object_type type
21947836SJohn.Forte@Sun.COM /* any additional arguments go here */
21957836SJohn.Forte@Sun.COM )
21967836SJohn.Forte@Sun.COM {
21977836SJohn.Forte@Sun.COM result_code_t ret = 0, ret_save = 0;
21987836SJohn.Forte@Sun.COM isns_type_t lc_type;
21997836SJohn.Forte@Sun.COM int i = 0, err_count = 0;
22007836SJohn.Forte@Sun.COM lookup_ctrl_t lc;
22017836SJohn.Forte@Sun.COM uint32_t uid;
22027836SJohn.Forte@Sun.COM xmlNodePtr n_obj, n_node, root;
22037836SJohn.Forte@Sun.COM xmlAttrPtr n_attr;
22047836SJohn.Forte@Sun.COM int different_err = 0;
22057836SJohn.Forte@Sun.COM
22067836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
22077836SJohn.Forte@Sun.COM if (root == NULL) {
22087836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
22097836SJohn.Forte@Sun.COM }
22107836SJohn.Forte@Sun.COM lc_type = get_lc_type(type);
22117836SJohn.Forte@Sun.COM if ((lc_type != OBJ_DD) && (lc_type != OBJ_DDS)) {
22127836SJohn.Forte@Sun.COM return (ERR_INVALID_MGMT_REQUEST);
22137836SJohn.Forte@Sun.COM }
22147836SJohn.Forte@Sun.COM
22157836SJohn.Forte@Sun.COM /* prepare lookup ctrl data for looking for the node object */
22167836SJohn.Forte@Sun.COM lc.curr_uid = 0;
22177836SJohn.Forte@Sun.COM lc.type = lc_type;
22187836SJohn.Forte@Sun.COM lc.id[0] = get_lc_id(req->op_info.obj);
22197836SJohn.Forte@Sun.COM lc.op[0] = OP_STRING;
22207836SJohn.Forte@Sun.COM lc.op[1] = 0;
22217836SJohn.Forte@Sun.COM lc.data[1].ptr = (uchar_t *)doc; /* xml writer descriptor */
22227836SJohn.Forte@Sun.COM while (i < req->count) {
22237836SJohn.Forte@Sun.COM lc.data[0].ptr = (uchar_t *)req->req_data.data[i];
22247836SJohn.Forte@Sun.COM
22257836SJohn.Forte@Sun.COM /* lock the cache for writing */
22267836SJohn.Forte@Sun.COM (void) cache_lock_write();
22277836SJohn.Forte@Sun.COM
22287836SJohn.Forte@Sun.COM if ((uid = is_obj_there(&lc)) != 0) {
22297836SJohn.Forte@Sun.COM /* remove the dd/ddset */
22307836SJohn.Forte@Sun.COM ret = (lc_type == OBJ_DD) ?
22317836SJohn.Forte@Sun.COM remove_dd_object(uid) :
22327836SJohn.Forte@Sun.COM remove_dds_object(uid);
22337836SJohn.Forte@Sun.COM /* unlock the cache and sync the data */
22347836SJohn.Forte@Sun.COM ret = cache_unlock_sync(ret);
22357836SJohn.Forte@Sun.COM } else {
22367836SJohn.Forte@Sun.COM /* unlock the cache and no need to sync data */
22377836SJohn.Forte@Sun.COM (void) cache_unlock_nosync();
22387836SJohn.Forte@Sun.COM /* set an error and continue. */
2239*8854Swl202157@icefox ret = (lc_type == OBJ_DD) ? ERR_MATCHING_DD_NOT_FOUND :
2240*8854Swl202157@icefox ERR_MATCHING_DDSET_NOT_FOUND;
22417836SJohn.Forte@Sun.COM }
22427836SJohn.Forte@Sun.COM
22437836SJohn.Forte@Sun.COM if (ret != 0) {
22447836SJohn.Forte@Sun.COM /* keep track if there are different errors encountered. */
22457836SJohn.Forte@Sun.COM if (ret_save != 0 && ret != ret_save) {
22467836SJohn.Forte@Sun.COM different_err++;
22477836SJohn.Forte@Sun.COM }
22487836SJohn.Forte@Sun.COM err_count++;
22497836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
22507836SJohn.Forte@Sun.COM if (n_obj) {
22517836SJohn.Forte@Sun.COM if ((n_obj = xmlAddChild(root, n_obj)) == NULL) {
22527836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
22537836SJohn.Forte@Sun.COM }
22547836SJohn.Forte@Sun.COM } else {
22557836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
22567836SJohn.Forte@Sun.COM }
22577836SJohn.Forte@Sun.COM
22587836SJohn.Forte@Sun.COM n_node = (lc_type == OBJ_DD) ?
22597836SJohn.Forte@Sun.COM xmlNewNode(NULL, (xmlChar *)DDOBJECT) :
22607836SJohn.Forte@Sun.COM xmlNewNode(NULL, (xmlChar *)DDSETOBJECT);
22617836SJohn.Forte@Sun.COM if (n_node) {
22627836SJohn.Forte@Sun.COM if ((n_node = xmlAddChild(n_obj, n_node)) == NULL) {
22637836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
22647836SJohn.Forte@Sun.COM }
22657836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)NAMEATTR,
22667836SJohn.Forte@Sun.COM (xmlChar *)req->req_data.data[i]);
22677836SJohn.Forte@Sun.COM if (n_attr == NULL) {
22687836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
22697836SJohn.Forte@Sun.COM }
22707836SJohn.Forte@Sun.COM } else {
22717836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
22727836SJohn.Forte@Sun.COM }
22737836SJohn.Forte@Sun.COM ret_save = ret;
22747836SJohn.Forte@Sun.COM }
22757836SJohn.Forte@Sun.COM i ++;
22767836SJohn.Forte@Sun.COM }
22777836SJohn.Forte@Sun.COM
22787836SJohn.Forte@Sun.COM return (handle_partial_failure(doc, ret_save,
22797836SJohn.Forte@Sun.COM (req->count == err_count && !different_err) ? B_TRUE : B_FALSE));
22807836SJohn.Forte@Sun.COM }
22817836SJohn.Forte@Sun.COM
22827836SJohn.Forte@Sun.COM /*
22837836SJohn.Forte@Sun.COM * ****************************************************************************
22847836SJohn.Forte@Sun.COM *
22857836SJohn.Forte@Sun.COM * delete_ddmember_ddsetmember_op:
22867836SJohn.Forte@Sun.COM * removes a list of dd memeber or dd seti member.
22877836SJohn.Forte@Sun.COM *
22887836SJohn.Forte@Sun.COM * req - contains delete request info.
22897836SJohn.Forte@Sun.COM * doc - response doc to fill up
22907836SJohn.Forte@Sun.COM * type - object type(either dd or dd set)
22917836SJohn.Forte@Sun.COM *
22927836SJohn.Forte@Sun.COM * ****************************************************************************
22937836SJohn.Forte@Sun.COM */
22947836SJohn.Forte@Sun.COM int
delete_ddmember_ddsetmember_op(request_t * req,xmlDocPtr doc,object_type type)22957836SJohn.Forte@Sun.COM delete_ddmember_ddsetmember_op(
22967836SJohn.Forte@Sun.COM request_t *req,
22977836SJohn.Forte@Sun.COM xmlDocPtr doc,
22987836SJohn.Forte@Sun.COM object_type type
22997836SJohn.Forte@Sun.COM /* any additional arguments go here */
23007836SJohn.Forte@Sun.COM )
23017836SJohn.Forte@Sun.COM {
23027836SJohn.Forte@Sun.COM result_code_t ret = 0, ret_save = 0;
23037836SJohn.Forte@Sun.COM isns_type_t lc_type;
23047836SJohn.Forte@Sun.COM int i = 0, err_count = 0;
23057836SJohn.Forte@Sun.COM lookup_ctrl_t lc, lc2;
23067836SJohn.Forte@Sun.COM uint32_t container_id, member_id;
23077836SJohn.Forte@Sun.COM xmlNodePtr n_node, n_obj, root;
23087836SJohn.Forte@Sun.COM xmlAttrPtr n_attr;
23097836SJohn.Forte@Sun.COM int different_err = 0;
23107836SJohn.Forte@Sun.COM int is_a_member;
23117836SJohn.Forte@Sun.COM
23127836SJohn.Forte@Sun.COM lc_type = get_lc_type(type);
23137836SJohn.Forte@Sun.COM if ((lc_type != OBJ_DD) && (lc_type != OBJ_DDS)) {
23147836SJohn.Forte@Sun.COM return (ERR_INVALID_MGMT_REQUEST);
23157836SJohn.Forte@Sun.COM }
23167836SJohn.Forte@Sun.COM
23177836SJohn.Forte@Sun.COM /* prepare lookup ctrl data for looking for the node object */
23187836SJohn.Forte@Sun.COM lc.curr_uid = 0;
23197836SJohn.Forte@Sun.COM lc.type = lc_type;
23207836SJohn.Forte@Sun.COM lc.id[0] = get_lc_id(req->op_info.obj);
23217836SJohn.Forte@Sun.COM lc.op[0] = OP_STRING;
23227836SJohn.Forte@Sun.COM lc.op[1] = 0;
23237836SJohn.Forte@Sun.COM
23247836SJohn.Forte@Sun.COM lc2.curr_uid = 0;
23257836SJohn.Forte@Sun.COM if (lc_type == OBJ_DD) {
23267836SJohn.Forte@Sun.COM lc2.type = OBJ_ISCSI;
23277836SJohn.Forte@Sun.COM lc2.id[0] = ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID);
23287836SJohn.Forte@Sun.COM } else {
23297836SJohn.Forte@Sun.COM lc2.type = OBJ_DD;
23307836SJohn.Forte@Sun.COM lc2.id[0] = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
23317836SJohn.Forte@Sun.COM }
23327836SJohn.Forte@Sun.COM lc2.op[0] = OP_STRING;
23337836SJohn.Forte@Sun.COM lc2.op[1] = 0;
23347836SJohn.Forte@Sun.COM
23357836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
23367836SJohn.Forte@Sun.COM if (root == NULL) {
23377836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
23387836SJohn.Forte@Sun.COM }
23397836SJohn.Forte@Sun.COM
23407836SJohn.Forte@Sun.COM while (i < req->count) {
23417836SJohn.Forte@Sun.COM lc.data[0].ptr = (uchar_t *)req->req_data.pair[i]->container;
23427836SJohn.Forte@Sun.COM
23437836SJohn.Forte@Sun.COM /* get the dd_id/dds_id */
23447836SJohn.Forte@Sun.COM (void) cache_lock_write();
23457836SJohn.Forte@Sun.COM container_id = is_obj_there(&lc);
23467836SJohn.Forte@Sun.COM
23477836SJohn.Forte@Sun.COM if (container_id != 0) {
23487836SJohn.Forte@Sun.COM lc2.data[0].ptr = (uchar_t *)req->req_data.pair[i]->member;
23497836SJohn.Forte@Sun.COM
23507836SJohn.Forte@Sun.COM member_id = is_obj_there(&lc2);
23517836SJohn.Forte@Sun.COM if (member_id != 0) {
23527836SJohn.Forte@Sun.COM is_a_member =
23537836SJohn.Forte@Sun.COM (container_id ==
23547836SJohn.Forte@Sun.COM ((lc_type == OBJ_DD) ?
23557836SJohn.Forte@Sun.COM get_dd_id(member_id, container_id - 1) :
23567836SJohn.Forte@Sun.COM get_dds_id(member_id, container_id - 1)));
23577836SJohn.Forte@Sun.COM }
23587836SJohn.Forte@Sun.COM if (member_id != 0 && is_a_member != 0) {
23597836SJohn.Forte@Sun.COM /* delete the dd member */
23607836SJohn.Forte@Sun.COM ret = (lc_type == OBJ_DD) ?
23617836SJohn.Forte@Sun.COM i_delete_ddmember_op(
23627836SJohn.Forte@Sun.COM (uchar_t *)req->req_data.pair[i]->container,
23637836SJohn.Forte@Sun.COM (uchar_t *)req->req_data.pair[i]->member) :
23647836SJohn.Forte@Sun.COM i_delete_ddsetmember_op(
23657836SJohn.Forte@Sun.COM (uchar_t *)req->req_data.pair[i]->container,
23667836SJohn.Forte@Sun.COM (uchar_t *)req->req_data.pair[i]->member);
23677836SJohn.Forte@Sun.COM /* unlock the cache and sync the data */
23687836SJohn.Forte@Sun.COM ret = cache_unlock_sync(ret);
23697836SJohn.Forte@Sun.COM } else {
23707836SJohn.Forte@Sun.COM /* unlock the cache and no need to sync */
23717836SJohn.Forte@Sun.COM (void) cache_unlock_nosync();
23727836SJohn.Forte@Sun.COM ret = ERR_NO_SUCH_ASSOCIATION;
23737836SJohn.Forte@Sun.COM }
23747836SJohn.Forte@Sun.COM } else {
23757836SJohn.Forte@Sun.COM /* unlock the cache and no need to sync */
23767836SJohn.Forte@Sun.COM (void) cache_unlock_nosync();
23777836SJohn.Forte@Sun.COM ret = (lc_type == OBJ_DD) ? ERR_MATCHING_DD_NOT_FOUND :
23787836SJohn.Forte@Sun.COM ERR_MATCHING_DDSET_NOT_FOUND;
23797836SJohn.Forte@Sun.COM }
23807836SJohn.Forte@Sun.COM
23817836SJohn.Forte@Sun.COM if (ret != 0) {
23827836SJohn.Forte@Sun.COM /* keep track if there are different errors encountered. */
23837836SJohn.Forte@Sun.COM if (ret_save != 0 && ret != ret_save) {
23847836SJohn.Forte@Sun.COM different_err++;
23857836SJohn.Forte@Sun.COM }
23867836SJohn.Forte@Sun.COM ret_save = ret;
23877836SJohn.Forte@Sun.COM err_count++;
23887836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ASSOCIATION);
23897836SJohn.Forte@Sun.COM if (n_obj) {
23907836SJohn.Forte@Sun.COM n_obj = xmlAddChild(root, n_obj);
23917836SJohn.Forte@Sun.COM if (n_obj == NULL) {
23927836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
23937836SJohn.Forte@Sun.COM }
23947836SJohn.Forte@Sun.COM } else {
23957836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
23967836SJohn.Forte@Sun.COM }
23977836SJohn.Forte@Sun.COM if (lc_type == OBJ_DD) {
23987836SJohn.Forte@Sun.COM n_node =
23997836SJohn.Forte@Sun.COM xmlNewNode(NULL, (xmlChar *)DDOBJECTMEMBER);
24007836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)NODENAMEATTR,
24017836SJohn.Forte@Sun.COM (xmlChar *)req->req_data.pair[i]->member);
24027836SJohn.Forte@Sun.COM if (n_attr == NULL) {
24037836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
24047836SJohn.Forte@Sun.COM }
24057836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
24067836SJohn.Forte@Sun.COM (xmlChar *)req->req_data.pair[i]->container);
24077836SJohn.Forte@Sun.COM if (n_attr == NULL) {
24087836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
24097836SJohn.Forte@Sun.COM }
24107836SJohn.Forte@Sun.COM } else {
24117836SJohn.Forte@Sun.COM n_node =
24127836SJohn.Forte@Sun.COM xmlNewNode(NULL, (xmlChar *)DDSETOBJECTMEMBER);
24137836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
24147836SJohn.Forte@Sun.COM (xmlChar *)req->req_data.pair[i]->member);
24157836SJohn.Forte@Sun.COM if (n_attr == NULL) {
24167836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
24177836SJohn.Forte@Sun.COM }
24187836SJohn.Forte@Sun.COM n_attr = xmlSetProp(n_node, (xmlChar *)DDSETNAMEATTR,
24197836SJohn.Forte@Sun.COM (xmlChar *)req->req_data.pair[i]->container);
24207836SJohn.Forte@Sun.COM if (n_attr == NULL) {
24217836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
24227836SJohn.Forte@Sun.COM }
24237836SJohn.Forte@Sun.COM }
24247836SJohn.Forte@Sun.COM if (xmlAddChild(n_obj, n_node) == NULL) {
24257836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
24267836SJohn.Forte@Sun.COM }
24277836SJohn.Forte@Sun.COM }
24287836SJohn.Forte@Sun.COM i++;
24297836SJohn.Forte@Sun.COM }
24307836SJohn.Forte@Sun.COM
24317836SJohn.Forte@Sun.COM return (handle_partial_failure(doc, ret_save,
24327836SJohn.Forte@Sun.COM (req->count == err_count && !different_err) ? B_TRUE : B_FALSE));
24337836SJohn.Forte@Sun.COM }
24347836SJohn.Forte@Sun.COM
24357836SJohn.Forte@Sun.COM /*
24367836SJohn.Forte@Sun.COM * ****************************************************************************
24377836SJohn.Forte@Sun.COM *
24387836SJohn.Forte@Sun.COM * create_ddmember_ddsetmember_op:
24397836SJohn.Forte@Sun.COM * removes a list of dd memeber or dd seti member.
24407836SJohn.Forte@Sun.COM *
24417836SJohn.Forte@Sun.COM * req - contains delete request info.
24427836SJohn.Forte@Sun.COM * doc - response doc to fill up
24437836SJohn.Forte@Sun.COM * type - object type(either dd or dd set)
24447836SJohn.Forte@Sun.COM *
24457836SJohn.Forte@Sun.COM * ****************************************************************************
24467836SJohn.Forte@Sun.COM */
24477836SJohn.Forte@Sun.COM int
create_ddmember_ddsetmember_op(request_t * req,xmlDocPtr doc,object_type type)24487836SJohn.Forte@Sun.COM create_ddmember_ddsetmember_op(
24497836SJohn.Forte@Sun.COM request_t *req,
24507836SJohn.Forte@Sun.COM xmlDocPtr doc,
24517836SJohn.Forte@Sun.COM object_type type
24527836SJohn.Forte@Sun.COM /* any additional arguments go here */
24537836SJohn.Forte@Sun.COM )
24547836SJohn.Forte@Sun.COM {
24557836SJohn.Forte@Sun.COM result_code_t ret = 0, ret_save = 0;
24567836SJohn.Forte@Sun.COM isns_type_t lc_type;
24577836SJohn.Forte@Sun.COM int i = 0, err_count = 0;
24587836SJohn.Forte@Sun.COM lookup_ctrl_t lc, lc2;
24597836SJohn.Forte@Sun.COM uint32_t container_id, member_id;
24607836SJohn.Forte@Sun.COM xmlNodePtr n_node, n_obj, root;
24617836SJohn.Forte@Sun.COM isns_assoc_iscsi_t aiscsi = { 0 };
24627836SJohn.Forte@Sun.COM isns_assoc_dd_t add = { 0 };
24637836SJohn.Forte@Sun.COM isns_obj_t *assoc;
24647836SJohn.Forte@Sun.COM isns_attr_t *attr;
24657836SJohn.Forte@Sun.COM uint32_t len;
24667836SJohn.Forte@Sun.COM int different_err = 0;
24677836SJohn.Forte@Sun.COM
24687836SJohn.Forte@Sun.COM lc_type = get_lc_type(type);
24697836SJohn.Forte@Sun.COM if ((lc_type != OBJ_DD) && (lc_type != OBJ_DDS)) {
24707836SJohn.Forte@Sun.COM return (ERR_INVALID_MGMT_REQUEST);
24717836SJohn.Forte@Sun.COM }
24727836SJohn.Forte@Sun.COM
24737836SJohn.Forte@Sun.COM /* prepare lookup ctrl data for looking for the node object */
24747836SJohn.Forte@Sun.COM lc.curr_uid = 0;
24757836SJohn.Forte@Sun.COM lc.type = lc_type;
24767836SJohn.Forte@Sun.COM lc.id[0] = get_lc_id(req->op_info.obj);
24777836SJohn.Forte@Sun.COM lc.op[0] = OP_STRING;
24787836SJohn.Forte@Sun.COM lc.op[1] = 0;
24797836SJohn.Forte@Sun.COM
24807836SJohn.Forte@Sun.COM lc2.curr_uid = 0;
24817836SJohn.Forte@Sun.COM if (lc_type == OBJ_DD) {
24827836SJohn.Forte@Sun.COM lc2.type = OBJ_ISCSI;
24837836SJohn.Forte@Sun.COM lc2.id[0] = ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID);
24847836SJohn.Forte@Sun.COM } else {
24857836SJohn.Forte@Sun.COM lc2.type = OBJ_DD;
24867836SJohn.Forte@Sun.COM lc2.id[0] = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
24877836SJohn.Forte@Sun.COM }
24887836SJohn.Forte@Sun.COM lc2.op[0] = OP_STRING;
24897836SJohn.Forte@Sun.COM lc2.op[1] = 0;
24907836SJohn.Forte@Sun.COM
24917836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
24927836SJohn.Forte@Sun.COM if (root == NULL) {
24937836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
24947836SJohn.Forte@Sun.COM }
24957836SJohn.Forte@Sun.COM
24967836SJohn.Forte@Sun.COM while (i < req->count) {
24977836SJohn.Forte@Sun.COM lc.data[0].ptr = (uchar_t *)req->req_data.pair[i]->container;
24987836SJohn.Forte@Sun.COM
24997836SJohn.Forte@Sun.COM /* get the dd_id/dds_id */
25007836SJohn.Forte@Sun.COM (void) cache_lock_write();
25017836SJohn.Forte@Sun.COM container_id = is_obj_there(&lc);
25027836SJohn.Forte@Sun.COM
25037836SJohn.Forte@Sun.COM if (container_id != 0) {
25047836SJohn.Forte@Sun.COM (void) memset(&aiscsi, 0, sizeof (aiscsi));
25057836SJohn.Forte@Sun.COM if (lc_type == OBJ_DD) {
25067836SJohn.Forte@Sun.COM aiscsi.puid = container_id;
25077836SJohn.Forte@Sun.COM aiscsi.type = OBJ_ASSOC_ISCSI;
25087836SJohn.Forte@Sun.COM attr = &aiscsi.attrs[ATTR_INDEX_ASSOC_ISCSI(
25097836SJohn.Forte@Sun.COM ISNS_DD_ISCSI_NAME_ATTR_ID)];
25107836SJohn.Forte@Sun.COM attr->tag = ISNS_DD_ISCSI_NAME_ATTR_ID;
25117836SJohn.Forte@Sun.COM len = xmlStrlen(
25127836SJohn.Forte@Sun.COM (xmlChar *)req->req_data.pair[i]->member) + 1;
25137836SJohn.Forte@Sun.COM len += 4 - (len % 4); /* on 4 bytes aligned */
25147836SJohn.Forte@Sun.COM attr->len = len;
25157836SJohn.Forte@Sun.COM attr->value.ptr =
25167836SJohn.Forte@Sun.COM (uchar_t *)req->req_data.pair[i]->member;
25177836SJohn.Forte@Sun.COM assoc = (isns_obj_t *)&aiscsi;
25187836SJohn.Forte@Sun.COM
25197836SJohn.Forte@Sun.COM /* add the dd member */
25207836SJohn.Forte@Sun.COM ret = add_dd_member(assoc);
25217836SJohn.Forte@Sun.COM
25227836SJohn.Forte@Sun.COM /* unlock the cache and sync the data */
25237836SJohn.Forte@Sun.COM ret = cache_unlock_sync(ret);
25247836SJohn.Forte@Sun.COM } else {
25257836SJohn.Forte@Sun.COM lc2.data[0].ptr =
25267836SJohn.Forte@Sun.COM (uchar_t *)req->req_data.pair[i]->member;
25277836SJohn.Forte@Sun.COM
25287836SJohn.Forte@Sun.COM if ((member_id = is_obj_there(&lc2)) != 0) {
25297836SJohn.Forte@Sun.COM add.puid = container_id;
25307836SJohn.Forte@Sun.COM add.type = OBJ_ASSOC_DD;
25317836SJohn.Forte@Sun.COM attr = &add.attrs[ATTR_INDEX_ASSOC_DD(
25327836SJohn.Forte@Sun.COM ISNS_DD_ID_ATTR_ID)];
25337836SJohn.Forte@Sun.COM attr->tag = ISNS_DD_ID_ATTR_ID;
25347836SJohn.Forte@Sun.COM attr->len = 4;
25357836SJohn.Forte@Sun.COM attr->value.ui = member_id;
25367836SJohn.Forte@Sun.COM assoc = (isns_obj_t *)&add;
25377836SJohn.Forte@Sun.COM
25387836SJohn.Forte@Sun.COM /* add the dd-set member */
25397836SJohn.Forte@Sun.COM ret = add_dds_member(assoc);
25407836SJohn.Forte@Sun.COM
25417836SJohn.Forte@Sun.COM /* unlock the cache and sync the data */
25427836SJohn.Forte@Sun.COM ret = cache_unlock_sync(ret);
25437836SJohn.Forte@Sun.COM } else {
25447836SJohn.Forte@Sun.COM /* unlock the cache and no need to sync */
25457836SJohn.Forte@Sun.COM (void) cache_unlock_nosync();
25467836SJohn.Forte@Sun.COM ret = ERR_MATCHING_DD_NOT_FOUND;
25477836SJohn.Forte@Sun.COM }
25487836SJohn.Forte@Sun.COM }
25497836SJohn.Forte@Sun.COM } else {
25507836SJohn.Forte@Sun.COM /* unlock the cache and no need to sync */
25517836SJohn.Forte@Sun.COM (void) cache_unlock_nosync();
25527836SJohn.Forte@Sun.COM ret = (lc_type == OBJ_DD) ? ERR_MATCHING_DD_NOT_FOUND :
25537836SJohn.Forte@Sun.COM ERR_MATCHING_DDSET_NOT_FOUND;
25547836SJohn.Forte@Sun.COM }
25557836SJohn.Forte@Sun.COM if (ret != 0) {
25567836SJohn.Forte@Sun.COM /* keep track if there are different errors encountered. */
25577836SJohn.Forte@Sun.COM if (ret_save != 0 && ret != ret_save) {
25587836SJohn.Forte@Sun.COM different_err++;
25597836SJohn.Forte@Sun.COM }
25607836SJohn.Forte@Sun.COM err_count++;
25617836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ASSOCIATION);
25627836SJohn.Forte@Sun.COM if (n_obj) {
25637836SJohn.Forte@Sun.COM n_obj = xmlAddChild(root, n_obj);
25647836SJohn.Forte@Sun.COM if (n_obj == NULL) {
25657836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
25667836SJohn.Forte@Sun.COM }
25677836SJohn.Forte@Sun.COM } else {
25687836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
25697836SJohn.Forte@Sun.COM }
25707836SJohn.Forte@Sun.COM if (lc_type == OBJ_DD) {
25717836SJohn.Forte@Sun.COM n_node =
25727836SJohn.Forte@Sun.COM xmlNewNode(NULL, (xmlChar *)DDOBJECTMEMBER);
25737836SJohn.Forte@Sun.COM if (xmlSetProp(n_node, (xmlChar *)NODENAMEATTR,
25747836SJohn.Forte@Sun.COM (xmlChar *)req->req_data.pair[i]->member) == NULL) {
25757836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
25767836SJohn.Forte@Sun.COM }
25777836SJohn.Forte@Sun.COM if (xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
25787836SJohn.Forte@Sun.COM (xmlChar *)req->req_data.pair[i]->container) ==
25797836SJohn.Forte@Sun.COM NULL) {
25807836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
25817836SJohn.Forte@Sun.COM }
25827836SJohn.Forte@Sun.COM } else {
25837836SJohn.Forte@Sun.COM n_node =
25847836SJohn.Forte@Sun.COM xmlNewNode(NULL, (xmlChar *)DDSETOBJECTMEMBER);
25857836SJohn.Forte@Sun.COM if (xmlSetProp(n_node, (xmlChar *)DDNAMEATTR,
25867836SJohn.Forte@Sun.COM (xmlChar *)req->req_data.pair[i]->member) == NULL) {
25877836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
25887836SJohn.Forte@Sun.COM }
25897836SJohn.Forte@Sun.COM if (xmlSetProp(n_node, (xmlChar *)DDSETNAMEATTR,
25907836SJohn.Forte@Sun.COM (xmlChar *)req->req_data.pair[i]->container) ==
25917836SJohn.Forte@Sun.COM NULL) {
25927836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
25937836SJohn.Forte@Sun.COM }
25947836SJohn.Forte@Sun.COM }
25957836SJohn.Forte@Sun.COM if (xmlAddChild(n_obj, n_node) == NULL) {
25967836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
25977836SJohn.Forte@Sun.COM }
25987836SJohn.Forte@Sun.COM ret_save = ret;
25997836SJohn.Forte@Sun.COM }
26007836SJohn.Forte@Sun.COM i++;
26017836SJohn.Forte@Sun.COM }
26027836SJohn.Forte@Sun.COM
26037836SJohn.Forte@Sun.COM return (handle_partial_failure(doc, ret_save,
26047836SJohn.Forte@Sun.COM (req->count == err_count && !different_err) ? B_TRUE : B_FALSE));
26057836SJohn.Forte@Sun.COM }
26067836SJohn.Forte@Sun.COM
26077836SJohn.Forte@Sun.COM /*
26087836SJohn.Forte@Sun.COM * ****************************************************************************
26097836SJohn.Forte@Sun.COM *
26107836SJohn.Forte@Sun.COM * rename_dd_ddset_op:
26117836SJohn.Forte@Sun.COM * removes a list of dd memeber or dd seti member.
26127836SJohn.Forte@Sun.COM *
26137836SJohn.Forte@Sun.COM * req - contains delete request info.
26147836SJohn.Forte@Sun.COM * doc - response doc to fill up
26157836SJohn.Forte@Sun.COM * type - object type(either dd or dd set)
26167836SJohn.Forte@Sun.COM *
26177836SJohn.Forte@Sun.COM * ****************************************************************************
26187836SJohn.Forte@Sun.COM */
26197836SJohn.Forte@Sun.COM static int
rename_dd_ddset_op(request_t * req,xmlDocPtr doc,object_type type)26207836SJohn.Forte@Sun.COM rename_dd_ddset_op(
26217836SJohn.Forte@Sun.COM request_t *req,
26227836SJohn.Forte@Sun.COM xmlDocPtr doc,
26237836SJohn.Forte@Sun.COM object_type type
26247836SJohn.Forte@Sun.COM /* any additional arguments go here */
26257836SJohn.Forte@Sun.COM )
26267836SJohn.Forte@Sun.COM {
26277836SJohn.Forte@Sun.COM result_code_t ret = 0, ret_save = 0;
26287836SJohn.Forte@Sun.COM isns_type_t lc_type;
26297836SJohn.Forte@Sun.COM int i = 0, err_count = 0;
26307836SJohn.Forte@Sun.COM lookup_ctrl_t lc;
26317836SJohn.Forte@Sun.COM uint32_t container_id;
26327836SJohn.Forte@Sun.COM xmlNodePtr n_node, n_obj, root;
26337836SJohn.Forte@Sun.COM uchar_t *name;
26347836SJohn.Forte@Sun.COM uint32_t len;
26357836SJohn.Forte@Sun.COM int different_err = 0;
26367836SJohn.Forte@Sun.COM
26377836SJohn.Forte@Sun.COM lc_type = get_lc_type(type);
26387836SJohn.Forte@Sun.COM if ((lc_type != OBJ_DD) && (lc_type != OBJ_DDS)) {
26397836SJohn.Forte@Sun.COM return (ERR_INVALID_MGMT_REQUEST);
26407836SJohn.Forte@Sun.COM }
26417836SJohn.Forte@Sun.COM
26427836SJohn.Forte@Sun.COM /* prepare lookup ctrl data for looking for the node object */
26437836SJohn.Forte@Sun.COM SET_UID_LCP(&lc, lc_type, 0);
26447836SJohn.Forte@Sun.COM
26457836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
26467836SJohn.Forte@Sun.COM if (root == NULL) {
26477836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
26487836SJohn.Forte@Sun.COM }
26497836SJohn.Forte@Sun.COM
26507836SJohn.Forte@Sun.COM while (i < req->count) {
26517836SJohn.Forte@Sun.COM /* id is checked to be not NULL before calling this routine. */
26527836SJohn.Forte@Sun.COM lc.data[0].ui = *(req->req_data.attrlist[i]->id);
26537836SJohn.Forte@Sun.COM
26547836SJohn.Forte@Sun.COM /* get the dd_id/dds_id */
26557836SJohn.Forte@Sun.COM (void) cache_lock_write();
26567836SJohn.Forte@Sun.COM
26577836SJohn.Forte@Sun.COM if ((container_id = is_obj_there(&lc)) != 0) {
26587836SJohn.Forte@Sun.COM name = (uchar_t *)req->req_data.attrlist[i]->name;
26597836SJohn.Forte@Sun.COM /* the length of the name need to include the */
26607836SJohn.Forte@Sun.COM /* null terminator and be on 4 bytes aligned */
26617836SJohn.Forte@Sun.COM len = xmlStrlen(name) + 1;
26627836SJohn.Forte@Sun.COM len += 4 - (len % 4);
26637836SJohn.Forte@Sun.COM
26647836SJohn.Forte@Sun.COM /* rename the dd/dds */
26657836SJohn.Forte@Sun.COM ret = (lc_type == OBJ_DD) ?
26667836SJohn.Forte@Sun.COM update_dd_name(container_id, len, name) :
26677836SJohn.Forte@Sun.COM update_dds_name(container_id, len, name);
26687836SJohn.Forte@Sun.COM
26697836SJohn.Forte@Sun.COM /* release the lock and sync the data */
26707836SJohn.Forte@Sun.COM ret = cache_unlock_sync(ret);
26717836SJohn.Forte@Sun.COM } else {
26727836SJohn.Forte@Sun.COM /* release the lock and no need to sync */
26737836SJohn.Forte@Sun.COM (void) cache_unlock_nosync();
26747836SJohn.Forte@Sun.COM ret = (lc_type == OBJ_DD) ? ERR_MATCHING_DD_NOT_FOUND :
26757836SJohn.Forte@Sun.COM ERR_MATCHING_DDSET_NOT_FOUND;
26767836SJohn.Forte@Sun.COM }
26777836SJohn.Forte@Sun.COM if (ret != 0) {
26787836SJohn.Forte@Sun.COM /* keep track if there are different errors encountered. */
26797836SJohn.Forte@Sun.COM if (ret_save != 0 && ret != ret_save) {
26807836SJohn.Forte@Sun.COM different_err++;
26817836SJohn.Forte@Sun.COM }
26827836SJohn.Forte@Sun.COM ret_save = ret;
26837836SJohn.Forte@Sun.COM err_count++;
26847836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
26857836SJohn.Forte@Sun.COM if (n_obj) {
26867836SJohn.Forte@Sun.COM if ((n_obj = xmlAddChild(root, n_obj)) == NULL) {
26877836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
26887836SJohn.Forte@Sun.COM }
26897836SJohn.Forte@Sun.COM } else {
26907836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
26917836SJohn.Forte@Sun.COM }
26927836SJohn.Forte@Sun.COM
26937836SJohn.Forte@Sun.COM n_node = (lc_type == OBJ_DD) ?
26947836SJohn.Forte@Sun.COM xmlNewNode(NULL, (xmlChar *)DDOBJECT) :
26957836SJohn.Forte@Sun.COM xmlNewNode(NULL, (xmlChar *)DDSETOBJECT);
26967836SJohn.Forte@Sun.COM if (n_node) {
26977836SJohn.Forte@Sun.COM if ((n_node = xmlAddChild(n_obj, n_node)) == NULL) {
26987836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
26997836SJohn.Forte@Sun.COM } else {
27007836SJohn.Forte@Sun.COM if (xmlSetProp(n_node, (xmlChar *)NAMEATTR,
27017836SJohn.Forte@Sun.COM (xmlChar *)req->req_data.attrlist[i]->name) ==
27027836SJohn.Forte@Sun.COM NULL) {
27037836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
27047836SJohn.Forte@Sun.COM }
27057836SJohn.Forte@Sun.COM }
27067836SJohn.Forte@Sun.COM } else {
27077836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
27087836SJohn.Forte@Sun.COM }
27097836SJohn.Forte@Sun.COM
27107836SJohn.Forte@Sun.COM }
27117836SJohn.Forte@Sun.COM i++;
27127836SJohn.Forte@Sun.COM }
27137836SJohn.Forte@Sun.COM
27147836SJohn.Forte@Sun.COM return (handle_partial_failure(doc, ret_save,
27157836SJohn.Forte@Sun.COM (req->count == err_count && !different_err) ? B_TRUE : B_FALSE));
27167836SJohn.Forte@Sun.COM }
27177836SJohn.Forte@Sun.COM
27187836SJohn.Forte@Sun.COM /*
27197836SJohn.Forte@Sun.COM * ****************************************************************************
27207836SJohn.Forte@Sun.COM *
27217836SJohn.Forte@Sun.COM * update_dd_ddset_op:
27227836SJohn.Forte@Sun.COM * removes a list of dd memeber or dd seti member.
27237836SJohn.Forte@Sun.COM *
27247836SJohn.Forte@Sun.COM * req - contains delete request info.
27257836SJohn.Forte@Sun.COM * doc - response doc to fill up
27267836SJohn.Forte@Sun.COM * type - object type(either dd or dd set)
27277836SJohn.Forte@Sun.COM *
27287836SJohn.Forte@Sun.COM * ****************************************************************************
27297836SJohn.Forte@Sun.COM */
27307836SJohn.Forte@Sun.COM static int
update_dd_ddset_op(request_t * req,xmlDocPtr doc,object_type type)27317836SJohn.Forte@Sun.COM update_dd_ddset_op(
27327836SJohn.Forte@Sun.COM request_t *req,
27337836SJohn.Forte@Sun.COM xmlDocPtr doc,
27347836SJohn.Forte@Sun.COM object_type type
27357836SJohn.Forte@Sun.COM /* any additional arguments go here */
27367836SJohn.Forte@Sun.COM )
27377836SJohn.Forte@Sun.COM {
27387836SJohn.Forte@Sun.COM result_code_t ret = 0, ret_save = 0;
27397836SJohn.Forte@Sun.COM isns_type_t lc_type;
27407836SJohn.Forte@Sun.COM int i = 0, err_count = 0;
27417836SJohn.Forte@Sun.COM lookup_ctrl_t lc;
27427836SJohn.Forte@Sun.COM uint32_t container_id;
27437836SJohn.Forte@Sun.COM xmlNodePtr n_node, n_obj, root;
27447836SJohn.Forte@Sun.COM int different_err = 0;
27457836SJohn.Forte@Sun.COM
27467836SJohn.Forte@Sun.COM lc_type = get_lc_type(type);
27477836SJohn.Forte@Sun.COM if ((lc_type != OBJ_DD) && (lc_type != OBJ_DDS)) {
27487836SJohn.Forte@Sun.COM return (ERR_INVALID_MGMT_REQUEST);
27497836SJohn.Forte@Sun.COM }
27507836SJohn.Forte@Sun.COM
27517836SJohn.Forte@Sun.COM /* prepare lookup ctrl data for looking for the node object */
27527836SJohn.Forte@Sun.COM lc.curr_uid = 0;
27537836SJohn.Forte@Sun.COM lc.type = lc_type;
27547836SJohn.Forte@Sun.COM lc.id[0] = get_lc_id(req->op_info.obj);
27557836SJohn.Forte@Sun.COM lc.op[0] = OP_STRING;
27567836SJohn.Forte@Sun.COM lc.op[1] = 0;
27577836SJohn.Forte@Sun.COM
27587836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
27597836SJohn.Forte@Sun.COM if (root == NULL) {
27607836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
27617836SJohn.Forte@Sun.COM }
27627836SJohn.Forte@Sun.COM
27637836SJohn.Forte@Sun.COM while (i < req->count) {
27647836SJohn.Forte@Sun.COM lc.data[0].ptr = req->req_data.attrlist[i]->name;
27657836SJohn.Forte@Sun.COM
27667836SJohn.Forte@Sun.COM /* lock the cache for writing */
27677836SJohn.Forte@Sun.COM (void) cache_lock_write();
27687836SJohn.Forte@Sun.COM
27697836SJohn.Forte@Sun.COM if ((container_id = is_obj_there(&lc)) != 0) {
27707836SJohn.Forte@Sun.COM ret = (lc_type == OBJ_DD) ?
27717836SJohn.Forte@Sun.COM /* enabled is checked to be not NULL before calling. */
27727836SJohn.Forte@Sun.COM update_dd_features(container_id,
27737836SJohn.Forte@Sun.COM *(req->req_data.attrlist[i]->enabled) ? 1 : 0):
27747836SJohn.Forte@Sun.COM update_dds_status(container_id,
27757836SJohn.Forte@Sun.COM *(req->req_data.attrlist[i]->enabled) ? 1 : 0);
27767836SJohn.Forte@Sun.COM /* unlock the cache and sync the data */
27777836SJohn.Forte@Sun.COM ret = cache_unlock_sync(ret);
27787836SJohn.Forte@Sun.COM } else {
27797836SJohn.Forte@Sun.COM (void) cache_unlock_nosync();
27807836SJohn.Forte@Sun.COM ret = (lc_type == OBJ_DD) ? ERR_MATCHING_DD_NOT_FOUND :
27817836SJohn.Forte@Sun.COM ERR_MATCHING_DDSET_NOT_FOUND;
27827836SJohn.Forte@Sun.COM }
27837836SJohn.Forte@Sun.COM if (ret != 0) {
27847836SJohn.Forte@Sun.COM /* keep track if there are different errors encountered. */
27857836SJohn.Forte@Sun.COM if (ret_save != 0 && ret != ret_save) {
27867836SJohn.Forte@Sun.COM different_err++;
27877836SJohn.Forte@Sun.COM }
27887836SJohn.Forte@Sun.COM ret_save = ret;
27897836SJohn.Forte@Sun.COM err_count++;
27907836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
27917836SJohn.Forte@Sun.COM if (n_obj) {
27927836SJohn.Forte@Sun.COM if ((n_obj = xmlAddChild(root, n_obj)) == NULL) {
27937836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
27947836SJohn.Forte@Sun.COM }
27957836SJohn.Forte@Sun.COM } else {
27967836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
27977836SJohn.Forte@Sun.COM }
27987836SJohn.Forte@Sun.COM
27997836SJohn.Forte@Sun.COM n_node = (lc_type == OBJ_DD) ?
28007836SJohn.Forte@Sun.COM xmlNewNode(NULL, (xmlChar *)DDOBJECT) :
28017836SJohn.Forte@Sun.COM xmlNewNode(NULL, (xmlChar *)DDSETOBJECT);
28027836SJohn.Forte@Sun.COM if (n_node) {
28037836SJohn.Forte@Sun.COM if ((n_node = xmlAddChild(n_obj, n_node)) == NULL) {
28047836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
28057836SJohn.Forte@Sun.COM } else {
28067836SJohn.Forte@Sun.COM if (xmlSetProp(n_node, (xmlChar *)NAMEATTR,
28077836SJohn.Forte@Sun.COM (xmlChar *)req->req_data.attrlist[i]->name) ==
28087836SJohn.Forte@Sun.COM NULL) {
28097836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
28107836SJohn.Forte@Sun.COM }
28117836SJohn.Forte@Sun.COM }
28127836SJohn.Forte@Sun.COM } else {
28137836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
28147836SJohn.Forte@Sun.COM }
28157836SJohn.Forte@Sun.COM }
28167836SJohn.Forte@Sun.COM i++;
28177836SJohn.Forte@Sun.COM }
28187836SJohn.Forte@Sun.COM
28197836SJohn.Forte@Sun.COM return (handle_partial_failure(doc, ret_save,
28207836SJohn.Forte@Sun.COM (req->count == err_count && !different_err) ? B_TRUE : B_FALSE));
28217836SJohn.Forte@Sun.COM }
28227836SJohn.Forte@Sun.COM
28237836SJohn.Forte@Sun.COM /*
28247836SJohn.Forte@Sun.COM * ****************************************************************************
28257836SJohn.Forte@Sun.COM *
28267836SJohn.Forte@Sun.COM * createModify_dd_ddset_op:
28277836SJohn.Forte@Sun.COM * removes a list of dd memeber or dd seti member.
28287836SJohn.Forte@Sun.COM *
28297836SJohn.Forte@Sun.COM * req - contains delete request info.
28307836SJohn.Forte@Sun.COM * doc - response doc to fill up
28317836SJohn.Forte@Sun.COM *
28327836SJohn.Forte@Sun.COM * ****************************************************************************
28337836SJohn.Forte@Sun.COM */
28347836SJohn.Forte@Sun.COM static int
create_dd_ddset_op(request_t * req,xmlDocPtr doc,object_type type)28357836SJohn.Forte@Sun.COM create_dd_ddset_op(
28367836SJohn.Forte@Sun.COM request_t *req,
28377836SJohn.Forte@Sun.COM xmlDocPtr doc,
28387836SJohn.Forte@Sun.COM object_type type
28397836SJohn.Forte@Sun.COM /* any additional arguments go here */
28407836SJohn.Forte@Sun.COM )
28417836SJohn.Forte@Sun.COM {
28427836SJohn.Forte@Sun.COM isns_obj_t *obj;
28437836SJohn.Forte@Sun.COM result_code_t ret = 0, ret_save = 0;
28447836SJohn.Forte@Sun.COM isns_type_t lc_type;
28457836SJohn.Forte@Sun.COM lookup_ctrl_t lc;
28467836SJohn.Forte@Sun.COM uint32_t uid;
28477836SJohn.Forte@Sun.COM int i = 0, err_count = 0;
28487836SJohn.Forte@Sun.COM xmlNodePtr n_obj, n_node, root;
28497836SJohn.Forte@Sun.COM int different_err = 0;
28507836SJohn.Forte@Sun.COM
28517836SJohn.Forte@Sun.COM lc_type = get_lc_type(type);
28527836SJohn.Forte@Sun.COM if ((lc_type != OBJ_DD) && (lc_type != OBJ_DDS)) {
28537836SJohn.Forte@Sun.COM return (ERR_INVALID_MGMT_REQUEST);
28547836SJohn.Forte@Sun.COM }
28557836SJohn.Forte@Sun.COM
28567836SJohn.Forte@Sun.COM root = xmlDocGetRootElement(doc);
28577836SJohn.Forte@Sun.COM if (root == NULL) {
28587836SJohn.Forte@Sun.COM return (ERR_SYNTAX_MISSING_ROOT);
28597836SJohn.Forte@Sun.COM }
28607836SJohn.Forte@Sun.COM lc_type = get_lc_type(type);
28617836SJohn.Forte@Sun.COM if ((lc_type != OBJ_DD) && (lc_type != OBJ_DDS)) {
28627836SJohn.Forte@Sun.COM return (ERR_INVALID_MGMT_REQUEST);
28637836SJohn.Forte@Sun.COM }
28647836SJohn.Forte@Sun.COM
28657836SJohn.Forte@Sun.COM /* prepare lookup ctrl data for looking for the node object */
28667836SJohn.Forte@Sun.COM lc.curr_uid = 0;
28677836SJohn.Forte@Sun.COM lc.type = lc_type;
28687836SJohn.Forte@Sun.COM lc.id[0] = get_lc_id(req->op_info.obj);
28697836SJohn.Forte@Sun.COM lc.op[0] = OP_STRING;
28707836SJohn.Forte@Sun.COM lc.op[1] = 0;
28717836SJohn.Forte@Sun.COM lc.data[1].ptr = (uchar_t *)doc; /* xml writer descriptor */
28727836SJohn.Forte@Sun.COM while (i < req->count) {
28737836SJohn.Forte@Sun.COM lc.data[0].ptr = req->req_data.attrlist[i]->name,
28747836SJohn.Forte@Sun.COM /* grab the write lock */
28757836SJohn.Forte@Sun.COM (void) cache_lock_write();
28767836SJohn.Forte@Sun.COM
28777836SJohn.Forte@Sun.COM uid = is_obj_there(&lc);
28787836SJohn.Forte@Sun.COM if (uid == 0) {
28797836SJohn.Forte@Sun.COM ret = (lc_type == OBJ_DD) ?
28807836SJohn.Forte@Sun.COM adm_create_dd(&obj, req->req_data.attrlist[i]->name,
28817836SJohn.Forte@Sun.COM 0, 0) :
28827836SJohn.Forte@Sun.COM adm_create_dds(&obj, req->req_data.attrlist[i]->name,
28837836SJohn.Forte@Sun.COM 0, 0);
28847836SJohn.Forte@Sun.COM if (ret == 0) {
28857836SJohn.Forte@Sun.COM ret = register_object(obj, NULL, NULL);
28867836SJohn.Forte@Sun.COM if (ret != 0) {
28877836SJohn.Forte@Sun.COM free_object(obj);
28887836SJohn.Forte@Sun.COM }
28897836SJohn.Forte@Sun.COM /* release the lock and sync the cache and data store */
28907836SJohn.Forte@Sun.COM ret = cache_unlock_sync(ret);
28917836SJohn.Forte@Sun.COM }
28927836SJohn.Forte@Sun.COM } else {
28937836SJohn.Forte@Sun.COM /* release the lock and no need to sync the data */
28947836SJohn.Forte@Sun.COM (void) cache_unlock_nosync();
28957836SJohn.Forte@Sun.COM ret = ERR_NAME_IN_USE;
28967836SJohn.Forte@Sun.COM }
28977836SJohn.Forte@Sun.COM
28987836SJohn.Forte@Sun.COM if (ret != 0) {
28997836SJohn.Forte@Sun.COM /* keep track if there are different errors encountered. */
29007836SJohn.Forte@Sun.COM if (ret_save != 0 && ret != ret_save) {
29017836SJohn.Forte@Sun.COM different_err++;
29027836SJohn.Forte@Sun.COM }
29037836SJohn.Forte@Sun.COM ret_save = ret;
29047836SJohn.Forte@Sun.COM err_count++;
29057836SJohn.Forte@Sun.COM n_obj = xmlNewNode(NULL, (xmlChar *)ISNSOBJECT);
29067836SJohn.Forte@Sun.COM if (n_obj) {
29077836SJohn.Forte@Sun.COM if ((n_obj = xmlAddChild(root, n_obj)) == NULL) {
29087836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
29097836SJohn.Forte@Sun.COM }
29107836SJohn.Forte@Sun.COM } else {
29117836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
29127836SJohn.Forte@Sun.COM }
29137836SJohn.Forte@Sun.COM
29147836SJohn.Forte@Sun.COM n_node = (lc_type == OBJ_DD) ?
29157836SJohn.Forte@Sun.COM xmlNewNode(NULL, (xmlChar *)DDOBJECT) :
29167836SJohn.Forte@Sun.COM xmlNewNode(NULL, (xmlChar *)DDSETOBJECT);
29177836SJohn.Forte@Sun.COM if (n_node) {
29187836SJohn.Forte@Sun.COM if ((n_node = xmlAddChild(n_obj, n_node)) == NULL) {
29197836SJohn.Forte@Sun.COM return (ERR_XML_ADDCHILD_FAILED);
29207836SJohn.Forte@Sun.COM } else {
29217836SJohn.Forte@Sun.COM if (xmlSetProp(n_node, (xmlChar *)NAMEATTR,
29227836SJohn.Forte@Sun.COM (xmlChar *)req->req_data.attrlist[i]->name) ==
29237836SJohn.Forte@Sun.COM NULL) {
29247836SJohn.Forte@Sun.COM return (ERR_XML_SETPROP_FAILED);
29257836SJohn.Forte@Sun.COM }
29267836SJohn.Forte@Sun.COM }
29277836SJohn.Forte@Sun.COM } else {
29287836SJohn.Forte@Sun.COM return (ERR_XML_NEWNODE_FAILED);
29297836SJohn.Forte@Sun.COM }
29307836SJohn.Forte@Sun.COM }
29317836SJohn.Forte@Sun.COM i++;
29327836SJohn.Forte@Sun.COM }
29337836SJohn.Forte@Sun.COM
29347836SJohn.Forte@Sun.COM return (handle_partial_failure(doc, ret_save,
29357836SJohn.Forte@Sun.COM (req->count == err_count && !different_err) ? B_TRUE : B_FALSE));
29367836SJohn.Forte@Sun.COM }
29377836SJohn.Forte@Sun.COM
29387836SJohn.Forte@Sun.COM /*
29397836SJohn.Forte@Sun.COM * ****************************************************************************
29407836SJohn.Forte@Sun.COM *
29417836SJohn.Forte@Sun.COM * createModify_dd_ddset_op:
29427836SJohn.Forte@Sun.COM * removes a list of dd memeber or dd seti member.
29437836SJohn.Forte@Sun.COM *
29447836SJohn.Forte@Sun.COM * req - contains delete request info.
29457836SJohn.Forte@Sun.COM * doc - response doc to fill up
29467836SJohn.Forte@Sun.COM *
29477836SJohn.Forte@Sun.COM * ****************************************************************************
29487836SJohn.Forte@Sun.COM */
29497836SJohn.Forte@Sun.COM int
createModify_dd_ddset_op(request_t * req,xmlDocPtr doc)29507836SJohn.Forte@Sun.COM createModify_dd_ddset_op(
29517836SJohn.Forte@Sun.COM request_t *req,
29527836SJohn.Forte@Sun.COM xmlDocPtr doc
29537836SJohn.Forte@Sun.COM /* any additional arguments go here */
29547836SJohn.Forte@Sun.COM )
29557836SJohn.Forte@Sun.COM {
29567836SJohn.Forte@Sun.COM result_code_t ret = 0;
29577836SJohn.Forte@Sun.COM
29587836SJohn.Forte@Sun.COM if (req->req_data.attrlist[0]->id != NULL) {
29597836SJohn.Forte@Sun.COM ret = rename_dd_ddset_op(req, doc, req->op_info.obj);
29607836SJohn.Forte@Sun.COM } else if (req->req_data.attrlist[0]->enabled != NULL) {
29617836SJohn.Forte@Sun.COM ret = update_dd_ddset_op(req, doc, req->op_info.obj);
29627836SJohn.Forte@Sun.COM } else {
29637836SJohn.Forte@Sun.COM ret = create_dd_ddset_op(req, doc, req->op_info.obj);
29647836SJohn.Forte@Sun.COM }
29657836SJohn.Forte@Sun.COM
29667836SJohn.Forte@Sun.COM return (ret);
29677836SJohn.Forte@Sun.COM }
2968