1*7836SJohn.Forte@Sun.COM /* 2*7836SJohn.Forte@Sun.COM * CDDL HEADER START 3*7836SJohn.Forte@Sun.COM * 4*7836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the 5*7836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License"). 6*7836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License. 7*7836SJohn.Forte@Sun.COM * 8*7836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*7836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*7836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions 11*7836SJohn.Forte@Sun.COM * and limitations under the License. 12*7836SJohn.Forte@Sun.COM * 13*7836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*7836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*7836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*7836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*7836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*7836SJohn.Forte@Sun.COM * 19*7836SJohn.Forte@Sun.COM * CDDL HEADER END 20*7836SJohn.Forte@Sun.COM */ 21*7836SJohn.Forte@Sun.COM /* 22*7836SJohn.Forte@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23*7836SJohn.Forte@Sun.COM * Use is subject to license terms. 24*7836SJohn.Forte@Sun.COM */ 25*7836SJohn.Forte@Sun.COM 26*7836SJohn.Forte@Sun.COM /* 27*7836SJohn.Forte@Sun.COM * isnsadm.c : isnsadm CL 28*7836SJohn.Forte@Sun.COM * 29*7836SJohn.Forte@Sun.COM */ 30*7836SJohn.Forte@Sun.COM 31*7836SJohn.Forte@Sun.COM #include <sys/types.h> 32*7836SJohn.Forte@Sun.COM #include <sys/stat.h> 33*7836SJohn.Forte@Sun.COM #include <unistd.h> 34*7836SJohn.Forte@Sun.COM #include <stdlib.h> 35*7836SJohn.Forte@Sun.COM #include <devid.h> 36*7836SJohn.Forte@Sun.COM #include <fcntl.h> 37*7836SJohn.Forte@Sun.COM #include <door.h> 38*7836SJohn.Forte@Sun.COM #include <errno.h> 39*7836SJohn.Forte@Sun.COM #include <strings.h> 40*7836SJohn.Forte@Sun.COM #include <libscf.h> 41*7836SJohn.Forte@Sun.COM #include <libxml/xmlreader.h> 42*7836SJohn.Forte@Sun.COM #include <libxml/xmlwriter.h> 43*7836SJohn.Forte@Sun.COM #include <libxml/parser.h> 44*7836SJohn.Forte@Sun.COM #include <libxml/xpath.h> 45*7836SJohn.Forte@Sun.COM #include <libxml/tree.h> 46*7836SJohn.Forte@Sun.COM #include <wchar.h> 47*7836SJohn.Forte@Sun.COM #include <locale.h> 48*7836SJohn.Forte@Sun.COM #include "isns_mgmt.h" 49*7836SJohn.Forte@Sun.COM #include "isns_utils.h" 50*7836SJohn.Forte@Sun.COM #include "isns_protocol.h" 51*7836SJohn.Forte@Sun.COM #include "cmdparse.h" 52*7836SJohn.Forte@Sun.COM #include "isnsadm.h" 53*7836SJohn.Forte@Sun.COM 54*7836SJohn.Forte@Sun.COM /* object functions per subcommand */ 55*7836SJohn.Forte@Sun.COM static int list_node_func(int, char **, cmdOptions_t *, void *); 56*7836SJohn.Forte@Sun.COM static int list_dd_func(int, char **, cmdOptions_t *, void *); 57*7836SJohn.Forte@Sun.COM static int list_ddset_func(int, char **, cmdOptions_t *, void *); 58*7836SJohn.Forte@Sun.COM static int add_node_func(int, char **, cmdOptions_t *, void *); 59*7836SJohn.Forte@Sun.COM static int add_dd_func(int, char **, cmdOptions_t *, void *); 60*7836SJohn.Forte@Sun.COM static int delete_dd_func(int, char **, cmdOptions_t *, void *); 61*7836SJohn.Forte@Sun.COM static int delete_ddset_func(int, char **, cmdOptions_t *, void *); 62*7836SJohn.Forte@Sun.COM static int create_dd_func(int, char **, cmdOptions_t *, void *); 63*7836SJohn.Forte@Sun.COM static int create_ddset_func(int, char **, cmdOptions_t *, void *); 64*7836SJohn.Forte@Sun.COM static int remove_node_func(int, char **, cmdOptions_t *, void *); 65*7836SJohn.Forte@Sun.COM static int remove_dd_func(int, char **, cmdOptions_t *, void *); 66*7836SJohn.Forte@Sun.COM static int modify_dd_func(int, char **, cmdOptions_t *, void *); 67*7836SJohn.Forte@Sun.COM static int modify_ddset_func(int, char **, cmdOptions_t *, void *); 68*7836SJohn.Forte@Sun.COM static int enable_ddset_func(int, char **, cmdOptions_t *, void *); 69*7836SJohn.Forte@Sun.COM static int disable_ddset_func(int, char **, cmdOptions_t *, void *); 70*7836SJohn.Forte@Sun.COM static int show_config_func(int, char **, cmdOptions_t *, void *); 71*7836SJohn.Forte@Sun.COM static int i_enableddset(int, char **, boolean_t); 72*7836SJohn.Forte@Sun.COM static xmlTextReaderPtr lookup_next_matching_elem(xmlTextReaderPtr, int *, 73*7836SJohn.Forte@Sun.COM const char *, const char *); 74*7836SJohn.Forte@Sun.COM static int handle_association_info(xmlChar *, association_t); 75*7836SJohn.Forte@Sun.COM static int process_result_response(xmlChar *, int obj); 76*7836SJohn.Forte@Sun.COM static int process_get_assoc_response(xmlChar *, association_t); 77*7836SJohn.Forte@Sun.COM static int process_get_response(object_type, xmlChar *, uint32_t); 78*7836SJohn.Forte@Sun.COM static int cvt_enumerate_rsp_to_get_req(xmlChar *, xmlChar **, object_type, 79*7836SJohn.Forte@Sun.COM uint32_t); 80*7836SJohn.Forte@Sun.COM static int build_get_xml_doc(int, char **, object_type, xmlChar **); 81*7836SJohn.Forte@Sun.COM static int build_delete_xml_doc(int, char **, object_type, char *, xmlChar **); 82*7836SJohn.Forte@Sun.COM static int build_create_xml_doc(int, char **, object_type, char *, xmlChar **); 83*7836SJohn.Forte@Sun.COM static int build_modify_xml_doc(int, char **, object_type, boolean_t, 84*7836SJohn.Forte@Sun.COM xmlChar **); 85*7836SJohn.Forte@Sun.COM static int build_rename_xml_doc(char *, object_type, uint32_t, xmlChar **); 86*7836SJohn.Forte@Sun.COM static int build_assoc_xml_doc(xmlChar *, association_t, xmlChar **); 87*7836SJohn.Forte@Sun.COM static int build_assoc_xml_doc(xmlChar *, association_t, xmlChar **); 88*7836SJohn.Forte@Sun.COM static int build_enumerate_xml_doc(object_type, xmlChar **); 89*7836SJohn.Forte@Sun.COM 90*7836SJohn.Forte@Sun.COM #define NEW_XMLARGV(old, n) (xmlChar **)realloc((xmlChar *)old, \ 91*7836SJohn.Forte@Sun.COM (unsigned)(n+2) * sizeof (xmlChar *)) 92*7836SJohn.Forte@Sun.COM 93*7836SJohn.Forte@Sun.COM #define XML_SFREE(x) (((x) != NULL) ? (xmlFree(x), (x) = NULL) : (void *)0) 94*7836SJohn.Forte@Sun.COM 95*7836SJohn.Forte@Sun.COM #define VERSION_STRING_MAX_LEN 10 96*7836SJohn.Forte@Sun.COM 97*7836SJohn.Forte@Sun.COM #define OPTIONSTRING_NAME "name" 98*7836SJohn.Forte@Sun.COM #define OPTIONSTRING_DDNAME "Discovery Domain name" 99*7836SJohn.Forte@Sun.COM #define OPTIONSTRING_DDSETNAME "Discovery Domain Set name" 100*7836SJohn.Forte@Sun.COM #define OPTIONSTRING_TARGET "target" 101*7836SJohn.Forte@Sun.COM #define OPTIONSTRING_INITIATOR "initiator" 102*7836SJohn.Forte@Sun.COM #define OPTIONSTRING_VERBOSE "verbose" 103*7836SJohn.Forte@Sun.COM 104*7836SJohn.Forte@Sun.COM #define VERBOSE 0x00000001 105*7836SJohn.Forte@Sun.COM #define INITIATOR_ONLY 0x00000010 106*7836SJohn.Forte@Sun.COM #define TARGET_ONLY 0x00000100 107*7836SJohn.Forte@Sun.COM 108*7836SJohn.Forte@Sun.COM /* object table based on definitions in isns_mgmt.h. */ 109*7836SJohn.Forte@Sun.COM static obj_table_entry_t obj_table[] = { 110*7836SJohn.Forte@Sun.COM {NODEOBJECT, Node}, 111*7836SJohn.Forte@Sun.COM {DDOBJECT, DiscoveryDomain}, 112*7836SJohn.Forte@Sun.COM {DDSETOBJECT, DiscoveryDomainSet}, 113*7836SJohn.Forte@Sun.COM {DDOBJECTMEMBER, DiscoveryDomainMember}, 114*7836SJohn.Forte@Sun.COM {DDSETOBJECTMEMBER, DiscoveryDomainSetMember}, 115*7836SJohn.Forte@Sun.COM {ISNSSERVER, ServerConfig}, 116*7836SJohn.Forte@Sun.COM {NULL, 0} 117*7836SJohn.Forte@Sun.COM }; 118*7836SJohn.Forte@Sun.COM 119*7836SJohn.Forte@Sun.COM /* 120*7836SJohn.Forte@Sun.COM * MAJOR - This should only change when there is an incompatible change made 121*7836SJohn.Forte@Sun.COM * to the interfaces or the output. 122*7836SJohn.Forte@Sun.COM * 123*7836SJohn.Forte@Sun.COM * MINOR - This should change whenever there is a new command or new feature 124*7836SJohn.Forte@Sun.COM * with no incompatible change. 125*7836SJohn.Forte@Sun.COM */ 126*7836SJohn.Forte@Sun.COM #define VERSION_STRING_MAJOR "1" 127*7836SJohn.Forte@Sun.COM #define VERSION_STRING_MINOR "0" 128*7836SJohn.Forte@Sun.COM static char *ISNS_FMRI = "network/isns_server:default"; 129*7836SJohn.Forte@Sun.COM 130*7836SJohn.Forte@Sun.COM /* 131*7836SJohn.Forte@Sun.COM * Add new options here 132*7836SJohn.Forte@Sun.COM */ 133*7836SJohn.Forte@Sun.COM 134*7836SJohn.Forte@Sun.COM /* tables set up based on cmdparse instructions */ 135*7836SJohn.Forte@Sun.COM optionTbl_t longOptions[] = { 136*7836SJohn.Forte@Sun.COM {"target", no_arg, 't', OPTIONSTRING_TARGET}, 137*7836SJohn.Forte@Sun.COM {"initiator", no_arg, 'i', OPTIONSTRING_INITIATOR}, 138*7836SJohn.Forte@Sun.COM {"verbose", no_arg, 'v', OPTIONSTRING_VERBOSE}, 139*7836SJohn.Forte@Sun.COM {"name", required_arg, 'n', OPTIONSTRING_NAME}, 140*7836SJohn.Forte@Sun.COM {"dd", required_arg, 'd', OPTIONSTRING_DDNAME}, 141*7836SJohn.Forte@Sun.COM {"dd-set", required_arg, 's', OPTIONSTRING_DDSETNAME}, 142*7836SJohn.Forte@Sun.COM {NULL, 0, 0, 0} 143*7836SJohn.Forte@Sun.COM }; 144*7836SJohn.Forte@Sun.COM 145*7836SJohn.Forte@Sun.COM 146*7836SJohn.Forte@Sun.COM /* 147*7836SJohn.Forte@Sun.COM * Add new subcommands here 148*7836SJohn.Forte@Sun.COM */ 149*7836SJohn.Forte@Sun.COM subCommandProps_t subcommands[] = { 150*7836SJohn.Forte@Sun.COM {"list-node", LISTNODE, list_node_func, "itv", B_FALSE, NULL, 151*7836SJohn.Forte@Sun.COM OPERAND_OPTIONAL_MULTIPLE, "node-name"}, 152*7836SJohn.Forte@Sun.COM {"list-dd", LISTDD, list_dd_func, "v", B_FALSE, NULL, 153*7836SJohn.Forte@Sun.COM OPERAND_OPTIONAL_MULTIPLE, OPTIONSTRING_DDNAME}, 154*7836SJohn.Forte@Sun.COM {"list-dd-set", LISTDDSET, list_ddset_func, "v", B_FALSE, NULL, 155*7836SJohn.Forte@Sun.COM OPERAND_OPTIONAL_MULTIPLE, OPTIONSTRING_DDSETNAME}, 156*7836SJohn.Forte@Sun.COM {"create-dd", CREATEDD, create_dd_func, NULL, B_FALSE, NULL, 157*7836SJohn.Forte@Sun.COM OPERAND_MANDATORY_MULTIPLE, OPTIONSTRING_DDNAME}, 158*7836SJohn.Forte@Sun.COM {"create-dd-set", CREATEDDSET, create_ddset_func, NULL, B_FALSE, NULL, 159*7836SJohn.Forte@Sun.COM OPERAND_MANDATORY_MULTIPLE, OPTIONSTRING_DDSETNAME}, 160*7836SJohn.Forte@Sun.COM {"delete-dd", DELETEDD, delete_dd_func, NULL, B_FALSE, NULL, 161*7836SJohn.Forte@Sun.COM OPERAND_MANDATORY_MULTIPLE, OPTIONSTRING_DDNAME}, 162*7836SJohn.Forte@Sun.COM {"delete-dd-set", DELETEDDSET, delete_ddset_func, NULL, B_FALSE, NULL, 163*7836SJohn.Forte@Sun.COM OPERAND_MANDATORY_MULTIPLE, OPTIONSTRING_DDSETNAME}, 164*7836SJohn.Forte@Sun.COM {"add-node", ADDNODE, add_node_func, "d", B_TRUE, NULL, 165*7836SJohn.Forte@Sun.COM OPERAND_MANDATORY_MULTIPLE, "node-name"}, 166*7836SJohn.Forte@Sun.COM {"add-dd", ADDDD, add_dd_func, "s", B_TRUE, NULL, 167*7836SJohn.Forte@Sun.COM OPERAND_MANDATORY_MULTIPLE, OPTIONSTRING_DDNAME}, 168*7836SJohn.Forte@Sun.COM {"remove-node", REMOVENODE, remove_node_func, "d", B_TRUE, NULL, 169*7836SJohn.Forte@Sun.COM OPERAND_MANDATORY_MULTIPLE, "node-name"}, 170*7836SJohn.Forte@Sun.COM {"remove-dd", REMOVEDD, remove_dd_func, "s", B_TRUE, NULL, 171*7836SJohn.Forte@Sun.COM OPERAND_MANDATORY_MULTIPLE, OPTIONSTRING_DDNAME}, 172*7836SJohn.Forte@Sun.COM {"modify-dd", MODIFYDD, modify_dd_func, "n", B_TRUE, NULL, 173*7836SJohn.Forte@Sun.COM OPERAND_MANDATORY_SINGLE, OPTIONSTRING_NAME}, 174*7836SJohn.Forte@Sun.COM {"modify-dd-set", MODIFYDDSET, modify_ddset_func, "n", B_TRUE, NULL, 175*7836SJohn.Forte@Sun.COM OPERAND_MANDATORY_SINGLE, OPTIONSTRING_NAME}, 176*7836SJohn.Forte@Sun.COM {"enable-dd-set", ENABLEDDSET, enable_ddset_func, NULL, B_FALSE, NULL, 177*7836SJohn.Forte@Sun.COM OPERAND_MANDATORY_MULTIPLE, OPTIONSTRING_DDSETNAME}, 178*7836SJohn.Forte@Sun.COM {"disable-dd-set", DISABLEDDSET, disable_ddset_func, NULL, B_FALSE, 179*7836SJohn.Forte@Sun.COM NULL, OPERAND_MANDATORY_MULTIPLE, OPTIONSTRING_DDSETNAME}, 180*7836SJohn.Forte@Sun.COM {"show-config", SHOWCONFIG, show_config_func, NULL, B_FALSE, NULL, 181*7836SJohn.Forte@Sun.COM OPERAND_NONE, NULL}, 182*7836SJohn.Forte@Sun.COM {NULL, 0, NULL, NULL, 0, NULL, 0, NULL} 183*7836SJohn.Forte@Sun.COM }; 184*7836SJohn.Forte@Sun.COM 185*7836SJohn.Forte@Sun.COM /* 186*7836SJohn.Forte@Sun.COM * **************************************************************************** 187*7836SJohn.Forte@Sun.COM * 188*7836SJohn.Forte@Sun.COM * check_door_error 189*7836SJohn.Forte@Sun.COM * 190*7836SJohn.Forte@Sun.COM * input: 191*7836SJohn.Forte@Sun.COM * errno from the door call. 192*7836SJohn.Forte@Sun.COM * 193*7836SJohn.Forte@Sun.COM * Returns: 194*7836SJohn.Forte@Sun.COM * either door error or smf service error. 195*7836SJohn.Forte@Sun.COM * 196*7836SJohn.Forte@Sun.COM * **************************************************************************** 197*7836SJohn.Forte@Sun.COM */ 198*7836SJohn.Forte@Sun.COM static int 199*7836SJohn.Forte@Sun.COM check_door_error(int door_err, int err) 200*7836SJohn.Forte@Sun.COM { 201*7836SJohn.Forte@Sun.COM char *state = NULL; 202*7836SJohn.Forte@Sun.COM int ret; 203*7836SJohn.Forte@Sun.COM 204*7836SJohn.Forte@Sun.COM if (((state = smf_get_state(ISNS_FMRI)) != NULL) && 205*7836SJohn.Forte@Sun.COM (strcmp(state, SCF_STATE_STRING_ONLINE) != 0)) { 206*7836SJohn.Forte@Sun.COM ret = ERROR_ISNS_SMF_SERVICE_NOT_ONLINE; 207*7836SJohn.Forte@Sun.COM } else { 208*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 209*7836SJohn.Forte@Sun.COM (door_err == ERROR_DOOR_CALL_FAILED) ? 210*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_DOOR_CALL_FAILED) : 211*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_DOOR_OPEN_FAILED)); 212*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "\terrno: %s\n", strerror(err)); 213*7836SJohn.Forte@Sun.COM ret = door_err; 214*7836SJohn.Forte@Sun.COM } 215*7836SJohn.Forte@Sun.COM 216*7836SJohn.Forte@Sun.COM if (state) free(state); 217*7836SJohn.Forte@Sun.COM 218*7836SJohn.Forte@Sun.COM return (ret); 219*7836SJohn.Forte@Sun.COM } 220*7836SJohn.Forte@Sun.COM 221*7836SJohn.Forte@Sun.COM /* 222*7836SJohn.Forte@Sun.COM * **************************************************************************** 223*7836SJohn.Forte@Sun.COM * 224*7836SJohn.Forte@Sun.COM * lookup an element based on the element name. 225*7836SJohn.Forte@Sun.COM * 226*7836SJohn.Forte@Sun.COM * reader - current xmlReaderReadPtr 227*7836SJohn.Forte@Sun.COM * m_falg - indicate lookup result 228*7836SJohn.Forte@Sun.COM * elem - name of element to look up. 229*7836SJohn.Forte@Sun.COM * endelem - name of end element to look up. 230*7836SJohn.Forte@Sun.COM * 231*7836SJohn.Forte@Sun.COM * **************************************************************************** 232*7836SJohn.Forte@Sun.COM */ 233*7836SJohn.Forte@Sun.COM static xmlTextReaderPtr 234*7836SJohn.Forte@Sun.COM lookup_next_matching_elem(xmlTextReaderPtr reader, int *m_flag, 235*7836SJohn.Forte@Sun.COM const char *elem, const char *endelem) 236*7836SJohn.Forte@Sun.COM { 237*7836SJohn.Forte@Sun.COM 238*7836SJohn.Forte@Sun.COM if (reader == NULL) { 239*7836SJohn.Forte@Sun.COM *m_flag = NO_MATCH; 240*7836SJohn.Forte@Sun.COM return (NULL); 241*7836SJohn.Forte@Sun.COM } 242*7836SJohn.Forte@Sun.COM 243*7836SJohn.Forte@Sun.COM do { 244*7836SJohn.Forte@Sun.COM /* 245*7836SJohn.Forte@Sun.COM * if (xmlTextReaderName(reader) != NULL) { 246*7836SJohn.Forte@Sun.COM * printf("%s ", xmlTextReaderName(reader)); 247*7836SJohn.Forte@Sun.COM * } 248*7836SJohn.Forte@Sun.COM * printf("%d %d %d\n", 249*7836SJohn.Forte@Sun.COM * xmlTextReaderDepth(reader), 250*7836SJohn.Forte@Sun.COM * xmlTextReaderNodeType(reader), 251*7836SJohn.Forte@Sun.COM * xmlTextReaderIsEmptyElement(reader)); 252*7836SJohn.Forte@Sun.COM */ 253*7836SJohn.Forte@Sun.COM /* 254*7836SJohn.Forte@Sun.COM * if match with elem, return the reader with READER_MATCH flag. 255*7836SJohn.Forte@Sun.COM * if match with end elem, return the reader wtih 256*7836SJohn.Forte@Sun.COM * END_READER_MATCH flag. 257*7836SJohn.Forte@Sun.COM */ 258*7836SJohn.Forte@Sun.COM if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) { 259*7836SJohn.Forte@Sun.COM if (XMLNCMP(reader, elem) == 0) { 260*7836SJohn.Forte@Sun.COM *m_flag = READER_MATCH; 261*7836SJohn.Forte@Sun.COM return (reader); 262*7836SJohn.Forte@Sun.COM } 263*7836SJohn.Forte@Sun.COM } else if (xmlTextReaderNodeType(reader) == 264*7836SJohn.Forte@Sun.COM XML_READER_TYPE_END_ELEMENT) { 265*7836SJohn.Forte@Sun.COM if (XMLNCMP(reader, endelem) == 0) { 266*7836SJohn.Forte@Sun.COM *m_flag = END_READER_MATCH; 267*7836SJohn.Forte@Sun.COM return (reader); 268*7836SJohn.Forte@Sun.COM } 269*7836SJohn.Forte@Sun.COM } 270*7836SJohn.Forte@Sun.COM } while (xmlTextReaderRead(reader) == 1); 271*7836SJohn.Forte@Sun.COM 272*7836SJohn.Forte@Sun.COM *m_flag = NO_MATCH; 273*7836SJohn.Forte@Sun.COM return (NULL); 274*7836SJohn.Forte@Sun.COM } 275*7836SJohn.Forte@Sun.COM 276*7836SJohn.Forte@Sun.COM /* 277*7836SJohn.Forte@Sun.COM * **************************************************************************** 278*7836SJohn.Forte@Sun.COM * 279*7836SJohn.Forte@Sun.COM * Routine for getAssociated operation 280*7836SJohn.Forte@Sun.COM * Construct association request based on the name and calls door 281*7836SJohn.Forte@Sun.COM * interface. 282*7836SJohn.Forte@Sun.COM * 283*7836SJohn.Forte@Sun.COM * name - name attributes of an object for getting an association 284*7836SJohn.Forte@Sun.COM * assoc - association type 285*7836SJohn.Forte@Sun.COM * 286*7836SJohn.Forte@Sun.COM * **************************************************************************** 287*7836SJohn.Forte@Sun.COM */ 288*7836SJohn.Forte@Sun.COM static int 289*7836SJohn.Forte@Sun.COM handle_association_info(xmlChar *name, association_t assoc) 290*7836SJohn.Forte@Sun.COM { 291*7836SJohn.Forte@Sun.COM 292*7836SJohn.Forte@Sun.COM xmlChar *doc; 293*7836SJohn.Forte@Sun.COM door_arg_t darg; 294*7836SJohn.Forte@Sun.COM msg_code_t ret; 295*7836SJohn.Forte@Sun.COM int fd; 296*7836SJohn.Forte@Sun.COM 297*7836SJohn.Forte@Sun.COM if ((ret = build_assoc_xml_doc(name, assoc, &doc)) != 0) { 298*7836SJohn.Forte@Sun.COM return (ret); 299*7836SJohn.Forte@Sun.COM } 300*7836SJohn.Forte@Sun.COM 301*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 302*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 303*7836SJohn.Forte@Sun.COM return (ret); 304*7836SJohn.Forte@Sun.COM } 305*7836SJohn.Forte@Sun.COM 306*7836SJohn.Forte@Sun.COM (void) bzero(&darg, sizeof (darg)); 307*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 308*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 309*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 310*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 311*7836SJohn.Forte@Sun.COM darg.rsize = 0; 312*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 313*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 314*7836SJohn.Forte@Sun.COM (void) close(fd); 315*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 316*7836SJohn.Forte@Sun.COM return (ret); 317*7836SJohn.Forte@Sun.COM } 318*7836SJohn.Forte@Sun.COM 319*7836SJohn.Forte@Sun.COM if ((ret = process_get_assoc_response((xmlChar *)darg.rbuf, 320*7836SJohn.Forte@Sun.COM assoc)) != 0) { 321*7836SJohn.Forte@Sun.COM /* 322*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager 323*7836SJohn.Forte@Sun.COM * that rbuf. indicate if munmap is required on rbuf. 324*7836SJohn.Forte@Sun.COM */ 325*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 326*7836SJohn.Forte@Sun.COM (void) close(fd); 327*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 328*7836SJohn.Forte@Sun.COM return (ret); 329*7836SJohn.Forte@Sun.COM } 330*7836SJohn.Forte@Sun.COM 331*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 332*7836SJohn.Forte@Sun.COM 333*7836SJohn.Forte@Sun.COM (void) close(fd); 334*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 335*7836SJohn.Forte@Sun.COM 336*7836SJohn.Forte@Sun.COM return (0); 337*7836SJohn.Forte@Sun.COM } 338*7836SJohn.Forte@Sun.COM 339*7836SJohn.Forte@Sun.COM /* 340*7836SJohn.Forte@Sun.COM * **************************************************************************** 341*7836SJohn.Forte@Sun.COM * 342*7836SJohn.Forte@Sun.COM * process_error_status 343*7836SJohn.Forte@Sun.COM * The routine process non 0 status and print out error message. 344*7836SJohn.Forte@Sun.COM * 345*7836SJohn.Forte@Sun.COM * status - status code 346*7836SJohn.Forte@Sun.COM * reader - reader that points to the message element. 347*7836SJohn.Forte@Sun.COM * 348*7836SJohn.Forte@Sun.COM * **************************************************************************** 349*7836SJohn.Forte@Sun.COM */ 350*7836SJohn.Forte@Sun.COM static void 351*7836SJohn.Forte@Sun.COM print_error_status(int status, int obj, xmlTextReaderPtr reader) 352*7836SJohn.Forte@Sun.COM { 353*7836SJohn.Forte@Sun.COM int m_flag = 0; 354*7836SJohn.Forte@Sun.COM 355*7836SJohn.Forte@Sun.COM switch (status) { 356*7836SJohn.Forte@Sun.COM case ISNS_RSP_BUSY: 357*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 358*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_SERVER_BUSY)); 359*7836SJohn.Forte@Sun.COM break; 360*7836SJohn.Forte@Sun.COM case ISNS_RSP_INTERNAL_ERROR: 361*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 362*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_SERVER_INTERNAL_ERROR)); 363*7836SJohn.Forte@Sun.COM break; 364*7836SJohn.Forte@Sun.COM case ISNS_RSP_OPTION_NOT_UNDERSTOOD: 365*7836SJohn.Forte@Sun.COM if ((obj == DiscoveryDomain) || 366*7836SJohn.Forte@Sun.COM (obj == DiscoveryDomainMember)) { 367*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 368*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_OPERATION_NOT_ALLOWED_FOR_DEFAULT_DD)); 369*7836SJohn.Forte@Sun.COM } else { 370*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 371*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_OPERATION_NOT_ALLOWED_FOR_DEFAULT_DDSET)); 372*7836SJohn.Forte@Sun.COM } 373*7836SJohn.Forte@Sun.COM break; 374*7836SJohn.Forte@Sun.COM case PARTIAL_FAILURE: 375*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 376*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_PARTIAL_FAILURE)); 377*7836SJohn.Forte@Sun.COM break; 378*7836SJohn.Forte@Sun.COM case ERR_NO_SUCH_ASSOCIATION: 379*7836SJohn.Forte@Sun.COM if ((obj == DiscoveryDomain) || 380*7836SJohn.Forte@Sun.COM (obj == DiscoveryDomainMember)) { 381*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 382*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_DDMEMBER_NOT_FOUND)); 383*7836SJohn.Forte@Sun.COM } else { 384*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 385*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_DDSETMEMBER_NOT_FOUND)); 386*7836SJohn.Forte@Sun.COM } 387*7836SJohn.Forte@Sun.COM break; 388*7836SJohn.Forte@Sun.COM case ERR_ALREADY_ASSOCIATED: 389*7836SJohn.Forte@Sun.COM if ((obj == DiscoveryDomain) || 390*7836SJohn.Forte@Sun.COM (obj == DiscoveryDomainMember)) { 391*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 392*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_DDMEMBER_ALREADY_EXIST)); 393*7836SJohn.Forte@Sun.COM } else { 394*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 395*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_DDSETMEMBER_ALREADY_EXIST)); 396*7836SJohn.Forte@Sun.COM } 397*7836SJohn.Forte@Sun.COM break; 398*7836SJohn.Forte@Sun.COM case ERR_NAME_IN_USE: 399*7836SJohn.Forte@Sun.COM if ((obj == DiscoveryDomain) || 400*7836SJohn.Forte@Sun.COM (obj == DiscoveryDomainMember)) { 401*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 402*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_DD_NAME_IN_USE)); 403*7836SJohn.Forte@Sun.COM } else { 404*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 405*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_DDSET_NAME_IN_USE)); 406*7836SJohn.Forte@Sun.COM } 407*7836SJohn.Forte@Sun.COM break; 408*7836SJohn.Forte@Sun.COM default: 409*7836SJohn.Forte@Sun.COM reader = lookup_next_matching_elem(reader, &m_flag, 410*7836SJohn.Forte@Sun.COM MESSAGEELEMENT, RESULTELEMENT); 411*7836SJohn.Forte@Sun.COM if (m_flag == READER_MATCH) { 412*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 413*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "Error: %s\n", 414*7836SJohn.Forte@Sun.COM (const char *) xmlTextReaderConstValue(reader)); 415*7836SJohn.Forte@Sun.COM } else { 416*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "Error: %s\n", 417*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_XML_MESSAGE_ELEM_NOT_FOUND)); 418*7836SJohn.Forte@Sun.COM } 419*7836SJohn.Forte@Sun.COM } 420*7836SJohn.Forte@Sun.COM } 421*7836SJohn.Forte@Sun.COM 422*7836SJohn.Forte@Sun.COM /* 423*7836SJohn.Forte@Sun.COM * **************************************************************************** 424*7836SJohn.Forte@Sun.COM * 425*7836SJohn.Forte@Sun.COM * print_partial_failure_info 426*7836SJohn.Forte@Sun.COM * The routine prints partial failure info. 427*7836SJohn.Forte@Sun.COM * 428*7836SJohn.Forte@Sun.COM * status - status code 429*7836SJohn.Forte@Sun.COM * reader - reader that points to the message element. 430*7836SJohn.Forte@Sun.COM * 431*7836SJohn.Forte@Sun.COM * **************************************************************************** 432*7836SJohn.Forte@Sun.COM */ 433*7836SJohn.Forte@Sun.COM static void 434*7836SJohn.Forte@Sun.COM print_partial_failure_info(xmlChar *doc) 435*7836SJohn.Forte@Sun.COM { 436*7836SJohn.Forte@Sun.COM xmlChar expr[ISNS_MAX_LABEL_LEN + 13]; 437*7836SJohn.Forte@Sun.COM xmlDocPtr x_doc; 438*7836SJohn.Forte@Sun.COM xmlXPathContextPtr ctext = NULL; 439*7836SJohn.Forte@Sun.COM xmlXPathObjectPtr xpath_obj = NULL; 440*7836SJohn.Forte@Sun.COM xmlNodeSetPtr r_nodes = NULL; 441*7836SJohn.Forte@Sun.COM xmlAttrPtr attr = NULL; 442*7836SJohn.Forte@Sun.COM int i, cnt, obj = 0; 443*7836SJohn.Forte@Sun.COM 444*7836SJohn.Forte@Sun.COM if ((x_doc = xmlParseMemory((const char *)doc, xmlStrlen(doc))) == 445*7836SJohn.Forte@Sun.COM NULL) { 446*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 447*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_NO_ADDITIONAL_PARTIAL_FAILIRE_INFO)); 448*7836SJohn.Forte@Sun.COM } 449*7836SJohn.Forte@Sun.COM 450*7836SJohn.Forte@Sun.COM ctext = xmlXPathNewContext(x_doc); 451*7836SJohn.Forte@Sun.COM if (ctext == NULL) { 452*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 453*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_NO_ADDITIONAL_PARTIAL_FAILIRE_INFO)); 454*7836SJohn.Forte@Sun.COM } 455*7836SJohn.Forte@Sun.COM 456*7836SJohn.Forte@Sun.COM for (i = 0; obj_table[i].obj_str != NULL; i++) { 457*7836SJohn.Forte@Sun.COM (void) xmlStrPrintf(expr, ISNS_MAX_LABEL_LEN + 13, 458*7836SJohn.Forte@Sun.COM (const unsigned char *)"%s\"%s\"]", "//*[name()=", 459*7836SJohn.Forte@Sun.COM obj_table[i].obj_str); 460*7836SJohn.Forte@Sun.COM xpath_obj = xmlXPathEvalExpression(expr, ctext); 461*7836SJohn.Forte@Sun.COM if ((xpath_obj) && (xpath_obj->nodesetval) && 462*7836SJohn.Forte@Sun.COM (xpath_obj->nodesetval->nodeNr > 0) && 463*7836SJohn.Forte@Sun.COM (xpath_obj->nodesetval->nodeTab)) { 464*7836SJohn.Forte@Sun.COM obj = obj_table[i].obj_id; 465*7836SJohn.Forte@Sun.COM break; 466*7836SJohn.Forte@Sun.COM } 467*7836SJohn.Forte@Sun.COM } 468*7836SJohn.Forte@Sun.COM 469*7836SJohn.Forte@Sun.COM if (obj == 0) { 470*7836SJohn.Forte@Sun.COM if (xpath_obj) xmlXPathFreeObject(xpath_obj); 471*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 472*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_NO_ADDITIONAL_PARTIAL_FAILIRE_INFO)); 473*7836SJohn.Forte@Sun.COM } 474*7836SJohn.Forte@Sun.COM 475*7836SJohn.Forte@Sun.COM switch (obj) { 476*7836SJohn.Forte@Sun.COM case DiscoveryDomainMember: 477*7836SJohn.Forte@Sun.COM r_nodes = xpath_obj->nodesetval; 478*7836SJohn.Forte@Sun.COM cnt = r_nodes->nodeNr; 479*7836SJohn.Forte@Sun.COM for (i = 0; i < cnt; i++) { 480*7836SJohn.Forte@Sun.COM attr = r_nodes->nodeTab[i]->properties; 481*7836SJohn.Forte@Sun.COM for (; attr != NULL; attr = attr->next) { 482*7836SJohn.Forte@Sun.COM if (xmlStrncmp(attr->name, (xmlChar *)DDNAMEATTR, 483*7836SJohn.Forte@Sun.COM xmlStrlen((xmlChar *)DDNAMEATTR)) == 0) { 484*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "DD Name: %s\t", 485*7836SJohn.Forte@Sun.COM xmlNodeGetContent(attr->children)); 486*7836SJohn.Forte@Sun.COM } 487*7836SJohn.Forte@Sun.COM if (xmlStrncmp(attr->name, (xmlChar *)NODENAMEATTR, 488*7836SJohn.Forte@Sun.COM xmlStrlen((xmlChar *)NODENAMEATTR)) == 0) { 489*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "Node Name: %s\t", 490*7836SJohn.Forte@Sun.COM xmlNodeGetContent(attr->children)); 491*7836SJohn.Forte@Sun.COM } 492*7836SJohn.Forte@Sun.COM } 493*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "\n"); 494*7836SJohn.Forte@Sun.COM } 495*7836SJohn.Forte@Sun.COM if (xpath_obj) xmlXPathFreeObject(xpath_obj); 496*7836SJohn.Forte@Sun.COM break; 497*7836SJohn.Forte@Sun.COM case DiscoveryDomainSetMember: 498*7836SJohn.Forte@Sun.COM r_nodes = xpath_obj->nodesetval; 499*7836SJohn.Forte@Sun.COM cnt = r_nodes->nodeNr; 500*7836SJohn.Forte@Sun.COM for (i = 0; i < cnt; i++) { 501*7836SJohn.Forte@Sun.COM attr = r_nodes->nodeTab[i]->properties; 502*7836SJohn.Forte@Sun.COM for (; attr != NULL; attr = attr->next) { 503*7836SJohn.Forte@Sun.COM if (xmlStrncmp(attr->name, (xmlChar *)DDSETNAMEATTR, 504*7836SJohn.Forte@Sun.COM xmlStrlen((xmlChar *)DDNAMEATTR)) == 0) { 505*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "DD Set Name: %s\t", 506*7836SJohn.Forte@Sun.COM xmlNodeGetContent(attr->children)); 507*7836SJohn.Forte@Sun.COM } 508*7836SJohn.Forte@Sun.COM if (xmlStrncmp(attr->name, (xmlChar *)DDNAMEATTR, 509*7836SJohn.Forte@Sun.COM xmlStrlen((xmlChar *)NODENAMEATTR)) == 0) { 510*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "DD Name: %s\t", 511*7836SJohn.Forte@Sun.COM xmlNodeGetContent(attr->children)); 512*7836SJohn.Forte@Sun.COM } 513*7836SJohn.Forte@Sun.COM } 514*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "\n"); 515*7836SJohn.Forte@Sun.COM } 516*7836SJohn.Forte@Sun.COM if (xpath_obj) xmlXPathFreeObject(xpath_obj); 517*7836SJohn.Forte@Sun.COM break; 518*7836SJohn.Forte@Sun.COM case Node: 519*7836SJohn.Forte@Sun.COM case DiscoveryDomain: 520*7836SJohn.Forte@Sun.COM case DiscoveryDomainSet: 521*7836SJohn.Forte@Sun.COM r_nodes = xpath_obj->nodesetval; 522*7836SJohn.Forte@Sun.COM cnt = r_nodes->nodeNr; 523*7836SJohn.Forte@Sun.COM for (i = 0; i < cnt; i++) { 524*7836SJohn.Forte@Sun.COM attr = r_nodes->nodeTab[i]->properties; 525*7836SJohn.Forte@Sun.COM for (; attr != NULL; attr = attr->next) { 526*7836SJohn.Forte@Sun.COM if ((xmlStrncmp(attr->name, (xmlChar *)NAMEATTR, 527*7836SJohn.Forte@Sun.COM xmlStrlen((xmlChar *)NAMEATTR))) == 0) { 528*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "Object Name: %s\n", 529*7836SJohn.Forte@Sun.COM xmlNodeGetContent(attr->children)); 530*7836SJohn.Forte@Sun.COM } 531*7836SJohn.Forte@Sun.COM } 532*7836SJohn.Forte@Sun.COM } 533*7836SJohn.Forte@Sun.COM if (xpath_obj) xmlXPathFreeObject(xpath_obj); 534*7836SJohn.Forte@Sun.COM break; 535*7836SJohn.Forte@Sun.COM } 536*7836SJohn.Forte@Sun.COM } 537*7836SJohn.Forte@Sun.COM 538*7836SJohn.Forte@Sun.COM /* 539*7836SJohn.Forte@Sun.COM * **************************************************************************** 540*7836SJohn.Forte@Sun.COM * 541*7836SJohn.Forte@Sun.COM * process_result_response 542*7836SJohn.Forte@Sun.COM * The routine process association data based on the association type. 543*7836SJohn.Forte@Sun.COM * 544*7836SJohn.Forte@Sun.COM * doc - result 545*7836SJohn.Forte@Sun.COM * obj - associated object type 546*7836SJohn.Forte@Sun.COM * 547*7836SJohn.Forte@Sun.COM * **************************************************************************** 548*7836SJohn.Forte@Sun.COM */ 549*7836SJohn.Forte@Sun.COM static int 550*7836SJohn.Forte@Sun.COM process_result_response(xmlChar *doc, int obj) 551*7836SJohn.Forte@Sun.COM { 552*7836SJohn.Forte@Sun.COM xmlTextReaderPtr reader; 553*7836SJohn.Forte@Sun.COM int m_flag = 0, status; 554*7836SJohn.Forte@Sun.COM 555*7836SJohn.Forte@Sun.COM if ((reader = (xmlTextReaderPtr)xmlReaderForMemory((const char *)doc, 556*7836SJohn.Forte@Sun.COM xmlStrlen(doc), NULL, NULL, 0)) == NULL) { 557*7836SJohn.Forte@Sun.COM return (ERROR_XML_READER_NULL); 558*7836SJohn.Forte@Sun.COM } 559*7836SJohn.Forte@Sun.COM 560*7836SJohn.Forte@Sun.COM /* if status is 0, continue on. Otherwise return an error. */ 561*7836SJohn.Forte@Sun.COM if (reader = lookup_next_matching_elem(reader, &m_flag, STATUSELEMENT, 562*7836SJohn.Forte@Sun.COM RESULTELEMENT)) { 563*7836SJohn.Forte@Sun.COM if (m_flag == READER_MATCH) { 564*7836SJohn.Forte@Sun.COM if (xmlTextReaderRead(reader) == 1) { 565*7836SJohn.Forte@Sun.COM status = 566*7836SJohn.Forte@Sun.COM atoi((const char *)xmlTextReaderConstValue(reader)); 567*7836SJohn.Forte@Sun.COM if (status != 0) { 568*7836SJohn.Forte@Sun.COM print_error_status(status, obj, reader); 569*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 570*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 571*7836SJohn.Forte@Sun.COM if (status == PARTIAL_FAILURE) { 572*7836SJohn.Forte@Sun.COM print_partial_failure_info(doc); 573*7836SJohn.Forte@Sun.COM } 574*7836SJohn.Forte@Sun.COM return (status); 575*7836SJohn.Forte@Sun.COM } 576*7836SJohn.Forte@Sun.COM } else { 577*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 578*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 579*7836SJohn.Forte@Sun.COM return (ERROR_XML_STATUS_ELEM_NOT_FOUND); 580*7836SJohn.Forte@Sun.COM } 581*7836SJohn.Forte@Sun.COM } else { 582*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 583*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 584*7836SJohn.Forte@Sun.COM return (ERROR_XML_STATUS_ELEM_NOT_FOUND); 585*7836SJohn.Forte@Sun.COM } 586*7836SJohn.Forte@Sun.COM } else { 587*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 588*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_XML_READER_NULL)); 589*7836SJohn.Forte@Sun.COM return (ERROR_XML_READER_NULL); 590*7836SJohn.Forte@Sun.COM } 591*7836SJohn.Forte@Sun.COM 592*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 593*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 594*7836SJohn.Forte@Sun.COM return (0); 595*7836SJohn.Forte@Sun.COM } 596*7836SJohn.Forte@Sun.COM 597*7836SJohn.Forte@Sun.COM /* 598*7836SJohn.Forte@Sun.COM * **************************************************************************** 599*7836SJohn.Forte@Sun.COM * 600*7836SJohn.Forte@Sun.COM * process_get_assoc_response 601*7836SJohn.Forte@Sun.COM * The routine process association data based on the association type. 602*7836SJohn.Forte@Sun.COM * 603*7836SJohn.Forte@Sun.COM * doc - association data 604*7836SJohn.Forte@Sun.COM * assoc - associatiion type 605*7836SJohn.Forte@Sun.COM * 606*7836SJohn.Forte@Sun.COM * **************************************************************************** 607*7836SJohn.Forte@Sun.COM */ 608*7836SJohn.Forte@Sun.COM static int 609*7836SJohn.Forte@Sun.COM process_get_assoc_response(xmlChar *doc, association_t assoc) 610*7836SJohn.Forte@Sun.COM { 611*7836SJohn.Forte@Sun.COM xmlTextReaderPtr reader; 612*7836SJohn.Forte@Sun.COM xmlChar *ddsname, *ddname, *nodename; 613*7836SJohn.Forte@Sun.COM wchar_t wc_name[ISNS_MAX_NAME_LEN]; 614*7836SJohn.Forte@Sun.COM int m_flag = 0, h_printed = 0, status; 615*7836SJohn.Forte@Sun.COM 616*7836SJohn.Forte@Sun.COM if ((reader = (xmlTextReaderPtr)xmlReaderForMemory((const char *)doc, 617*7836SJohn.Forte@Sun.COM xmlStrlen(doc), NULL, NULL, 0)) == NULL) { 618*7836SJohn.Forte@Sun.COM return (ERROR_XML_READER_NULL); 619*7836SJohn.Forte@Sun.COM } 620*7836SJohn.Forte@Sun.COM 621*7836SJohn.Forte@Sun.COM /* if status is 0, continue on. Otherwise return an error. */ 622*7836SJohn.Forte@Sun.COM if (reader = lookup_next_matching_elem(reader, &m_flag, STATUSELEMENT, 623*7836SJohn.Forte@Sun.COM RESULTELEMENT)) { 624*7836SJohn.Forte@Sun.COM if (m_flag == READER_MATCH) { 625*7836SJohn.Forte@Sun.COM if (xmlTextReaderRead(reader) == 1) { 626*7836SJohn.Forte@Sun.COM status = 627*7836SJohn.Forte@Sun.COM atoi((const char *)xmlTextReaderConstValue(reader)); 628*7836SJohn.Forte@Sun.COM if ((status != 0) && (status != PARTIAL_SUCCESS)) { 629*7836SJohn.Forte@Sun.COM /* not an error */ 630*7836SJohn.Forte@Sun.COM if ((status != ERR_NO_SUCH_ASSOCIATION) && 631*7836SJohn.Forte@Sun.COM (status != ERR_NO_ASSOCIATED_DD_FOUND) && 632*7836SJohn.Forte@Sun.COM (status != ERR_NO_ASSOCIATED_DDSET_FOUND)) { 633*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 634*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 635*7836SJohn.Forte@Sun.COM return (0); 636*7836SJohn.Forte@Sun.COM } else { 637*7836SJohn.Forte@Sun.COM print_error_status(status, 638*7836SJohn.Forte@Sun.COM ((assoc == node_to_dd) || (dd_to_node)) ? 639*7836SJohn.Forte@Sun.COM DiscoveryDomain : DiscoveryDomainSet, reader); 640*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 641*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 642*7836SJohn.Forte@Sun.COM return (status); 643*7836SJohn.Forte@Sun.COM } 644*7836SJohn.Forte@Sun.COM } 645*7836SJohn.Forte@Sun.COM } else { 646*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 647*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 648*7836SJohn.Forte@Sun.COM return (ERROR_XML_STATUS_ELEM_NOT_FOUND); 649*7836SJohn.Forte@Sun.COM } 650*7836SJohn.Forte@Sun.COM } else { 651*7836SJohn.Forte@Sun.COM return (ERROR_XML_STATUS_ELEM_NOT_FOUND); 652*7836SJohn.Forte@Sun.COM } 653*7836SJohn.Forte@Sun.COM } else { 654*7836SJohn.Forte@Sun.COM return (ERROR_XML_READER_NULL); 655*7836SJohn.Forte@Sun.COM } 656*7836SJohn.Forte@Sun.COM 657*7836SJohn.Forte@Sun.COM m_flag = 0; 658*7836SJohn.Forte@Sun.COM 659*7836SJohn.Forte@Sun.COM switch (assoc) { 660*7836SJohn.Forte@Sun.COM case node_to_dd: 661*7836SJohn.Forte@Sun.COM /* process DD elements */ 662*7836SJohn.Forte@Sun.COM while (reader = lookup_next_matching_elem(reader, &m_flag, 663*7836SJohn.Forte@Sun.COM DDOBJECTMEMBER, ISNSRESPONSE)) { 664*7836SJohn.Forte@Sun.COM if (m_flag == END_READER_MATCH) { 665*7836SJohn.Forte@Sun.COM (void) xmlTextReaderNext(reader); 666*7836SJohn.Forte@Sun.COM break; 667*7836SJohn.Forte@Sun.COM } else if (m_flag == READER_MATCH) { 668*7836SJohn.Forte@Sun.COM if ((ddname = (xmlTextReaderGetAttribute(reader, 669*7836SJohn.Forte@Sun.COM (const xmlChar *)DDNAMEATTR))) != NULL) { 670*7836SJohn.Forte@Sun.COM if (mbstowcs(wc_name, (const char *)ddname, 671*7836SJohn.Forte@Sun.COM ISNS_MAX_NAME_LEN) == (size_t)-1) { 672*7836SJohn.Forte@Sun.COM (void) wcscpy(wc_name, L"-"); 673*7836SJohn.Forte@Sun.COM } 674*7836SJohn.Forte@Sun.COM if (h_printed) { 675*7836SJohn.Forte@Sun.COM (void) printf("\tDD Name: %ws\n", wc_name); 676*7836SJohn.Forte@Sun.COM } else { 677*7836SJohn.Forte@Sun.COM (void) printf("\tDD Name: %ws\n", wc_name); 678*7836SJohn.Forte@Sun.COM h_printed = 1; 679*7836SJohn.Forte@Sun.COM } 680*7836SJohn.Forte@Sun.COM xmlFree(ddname); 681*7836SJohn.Forte@Sun.COM } else { 682*7836SJohn.Forte@Sun.COM if (h_printed) { 683*7836SJohn.Forte@Sun.COM (void) printf("\t %s\n", "-"); 684*7836SJohn.Forte@Sun.COM } else { 685*7836SJohn.Forte@Sun.COM (void) printf("\tDD Name: %s\n", "-"); 686*7836SJohn.Forte@Sun.COM h_printed = 1; 687*7836SJohn.Forte@Sun.COM } 688*7836SJohn.Forte@Sun.COM } 689*7836SJohn.Forte@Sun.COM } 690*7836SJohn.Forte@Sun.COM m_flag = 0; 691*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 692*7836SJohn.Forte@Sun.COM } 693*7836SJohn.Forte@Sun.COM break; 694*7836SJohn.Forte@Sun.COM case dd_to_node: 695*7836SJohn.Forte@Sun.COM /* process the DiscoveryDoamin elements */ 696*7836SJohn.Forte@Sun.COM while (reader = lookup_next_matching_elem(reader, &m_flag, 697*7836SJohn.Forte@Sun.COM DDOBJECTMEMBER, ISNSRESPONSE)) { 698*7836SJohn.Forte@Sun.COM if (m_flag == END_READER_MATCH) { 699*7836SJohn.Forte@Sun.COM (void) xmlTextReaderNext(reader); 700*7836SJohn.Forte@Sun.COM break; 701*7836SJohn.Forte@Sun.COM } else if (m_flag == READER_MATCH) { 702*7836SJohn.Forte@Sun.COM if ((nodename = (xmlTextReaderGetAttribute(reader, 703*7836SJohn.Forte@Sun.COM (const xmlChar *)NODENAMEATTR))) != NULL) { 704*7836SJohn.Forte@Sun.COM if (mbstowcs(wc_name, (const char *)nodename, 705*7836SJohn.Forte@Sun.COM ISNS_MAX_NAME_LEN) == (size_t)-1) { 706*7836SJohn.Forte@Sun.COM (void) wcscpy(wc_name, L"-"); 707*7836SJohn.Forte@Sun.COM } 708*7836SJohn.Forte@Sun.COM (void) printf("\tiSCSI name: %ws\n", wc_name); 709*7836SJohn.Forte@Sun.COM xmlFree(nodename); 710*7836SJohn.Forte@Sun.COM } else { 711*7836SJohn.Forte@Sun.COM (void) printf("\tiSCSI name: %s\n", "-"); 712*7836SJohn.Forte@Sun.COM } 713*7836SJohn.Forte@Sun.COM } 714*7836SJohn.Forte@Sun.COM m_flag = 0; 715*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 716*7836SJohn.Forte@Sun.COM } 717*7836SJohn.Forte@Sun.COM break; 718*7836SJohn.Forte@Sun.COM case dd_to_ddset: 719*7836SJohn.Forte@Sun.COM /* process the DiscoveryDoaminSet elements */ 720*7836SJohn.Forte@Sun.COM while (reader = lookup_next_matching_elem(reader, &m_flag, 721*7836SJohn.Forte@Sun.COM DDSETOBJECTMEMBER, ISNSRESPONSE)) { 722*7836SJohn.Forte@Sun.COM if (m_flag == END_READER_MATCH) { 723*7836SJohn.Forte@Sun.COM (void) xmlTextReaderNext(reader); 724*7836SJohn.Forte@Sun.COM break; 725*7836SJohn.Forte@Sun.COM } else if (m_flag == READER_MATCH) { 726*7836SJohn.Forte@Sun.COM if ((ddsname = (xmlTextReaderGetAttribute(reader, 727*7836SJohn.Forte@Sun.COM (const xmlChar *)DDSETNAMEATTR))) != NULL) { 728*7836SJohn.Forte@Sun.COM if (mbstowcs(wc_name, (const char *)ddsname, 729*7836SJohn.Forte@Sun.COM ISNS_MAX_NAME_LEN) == (size_t)-1) { 730*7836SJohn.Forte@Sun.COM (void) wcscpy(wc_name, L"-"); 731*7836SJohn.Forte@Sun.COM } 732*7836SJohn.Forte@Sun.COM if (h_printed) { 733*7836SJohn.Forte@Sun.COM (void) printf("\t %ws\n", wc_name); 734*7836SJohn.Forte@Sun.COM } else { 735*7836SJohn.Forte@Sun.COM (void) printf("\tDD set(s): %ws\n", wc_name); 736*7836SJohn.Forte@Sun.COM h_printed = 1; 737*7836SJohn.Forte@Sun.COM } 738*7836SJohn.Forte@Sun.COM xmlFree(ddsname); 739*7836SJohn.Forte@Sun.COM } else { 740*7836SJohn.Forte@Sun.COM (void) printf("\tDD set(s): %s\n", "-"); 741*7836SJohn.Forte@Sun.COM } 742*7836SJohn.Forte@Sun.COM } 743*7836SJohn.Forte@Sun.COM m_flag = 0; 744*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 745*7836SJohn.Forte@Sun.COM } 746*7836SJohn.Forte@Sun.COM break; 747*7836SJohn.Forte@Sun.COM case ddset_to_dd: 748*7836SJohn.Forte@Sun.COM /* process the DiscoveryDoaminSet elements */ 749*7836SJohn.Forte@Sun.COM while (reader = lookup_next_matching_elem(reader, &m_flag, 750*7836SJohn.Forte@Sun.COM DDSETOBJECTMEMBER, ISNSRESPONSE)) { 751*7836SJohn.Forte@Sun.COM if (m_flag == END_READER_MATCH) { 752*7836SJohn.Forte@Sun.COM (void) xmlTextReaderNext(reader); 753*7836SJohn.Forte@Sun.COM break; 754*7836SJohn.Forte@Sun.COM } else if (m_flag == READER_MATCH) { 755*7836SJohn.Forte@Sun.COM if ((ddname = (xmlTextReaderGetAttribute(reader, 756*7836SJohn.Forte@Sun.COM (const xmlChar *)DDNAMEATTR))) != NULL) { 757*7836SJohn.Forte@Sun.COM if (mbstowcs(wc_name, (const char *)ddname, 758*7836SJohn.Forte@Sun.COM ISNS_MAX_NAME_LEN) == (size_t)-1) { 759*7836SJohn.Forte@Sun.COM (void) wcscpy(wc_name, L"-"); 760*7836SJohn.Forte@Sun.COM } 761*7836SJohn.Forte@Sun.COM (void) printf("\tDD Name: %ws\n", wc_name); 762*7836SJohn.Forte@Sun.COM xmlFree(ddname); 763*7836SJohn.Forte@Sun.COM } else { 764*7836SJohn.Forte@Sun.COM (void) printf("\tDD Name: %s\n", "-"); 765*7836SJohn.Forte@Sun.COM } 766*7836SJohn.Forte@Sun.COM } 767*7836SJohn.Forte@Sun.COM m_flag = 0; 768*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 769*7836SJohn.Forte@Sun.COM } 770*7836SJohn.Forte@Sun.COM break; 771*7836SJohn.Forte@Sun.COM default: 772*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 773*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 774*7836SJohn.Forte@Sun.COM return (UNKNOWN); 775*7836SJohn.Forte@Sun.COM } 776*7836SJohn.Forte@Sun.COM 777*7836SJohn.Forte@Sun.COM if (status == PARTIAL_SUCCESS) { 778*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 779*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_PARTIAL_SUCCESS)); 780*7836SJohn.Forte@Sun.COM } 781*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 782*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 783*7836SJohn.Forte@Sun.COM return (status); 784*7836SJohn.Forte@Sun.COM } 785*7836SJohn.Forte@Sun.COM 786*7836SJohn.Forte@Sun.COM /* 787*7836SJohn.Forte@Sun.COM * **************************************************************************** 788*7836SJohn.Forte@Sun.COM * 789*7836SJohn.Forte@Sun.COM * process_get_response : 790*7836SJohn.Forte@Sun.COM * display data from the get response doc based on flag. 791*7836SJohn.Forte@Sun.COM * 792*7836SJohn.Forte@Sun.COM * obj - object type 793*7836SJohn.Forte@Sun.COM * doc - docuemet to process 794*7836SJohn.Forte@Sun.COM * flag - options from the subcommand 795*7836SJohn.Forte@Sun.COM * 796*7836SJohn.Forte@Sun.COM * **************************************************************************** 797*7836SJohn.Forte@Sun.COM */ 798*7836SJohn.Forte@Sun.COM static int 799*7836SJohn.Forte@Sun.COM process_get_response(object_type obj, xmlChar *doc, uint32_t flag) 800*7836SJohn.Forte@Sun.COM { 801*7836SJohn.Forte@Sun.COM xmlTextReaderPtr reader; 802*7836SJohn.Forte@Sun.COM int m_flag = 0, ret = 0, status; 803*7836SJohn.Forte@Sun.COM xmlChar *name = NULL; 804*7836SJohn.Forte@Sun.COM wchar_t wc_name[ISNS_MAX_NAME_LEN]; 805*7836SJohn.Forte@Sun.COM int tag_printed = 0; 806*7836SJohn.Forte@Sun.COM 807*7836SJohn.Forte@Sun.COM if ((reader = (xmlTextReaderPtr)xmlReaderForMemory((const char *)doc, 808*7836SJohn.Forte@Sun.COM xmlStrlen(doc), NULL, NULL, 0)) == NULL) { 809*7836SJohn.Forte@Sun.COM return (ERROR_XML_READER_NULL); 810*7836SJohn.Forte@Sun.COM } 811*7836SJohn.Forte@Sun.COM 812*7836SJohn.Forte@Sun.COM /* if status is 0, continue on. Otherwise return an error. */ 813*7836SJohn.Forte@Sun.COM if (reader = lookup_next_matching_elem(reader, &m_flag, STATUSELEMENT, 814*7836SJohn.Forte@Sun.COM RESULTELEMENT)) { 815*7836SJohn.Forte@Sun.COM if (m_flag == READER_MATCH) { 816*7836SJohn.Forte@Sun.COM if (xmlTextReaderRead(reader) == 1) { 817*7836SJohn.Forte@Sun.COM status = 818*7836SJohn.Forte@Sun.COM atoi((const char *)xmlTextReaderConstValue(reader)); 819*7836SJohn.Forte@Sun.COM if ((status != 0) && (status != PARTIAL_SUCCESS)) { 820*7836SJohn.Forte@Sun.COM print_error_status(status, obj, reader); 821*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 822*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 823*7836SJohn.Forte@Sun.COM return (status); 824*7836SJohn.Forte@Sun.COM } 825*7836SJohn.Forte@Sun.COM } else { 826*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 827*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 828*7836SJohn.Forte@Sun.COM return (ERROR_XML_STATUS_ELEM_NOT_FOUND); 829*7836SJohn.Forte@Sun.COM } 830*7836SJohn.Forte@Sun.COM } else { 831*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 832*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 833*7836SJohn.Forte@Sun.COM return (ERROR_XML_STATUS_ELEM_NOT_FOUND); 834*7836SJohn.Forte@Sun.COM } 835*7836SJohn.Forte@Sun.COM } else { 836*7836SJohn.Forte@Sun.COM return (ERROR_XML_READER_NULL); 837*7836SJohn.Forte@Sun.COM } 838*7836SJohn.Forte@Sun.COM 839*7836SJohn.Forte@Sun.COM m_flag = 0; 840*7836SJohn.Forte@Sun.COM 841*7836SJohn.Forte@Sun.COM switch (obj) { 842*7836SJohn.Forte@Sun.COM case Node: 843*7836SJohn.Forte@Sun.COM /* process the node elements */ 844*7836SJohn.Forte@Sun.COM while (reader = lookup_next_matching_elem(reader, &m_flag, 845*7836SJohn.Forte@Sun.COM NODEOBJECT, ISNSRESPONSE)) { 846*7836SJohn.Forte@Sun.COM if (m_flag == END_READER_MATCH) { 847*7836SJohn.Forte@Sun.COM break; 848*7836SJohn.Forte@Sun.COM } 849*7836SJohn.Forte@Sun.COM 850*7836SJohn.Forte@Sun.COM /* check the type */ 851*7836SJohn.Forte@Sun.COM if ((xmlTextReaderMoveToAttribute(reader, 852*7836SJohn.Forte@Sun.COM (const xmlChar *)TYPEATTR)) == 1) { 853*7836SJohn.Forte@Sun.COM if (((flag & TARGET_ONLY) == TARGET_ONLY) && 854*7836SJohn.Forte@Sun.COM (XMLNCMPVAL(reader, TARGETTYPE) != 0)) { 855*7836SJohn.Forte@Sun.COM /* move to next node object. */ 856*7836SJohn.Forte@Sun.COM (void) xmlTextReaderMoveToElement(reader); 857*7836SJohn.Forte@Sun.COM (void) xmlTextReaderNext(reader); 858*7836SJohn.Forte@Sun.COM continue; 859*7836SJohn.Forte@Sun.COM } 860*7836SJohn.Forte@Sun.COM if (((flag & INITIATOR_ONLY) == INITIATOR_ONLY) && 861*7836SJohn.Forte@Sun.COM (XMLNCMPVAL(reader, INITIATORTYPE) != 0)) { 862*7836SJohn.Forte@Sun.COM /* move to next node object. */ 863*7836SJohn.Forte@Sun.COM (void) xmlTextReaderMoveToElement(reader); 864*7836SJohn.Forte@Sun.COM (void) xmlTextReaderNext(reader); 865*7836SJohn.Forte@Sun.COM continue; 866*7836SJohn.Forte@Sun.COM } 867*7836SJohn.Forte@Sun.COM } else { 868*7836SJohn.Forte@Sun.COM ret = ERROR_XML_TYPE_ATTR_NOT_FOUND; 869*7836SJohn.Forte@Sun.COM goto out; 870*7836SJohn.Forte@Sun.COM } 871*7836SJohn.Forte@Sun.COM 872*7836SJohn.Forte@Sun.COM if (((xmlTextReaderMoveToAttribute(reader, 873*7836SJohn.Forte@Sun.COM (const xmlChar *)NAMEATTR)) == 1) && 874*7836SJohn.Forte@Sun.COM (const char *)xmlTextReaderConstValue(reader)) { 875*7836SJohn.Forte@Sun.COM if (mbstowcs(wc_name, 876*7836SJohn.Forte@Sun.COM (const char *)xmlTextReaderConstValue(reader), 877*7836SJohn.Forte@Sun.COM ISNS_MAX_NAME_LEN) == (size_t)-1) { 878*7836SJohn.Forte@Sun.COM (void) wcscpy(wc_name, L"-"); 879*7836SJohn.Forte@Sun.COM } 880*7836SJohn.Forte@Sun.COM if ((flag & VERBOSE) == VERBOSE) { 881*7836SJohn.Forte@Sun.COM name = xmlTextReaderValue(reader); 882*7836SJohn.Forte@Sun.COM (void) printf("iSCSI Name: %ws\n", wc_name); 883*7836SJohn.Forte@Sun.COM } else { 884*7836SJohn.Forte@Sun.COM (void) printf("iSCSI Name: %ws\n", wc_name); 885*7836SJohn.Forte@Sun.COM } 886*7836SJohn.Forte@Sun.COM } else { 887*7836SJohn.Forte@Sun.COM XML_SFREE(name); 888*7836SJohn.Forte@Sun.COM ret = ERROR_XML_TYPE_ATTR_NOT_FOUND; 889*7836SJohn.Forte@Sun.COM goto out; 890*7836SJohn.Forte@Sun.COM } 891*7836SJohn.Forte@Sun.COM if ((xmlTextReaderMoveToAttribute(reader, 892*7836SJohn.Forte@Sun.COM (const xmlChar *)ALIASATTR)) == 1) { 893*7836SJohn.Forte@Sun.COM if (xmlStrcmp(xmlTextReaderConstValue(reader), 894*7836SJohn.Forte@Sun.COM (xmlChar *)"") == 0) { 895*7836SJohn.Forte@Sun.COM (void) printf("\tAlias: %s\n", "-"); 896*7836SJohn.Forte@Sun.COM } else { 897*7836SJohn.Forte@Sun.COM if (mbstowcs(wc_name, 898*7836SJohn.Forte@Sun.COM (const char *)xmlTextReaderConstValue(reader), 899*7836SJohn.Forte@Sun.COM ISNS_MAX_NAME_LEN) == (size_t)-1) { 900*7836SJohn.Forte@Sun.COM (void) wcscpy(wc_name, L"-"); 901*7836SJohn.Forte@Sun.COM } 902*7836SJohn.Forte@Sun.COM (void) printf("\tAlias: %ws\n", wc_name); 903*7836SJohn.Forte@Sun.COM } 904*7836SJohn.Forte@Sun.COM } 905*7836SJohn.Forte@Sun.COM 906*7836SJohn.Forte@Sun.COM /* type attribute exist based on the previous checking. */ 907*7836SJohn.Forte@Sun.COM (void) xmlTextReaderMoveToAttribute(reader, 908*7836SJohn.Forte@Sun.COM (const xmlChar *)TYPEATTR); 909*7836SJohn.Forte@Sun.COM (void) printf("\tType: %s\n", 910*7836SJohn.Forte@Sun.COM (const char *)xmlTextReaderConstValue(reader) ? 911*7836SJohn.Forte@Sun.COM (const char *)xmlTextReaderConstValue(reader) : "-"); 912*7836SJohn.Forte@Sun.COM 913*7836SJohn.Forte@Sun.COM if ((flag & VERBOSE) == VERBOSE) { 914*7836SJohn.Forte@Sun.COM /* print more details */ 915*7836SJohn.Forte@Sun.COM m_flag = 0; 916*7836SJohn.Forte@Sun.COM /* 917*7836SJohn.Forte@Sun.COM * No details for deregistered node. 918*7836SJohn.Forte@Sun.COM * skip to next isns object. 919*7836SJohn.Forte@Sun.COM */ 920*7836SJohn.Forte@Sun.COM if ((reader = lookup_next_matching_elem(reader, 921*7836SJohn.Forte@Sun.COM &m_flag, ENTITYID, ISNSOBJECT))) { 922*7836SJohn.Forte@Sun.COM if (m_flag == READER_MATCH) { 923*7836SJohn.Forte@Sun.COM /* move to entity id value. */ 924*7836SJohn.Forte@Sun.COM if ((xmlTextReaderRead(reader) == 1) && 925*7836SJohn.Forte@Sun.COM xmlTextReaderConstValue(reader)) { 926*7836SJohn.Forte@Sun.COM if (mbstowcs(wc_name, 927*7836SJohn.Forte@Sun.COM (const char *) 928*7836SJohn.Forte@Sun.COM xmlTextReaderConstValue(reader), 929*7836SJohn.Forte@Sun.COM ISNS_MAX_NAME_LEN) == (size_t)-1) { 930*7836SJohn.Forte@Sun.COM (void) wcscpy(wc_name, 931*7836SJohn.Forte@Sun.COM L"-"); 932*7836SJohn.Forte@Sun.COM } 933*7836SJohn.Forte@Sun.COM (void) printf("\tNetwork Entity: %ws\n", 934*7836SJohn.Forte@Sun.COM wc_name); 935*7836SJohn.Forte@Sun.COM } else { 936*7836SJohn.Forte@Sun.COM (void) printf("\tNework Entity: -\n"); 937*7836SJohn.Forte@Sun.COM } 938*7836SJohn.Forte@Sun.COM } else if (m_flag == END_READER_MATCH) { 939*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 940*7836SJohn.Forte@Sun.COM XML_SFREE(name); 941*7836SJohn.Forte@Sun.COM continue; 942*7836SJohn.Forte@Sun.COM } 943*7836SJohn.Forte@Sun.COM } 944*7836SJohn.Forte@Sun.COM 945*7836SJohn.Forte@Sun.COM /* print portal info */ 946*7836SJohn.Forte@Sun.COM m_flag = 0; 947*7836SJohn.Forte@Sun.COM while ((reader = lookup_next_matching_elem(reader, 948*7836SJohn.Forte@Sun.COM &m_flag, IPADDR, NODEOBJECT))) { 949*7836SJohn.Forte@Sun.COM if (m_flag == END_READER_MATCH) { 950*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 951*7836SJohn.Forte@Sun.COM break; 952*7836SJohn.Forte@Sun.COM } 953*7836SJohn.Forte@Sun.COM /* move to the value of IP addr. */ 954*7836SJohn.Forte@Sun.COM if ((xmlTextReaderRead(reader) == 1) && 955*7836SJohn.Forte@Sun.COM xmlTextReaderConstValue(reader)) { 956*7836SJohn.Forte@Sun.COM (void) printf("\tPortal: %s", 957*7836SJohn.Forte@Sun.COM xmlTextReaderConstValue(reader)); 958*7836SJohn.Forte@Sun.COM /* get port number */ 959*7836SJohn.Forte@Sun.COM m_flag = 0; 960*7836SJohn.Forte@Sun.COM if (reader = lookup_next_matching_elem(reader, 961*7836SJohn.Forte@Sun.COM &m_flag, PORTNUMBER, UDPTCPPORT)) { 962*7836SJohn.Forte@Sun.COM if ((xmlTextReaderRead(reader) == 1) && 963*7836SJohn.Forte@Sun.COM xmlTextReaderConstValue(reader)) { 964*7836SJohn.Forte@Sun.COM (void) printf(":%d\n", 965*7836SJohn.Forte@Sun.COM atoi((const char *) 966*7836SJohn.Forte@Sun.COM xmlTextReaderConstValue(reader))); 967*7836SJohn.Forte@Sun.COM } else { 968*7836SJohn.Forte@Sun.COM (void) printf(":-\n"); 969*7836SJohn.Forte@Sun.COM } 970*7836SJohn.Forte@Sun.COM } 971*7836SJohn.Forte@Sun.COM m_flag = 0; 972*7836SJohn.Forte@Sun.COM if (reader = lookup_next_matching_elem(reader, 973*7836SJohn.Forte@Sun.COM &m_flag, GROUPTAG, GROUPTAG)) { 974*7836SJohn.Forte@Sun.COM if ((xmlTextReaderRead(reader) == 1) && 975*7836SJohn.Forte@Sun.COM xmlTextReaderConstValue(reader)) { 976*7836SJohn.Forte@Sun.COM (void) printf("\t\tPortal Group: %s\n", 977*7836SJohn.Forte@Sun.COM xmlTextReaderConstValue(reader)); 978*7836SJohn.Forte@Sun.COM } else { 979*7836SJohn.Forte@Sun.COM (void) printf(":-\n"); 980*7836SJohn.Forte@Sun.COM } 981*7836SJohn.Forte@Sun.COM } 982*7836SJohn.Forte@Sun.COM } 983*7836SJohn.Forte@Sun.COM } /* Portal end */ 984*7836SJohn.Forte@Sun.COM if ((ret = handle_association_info(name, 985*7836SJohn.Forte@Sun.COM node_to_dd)) != 0) { 986*7836SJohn.Forte@Sun.COM XML_SFREE(name); 987*7836SJohn.Forte@Sun.COM goto out; 988*7836SJohn.Forte@Sun.COM } 989*7836SJohn.Forte@Sun.COM } /* verbose end */ 990*7836SJohn.Forte@Sun.COM XML_SFREE(name); 991*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 992*7836SJohn.Forte@Sun.COM m_flag = 0; 993*7836SJohn.Forte@Sun.COM } /* end for node while */ 994*7836SJohn.Forte@Sun.COM break; 995*7836SJohn.Forte@Sun.COM case DiscoveryDomain: 996*7836SJohn.Forte@Sun.COM /* process the DiscoveryDoamin elements */ 997*7836SJohn.Forte@Sun.COM while (reader = lookup_next_matching_elem(reader, &m_flag, 998*7836SJohn.Forte@Sun.COM DDOBJECT, ISNSRESPONSE)) { 999*7836SJohn.Forte@Sun.COM if (m_flag == END_READER_MATCH) { 1000*7836SJohn.Forte@Sun.COM (void) xmlTextReaderNext(reader); 1001*7836SJohn.Forte@Sun.COM break; 1002*7836SJohn.Forte@Sun.COM } 1003*7836SJohn.Forte@Sun.COM 1004*7836SJohn.Forte@Sun.COM if (((xmlTextReaderMoveToAttribute(reader, 1005*7836SJohn.Forte@Sun.COM (const xmlChar *)NAMEATTR)) == 1) && 1006*7836SJohn.Forte@Sun.COM (name = xmlTextReaderValue(reader))) { 1007*7836SJohn.Forte@Sun.COM if (mbstowcs(wc_name, (const char *)name, 1008*7836SJohn.Forte@Sun.COM ISNS_MAX_NAME_LEN) == (size_t)-1) { 1009*7836SJohn.Forte@Sun.COM (void) wcscpy(wc_name, L"-"); 1010*7836SJohn.Forte@Sun.COM } 1011*7836SJohn.Forte@Sun.COM (void) printf("DD name: %ws\n", wc_name); 1012*7836SJohn.Forte@Sun.COM } else { 1013*7836SJohn.Forte@Sun.COM ret = ERROR_XML_NAME_ATTR_NOT_FOUND; 1014*7836SJohn.Forte@Sun.COM XML_SFREE(name); 1015*7836SJohn.Forte@Sun.COM goto out; 1016*7836SJohn.Forte@Sun.COM } 1017*7836SJohn.Forte@Sun.COM if ((ret = handle_association_info(name, dd_to_ddset)) != 1018*7836SJohn.Forte@Sun.COM 0) { 1019*7836SJohn.Forte@Sun.COM XML_SFREE(name); 1020*7836SJohn.Forte@Sun.COM goto out; 1021*7836SJohn.Forte@Sun.COM } 1022*7836SJohn.Forte@Sun.COM /* handle verbose */ 1023*7836SJohn.Forte@Sun.COM if ((flag & VERBOSE) == VERBOSE) { 1024*7836SJohn.Forte@Sun.COM if ((ret = handle_association_info(name, 1025*7836SJohn.Forte@Sun.COM dd_to_node)) != 0) { 1026*7836SJohn.Forte@Sun.COM XML_SFREE(name); 1027*7836SJohn.Forte@Sun.COM goto out; 1028*7836SJohn.Forte@Sun.COM } 1029*7836SJohn.Forte@Sun.COM } 1030*7836SJohn.Forte@Sun.COM XML_SFREE(name); 1031*7836SJohn.Forte@Sun.COM m_flag = 0; 1032*7836SJohn.Forte@Sun.COM } 1033*7836SJohn.Forte@Sun.COM break; 1034*7836SJohn.Forte@Sun.COM case DiscoveryDomainSet: 1035*7836SJohn.Forte@Sun.COM /* process the DiscoveryDoaminSet elements */ 1036*7836SJohn.Forte@Sun.COM while (reader = lookup_next_matching_elem(reader, &m_flag, 1037*7836SJohn.Forte@Sun.COM DDSETOBJECT, ISNSRESPONSE)) { 1038*7836SJohn.Forte@Sun.COM if (m_flag == END_READER_MATCH) { 1039*7836SJohn.Forte@Sun.COM (void) xmlTextReaderNext(reader); 1040*7836SJohn.Forte@Sun.COM break; 1041*7836SJohn.Forte@Sun.COM } 1042*7836SJohn.Forte@Sun.COM 1043*7836SJohn.Forte@Sun.COM if (((xmlTextReaderMoveToAttribute(reader, 1044*7836SJohn.Forte@Sun.COM (const xmlChar *)NAMEATTR)) == 1) && 1045*7836SJohn.Forte@Sun.COM (const char *)xmlTextReaderConstValue(reader)) { 1046*7836SJohn.Forte@Sun.COM if (mbstowcs(wc_name, 1047*7836SJohn.Forte@Sun.COM (const char *)xmlTextReaderConstValue(reader), 1048*7836SJohn.Forte@Sun.COM ISNS_MAX_NAME_LEN) == (size_t)-1) { 1049*7836SJohn.Forte@Sun.COM (void) wcscpy(wc_name, L"-"); 1050*7836SJohn.Forte@Sun.COM } 1051*7836SJohn.Forte@Sun.COM if ((flag & VERBOSE) == VERBOSE) { 1052*7836SJohn.Forte@Sun.COM name = xmlTextReaderValue(reader); 1053*7836SJohn.Forte@Sun.COM (void) printf("DD Set name: %ws\n", wc_name); 1054*7836SJohn.Forte@Sun.COM } else { 1055*7836SJohn.Forte@Sun.COM (void) printf("DD Set name: %ws\n", wc_name); 1056*7836SJohn.Forte@Sun.COM } 1057*7836SJohn.Forte@Sun.COM } else { 1058*7836SJohn.Forte@Sun.COM ret = ERROR_XML_NAME_ATTR_NOT_FOUND; 1059*7836SJohn.Forte@Sun.COM XML_SFREE(name); 1060*7836SJohn.Forte@Sun.COM goto out; 1061*7836SJohn.Forte@Sun.COM } 1062*7836SJohn.Forte@Sun.COM m_flag = 0; 1063*7836SJohn.Forte@Sun.COM if ((reader = lookup_next_matching_elem(reader, 1064*7836SJohn.Forte@Sun.COM &m_flag, ENABLEDELEM, ISNSOBJECT))) { 1065*7836SJohn.Forte@Sun.COM if (m_flag == READER_MATCH) { 1066*7836SJohn.Forte@Sun.COM /* move to entity id value. */ 1067*7836SJohn.Forte@Sun.COM if ((xmlTextReaderRead(reader) == 1) && 1068*7836SJohn.Forte@Sun.COM (XMLNCMPVAL(reader, XMLTRUE) == 0)) { 1069*7836SJohn.Forte@Sun.COM (void) printf("\tState: Enabled\n"); 1070*7836SJohn.Forte@Sun.COM } else { 1071*7836SJohn.Forte@Sun.COM (void) printf("\tState: Disabled\n"); 1072*7836SJohn.Forte@Sun.COM } 1073*7836SJohn.Forte@Sun.COM } else if (m_flag == END_READER_MATCH) { 1074*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 1075*7836SJohn.Forte@Sun.COM } 1076*7836SJohn.Forte@Sun.COM } 1077*7836SJohn.Forte@Sun.COM 1078*7836SJohn.Forte@Sun.COM /* handle verbose */ 1079*7836SJohn.Forte@Sun.COM if ((flag & VERBOSE) == VERBOSE) { 1080*7836SJohn.Forte@Sun.COM if ((ret = handle_association_info(name, 1081*7836SJohn.Forte@Sun.COM ddset_to_dd)) != 0) { 1082*7836SJohn.Forte@Sun.COM XML_SFREE(name); 1083*7836SJohn.Forte@Sun.COM goto out; 1084*7836SJohn.Forte@Sun.COM } 1085*7836SJohn.Forte@Sun.COM } 1086*7836SJohn.Forte@Sun.COM XML_SFREE(name); 1087*7836SJohn.Forte@Sun.COM m_flag = 0; 1088*7836SJohn.Forte@Sun.COM } 1089*7836SJohn.Forte@Sun.COM break; 1090*7836SJohn.Forte@Sun.COM case ServerConfig: 1091*7836SJohn.Forte@Sun.COM /* process the DiscoveryDoaminSet elements */ 1092*7836SJohn.Forte@Sun.COM m_flag = 0; 1093*7836SJohn.Forte@Sun.COM reader = lookup_next_matching_elem(reader, &m_flag, 1094*7836SJohn.Forte@Sun.COM ISNSSERVER, ISNSRESPONSE); 1095*7836SJohn.Forte@Sun.COM if (m_flag == END_READER_MATCH) { 1096*7836SJohn.Forte@Sun.COM ret = ERROR_XML_ISNSSERVER_ELEM_NOT_FOUND; 1097*7836SJohn.Forte@Sun.COM goto out; 1098*7836SJohn.Forte@Sun.COM } 1099*7836SJohn.Forte@Sun.COM m_flag = 0; 1100*7836SJohn.Forte@Sun.COM if ((reader = lookup_next_matching_elem(reader, 1101*7836SJohn.Forte@Sun.COM &m_flag, DATASTORELOCATION, ISNSRESPONSE))) { 1102*7836SJohn.Forte@Sun.COM if (m_flag == READER_MATCH) { 1103*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 1104*7836SJohn.Forte@Sun.COM (void) printf("\tData Store Location: %s\n", 1105*7836SJohn.Forte@Sun.COM (const char *)xmlTextReaderConstValue(reader) ? 1106*7836SJohn.Forte@Sun.COM (const char *)xmlTextReaderConstValue(reader) : "-"); 1107*7836SJohn.Forte@Sun.COM } 1108*7836SJohn.Forte@Sun.COM } 1109*7836SJohn.Forte@Sun.COM m_flag = 0; 1110*7836SJohn.Forte@Sun.COM if ((reader = lookup_next_matching_elem(reader, 1111*7836SJohn.Forte@Sun.COM &m_flag, ESIRETRYTHRESHOLD, ISNSRESPONSE))) { 1112*7836SJohn.Forte@Sun.COM if (m_flag == READER_MATCH) { 1113*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 1114*7836SJohn.Forte@Sun.COM (void) printf("\tEntity Status Inquiry Non-Response "); 1115*7836SJohn.Forte@Sun.COM (void) printf("Threshold: %d\n", 1116*7836SJohn.Forte@Sun.COM xmlTextReaderConstValue(reader) ? 1117*7836SJohn.Forte@Sun.COM atoi((const char *)xmlTextReaderConstValue(reader)) 1118*7836SJohn.Forte@Sun.COM : 0); 1119*7836SJohn.Forte@Sun.COM } 1120*7836SJohn.Forte@Sun.COM } 1121*7836SJohn.Forte@Sun.COM m_flag = 0; 1122*7836SJohn.Forte@Sun.COM if ((reader = lookup_next_matching_elem(reader, 1123*7836SJohn.Forte@Sun.COM &m_flag, MANAGEMENTSCNENABLED, ISNSRESPONSE))) { 1124*7836SJohn.Forte@Sun.COM if (m_flag == READER_MATCH) { 1125*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 1126*7836SJohn.Forte@Sun.COM (void) printf("\tManagement SCN Enabled: %s\n", 1127*7836SJohn.Forte@Sun.COM (XMLNCMPVAL(reader, XMLTRUE) == 0) ? 1128*7836SJohn.Forte@Sun.COM "yes" : "no"); 1129*7836SJohn.Forte@Sun.COM } 1130*7836SJohn.Forte@Sun.COM } 1131*7836SJohn.Forte@Sun.COM m_flag = 0; 1132*7836SJohn.Forte@Sun.COM while ((reader = lookup_next_matching_elem(reader, 1133*7836SJohn.Forte@Sun.COM &m_flag, CONTROLNODENAME, ISNSSERVER))) { 1134*7836SJohn.Forte@Sun.COM if (m_flag == READER_MATCH) { 1135*7836SJohn.Forte@Sun.COM if (!xmlTextReaderIsEmptyElement(reader)) { 1136*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 1137*7836SJohn.Forte@Sun.COM if (mbstowcs(wc_name, 1138*7836SJohn.Forte@Sun.COM (const char *)xmlTextReaderConstValue(reader), 1139*7836SJohn.Forte@Sun.COM ISNS_MAX_NAME_LEN) == (size_t)-1) { 1140*7836SJohn.Forte@Sun.COM (void) wcscpy(wc_name, L"-"); 1141*7836SJohn.Forte@Sun.COM } 1142*7836SJohn.Forte@Sun.COM if (tag_printed) { 1143*7836SJohn.Forte@Sun.COM if (xmlTextReaderConstValue(reader)) { 1144*7836SJohn.Forte@Sun.COM if (mbstowcs(wc_name, 1145*7836SJohn.Forte@Sun.COM (const char *) 1146*7836SJohn.Forte@Sun.COM xmlTextReaderConstValue(reader), 1147*7836SJohn.Forte@Sun.COM ISNS_MAX_NAME_LEN) == (size_t)-1) { 1148*7836SJohn.Forte@Sun.COM (void) wcscpy(wc_name, L"-"); 1149*7836SJohn.Forte@Sun.COM } 1150*7836SJohn.Forte@Sun.COM (void) printf( 1151*7836SJohn.Forte@Sun.COM "\t %ws\n", 1152*7836SJohn.Forte@Sun.COM wc_name); 1153*7836SJohn.Forte@Sun.COM } else { 1154*7836SJohn.Forte@Sun.COM (void) printf( 1155*7836SJohn.Forte@Sun.COM "\t %s\n", 1156*7836SJohn.Forte@Sun.COM "-"); 1157*7836SJohn.Forte@Sun.COM } 1158*7836SJohn.Forte@Sun.COM } else { 1159*7836SJohn.Forte@Sun.COM if (xmlTextReaderConstValue(reader)) { 1160*7836SJohn.Forte@Sun.COM if (mbstowcs(wc_name, 1161*7836SJohn.Forte@Sun.COM (const char *) 1162*7836SJohn.Forte@Sun.COM xmlTextReaderConstValue(reader), 1163*7836SJohn.Forte@Sun.COM ISNS_MAX_NAME_LEN) == (size_t)-1) { 1164*7836SJohn.Forte@Sun.COM (void) wcscpy(wc_name, L"-"); 1165*7836SJohn.Forte@Sun.COM } 1166*7836SJohn.Forte@Sun.COM (void) printf( 1167*7836SJohn.Forte@Sun.COM "\tAuthorized Control Node Names: %ws\n", 1168*7836SJohn.Forte@Sun.COM wc_name); 1169*7836SJohn.Forte@Sun.COM } else { 1170*7836SJohn.Forte@Sun.COM (void) printf( 1171*7836SJohn.Forte@Sun.COM "\tAuthorized Control Node Names: %s\n", 1172*7836SJohn.Forte@Sun.COM "-"); 1173*7836SJohn.Forte@Sun.COM } 1174*7836SJohn.Forte@Sun.COM tag_printed = 1; 1175*7836SJohn.Forte@Sun.COM } 1176*7836SJohn.Forte@Sun.COM } else { 1177*7836SJohn.Forte@Sun.COM (void) printf( 1178*7836SJohn.Forte@Sun.COM "\tAuthorized Control Node Names: %s\n", "-"); 1179*7836SJohn.Forte@Sun.COM break; 1180*7836SJohn.Forte@Sun.COM } 1181*7836SJohn.Forte@Sun.COM } else { 1182*7836SJohn.Forte@Sun.COM break; 1183*7836SJohn.Forte@Sun.COM } 1184*7836SJohn.Forte@Sun.COM } 1185*7836SJohn.Forte@Sun.COM break; 1186*7836SJohn.Forte@Sun.COM default: 1187*7836SJohn.Forte@Sun.COM ret = UNKNOWN; 1188*7836SJohn.Forte@Sun.COM } 1189*7836SJohn.Forte@Sun.COM 1190*7836SJohn.Forte@Sun.COM out: 1191*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 1192*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 1193*7836SJohn.Forte@Sun.COM if (status == PARTIAL_SUCCESS) { 1194*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 1195*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_PARTIAL_SUCCESS)); 1196*7836SJohn.Forte@Sun.COM if (ret == 0) ret = status; 1197*7836SJohn.Forte@Sun.COM } 1198*7836SJohn.Forte@Sun.COM return (ret); 1199*7836SJohn.Forte@Sun.COM 1200*7836SJohn.Forte@Sun.COM } 1201*7836SJohn.Forte@Sun.COM 1202*7836SJohn.Forte@Sun.COM /* 1203*7836SJohn.Forte@Sun.COM * **************************************************************************** 1204*7836SJohn.Forte@Sun.COM * 1205*7836SJohn.Forte@Sun.COM * cvt_enumerate_rsp_to_get_req: 1206*7836SJohn.Forte@Sun.COM * pull out object info from enumerate response and calls 1207*7836SJohn.Forte@Sun.COM * build_get_xml_doc based on object type. 1208*7836SJohn.Forte@Sun.COM * 1209*7836SJohn.Forte@Sun.COM * doc - enumerate resonse from the server. 1210*7836SJohn.Forte@Sun.COM * req_do - pointer to get request doc. 1211*7836SJohn.Forte@Sun.COM * object_type - isns object type. 1212*7836SJohn.Forte@Sun.COM * flag - user options 1213*7836SJohn.Forte@Sun.COM * 1214*7836SJohn.Forte@Sun.COM * **************************************************************************** 1215*7836SJohn.Forte@Sun.COM */ 1216*7836SJohn.Forte@Sun.COM static int 1217*7836SJohn.Forte@Sun.COM cvt_enumerate_rsp_to_get_req(xmlChar *doc, xmlChar **req_doc, 1218*7836SJohn.Forte@Sun.COM object_type obj, uint32_t flag) 1219*7836SJohn.Forte@Sun.COM { 1220*7836SJohn.Forte@Sun.COM xmlTextReaderPtr reader; 1221*7836SJohn.Forte@Sun.COM xmlChar **argxmlv; 1222*7836SJohn.Forte@Sun.COM int ret = 0, status; 1223*7836SJohn.Forte@Sun.COM int i, argxmlc = 0, m_flag = 0; 1224*7836SJohn.Forte@Sun.COM 1225*7836SJohn.Forte@Sun.COM if ((reader = (xmlTextReaderPtr)xmlReaderForMemory((const char *)doc, 1226*7836SJohn.Forte@Sun.COM xmlStrlen(doc), NULL, NULL, 0)) == NULL) { 1227*7836SJohn.Forte@Sun.COM return (ERROR_XML_READER_NULL); 1228*7836SJohn.Forte@Sun.COM } 1229*7836SJohn.Forte@Sun.COM 1230*7836SJohn.Forte@Sun.COM /* if status is 0, continue on. Otherwise return an error. */ 1231*7836SJohn.Forte@Sun.COM if (reader = lookup_next_matching_elem(reader, &m_flag, STATUSELEMENT, 1232*7836SJohn.Forte@Sun.COM RESULTELEMENT)) { 1233*7836SJohn.Forte@Sun.COM if (m_flag == READER_MATCH) { 1234*7836SJohn.Forte@Sun.COM if (xmlTextReaderRead(reader) == 1) { 1235*7836SJohn.Forte@Sun.COM status = 1236*7836SJohn.Forte@Sun.COM atoi((const char *)xmlTextReaderConstValue(reader)); 1237*7836SJohn.Forte@Sun.COM if (status != 0) { 1238*7836SJohn.Forte@Sun.COM print_error_status(status, obj, reader); 1239*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 1240*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 1241*7836SJohn.Forte@Sun.COM return (status); 1242*7836SJohn.Forte@Sun.COM } 1243*7836SJohn.Forte@Sun.COM } else { 1244*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 1245*7836SJohn.Forte@Sun.COM xmlFreeTextReader(reader); 1246*7836SJohn.Forte@Sun.COM return (ERROR_XML_STATUS_ELEM_NOT_FOUND); 1247*7836SJohn.Forte@Sun.COM } 1248*7836SJohn.Forte@Sun.COM } else { 1249*7836SJohn.Forte@Sun.COM return (ERROR_XML_STATUS_ELEM_NOT_FOUND); 1250*7836SJohn.Forte@Sun.COM } 1251*7836SJohn.Forte@Sun.COM } else { 1252*7836SJohn.Forte@Sun.COM return (ERROR_XML_READER_NULL); 1253*7836SJohn.Forte@Sun.COM } 1254*7836SJohn.Forte@Sun.COM 1255*7836SJohn.Forte@Sun.COM m_flag = 0; 1256*7836SJohn.Forte@Sun.COM 1257*7836SJohn.Forte@Sun.COM argxmlv = (xmlChar **)malloc(sizeof (xmlChar *)); 1258*7836SJohn.Forte@Sun.COM 1259*7836SJohn.Forte@Sun.COM /* XXX - validate isnsResponse element from response doc. */ 1260*7836SJohn.Forte@Sun.COM switch (obj) { 1261*7836SJohn.Forte@Sun.COM case Node: 1262*7836SJohn.Forte@Sun.COM /* process the node elements */ 1263*7836SJohn.Forte@Sun.COM while (reader = lookup_next_matching_elem(reader, &m_flag, 1264*7836SJohn.Forte@Sun.COM NODEOBJECT, ISNSRESPONSE)) { 1265*7836SJohn.Forte@Sun.COM if (m_flag == END_READER_MATCH) { 1266*7836SJohn.Forte@Sun.COM (void) xmlTextReaderNext(reader); 1267*7836SJohn.Forte@Sun.COM break; 1268*7836SJohn.Forte@Sun.COM } 1269*7836SJohn.Forte@Sun.COM 1270*7836SJohn.Forte@Sun.COM /* check the type */ 1271*7836SJohn.Forte@Sun.COM if ((xmlTextReaderMoveToAttribute(reader, 1272*7836SJohn.Forte@Sun.COM (const xmlChar *)TYPEATTR)) == 1) { 1273*7836SJohn.Forte@Sun.COM if (((flag & TARGET_ONLY) == TARGET_ONLY) && 1274*7836SJohn.Forte@Sun.COM (XMLNCMPVAL(reader, TARGETTYPE) != 0)) { 1275*7836SJohn.Forte@Sun.COM /* move to next node object. */ 1276*7836SJohn.Forte@Sun.COM (void) xmlTextReaderMoveToElement(reader); 1277*7836SJohn.Forte@Sun.COM (void) xmlTextReaderNext(reader); 1278*7836SJohn.Forte@Sun.COM continue; 1279*7836SJohn.Forte@Sun.COM } 1280*7836SJohn.Forte@Sun.COM if (((flag & INITIATOR_ONLY) == INITIATOR_ONLY) && 1281*7836SJohn.Forte@Sun.COM (XMLNCMPVAL(reader, INITIATORTYPE) != 0)) { 1282*7836SJohn.Forte@Sun.COM /* move to next node object. */ 1283*7836SJohn.Forte@Sun.COM (void) xmlTextReaderMoveToElement(reader); 1284*7836SJohn.Forte@Sun.COM (void) xmlTextReaderNext(reader); 1285*7836SJohn.Forte@Sun.COM continue; 1286*7836SJohn.Forte@Sun.COM } 1287*7836SJohn.Forte@Sun.COM } else { 1288*7836SJohn.Forte@Sun.COM ret = ERROR_XML_TYPE_ATTR_NOT_FOUND; 1289*7836SJohn.Forte@Sun.COM goto out; 1290*7836SJohn.Forte@Sun.COM } 1291*7836SJohn.Forte@Sun.COM 1292*7836SJohn.Forte@Sun.COM if (((xmlTextReaderMoveToAttribute(reader, 1293*7836SJohn.Forte@Sun.COM (const xmlChar *)NAMEATTR)) == 1) && 1294*7836SJohn.Forte@Sun.COM xmlTextReaderConstValue(reader)) { 1295*7836SJohn.Forte@Sun.COM argxmlv = NEW_XMLARGV(argxmlv, argxmlc); 1296*7836SJohn.Forte@Sun.COM if (argxmlv == (xmlChar **)NULL) { 1297*7836SJohn.Forte@Sun.COM ret = ERROR_MALLOC_FAILED; 1298*7836SJohn.Forte@Sun.COM goto out; 1299*7836SJohn.Forte@Sun.COM } 1300*7836SJohn.Forte@Sun.COM argxmlv[argxmlc++] = 1301*7836SJohn.Forte@Sun.COM xmlStrdup(xmlTextReaderConstValue(reader)); 1302*7836SJohn.Forte@Sun.COM argxmlv[argxmlc] = NULL; 1303*7836SJohn.Forte@Sun.COM } else { 1304*7836SJohn.Forte@Sun.COM ret = ERROR_XML_NAME_ATTR_NOT_FOUND; 1305*7836SJohn.Forte@Sun.COM goto out; 1306*7836SJohn.Forte@Sun.COM } 1307*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 1308*7836SJohn.Forte@Sun.COM m_flag = 0; 1309*7836SJohn.Forte@Sun.COM } /* end for node while */ 1310*7836SJohn.Forte@Sun.COM break; 1311*7836SJohn.Forte@Sun.COM case DiscoveryDomain: 1312*7836SJohn.Forte@Sun.COM /* process the DiscoveryDoamin elements */ 1313*7836SJohn.Forte@Sun.COM while (reader = lookup_next_matching_elem(reader, &m_flag, 1314*7836SJohn.Forte@Sun.COM DDOBJECT, ISNSRESPONSE)) { 1315*7836SJohn.Forte@Sun.COM if (m_flag == END_READER_MATCH) { 1316*7836SJohn.Forte@Sun.COM (void) xmlTextReaderNext(reader); 1317*7836SJohn.Forte@Sun.COM break; 1318*7836SJohn.Forte@Sun.COM } 1319*7836SJohn.Forte@Sun.COM 1320*7836SJohn.Forte@Sun.COM if (((xmlTextReaderMoveToAttribute(reader, 1321*7836SJohn.Forte@Sun.COM (const xmlChar *)NAMEATTR)) == 1) && 1322*7836SJohn.Forte@Sun.COM xmlTextReaderConstValue(reader)) { 1323*7836SJohn.Forte@Sun.COM argxmlv = NEW_XMLARGV(argxmlv, argxmlc); 1324*7836SJohn.Forte@Sun.COM if (argxmlv == (xmlChar **)NULL) { 1325*7836SJohn.Forte@Sun.COM ret = ERROR_MALLOC_FAILED; 1326*7836SJohn.Forte@Sun.COM goto out; 1327*7836SJohn.Forte@Sun.COM } 1328*7836SJohn.Forte@Sun.COM argxmlv[argxmlc++] = 1329*7836SJohn.Forte@Sun.COM xmlStrdup(xmlTextReaderConstValue(reader)); 1330*7836SJohn.Forte@Sun.COM argxmlv[argxmlc] = NULL; 1331*7836SJohn.Forte@Sun.COM } else { 1332*7836SJohn.Forte@Sun.COM ret = ERROR_XML_NAME_ATTR_NOT_FOUND; 1333*7836SJohn.Forte@Sun.COM goto out; 1334*7836SJohn.Forte@Sun.COM } 1335*7836SJohn.Forte@Sun.COM m_flag = 0; 1336*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 1337*7836SJohn.Forte@Sun.COM } 1338*7836SJohn.Forte@Sun.COM break; 1339*7836SJohn.Forte@Sun.COM case DiscoveryDomainSet: 1340*7836SJohn.Forte@Sun.COM /* process the DiscoveryDoaminSet elements */ 1341*7836SJohn.Forte@Sun.COM while (reader = lookup_next_matching_elem(reader, &m_flag, 1342*7836SJohn.Forte@Sun.COM DDSETOBJECT, ISNSRESPONSE)) { 1343*7836SJohn.Forte@Sun.COM if (m_flag == END_READER_MATCH) { 1344*7836SJohn.Forte@Sun.COM (void) xmlTextReaderNext(reader); 1345*7836SJohn.Forte@Sun.COM break; 1346*7836SJohn.Forte@Sun.COM } 1347*7836SJohn.Forte@Sun.COM 1348*7836SJohn.Forte@Sun.COM if (((xmlTextReaderMoveToAttribute(reader, 1349*7836SJohn.Forte@Sun.COM (const xmlChar *)NAMEATTR)) == 1) && 1350*7836SJohn.Forte@Sun.COM (const char *)xmlTextReaderConstValue(reader)) { 1351*7836SJohn.Forte@Sun.COM argxmlv = NEW_XMLARGV(argxmlv, argxmlc); 1352*7836SJohn.Forte@Sun.COM if (argxmlv == (xmlChar **)NULL) { 1353*7836SJohn.Forte@Sun.COM ret = ERROR_MALLOC_FAILED; 1354*7836SJohn.Forte@Sun.COM goto out; 1355*7836SJohn.Forte@Sun.COM } 1356*7836SJohn.Forte@Sun.COM argxmlv[argxmlc++] = 1357*7836SJohn.Forte@Sun.COM xmlStrdup(xmlTextReaderConstValue(reader)); 1358*7836SJohn.Forte@Sun.COM argxmlv[argxmlc] = NULL; 1359*7836SJohn.Forte@Sun.COM } else { 1360*7836SJohn.Forte@Sun.COM ret = ERROR_XML_NAME_ATTR_NOT_FOUND; 1361*7836SJohn.Forte@Sun.COM goto out; 1362*7836SJohn.Forte@Sun.COM } 1363*7836SJohn.Forte@Sun.COM m_flag = 0; 1364*7836SJohn.Forte@Sun.COM (void) xmlTextReaderRead(reader); 1365*7836SJohn.Forte@Sun.COM } 1366*7836SJohn.Forte@Sun.COM break; 1367*7836SJohn.Forte@Sun.COM default: 1368*7836SJohn.Forte@Sun.COM ret = UNKNOWN; 1369*7836SJohn.Forte@Sun.COM goto out; 1370*7836SJohn.Forte@Sun.COM } 1371*7836SJohn.Forte@Sun.COM 1372*7836SJohn.Forte@Sun.COM /* if no object found, stop here. The status can be still 0. */ 1373*7836SJohn.Forte@Sun.COM if (argxmlc != 0) { 1374*7836SJohn.Forte@Sun.COM if ((ret = build_get_xml_doc(argxmlc, (char **)argxmlv, obj, 1375*7836SJohn.Forte@Sun.COM req_doc)) != 0) { 1376*7836SJohn.Forte@Sun.COM return (ret); 1377*7836SJohn.Forte@Sun.COM } 1378*7836SJohn.Forte@Sun.COM } else { 1379*7836SJohn.Forte@Sun.COM if (ret == 0) { 1380*7836SJohn.Forte@Sun.COM /* indicate there is no error but not object is found. */ 1381*7836SJohn.Forte@Sun.COM ret = SUCCESS_WITH_NO_OBJECT; 1382*7836SJohn.Forte@Sun.COM } 1383*7836SJohn.Forte@Sun.COM } 1384*7836SJohn.Forte@Sun.COM 1385*7836SJohn.Forte@Sun.COM out: 1386*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 1387*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 1388*7836SJohn.Forte@Sun.COM if (argxmlc != 0) { 1389*7836SJohn.Forte@Sun.COM for (i = 0; i < argxmlc; i++) { 1390*7836SJohn.Forte@Sun.COM xmlFree(argxmlv[i]); 1391*7836SJohn.Forte@Sun.COM } 1392*7836SJohn.Forte@Sun.COM (void) free(argxmlv); 1393*7836SJohn.Forte@Sun.COM } 1394*7836SJohn.Forte@Sun.COM return (ret); 1395*7836SJohn.Forte@Sun.COM 1396*7836SJohn.Forte@Sun.COM } 1397*7836SJohn.Forte@Sun.COM 1398*7836SJohn.Forte@Sun.COM /* 1399*7836SJohn.Forte@Sun.COM * **************************************************************************** 1400*7836SJohn.Forte@Sun.COM * 1401*7836SJohn.Forte@Sun.COM * build_delete_xml_doc - 1402*7836SJohn.Forte@Sun.COM * build remove request doc based the name. 1403*7836SJohn.Forte@Sun.COM * the resulted doc is passed in the doc ptr. 1404*7836SJohn.Forte@Sun.COM * 1405*7836SJohn.Forte@Sun.COM * name - object type 1406*7836SJohn.Forte@Sun.COM * assoc - association type 1407*7836SJohn.Forte@Sun.COM * doc - ptr to the resulted doc 1408*7836SJohn.Forte@Sun.COM * 1409*7836SJohn.Forte@Sun.COM * **************************************************************************** 1410*7836SJohn.Forte@Sun.COM */ 1411*7836SJohn.Forte@Sun.COM static int 1412*7836SJohn.Forte@Sun.COM build_delete_xml_doc(int operandLen, char **operand, object_type obj, 1413*7836SJohn.Forte@Sun.COM char *container, xmlChar **doc) 1414*7836SJohn.Forte@Sun.COM { 1415*7836SJohn.Forte@Sun.COM xmlTextWriterPtr writer; 1416*7836SJohn.Forte@Sun.COM xmlBufferPtr xbuf; 1417*7836SJohn.Forte@Sun.COM int i, len; 1418*7836SJohn.Forte@Sun.COM 1419*7836SJohn.Forte@Sun.COM if ((xbuf = xmlBufferCreate()) == NULL) { 1420*7836SJohn.Forte@Sun.COM return (ERROR_XML_CREATE_BUFFER_FAILED); 1421*7836SJohn.Forte@Sun.COM } 1422*7836SJohn.Forte@Sun.COM 1423*7836SJohn.Forte@Sun.COM if ((writer = xmlNewTextWriterMemory(xbuf, 0)) == NULL) { 1424*7836SJohn.Forte@Sun.COM return (ERROR_XML_CREATE_WRITER_FAILED); 1425*7836SJohn.Forte@Sun.COM } 1426*7836SJohn.Forte@Sun.COM 1427*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartDocument(writer, "1.0", NULL, NULL) < 0) { 1428*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_DOC_FAILED); 1429*7836SJohn.Forte@Sun.COM } 1430*7836SJohn.Forte@Sun.COM 1431*7836SJohn.Forte@Sun.COM /* Start element "isnsRequest". */ 1432*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, (xmlChar *)ISNSREQUEST) < 0) { 1433*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1434*7836SJohn.Forte@Sun.COM } 1435*7836SJohn.Forte@Sun.COM 1436*7836SJohn.Forte@Sun.COM if ((xmlTextWriterWriteAttribute(writer, 1437*7836SJohn.Forte@Sun.COM (xmlChar *)XMLNSATTR, (xmlChar *)XMLNSATTRVAL)) < 0) { 1438*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1439*7836SJohn.Forte@Sun.COM } 1440*7836SJohn.Forte@Sun.COM 1441*7836SJohn.Forte@Sun.COM /* request delete operation to get the entire list of obejct. */ 1442*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, (xmlChar *)DELETE) < 0) { 1443*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1444*7836SJohn.Forte@Sun.COM } 1445*7836SJohn.Forte@Sun.COM 1446*7836SJohn.Forte@Sun.COM switch (obj) { 1447*7836SJohn.Forte@Sun.COM case DiscoveryDomain: 1448*7836SJohn.Forte@Sun.COM for (i = 0; i < operandLen; i++) { 1449*7836SJohn.Forte@Sun.COM /* start Discovery Domain element. */ 1450*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 1451*7836SJohn.Forte@Sun.COM (xmlChar *)DDOBJECT) < 0) { 1452*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1453*7836SJohn.Forte@Sun.COM } 1454*7836SJohn.Forte@Sun.COM 1455*7836SJohn.Forte@Sun.COM /* Start attr "name". */ 1456*7836SJohn.Forte@Sun.COM if ((xmlTextWriterWriteAttribute(writer, 1457*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, (xmlChar *)operand[i])) < 0) { 1458*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1459*7836SJohn.Forte@Sun.COM } 1460*7836SJohn.Forte@Sun.COM 1461*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomain". */ 1462*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1463*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1464*7836SJohn.Forte@Sun.COM } 1465*7836SJohn.Forte@Sun.COM } 1466*7836SJohn.Forte@Sun.COM break; 1467*7836SJohn.Forte@Sun.COM case DiscoveryDomainSet: 1468*7836SJohn.Forte@Sun.COM for (i = 0; i < operandLen; i++) { 1469*7836SJohn.Forte@Sun.COM /* start Discovery DomainSet element. */ 1470*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 1471*7836SJohn.Forte@Sun.COM (xmlChar *)DDSETOBJECT) < 0) { 1472*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1473*7836SJohn.Forte@Sun.COM } 1474*7836SJohn.Forte@Sun.COM 1475*7836SJohn.Forte@Sun.COM /* Start attr "name". */ 1476*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 1477*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, (xmlChar *)operand[i]) < 0) { 1478*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1479*7836SJohn.Forte@Sun.COM } 1480*7836SJohn.Forte@Sun.COM 1481*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomainSet". */ 1482*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1483*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1484*7836SJohn.Forte@Sun.COM } 1485*7836SJohn.Forte@Sun.COM } 1486*7836SJohn.Forte@Sun.COM break; 1487*7836SJohn.Forte@Sun.COM case DiscoveryDomainMember: 1488*7836SJohn.Forte@Sun.COM for (i = 0; i < operandLen; i++) { 1489*7836SJohn.Forte@Sun.COM /* start Discovery Domain Member element. */ 1490*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 1491*7836SJohn.Forte@Sun.COM (xmlChar *)DDOBJECTMEMBER) < 0) { 1492*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1493*7836SJohn.Forte@Sun.COM } 1494*7836SJohn.Forte@Sun.COM 1495*7836SJohn.Forte@Sun.COM /* Start attr "DD Name". */ 1496*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 1497*7836SJohn.Forte@Sun.COM (xmlChar *)DDNAMEATTR, (xmlChar *)container) < 0) { 1498*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1499*7836SJohn.Forte@Sun.COM } 1500*7836SJohn.Forte@Sun.COM 1501*7836SJohn.Forte@Sun.COM /* Start attr "Node Name". */ 1502*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 1503*7836SJohn.Forte@Sun.COM (xmlChar *)NODENAMEATTR, (xmlChar *)operand[i]) < 0) { 1504*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1505*7836SJohn.Forte@Sun.COM } 1506*7836SJohn.Forte@Sun.COM 1507*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomainMember. */ 1508*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1509*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1510*7836SJohn.Forte@Sun.COM } 1511*7836SJohn.Forte@Sun.COM } 1512*7836SJohn.Forte@Sun.COM break; 1513*7836SJohn.Forte@Sun.COM case DiscoveryDomainSetMember: 1514*7836SJohn.Forte@Sun.COM for (i = 0; i < operandLen; i++) { 1515*7836SJohn.Forte@Sun.COM /* start Discovery Domain Member element. */ 1516*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 1517*7836SJohn.Forte@Sun.COM (xmlChar *)DDSETOBJECTMEMBER) < 0) { 1518*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1519*7836SJohn.Forte@Sun.COM } 1520*7836SJohn.Forte@Sun.COM 1521*7836SJohn.Forte@Sun.COM /* Start attr "DD Set Name". */ 1522*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 1523*7836SJohn.Forte@Sun.COM (xmlChar *)DDSETNAMEATTR, (xmlChar *)(container)) < 0) { 1524*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1525*7836SJohn.Forte@Sun.COM } 1526*7836SJohn.Forte@Sun.COM 1527*7836SJohn.Forte@Sun.COM /* Start attr "DD Name". */ 1528*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 1529*7836SJohn.Forte@Sun.COM (xmlChar *)DDNAMEATTR, (xmlChar *)(operand[i])) < 0) { 1530*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1531*7836SJohn.Forte@Sun.COM } 1532*7836SJohn.Forte@Sun.COM 1533*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomainSetMember. */ 1534*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1535*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1536*7836SJohn.Forte@Sun.COM } 1537*7836SJohn.Forte@Sun.COM } 1538*7836SJohn.Forte@Sun.COM break; 1539*7836SJohn.Forte@Sun.COM default: 1540*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1541*7836SJohn.Forte@Sun.COM return (UNKNOWN); 1542*7836SJohn.Forte@Sun.COM } 1543*7836SJohn.Forte@Sun.COM 1544*7836SJohn.Forte@Sun.COM /* end createModify */ 1545*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1546*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1547*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1548*7836SJohn.Forte@Sun.COM } 1549*7836SJohn.Forte@Sun.COM 1550*7836SJohn.Forte@Sun.COM /* End element "isnsRequest". */ 1551*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1552*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1553*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1554*7836SJohn.Forte@Sun.COM } 1555*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndDocument(writer) < 0) { 1556*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1557*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_DOC_FAILED); 1558*7836SJohn.Forte@Sun.COM } 1559*7836SJohn.Forte@Sun.COM 1560*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1561*7836SJohn.Forte@Sun.COM 1562*7836SJohn.Forte@Sun.COM len = xmlStrlen(xbuf->content) + 1; 1563*7836SJohn.Forte@Sun.COM /* XXX - copy NULL at the end by having one more extra byte */ 1564*7836SJohn.Forte@Sun.COM if ((*doc = xmlStrndup(xbuf->content, len)) == NULL) { 1565*7836SJohn.Forte@Sun.COM return (ERROR_XML_STRDUP_FAILED); 1566*7836SJohn.Forte@Sun.COM } 1567*7836SJohn.Forte@Sun.COM 1568*7836SJohn.Forte@Sun.COM xmlBufferFree(xbuf); 1569*7836SJohn.Forte@Sun.COM 1570*7836SJohn.Forte@Sun.COM return (0); 1571*7836SJohn.Forte@Sun.COM } 1572*7836SJohn.Forte@Sun.COM 1573*7836SJohn.Forte@Sun.COM /* 1574*7836SJohn.Forte@Sun.COM * **************************************************************************** 1575*7836SJohn.Forte@Sun.COM * 1576*7836SJohn.Forte@Sun.COM * build_modify_xml_doc - 1577*7836SJohn.Forte@Sun.COM * build create request doc based the name. 1578*7836SJohn.Forte@Sun.COM * the resulted doc is passed in the doc ptr. 1579*7836SJohn.Forte@Sun.COM * 1580*7836SJohn.Forte@Sun.COM * operannLen - number of objects 1581*7836SJohn.Forte@Sun.COM * operand - object list 1582*7836SJohn.Forte@Sun.COM * enabled - indication of enable and disable boolean type element. 1583*7836SJohn.Forte@Sun.COM * doc - ptr to the resulted doc 1584*7836SJohn.Forte@Sun.COM * 1585*7836SJohn.Forte@Sun.COM * **************************************************************************** 1586*7836SJohn.Forte@Sun.COM */ 1587*7836SJohn.Forte@Sun.COM static int 1588*7836SJohn.Forte@Sun.COM build_modify_xml_doc(int operandLen, char **operand, object_type obj, 1589*7836SJohn.Forte@Sun.COM boolean_t enabled, xmlChar **doc) 1590*7836SJohn.Forte@Sun.COM { 1591*7836SJohn.Forte@Sun.COM xmlTextWriterPtr writer; 1592*7836SJohn.Forte@Sun.COM xmlBufferPtr xbuf; 1593*7836SJohn.Forte@Sun.COM int i, len; 1594*7836SJohn.Forte@Sun.COM 1595*7836SJohn.Forte@Sun.COM if ((xbuf = xmlBufferCreate()) == NULL) { 1596*7836SJohn.Forte@Sun.COM return (ERROR_XML_CREATE_BUFFER_FAILED); 1597*7836SJohn.Forte@Sun.COM } 1598*7836SJohn.Forte@Sun.COM 1599*7836SJohn.Forte@Sun.COM if ((writer = xmlNewTextWriterMemory(xbuf, 0)) == NULL) { 1600*7836SJohn.Forte@Sun.COM return (ERROR_XML_CREATE_WRITER_FAILED); 1601*7836SJohn.Forte@Sun.COM } 1602*7836SJohn.Forte@Sun.COM 1603*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartDocument(writer, "1.0", NULL, NULL) < 0) { 1604*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_DOC_FAILED); 1605*7836SJohn.Forte@Sun.COM } 1606*7836SJohn.Forte@Sun.COM 1607*7836SJohn.Forte@Sun.COM /* Start element "isnsRequest". */ 1608*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, (xmlChar *)ISNSREQUEST) < 0) { 1609*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1610*7836SJohn.Forte@Sun.COM } 1611*7836SJohn.Forte@Sun.COM 1612*7836SJohn.Forte@Sun.COM if ((xmlTextWriterWriteAttribute(writer, 1613*7836SJohn.Forte@Sun.COM (xmlChar *)XMLNSATTR, (xmlChar *)XMLNSATTRVAL)) < 0) { 1614*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1615*7836SJohn.Forte@Sun.COM } 1616*7836SJohn.Forte@Sun.COM 1617*7836SJohn.Forte@Sun.COM /* request createModify operation to get the entire list of obejct. */ 1618*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, (xmlChar *)CREATEMODIFY) < 0) { 1619*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1620*7836SJohn.Forte@Sun.COM } 1621*7836SJohn.Forte@Sun.COM 1622*7836SJohn.Forte@Sun.COM switch (obj) { 1623*7836SJohn.Forte@Sun.COM case DiscoveryDomain: 1624*7836SJohn.Forte@Sun.COM for (i = 0; i < operandLen; i++) { 1625*7836SJohn.Forte@Sun.COM /* start Discovery Domain element. */ 1626*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 1627*7836SJohn.Forte@Sun.COM (xmlChar *)DDOBJECT) < 0) { 1628*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1629*7836SJohn.Forte@Sun.COM } 1630*7836SJohn.Forte@Sun.COM 1631*7836SJohn.Forte@Sun.COM /* write attr "name". */ 1632*7836SJohn.Forte@Sun.COM if ((xmlTextWriterWriteAttribute(writer, 1633*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, (xmlChar *)operand[i])) < 0) { 1634*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1635*7836SJohn.Forte@Sun.COM } 1636*7836SJohn.Forte@Sun.COM 1637*7836SJohn.Forte@Sun.COM /* write bootlist_enabled elem */ 1638*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteElement(writer, 1639*7836SJohn.Forte@Sun.COM (xmlChar *)BOOTLISTENABLEDELEM, (enabled)? 1640*7836SJohn.Forte@Sun.COM (xmlChar *)XMLTRUE : (xmlChar *)XMLFALSE) < 0) { 1641*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ELEMENT_FAILED); 1642*7836SJohn.Forte@Sun.COM } 1643*7836SJohn.Forte@Sun.COM 1644*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomain". */ 1645*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1646*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1647*7836SJohn.Forte@Sun.COM } 1648*7836SJohn.Forte@Sun.COM } 1649*7836SJohn.Forte@Sun.COM break; 1650*7836SJohn.Forte@Sun.COM case DiscoveryDomainSet: 1651*7836SJohn.Forte@Sun.COM for (i = 0; i < operandLen; i++) { 1652*7836SJohn.Forte@Sun.COM /* start Discovery DomainSet element. */ 1653*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 1654*7836SJohn.Forte@Sun.COM (xmlChar *)DDSETOBJECT) < 0) { 1655*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1656*7836SJohn.Forte@Sun.COM } 1657*7836SJohn.Forte@Sun.COM 1658*7836SJohn.Forte@Sun.COM /* Start attr "name". */ 1659*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 1660*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, (xmlChar *)operand[i]) < 0) { 1661*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1662*7836SJohn.Forte@Sun.COM } 1663*7836SJohn.Forte@Sun.COM 1664*7836SJohn.Forte@Sun.COM /* write enabled elem */ 1665*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteElement(writer, 1666*7836SJohn.Forte@Sun.COM (xmlChar *)ENABLEDELEM, (enabled) ? 1667*7836SJohn.Forte@Sun.COM (xmlChar *)XMLTRUE : (xmlChar *)XMLFALSE) < 0) { 1668*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ELEMENT_FAILED); 1669*7836SJohn.Forte@Sun.COM } 1670*7836SJohn.Forte@Sun.COM 1671*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomainSet". */ 1672*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1673*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1674*7836SJohn.Forte@Sun.COM } 1675*7836SJohn.Forte@Sun.COM } 1676*7836SJohn.Forte@Sun.COM break; 1677*7836SJohn.Forte@Sun.COM default: 1678*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1679*7836SJohn.Forte@Sun.COM return (UNKNOWN); 1680*7836SJohn.Forte@Sun.COM } 1681*7836SJohn.Forte@Sun.COM 1682*7836SJohn.Forte@Sun.COM /* end createModify */ 1683*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1684*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1685*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1686*7836SJohn.Forte@Sun.COM } 1687*7836SJohn.Forte@Sun.COM 1688*7836SJohn.Forte@Sun.COM /* End element "isnsRequest". */ 1689*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1690*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1691*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1692*7836SJohn.Forte@Sun.COM } 1693*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndDocument(writer) < 0) { 1694*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1695*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_DOC_FAILED); 1696*7836SJohn.Forte@Sun.COM } 1697*7836SJohn.Forte@Sun.COM 1698*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1699*7836SJohn.Forte@Sun.COM 1700*7836SJohn.Forte@Sun.COM len = xmlStrlen(xbuf->content) + 1; 1701*7836SJohn.Forte@Sun.COM /* XXX - copy NULL at the end by having one more extra byte */ 1702*7836SJohn.Forte@Sun.COM if ((*doc = xmlStrndup(xbuf->content, len)) == NULL) { 1703*7836SJohn.Forte@Sun.COM return (ERROR_XML_STRDUP_FAILED); 1704*7836SJohn.Forte@Sun.COM } 1705*7836SJohn.Forte@Sun.COM 1706*7836SJohn.Forte@Sun.COM xmlBufferFree(xbuf); 1707*7836SJohn.Forte@Sun.COM 1708*7836SJohn.Forte@Sun.COM return (0); 1709*7836SJohn.Forte@Sun.COM } 1710*7836SJohn.Forte@Sun.COM 1711*7836SJohn.Forte@Sun.COM /* 1712*7836SJohn.Forte@Sun.COM * **************************************************************************** 1713*7836SJohn.Forte@Sun.COM * 1714*7836SJohn.Forte@Sun.COM * build_rename_xml_doc - 1715*7836SJohn.Forte@Sun.COM * build create request doc based the name. 1716*7836SJohn.Forte@Sun.COM * the resulted doc is passed in the doc ptr. 1717*7836SJohn.Forte@Sun.COM * 1718*7836SJohn.Forte@Sun.COM * assoc - a new name 1719*7836SJohn.Forte@Sun.COM * id - index of the object of which name to be changed 1720*7836SJohn.Forte@Sun.COM * doc - ptr to the resulted doc 1721*7836SJohn.Forte@Sun.COM * 1722*7836SJohn.Forte@Sun.COM * **************************************************************************** 1723*7836SJohn.Forte@Sun.COM */ 1724*7836SJohn.Forte@Sun.COM static int 1725*7836SJohn.Forte@Sun.COM build_rename_xml_doc(char *name, object_type obj, uint32_t id, xmlChar **doc) 1726*7836SJohn.Forte@Sun.COM { 1727*7836SJohn.Forte@Sun.COM xmlTextWriterPtr writer; 1728*7836SJohn.Forte@Sun.COM xmlBufferPtr xbuf; 1729*7836SJohn.Forte@Sun.COM int len; 1730*7836SJohn.Forte@Sun.COM char namebuf[32]; 1731*7836SJohn.Forte@Sun.COM 1732*7836SJohn.Forte@Sun.COM if ((xbuf = xmlBufferCreate()) == NULL) { 1733*7836SJohn.Forte@Sun.COM return (ERROR_XML_CREATE_BUFFER_FAILED); 1734*7836SJohn.Forte@Sun.COM } 1735*7836SJohn.Forte@Sun.COM 1736*7836SJohn.Forte@Sun.COM if ((writer = xmlNewTextWriterMemory(xbuf, 0)) == NULL) { 1737*7836SJohn.Forte@Sun.COM return (ERROR_XML_CREATE_WRITER_FAILED); 1738*7836SJohn.Forte@Sun.COM } 1739*7836SJohn.Forte@Sun.COM 1740*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartDocument(writer, "1.0", NULL, NULL) < 0) { 1741*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_DOC_FAILED); 1742*7836SJohn.Forte@Sun.COM } 1743*7836SJohn.Forte@Sun.COM 1744*7836SJohn.Forte@Sun.COM /* Start element "isnsRequest". */ 1745*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, (xmlChar *)ISNSREQUEST) < 0) { 1746*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1747*7836SJohn.Forte@Sun.COM } 1748*7836SJohn.Forte@Sun.COM 1749*7836SJohn.Forte@Sun.COM if ((xmlTextWriterWriteAttribute(writer, 1750*7836SJohn.Forte@Sun.COM (xmlChar *)XMLNSATTR, (xmlChar *)XMLNSATTRVAL)) < 0) { 1751*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1752*7836SJohn.Forte@Sun.COM } 1753*7836SJohn.Forte@Sun.COM 1754*7836SJohn.Forte@Sun.COM /* request createModify operation to get the entire list of obejct. */ 1755*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, (xmlChar *)CREATEMODIFY) < 0) { 1756*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1757*7836SJohn.Forte@Sun.COM } 1758*7836SJohn.Forte@Sun.COM 1759*7836SJohn.Forte@Sun.COM switch (obj) { 1760*7836SJohn.Forte@Sun.COM case DiscoveryDomain: 1761*7836SJohn.Forte@Sun.COM /* start Discovery Domain element. */ 1762*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 1763*7836SJohn.Forte@Sun.COM (xmlChar *)DDOBJECT) < 0) { 1764*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1765*7836SJohn.Forte@Sun.COM } 1766*7836SJohn.Forte@Sun.COM 1767*7836SJohn.Forte@Sun.COM /* write attr "name". */ 1768*7836SJohn.Forte@Sun.COM if ((xmlTextWriterWriteAttribute(writer, 1769*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, (xmlChar *)name)) < 0) { 1770*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1771*7836SJohn.Forte@Sun.COM } 1772*7836SJohn.Forte@Sun.COM 1773*7836SJohn.Forte@Sun.COM /* write attr "id". */ 1774*7836SJohn.Forte@Sun.COM (void) sprintf(namebuf, "%d", id); 1775*7836SJohn.Forte@Sun.COM if ((xmlTextWriterWriteAttribute(writer, 1776*7836SJohn.Forte@Sun.COM (xmlChar *)IDATTR, (xmlChar *)namebuf)) < 0) { 1777*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1778*7836SJohn.Forte@Sun.COM } 1779*7836SJohn.Forte@Sun.COM 1780*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomain". */ 1781*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1782*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1783*7836SJohn.Forte@Sun.COM } 1784*7836SJohn.Forte@Sun.COM break; 1785*7836SJohn.Forte@Sun.COM case DiscoveryDomainSet: 1786*7836SJohn.Forte@Sun.COM /* start Discovery DomainSet element. */ 1787*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 1788*7836SJohn.Forte@Sun.COM (xmlChar *)DDSETOBJECT) < 0) { 1789*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1790*7836SJohn.Forte@Sun.COM } 1791*7836SJohn.Forte@Sun.COM 1792*7836SJohn.Forte@Sun.COM /* Start attr "name". */ 1793*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 1794*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, (xmlChar *)name) < 0) { 1795*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1796*7836SJohn.Forte@Sun.COM } 1797*7836SJohn.Forte@Sun.COM 1798*7836SJohn.Forte@Sun.COM /* write attr "id". */ 1799*7836SJohn.Forte@Sun.COM (void) sprintf(namebuf, "%d", id); 1800*7836SJohn.Forte@Sun.COM if ((xmlTextWriterWriteAttribute(writer, 1801*7836SJohn.Forte@Sun.COM (xmlChar *)IDATTR, (xmlChar *)namebuf)) < 0) { 1802*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1803*7836SJohn.Forte@Sun.COM } 1804*7836SJohn.Forte@Sun.COM 1805*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomainSet". */ 1806*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1807*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1808*7836SJohn.Forte@Sun.COM } 1809*7836SJohn.Forte@Sun.COM break; 1810*7836SJohn.Forte@Sun.COM default: 1811*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1812*7836SJohn.Forte@Sun.COM return (UNKNOWN); 1813*7836SJohn.Forte@Sun.COM } 1814*7836SJohn.Forte@Sun.COM 1815*7836SJohn.Forte@Sun.COM /* end createModify */ 1816*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1817*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1818*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1819*7836SJohn.Forte@Sun.COM } 1820*7836SJohn.Forte@Sun.COM 1821*7836SJohn.Forte@Sun.COM /* End element "isnsRequest". */ 1822*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1823*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1824*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1825*7836SJohn.Forte@Sun.COM } 1826*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndDocument(writer) < 0) { 1827*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1828*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_DOC_FAILED); 1829*7836SJohn.Forte@Sun.COM } 1830*7836SJohn.Forte@Sun.COM 1831*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1832*7836SJohn.Forte@Sun.COM 1833*7836SJohn.Forte@Sun.COM len = xmlStrlen(xbuf->content) + 1; 1834*7836SJohn.Forte@Sun.COM /* XXX - copy NULL at the end by having one more extra byte */ 1835*7836SJohn.Forte@Sun.COM if ((*doc = xmlStrndup(xbuf->content, len)) == NULL) { 1836*7836SJohn.Forte@Sun.COM return (ERROR_XML_STRDUP_FAILED); 1837*7836SJohn.Forte@Sun.COM } 1838*7836SJohn.Forte@Sun.COM 1839*7836SJohn.Forte@Sun.COM xmlBufferFree(xbuf); 1840*7836SJohn.Forte@Sun.COM 1841*7836SJohn.Forte@Sun.COM return (0); 1842*7836SJohn.Forte@Sun.COM } 1843*7836SJohn.Forte@Sun.COM 1844*7836SJohn.Forte@Sun.COM /* 1845*7836SJohn.Forte@Sun.COM * **************************************************************************** 1846*7836SJohn.Forte@Sun.COM * 1847*7836SJohn.Forte@Sun.COM * build_create_xml_doc - 1848*7836SJohn.Forte@Sun.COM * build create request doc based the name. 1849*7836SJohn.Forte@Sun.COM * the resulted doc is passed in the doc ptr. 1850*7836SJohn.Forte@Sun.COM * 1851*7836SJohn.Forte@Sun.COM * name - object type 1852*7836SJohn.Forte@Sun.COM * assoc - association type 1853*7836SJohn.Forte@Sun.COM * doc - ptr to the resulted doc 1854*7836SJohn.Forte@Sun.COM * 1855*7836SJohn.Forte@Sun.COM * **************************************************************************** 1856*7836SJohn.Forte@Sun.COM */ 1857*7836SJohn.Forte@Sun.COM static int 1858*7836SJohn.Forte@Sun.COM build_create_xml_doc(int operandLen, char **operand, object_type obj, 1859*7836SJohn.Forte@Sun.COM char *container, xmlChar **doc) 1860*7836SJohn.Forte@Sun.COM { 1861*7836SJohn.Forte@Sun.COM xmlTextWriterPtr writer; 1862*7836SJohn.Forte@Sun.COM xmlBufferPtr xbuf; 1863*7836SJohn.Forte@Sun.COM int i, len; 1864*7836SJohn.Forte@Sun.COM 1865*7836SJohn.Forte@Sun.COM if ((xbuf = xmlBufferCreate()) == NULL) { 1866*7836SJohn.Forte@Sun.COM return (ERROR_XML_CREATE_BUFFER_FAILED); 1867*7836SJohn.Forte@Sun.COM } 1868*7836SJohn.Forte@Sun.COM 1869*7836SJohn.Forte@Sun.COM if ((writer = xmlNewTextWriterMemory(xbuf, 0)) == NULL) { 1870*7836SJohn.Forte@Sun.COM return (ERROR_XML_CREATE_WRITER_FAILED); 1871*7836SJohn.Forte@Sun.COM } 1872*7836SJohn.Forte@Sun.COM 1873*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartDocument(writer, "1.0", NULL, NULL) < 0) { 1874*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_DOC_FAILED); 1875*7836SJohn.Forte@Sun.COM } 1876*7836SJohn.Forte@Sun.COM 1877*7836SJohn.Forte@Sun.COM /* Start element "isnsRequest". */ 1878*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, (xmlChar *)ISNSREQUEST) < 0) { 1879*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1880*7836SJohn.Forte@Sun.COM } 1881*7836SJohn.Forte@Sun.COM 1882*7836SJohn.Forte@Sun.COM /* request createModify operation to get the entire list of obejct. */ 1883*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, (xmlChar *)CREATEMODIFY) < 0) { 1884*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1885*7836SJohn.Forte@Sun.COM } 1886*7836SJohn.Forte@Sun.COM 1887*7836SJohn.Forte@Sun.COM switch (obj) { 1888*7836SJohn.Forte@Sun.COM case DiscoveryDomain: 1889*7836SJohn.Forte@Sun.COM for (i = 0; i < operandLen; i++) { 1890*7836SJohn.Forte@Sun.COM /* start Discovery Domain element. */ 1891*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 1892*7836SJohn.Forte@Sun.COM (xmlChar *)DDOBJECT) < 0) { 1893*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1894*7836SJohn.Forte@Sun.COM } 1895*7836SJohn.Forte@Sun.COM 1896*7836SJohn.Forte@Sun.COM /* Start attr "name". */ 1897*7836SJohn.Forte@Sun.COM if ((xmlTextWriterWriteAttribute(writer, 1898*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, (xmlChar *)operand[i])) < 0) { 1899*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1900*7836SJohn.Forte@Sun.COM } 1901*7836SJohn.Forte@Sun.COM 1902*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomain". */ 1903*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1904*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1905*7836SJohn.Forte@Sun.COM } 1906*7836SJohn.Forte@Sun.COM } 1907*7836SJohn.Forte@Sun.COM break; 1908*7836SJohn.Forte@Sun.COM case DiscoveryDomainSet: 1909*7836SJohn.Forte@Sun.COM for (i = 0; i < operandLen; i++) { 1910*7836SJohn.Forte@Sun.COM /* start Discovery DomainSet element. */ 1911*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 1912*7836SJohn.Forte@Sun.COM (xmlChar *)DDSETOBJECT) < 0) { 1913*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1914*7836SJohn.Forte@Sun.COM } 1915*7836SJohn.Forte@Sun.COM 1916*7836SJohn.Forte@Sun.COM /* Start attr "name". */ 1917*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 1918*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, (xmlChar *)operand[i]) < 0) { 1919*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1920*7836SJohn.Forte@Sun.COM } 1921*7836SJohn.Forte@Sun.COM 1922*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomainSet". */ 1923*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1924*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1925*7836SJohn.Forte@Sun.COM } 1926*7836SJohn.Forte@Sun.COM } 1927*7836SJohn.Forte@Sun.COM break; 1928*7836SJohn.Forte@Sun.COM case DiscoveryDomainMember: 1929*7836SJohn.Forte@Sun.COM for (i = 0; i < operandLen; i++) { 1930*7836SJohn.Forte@Sun.COM /* start Discovery Domain Member element. */ 1931*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 1932*7836SJohn.Forte@Sun.COM (xmlChar *)DDOBJECTMEMBER) < 0) { 1933*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1934*7836SJohn.Forte@Sun.COM } 1935*7836SJohn.Forte@Sun.COM 1936*7836SJohn.Forte@Sun.COM /* Start attr "DD Name". */ 1937*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 1938*7836SJohn.Forte@Sun.COM (xmlChar *)DDNAMEATTR, (xmlChar *)container) < 0) { 1939*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1940*7836SJohn.Forte@Sun.COM } 1941*7836SJohn.Forte@Sun.COM 1942*7836SJohn.Forte@Sun.COM /* Start attr "Node Name". */ 1943*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 1944*7836SJohn.Forte@Sun.COM (xmlChar *)NODENAMEATTR, (xmlChar *)operand[i]) < 0) { 1945*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1946*7836SJohn.Forte@Sun.COM } 1947*7836SJohn.Forte@Sun.COM 1948*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomainMember. */ 1949*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1950*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1951*7836SJohn.Forte@Sun.COM } 1952*7836SJohn.Forte@Sun.COM } 1953*7836SJohn.Forte@Sun.COM break; 1954*7836SJohn.Forte@Sun.COM case DiscoveryDomainSetMember: 1955*7836SJohn.Forte@Sun.COM for (i = 0; i < operandLen; i++) { 1956*7836SJohn.Forte@Sun.COM /* start Discovery Domain Member element. */ 1957*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 1958*7836SJohn.Forte@Sun.COM (xmlChar *)DDSETOBJECTMEMBER) < 0) { 1959*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 1960*7836SJohn.Forte@Sun.COM } 1961*7836SJohn.Forte@Sun.COM 1962*7836SJohn.Forte@Sun.COM /* Start attr "DD Set Name". */ 1963*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 1964*7836SJohn.Forte@Sun.COM (xmlChar *)DDSETNAMEATTR, (xmlChar *)(container)) < 0) { 1965*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1966*7836SJohn.Forte@Sun.COM } 1967*7836SJohn.Forte@Sun.COM 1968*7836SJohn.Forte@Sun.COM /* Start attr "DD Name". */ 1969*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 1970*7836SJohn.Forte@Sun.COM (xmlChar *)DDNAMEATTR, (xmlChar *)(operand[i])) < 0) { 1971*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 1972*7836SJohn.Forte@Sun.COM } 1973*7836SJohn.Forte@Sun.COM 1974*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomainSetMember. */ 1975*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1976*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1977*7836SJohn.Forte@Sun.COM } 1978*7836SJohn.Forte@Sun.COM } 1979*7836SJohn.Forte@Sun.COM break; 1980*7836SJohn.Forte@Sun.COM default: 1981*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1982*7836SJohn.Forte@Sun.COM return (UNKNOWN); 1983*7836SJohn.Forte@Sun.COM } 1984*7836SJohn.Forte@Sun.COM 1985*7836SJohn.Forte@Sun.COM /* end createModify */ 1986*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1987*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1988*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1989*7836SJohn.Forte@Sun.COM } 1990*7836SJohn.Forte@Sun.COM 1991*7836SJohn.Forte@Sun.COM /* End element "isnsRequest". */ 1992*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 1993*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1994*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 1995*7836SJohn.Forte@Sun.COM } 1996*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndDocument(writer) < 0) { 1997*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 1998*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_DOC_FAILED); 1999*7836SJohn.Forte@Sun.COM } 2000*7836SJohn.Forte@Sun.COM 2001*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 2002*7836SJohn.Forte@Sun.COM 2003*7836SJohn.Forte@Sun.COM len = xmlStrlen(xbuf->content) + 1; 2004*7836SJohn.Forte@Sun.COM /* XXX - copy NULL at the end by having one more extra byte */ 2005*7836SJohn.Forte@Sun.COM if ((*doc = xmlStrndup(xbuf->content, len)) == NULL) { 2006*7836SJohn.Forte@Sun.COM return (ERROR_XML_STRDUP_FAILED); 2007*7836SJohn.Forte@Sun.COM } 2008*7836SJohn.Forte@Sun.COM 2009*7836SJohn.Forte@Sun.COM xmlBufferFree(xbuf); 2010*7836SJohn.Forte@Sun.COM 2011*7836SJohn.Forte@Sun.COM return (0); 2012*7836SJohn.Forte@Sun.COM } 2013*7836SJohn.Forte@Sun.COM 2014*7836SJohn.Forte@Sun.COM /* 2015*7836SJohn.Forte@Sun.COM * **************************************************************************** 2016*7836SJohn.Forte@Sun.COM * 2017*7836SJohn.Forte@Sun.COM * build_assoc_xml_doc - 2018*7836SJohn.Forte@Sun.COM * build association request doc based the name. 2019*7836SJohn.Forte@Sun.COM * the resulted doc is passed in the doc ptr. 2020*7836SJohn.Forte@Sun.COM * 2021*7836SJohn.Forte@Sun.COM * name - object type 2022*7836SJohn.Forte@Sun.COM * assoc - association type 2023*7836SJohn.Forte@Sun.COM * doc - ptr to the resulted doc 2024*7836SJohn.Forte@Sun.COM * 2025*7836SJohn.Forte@Sun.COM * **************************************************************************** 2026*7836SJohn.Forte@Sun.COM */ 2027*7836SJohn.Forte@Sun.COM static int 2028*7836SJohn.Forte@Sun.COM build_assoc_xml_doc(xmlChar *name, association_t assoc, xmlChar **doc) 2029*7836SJohn.Forte@Sun.COM { 2030*7836SJohn.Forte@Sun.COM xmlTextWriterPtr writer; 2031*7836SJohn.Forte@Sun.COM xmlBufferPtr xbuf; 2032*7836SJohn.Forte@Sun.COM int len; 2033*7836SJohn.Forte@Sun.COM 2034*7836SJohn.Forte@Sun.COM if ((xbuf = xmlBufferCreate()) == NULL) { 2035*7836SJohn.Forte@Sun.COM return (ERROR_XML_CREATE_BUFFER_FAILED); 2036*7836SJohn.Forte@Sun.COM } 2037*7836SJohn.Forte@Sun.COM 2038*7836SJohn.Forte@Sun.COM if ((writer = xmlNewTextWriterMemory(xbuf, 0)) == NULL) { 2039*7836SJohn.Forte@Sun.COM return (ERROR_XML_CREATE_WRITER_FAILED); 2040*7836SJohn.Forte@Sun.COM } 2041*7836SJohn.Forte@Sun.COM 2042*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartDocument(writer, "1.0", NULL, NULL) < 0) { 2043*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_DOC_FAILED); 2044*7836SJohn.Forte@Sun.COM } 2045*7836SJohn.Forte@Sun.COM 2046*7836SJohn.Forte@Sun.COM /* Start element "isnsRequest". */ 2047*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, (xmlChar *)ISNSREQUEST) < 0) { 2048*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2049*7836SJohn.Forte@Sun.COM } 2050*7836SJohn.Forte@Sun.COM 2051*7836SJohn.Forte@Sun.COM /* request getAssociated operation to get the entire list of obejct. */ 2052*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, (xmlChar *)GETASSOCIATED) < 0) { 2053*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2054*7836SJohn.Forte@Sun.COM } 2055*7836SJohn.Forte@Sun.COM 2056*7836SJohn.Forte@Sun.COM switch (assoc) { 2057*7836SJohn.Forte@Sun.COM case (node_to_dd): 2058*7836SJohn.Forte@Sun.COM /* write association type. */ 2059*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteElement(writer, 2060*7836SJohn.Forte@Sun.COM (xmlChar *)ASSOCIATIONTYPE, 2061*7836SJohn.Forte@Sun.COM (xmlChar *)DDOBJECTMEMBER) < 0) { 2062*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ELEMENT_FAILED); 2063*7836SJohn.Forte@Sun.COM } 2064*7836SJohn.Forte@Sun.COM 2065*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2066*7836SJohn.Forte@Sun.COM (xmlChar *)ISNSOBJECT) < 0) { 2067*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2068*7836SJohn.Forte@Sun.COM } 2069*7836SJohn.Forte@Sun.COM 2070*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2071*7836SJohn.Forte@Sun.COM (xmlChar *)NODEOBJECT) < 0) { 2072*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2073*7836SJohn.Forte@Sun.COM } 2074*7836SJohn.Forte@Sun.COM 2075*7836SJohn.Forte@Sun.COM /* Start attr "name". */ 2076*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 2077*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, name) < 0) { 2078*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 2079*7836SJohn.Forte@Sun.COM } 2080*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 2081*7836SJohn.Forte@Sun.COM (xmlChar *)TYPEATTR, (xmlChar *)EMPTYSTR) < 0) { 2082*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 2083*7836SJohn.Forte@Sun.COM } 2084*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 2085*7836SJohn.Forte@Sun.COM (xmlChar *)ALIASATTR, (xmlChar *)EMPTYSTR) < 0) { 2086*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 2087*7836SJohn.Forte@Sun.COM } 2088*7836SJohn.Forte@Sun.COM 2089*7836SJohn.Forte@Sun.COM /* End element "Node". */ 2090*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2091*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2092*7836SJohn.Forte@Sun.COM } 2093*7836SJohn.Forte@Sun.COM 2094*7836SJohn.Forte@Sun.COM /* End element "isnsObject". */ 2095*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2096*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2097*7836SJohn.Forte@Sun.COM } 2098*7836SJohn.Forte@Sun.COM break; 2099*7836SJohn.Forte@Sun.COM case (dd_to_node): 2100*7836SJohn.Forte@Sun.COM /* write association type. */ 2101*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteElement(writer, 2102*7836SJohn.Forte@Sun.COM (xmlChar *)ASSOCIATIONTYPE, 2103*7836SJohn.Forte@Sun.COM (xmlChar *)DDOBJECTMEMBER) < 0) { 2104*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ELEMENT_FAILED); 2105*7836SJohn.Forte@Sun.COM } 2106*7836SJohn.Forte@Sun.COM 2107*7836SJohn.Forte@Sun.COM /* start isnsObject */ 2108*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2109*7836SJohn.Forte@Sun.COM (xmlChar *)ISNSOBJECT) < 0) { 2110*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2111*7836SJohn.Forte@Sun.COM } 2112*7836SJohn.Forte@Sun.COM 2113*7836SJohn.Forte@Sun.COM /* start DiscoveryDomain */ 2114*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2115*7836SJohn.Forte@Sun.COM (xmlChar *)DDOBJECT) < 0) { 2116*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2117*7836SJohn.Forte@Sun.COM } 2118*7836SJohn.Forte@Sun.COM 2119*7836SJohn.Forte@Sun.COM /* Start attr "name". */ 2120*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 2121*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, name) < 0) { 2122*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 2123*7836SJohn.Forte@Sun.COM } 2124*7836SJohn.Forte@Sun.COM 2125*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomain". */ 2126*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2127*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2128*7836SJohn.Forte@Sun.COM } 2129*7836SJohn.Forte@Sun.COM 2130*7836SJohn.Forte@Sun.COM /* End element "isnsObject". */ 2131*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2132*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2133*7836SJohn.Forte@Sun.COM } 2134*7836SJohn.Forte@Sun.COM break; 2135*7836SJohn.Forte@Sun.COM case (ddset_to_dd): 2136*7836SJohn.Forte@Sun.COM /* write association type. */ 2137*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteElement(writer, 2138*7836SJohn.Forte@Sun.COM (xmlChar *)ASSOCIATIONTYPE, 2139*7836SJohn.Forte@Sun.COM (xmlChar *)DDSETOBJECTMEMBER) < 0) { 2140*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ELEMENT_FAILED); 2141*7836SJohn.Forte@Sun.COM } 2142*7836SJohn.Forte@Sun.COM 2143*7836SJohn.Forte@Sun.COM /* start isnsObject */ 2144*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2145*7836SJohn.Forte@Sun.COM (xmlChar *)ISNSOBJECT) < 0) { 2146*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2147*7836SJohn.Forte@Sun.COM } 2148*7836SJohn.Forte@Sun.COM 2149*7836SJohn.Forte@Sun.COM /* start DiscoveryDomainSet */ 2150*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2151*7836SJohn.Forte@Sun.COM (xmlChar *)DDSETOBJECT) < 0) { 2152*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2153*7836SJohn.Forte@Sun.COM } 2154*7836SJohn.Forte@Sun.COM 2155*7836SJohn.Forte@Sun.COM /* Start attr "name". */ 2156*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 2157*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, name) < 0) { 2158*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 2159*7836SJohn.Forte@Sun.COM } 2160*7836SJohn.Forte@Sun.COM 2161*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomain". */ 2162*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2163*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2164*7836SJohn.Forte@Sun.COM } 2165*7836SJohn.Forte@Sun.COM 2166*7836SJohn.Forte@Sun.COM /* End element "isnsObject". */ 2167*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2168*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2169*7836SJohn.Forte@Sun.COM } 2170*7836SJohn.Forte@Sun.COM break; 2171*7836SJohn.Forte@Sun.COM case (dd_to_ddset): 2172*7836SJohn.Forte@Sun.COM /* write association type. */ 2173*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteElement(writer, 2174*7836SJohn.Forte@Sun.COM (xmlChar *)ASSOCIATIONTYPE, 2175*7836SJohn.Forte@Sun.COM (xmlChar *)DDSETOBJECTMEMBER) < 0) { 2176*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ELEMENT_FAILED); 2177*7836SJohn.Forte@Sun.COM } 2178*7836SJohn.Forte@Sun.COM 2179*7836SJohn.Forte@Sun.COM /* start isnsObject */ 2180*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2181*7836SJohn.Forte@Sun.COM (xmlChar *)ISNSOBJECT) < 0) { 2182*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2183*7836SJohn.Forte@Sun.COM } 2184*7836SJohn.Forte@Sun.COM 2185*7836SJohn.Forte@Sun.COM /* start DiscoveryDomain */ 2186*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2187*7836SJohn.Forte@Sun.COM (xmlChar *)DDOBJECT) < 0) { 2188*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2189*7836SJohn.Forte@Sun.COM } 2190*7836SJohn.Forte@Sun.COM 2191*7836SJohn.Forte@Sun.COM /* Start attr "name". */ 2192*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 2193*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, name) < 0) { 2194*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 2195*7836SJohn.Forte@Sun.COM } 2196*7836SJohn.Forte@Sun.COM 2197*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomain". */ 2198*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2199*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2200*7836SJohn.Forte@Sun.COM } 2201*7836SJohn.Forte@Sun.COM 2202*7836SJohn.Forte@Sun.COM /* End element "isnsObject". */ 2203*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2204*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2205*7836SJohn.Forte@Sun.COM } 2206*7836SJohn.Forte@Sun.COM break; 2207*7836SJohn.Forte@Sun.COM default: 2208*7836SJohn.Forte@Sun.COM return (UNKNOWN); 2209*7836SJohn.Forte@Sun.COM } 2210*7836SJohn.Forte@Sun.COM 2211*7836SJohn.Forte@Sun.COM /* end getAssociated */ 2212*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2213*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2214*7836SJohn.Forte@Sun.COM } 2215*7836SJohn.Forte@Sun.COM 2216*7836SJohn.Forte@Sun.COM /* End element "isnsRequest". */ 2217*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2218*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2219*7836SJohn.Forte@Sun.COM } 2220*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndDocument(writer) < 0) { 2221*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_DOC_FAILED); 2222*7836SJohn.Forte@Sun.COM } 2223*7836SJohn.Forte@Sun.COM 2224*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 2225*7836SJohn.Forte@Sun.COM 2226*7836SJohn.Forte@Sun.COM len = xmlStrlen(xbuf->content) + 1; 2227*7836SJohn.Forte@Sun.COM /* XXX - copy NULL at the end by having one more extra byte */ 2228*7836SJohn.Forte@Sun.COM if ((*doc = xmlStrndup(xbuf->content, len)) == NULL) { 2229*7836SJohn.Forte@Sun.COM return (ERROR_XML_STRDUP_FAILED); 2230*7836SJohn.Forte@Sun.COM } 2231*7836SJohn.Forte@Sun.COM 2232*7836SJohn.Forte@Sun.COM xmlBufferFree(xbuf); 2233*7836SJohn.Forte@Sun.COM return (0); 2234*7836SJohn.Forte@Sun.COM } 2235*7836SJohn.Forte@Sun.COM 2236*7836SJohn.Forte@Sun.COM /* 2237*7836SJohn.Forte@Sun.COM * **************************************************************************** 2238*7836SJohn.Forte@Sun.COM * 2239*7836SJohn.Forte@Sun.COM * build_enumerate_xml_doc - 2240*7836SJohn.Forte@Sun.COM * build association request doc based the name. 2241*7836SJohn.Forte@Sun.COM * the resulted doc is passed in the doc ptr. 2242*7836SJohn.Forte@Sun.COM * 2243*7836SJohn.Forte@Sun.COM * name - object type 2244*7836SJohn.Forte@Sun.COM * doc - ptr to the resulted doc 2245*7836SJohn.Forte@Sun.COM * 2246*7836SJohn.Forte@Sun.COM * **************************************************************************** 2247*7836SJohn.Forte@Sun.COM */ 2248*7836SJohn.Forte@Sun.COM static int 2249*7836SJohn.Forte@Sun.COM build_enumerate_xml_doc(object_type obj, xmlChar **doc) 2250*7836SJohn.Forte@Sun.COM { 2251*7836SJohn.Forte@Sun.COM xmlTextWriterPtr writer; 2252*7836SJohn.Forte@Sun.COM xmlBufferPtr xbuf; 2253*7836SJohn.Forte@Sun.COM int len; 2254*7836SJohn.Forte@Sun.COM 2255*7836SJohn.Forte@Sun.COM if ((xbuf = xmlBufferCreate()) == NULL) { 2256*7836SJohn.Forte@Sun.COM return (ERROR_XML_CREATE_BUFFER_FAILED); 2257*7836SJohn.Forte@Sun.COM } 2258*7836SJohn.Forte@Sun.COM 2259*7836SJohn.Forte@Sun.COM if ((writer = xmlNewTextWriterMemory(xbuf, 0)) == NULL) { 2260*7836SJohn.Forte@Sun.COM return (ERROR_XML_CREATE_WRITER_FAILED); 2261*7836SJohn.Forte@Sun.COM } 2262*7836SJohn.Forte@Sun.COM 2263*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartDocument(writer, "1.0", NULL, NULL) < 0) { 2264*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_DOC_FAILED); 2265*7836SJohn.Forte@Sun.COM } 2266*7836SJohn.Forte@Sun.COM 2267*7836SJohn.Forte@Sun.COM /* Start element "isnsRequest". */ 2268*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, (xmlChar *)ISNSREQUEST) < 0) { 2269*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2270*7836SJohn.Forte@Sun.COM } 2271*7836SJohn.Forte@Sun.COM 2272*7836SJohn.Forte@Sun.COM /* Start attr "xmlns". */ 2273*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 2274*7836SJohn.Forte@Sun.COM (xmlChar *)"xmlns", 2275*7836SJohn.Forte@Sun.COM (xmlChar *)"http://www.sun.com/schema/isnsmanagement")) { 2276*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 2277*7836SJohn.Forte@Sun.COM } 2278*7836SJohn.Forte@Sun.COM 2279*7836SJohn.Forte@Sun.COM /* request enumerate operation to get the entire list of obejct. */ 2280*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, (xmlChar *)ENUMERATE) < 0) { 2281*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2282*7836SJohn.Forte@Sun.COM } 2283*7836SJohn.Forte@Sun.COM 2284*7836SJohn.Forte@Sun.COM switch (obj) { 2285*7836SJohn.Forte@Sun.COM case (Node): 2286*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteElement(writer, 2287*7836SJohn.Forte@Sun.COM (xmlChar *)ISNSOBJECTTYPE, (xmlChar *)NODEOBJECT) < 0) { 2288*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ELEMENT_FAILED); 2289*7836SJohn.Forte@Sun.COM } 2290*7836SJohn.Forte@Sun.COM break; 2291*7836SJohn.Forte@Sun.COM case (DiscoveryDomain): 2292*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteElement(writer, 2293*7836SJohn.Forte@Sun.COM (xmlChar *)ISNSOBJECTTYPE, 2294*7836SJohn.Forte@Sun.COM (xmlChar *)DDOBJECT) < 0) { 2295*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ELEMENT_FAILED); 2296*7836SJohn.Forte@Sun.COM } 2297*7836SJohn.Forte@Sun.COM break; 2298*7836SJohn.Forte@Sun.COM case (DiscoveryDomainSet): 2299*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteElement(writer, 2300*7836SJohn.Forte@Sun.COM (xmlChar *)ISNSOBJECTTYPE, 2301*7836SJohn.Forte@Sun.COM (xmlChar *)DDSETOBJECT) < 0) { 2302*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ELEMENT_FAILED); 2303*7836SJohn.Forte@Sun.COM } 2304*7836SJohn.Forte@Sun.COM break; 2305*7836SJohn.Forte@Sun.COM default: 2306*7836SJohn.Forte@Sun.COM return (UNKNOWN); 2307*7836SJohn.Forte@Sun.COM } 2308*7836SJohn.Forte@Sun.COM 2309*7836SJohn.Forte@Sun.COM /* end isns object type */ 2310*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2311*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2312*7836SJohn.Forte@Sun.COM } 2313*7836SJohn.Forte@Sun.COM 2314*7836SJohn.Forte@Sun.COM /* End element "isnsRequest". */ 2315*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2316*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2317*7836SJohn.Forte@Sun.COM } 2318*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndDocument(writer) < 0) { 2319*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_DOC_FAILED); 2320*7836SJohn.Forte@Sun.COM } 2321*7836SJohn.Forte@Sun.COM 2322*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 2323*7836SJohn.Forte@Sun.COM 2324*7836SJohn.Forte@Sun.COM len = xmlStrlen(xbuf->content) + 1; 2325*7836SJohn.Forte@Sun.COM /* XXX - copy NULL at the end by having one more extra byte */ 2326*7836SJohn.Forte@Sun.COM if ((*doc = xmlStrndup(xbuf->content, len)) == NULL) { 2327*7836SJohn.Forte@Sun.COM return (ERROR_XML_STRDUP_FAILED); 2328*7836SJohn.Forte@Sun.COM } 2329*7836SJohn.Forte@Sun.COM 2330*7836SJohn.Forte@Sun.COM xmlBufferFree(xbuf); 2331*7836SJohn.Forte@Sun.COM return (0); 2332*7836SJohn.Forte@Sun.COM } 2333*7836SJohn.Forte@Sun.COM 2334*7836SJohn.Forte@Sun.COM /* 2335*7836SJohn.Forte@Sun.COM * **************************************************************************** 2336*7836SJohn.Forte@Sun.COM * 2337*7836SJohn.Forte@Sun.COM * build_get_xml_doc - 2338*7836SJohn.Forte@Sun.COM * build association request doc based the name. 2339*7836SJohn.Forte@Sun.COM * the resulted doc is passed in the doc ptr. 2340*7836SJohn.Forte@Sun.COM * 2341*7836SJohn.Forte@Sun.COM * name - object type 2342*7836SJohn.Forte@Sun.COM * assoc - association type 2343*7836SJohn.Forte@Sun.COM * doc - ptr to the resulted doc 2344*7836SJohn.Forte@Sun.COM * 2345*7836SJohn.Forte@Sun.COM * **************************************************************************** 2346*7836SJohn.Forte@Sun.COM */ 2347*7836SJohn.Forte@Sun.COM static int 2348*7836SJohn.Forte@Sun.COM build_get_xml_doc(int operandLen, char **operand, object_type obj, 2349*7836SJohn.Forte@Sun.COM xmlChar **doc) 2350*7836SJohn.Forte@Sun.COM { 2351*7836SJohn.Forte@Sun.COM xmlTextWriterPtr writer; 2352*7836SJohn.Forte@Sun.COM xmlBufferPtr xbuf; 2353*7836SJohn.Forte@Sun.COM int i, len; 2354*7836SJohn.Forte@Sun.COM 2355*7836SJohn.Forte@Sun.COM if ((xbuf = xmlBufferCreate()) == NULL) { 2356*7836SJohn.Forte@Sun.COM return (ERROR_XML_CREATE_BUFFER_FAILED); 2357*7836SJohn.Forte@Sun.COM } 2358*7836SJohn.Forte@Sun.COM 2359*7836SJohn.Forte@Sun.COM if ((writer = xmlNewTextWriterMemory(xbuf, 0)) == NULL) { 2360*7836SJohn.Forte@Sun.COM return (ERROR_XML_CREATE_WRITER_FAILED); 2361*7836SJohn.Forte@Sun.COM } 2362*7836SJohn.Forte@Sun.COM 2363*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartDocument(writer, "1.0", NULL, NULL) < 0) { 2364*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_DOC_FAILED); 2365*7836SJohn.Forte@Sun.COM } 2366*7836SJohn.Forte@Sun.COM 2367*7836SJohn.Forte@Sun.COM /* Start element "isnsRequest". */ 2368*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, (xmlChar *)ISNSREQUEST) < 0) { 2369*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2370*7836SJohn.Forte@Sun.COM } 2371*7836SJohn.Forte@Sun.COM 2372*7836SJohn.Forte@Sun.COM /* Start attr "xmlns". */ 2373*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 2374*7836SJohn.Forte@Sun.COM (xmlChar *)"xmlns", 2375*7836SJohn.Forte@Sun.COM (xmlChar *)"http://www.sun.com/schema/isnsmanagement")) { 2376*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 2377*7836SJohn.Forte@Sun.COM } 2378*7836SJohn.Forte@Sun.COM 2379*7836SJohn.Forte@Sun.COM /* Start element "get". */ 2380*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, (xmlChar *)GET) < 0) { 2381*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2382*7836SJohn.Forte@Sun.COM } 2383*7836SJohn.Forte@Sun.COM 2384*7836SJohn.Forte@Sun.COM switch (obj) { 2385*7836SJohn.Forte@Sun.COM case (Node): 2386*7836SJohn.Forte@Sun.COM for (i = 0; i < operandLen; i++) { 2387*7836SJohn.Forte@Sun.COM /* Start element "isnsObject". */ 2388*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2389*7836SJohn.Forte@Sun.COM (xmlChar *)ISNSOBJECT) < 0) { 2390*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2391*7836SJohn.Forte@Sun.COM } 2392*7836SJohn.Forte@Sun.COM 2393*7836SJohn.Forte@Sun.COM /* Start element Node. */ 2394*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2395*7836SJohn.Forte@Sun.COM (xmlChar *)NODEOBJECT) < 0) { 2396*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2397*7836SJohn.Forte@Sun.COM } 2398*7836SJohn.Forte@Sun.COM 2399*7836SJohn.Forte@Sun.COM /* Start attr "name". */ 2400*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 2401*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, (xmlChar *)operand[i]) < 0) { 2402*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 2403*7836SJohn.Forte@Sun.COM } 2404*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 2405*7836SJohn.Forte@Sun.COM (xmlChar *)TYPEATTR, (xmlChar *)EMPTYSTR) < 0) { 2406*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 2407*7836SJohn.Forte@Sun.COM } 2408*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 2409*7836SJohn.Forte@Sun.COM (xmlChar *)ALIASATTR, (xmlChar *)EMPTYSTR) < 0) { 2410*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 2411*7836SJohn.Forte@Sun.COM } 2412*7836SJohn.Forte@Sun.COM 2413*7836SJohn.Forte@Sun.COM /* End element "Node". */ 2414*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2415*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2416*7836SJohn.Forte@Sun.COM } 2417*7836SJohn.Forte@Sun.COM 2418*7836SJohn.Forte@Sun.COM /* End element "isnsObject". */ 2419*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2420*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2421*7836SJohn.Forte@Sun.COM } 2422*7836SJohn.Forte@Sun.COM } 2423*7836SJohn.Forte@Sun.COM break; 2424*7836SJohn.Forte@Sun.COM case (DiscoveryDomain): 2425*7836SJohn.Forte@Sun.COM for (i = 0; i < operandLen; i++) { 2426*7836SJohn.Forte@Sun.COM /* Start element "isnsObject". */ 2427*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2428*7836SJohn.Forte@Sun.COM (xmlChar *)ISNSOBJECT) < 0) { 2429*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2430*7836SJohn.Forte@Sun.COM } 2431*7836SJohn.Forte@Sun.COM 2432*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2433*7836SJohn.Forte@Sun.COM (xmlChar *)DDOBJECT) < 0) { 2434*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2435*7836SJohn.Forte@Sun.COM } 2436*7836SJohn.Forte@Sun.COM 2437*7836SJohn.Forte@Sun.COM /* Start attr "name". */ 2438*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 2439*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, (xmlChar *)operand[i]) < 0) { 2440*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 2441*7836SJohn.Forte@Sun.COM } 2442*7836SJohn.Forte@Sun.COM 2443*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomain". */ 2444*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2445*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2446*7836SJohn.Forte@Sun.COM } 2447*7836SJohn.Forte@Sun.COM 2448*7836SJohn.Forte@Sun.COM /* End element "isnsObject". */ 2449*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2450*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2451*7836SJohn.Forte@Sun.COM } 2452*7836SJohn.Forte@Sun.COM } 2453*7836SJohn.Forte@Sun.COM break; 2454*7836SJohn.Forte@Sun.COM case (DiscoveryDomainSet): 2455*7836SJohn.Forte@Sun.COM for (i = 0; i < operandLen; i++) { 2456*7836SJohn.Forte@Sun.COM /* Start element "isnsObject". */ 2457*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2458*7836SJohn.Forte@Sun.COM (xmlChar *)ISNSOBJECT) < 0) { 2459*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2460*7836SJohn.Forte@Sun.COM } 2461*7836SJohn.Forte@Sun.COM 2462*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2463*7836SJohn.Forte@Sun.COM (xmlChar *)DDSETOBJECT) < 0) { 2464*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2465*7836SJohn.Forte@Sun.COM } 2466*7836SJohn.Forte@Sun.COM 2467*7836SJohn.Forte@Sun.COM /* Start attr "name". */ 2468*7836SJohn.Forte@Sun.COM if (xmlTextWriterWriteAttribute(writer, 2469*7836SJohn.Forte@Sun.COM (xmlChar *)NAMEATTR, (xmlChar *)operand[i]) < 0) { 2470*7836SJohn.Forte@Sun.COM return (ERROR_XML_WRITE_ATTRIBUTE_FAILED); 2471*7836SJohn.Forte@Sun.COM } 2472*7836SJohn.Forte@Sun.COM 2473*7836SJohn.Forte@Sun.COM /* End element "DiscoveryDomain". */ 2474*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2475*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2476*7836SJohn.Forte@Sun.COM } 2477*7836SJohn.Forte@Sun.COM 2478*7836SJohn.Forte@Sun.COM /* End element "isnsObject". */ 2479*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2480*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2481*7836SJohn.Forte@Sun.COM } 2482*7836SJohn.Forte@Sun.COM } 2483*7836SJohn.Forte@Sun.COM break; 2484*7836SJohn.Forte@Sun.COM case (ServerConfig): 2485*7836SJohn.Forte@Sun.COM if (xmlTextWriterStartElement(writer, 2486*7836SJohn.Forte@Sun.COM (xmlChar *)ISNSSERVER) < 0) { 2487*7836SJohn.Forte@Sun.COM return (ERROR_XML_START_ELEMENT_FAILED); 2488*7836SJohn.Forte@Sun.COM } 2489*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2490*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2491*7836SJohn.Forte@Sun.COM } 2492*7836SJohn.Forte@Sun.COM break; 2493*7836SJohn.Forte@Sun.COM default: 2494*7836SJohn.Forte@Sun.COM return (UNKNOWN); 2495*7836SJohn.Forte@Sun.COM } 2496*7836SJohn.Forte@Sun.COM 2497*7836SJohn.Forte@Sun.COM /* End element "get". */ 2498*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2499*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2500*7836SJohn.Forte@Sun.COM } 2501*7836SJohn.Forte@Sun.COM /* End element "isnsRequest". */ 2502*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndElement(writer) < 0) { 2503*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_ELEMENT_FAILED); 2504*7836SJohn.Forte@Sun.COM } 2505*7836SJohn.Forte@Sun.COM if (xmlTextWriterEndDocument(writer) < 0) { 2506*7836SJohn.Forte@Sun.COM return (ERROR_XML_END_DOC_FAILED); 2507*7836SJohn.Forte@Sun.COM } 2508*7836SJohn.Forte@Sun.COM 2509*7836SJohn.Forte@Sun.COM xmlFreeTextWriter(writer); 2510*7836SJohn.Forte@Sun.COM 2511*7836SJohn.Forte@Sun.COM len = xmlStrlen(xbuf->content) + 1; 2512*7836SJohn.Forte@Sun.COM /* XXX - copy NULL at the end by having one more extra byte */ 2513*7836SJohn.Forte@Sun.COM if ((*doc = xmlStrndup(xbuf->content, len)) == NULL) { 2514*7836SJohn.Forte@Sun.COM return (ERROR_XML_STRDUP_FAILED); 2515*7836SJohn.Forte@Sun.COM } 2516*7836SJohn.Forte@Sun.COM 2517*7836SJohn.Forte@Sun.COM xmlBufferFree(xbuf); 2518*7836SJohn.Forte@Sun.COM return (0); 2519*7836SJohn.Forte@Sun.COM } 2520*7836SJohn.Forte@Sun.COM 2521*7836SJohn.Forte@Sun.COM /* 2522*7836SJohn.Forte@Sun.COM * **************************************************************************** 2523*7836SJohn.Forte@Sun.COM * 2524*7836SJohn.Forte@Sun.COM * list_node_func - 2525*7836SJohn.Forte@Sun.COM * isnsadm list-node [options] [<node name>, ...] 2526*7836SJohn.Forte@Sun.COM * 2527*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 2528*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 2529*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 2530*7836SJohn.Forte@Sun.COM * 2531*7836SJohn.Forte@Sun.COM * **************************************************************************** 2532*7836SJohn.Forte@Sun.COM */ 2533*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 2534*7836SJohn.Forte@Sun.COM static int 2535*7836SJohn.Forte@Sun.COM list_node_func(int operandLen, char *operand[], cmdOptions_t *options, 2536*7836SJohn.Forte@Sun.COM void *addarg) 2537*7836SJohn.Forte@Sun.COM { 2538*7836SJohn.Forte@Sun.COM 2539*7836SJohn.Forte@Sun.COM cmdOptions_t *optionList = options; 2540*7836SJohn.Forte@Sun.COM xmlChar *doc, *e_doc; 2541*7836SJohn.Forte@Sun.COM int ret; 2542*7836SJohn.Forte@Sun.COM door_arg_t darg; 2543*7836SJohn.Forte@Sun.COM int fd, flag = 0; 2544*7836SJohn.Forte@Sun.COM 2545*7836SJohn.Forte@Sun.COM for (; optionList->optval; optionList++) { 2546*7836SJohn.Forte@Sun.COM switch (optionList->optval) { 2547*7836SJohn.Forte@Sun.COM case 'i': 2548*7836SJohn.Forte@Sun.COM flag |= INITIATOR_ONLY; 2549*7836SJohn.Forte@Sun.COM break; 2550*7836SJohn.Forte@Sun.COM case 't': 2551*7836SJohn.Forte@Sun.COM flag |= TARGET_ONLY; 2552*7836SJohn.Forte@Sun.COM break; 2553*7836SJohn.Forte@Sun.COM case 'v': 2554*7836SJohn.Forte@Sun.COM flag |= VERBOSE; 2555*7836SJohn.Forte@Sun.COM break; 2556*7836SJohn.Forte@Sun.COM default: 2557*7836SJohn.Forte@Sun.COM return (UNKNOWN); 2558*7836SJohn.Forte@Sun.COM } 2559*7836SJohn.Forte@Sun.COM } 2560*7836SJohn.Forte@Sun.COM 2561*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 2562*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 2563*7836SJohn.Forte@Sun.COM return (ret); 2564*7836SJohn.Forte@Sun.COM } 2565*7836SJohn.Forte@Sun.COM 2566*7836SJohn.Forte@Sun.COM /* No operand specified. Issue enumerate. */ 2567*7836SJohn.Forte@Sun.COM if (operandLen == 0) { 2568*7836SJohn.Forte@Sun.COM ret = build_enumerate_xml_doc(Node, &doc); 2569*7836SJohn.Forte@Sun.COM if (ret != 0) { 2570*7836SJohn.Forte@Sun.COM (void) close(fd); 2571*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 2572*7836SJohn.Forte@Sun.COM return (ret); 2573*7836SJohn.Forte@Sun.COM } 2574*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 2575*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 2576*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 2577*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 2578*7836SJohn.Forte@Sun.COM darg.rsize = 0; 2579*7836SJohn.Forte@Sun.COM 2580*7836SJohn.Forte@Sun.COM if ((flag & VERBOSE) == VERBOSE) { 2581*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 2582*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 2583*7836SJohn.Forte@Sun.COM (void) close(fd); 2584*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2585*7836SJohn.Forte@Sun.COM return (ret); 2586*7836SJohn.Forte@Sun.COM } 2587*7836SJohn.Forte@Sun.COM 2588*7836SJohn.Forte@Sun.COM if ((ret = cvt_enumerate_rsp_to_get_req((xmlChar *)darg.rbuf, 2589*7836SJohn.Forte@Sun.COM &e_doc, Node, flag)) != 0) { 2590*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 2591*7836SJohn.Forte@Sun.COM (void) close(fd); 2592*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2593*7836SJohn.Forte@Sun.COM if (ret != SUCCESS_WITH_NO_OBJECT) { 2594*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 2595*7836SJohn.Forte@Sun.COM } else { 2596*7836SJohn.Forte@Sun.COM ret = SUBCOMMAND_SUCCESS; 2597*7836SJohn.Forte@Sun.COM } 2598*7836SJohn.Forte@Sun.COM return (ret); 2599*7836SJohn.Forte@Sun.COM } else { 2600*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 2601*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2602*7836SJohn.Forte@Sun.COM doc = e_doc; 2603*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (door_arg_t)); 2604*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 2605*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 2606*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 2607*7836SJohn.Forte@Sun.COM darg.rsize = 0; 2608*7836SJohn.Forte@Sun.COM } 2609*7836SJohn.Forte@Sun.COM } 2610*7836SJohn.Forte@Sun.COM } else { 2611*7836SJohn.Forte@Sun.COM if ((ret = build_get_xml_doc(operandLen, operand, Node, &doc)) == 2612*7836SJohn.Forte@Sun.COM 0) { 2613*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 2614*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 2615*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 2616*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 2617*7836SJohn.Forte@Sun.COM darg.rsize = 0; 2618*7836SJohn.Forte@Sun.COM } else { 2619*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 2620*7836SJohn.Forte@Sun.COM (void) close(fd); 2621*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2622*7836SJohn.Forte@Sun.COM return (ret); 2623*7836SJohn.Forte@Sun.COM } 2624*7836SJohn.Forte@Sun.COM } 2625*7836SJohn.Forte@Sun.COM 2626*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 2627*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 2628*7836SJohn.Forte@Sun.COM (void) close(fd); 2629*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2630*7836SJohn.Forte@Sun.COM return (ret); 2631*7836SJohn.Forte@Sun.COM } 2632*7836SJohn.Forte@Sun.COM 2633*7836SJohn.Forte@Sun.COM if ((ret = process_get_response(Node, (xmlChar *)darg.rbuf, flag)) != 2634*7836SJohn.Forte@Sun.COM 0) { 2635*7836SJohn.Forte@Sun.COM /* 2636*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager that rbuf. 2637*7836SJohn.Forte@Sun.COM * indicate if munmap is required on rbuf. 2638*7836SJohn.Forte@Sun.COM */ 2639*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 2640*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2641*7836SJohn.Forte@Sun.COM (void) close(fd); 2642*7836SJohn.Forte@Sun.COM return (ret); 2643*7836SJohn.Forte@Sun.COM } 2644*7836SJohn.Forte@Sun.COM 2645*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 2646*7836SJohn.Forte@Sun.COM (void) close(fd); 2647*7836SJohn.Forte@Sun.COM xmlFree(doc); 2648*7836SJohn.Forte@Sun.COM 2649*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 2650*7836SJohn.Forte@Sun.COM } 2651*7836SJohn.Forte@Sun.COM 2652*7836SJohn.Forte@Sun.COM /* 2653*7836SJohn.Forte@Sun.COM * **************************************************************************** 2654*7836SJohn.Forte@Sun.COM * 2655*7836SJohn.Forte@Sun.COM * list_dd_func - 2656*7836SJohn.Forte@Sun.COM * isnsadm list-dd [options] [<dd name>, ...] 2657*7836SJohn.Forte@Sun.COM * 2658*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 2659*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 2660*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 2661*7836SJohn.Forte@Sun.COM * 2662*7836SJohn.Forte@Sun.COM * **************************************************************************** 2663*7836SJohn.Forte@Sun.COM */ 2664*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 2665*7836SJohn.Forte@Sun.COM static int 2666*7836SJohn.Forte@Sun.COM list_dd_func(int operandLen, char *operand[], cmdOptions_t *options, 2667*7836SJohn.Forte@Sun.COM void *addarg) 2668*7836SJohn.Forte@Sun.COM { 2669*7836SJohn.Forte@Sun.COM cmdOptions_t *optionList = options; 2670*7836SJohn.Forte@Sun.COM xmlChar *doc, *e_doc; 2671*7836SJohn.Forte@Sun.COM int ret; 2672*7836SJohn.Forte@Sun.COM door_arg_t darg; 2673*7836SJohn.Forte@Sun.COM int fd, flag = 0; 2674*7836SJohn.Forte@Sun.COM 2675*7836SJohn.Forte@Sun.COM for (; optionList->optval; optionList++) { 2676*7836SJohn.Forte@Sun.COM switch (optionList->optval) { 2677*7836SJohn.Forte@Sun.COM case 'v': 2678*7836SJohn.Forte@Sun.COM flag |= VERBOSE; 2679*7836SJohn.Forte@Sun.COM break; 2680*7836SJohn.Forte@Sun.COM } 2681*7836SJohn.Forte@Sun.COM } 2682*7836SJohn.Forte@Sun.COM 2683*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 2684*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 2685*7836SJohn.Forte@Sun.COM return (ret); 2686*7836SJohn.Forte@Sun.COM } 2687*7836SJohn.Forte@Sun.COM 2688*7836SJohn.Forte@Sun.COM /* No operand specified. Issue enumerate. */ 2689*7836SJohn.Forte@Sun.COM if (operandLen == 0) { 2690*7836SJohn.Forte@Sun.COM ret = build_enumerate_xml_doc(DiscoveryDomain, &doc); 2691*7836SJohn.Forte@Sun.COM if (ret != 0) { 2692*7836SJohn.Forte@Sun.COM (void) close(fd); 2693*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 2694*7836SJohn.Forte@Sun.COM return (ret); 2695*7836SJohn.Forte@Sun.COM } 2696*7836SJohn.Forte@Sun.COM /* get the enumerate resposne first. */ 2697*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 2698*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 2699*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 2700*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 2701*7836SJohn.Forte@Sun.COM darg.rsize = 0; 2702*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 2703*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 2704*7836SJohn.Forte@Sun.COM (void) close(fd); 2705*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2706*7836SJohn.Forte@Sun.COM return (ret); 2707*7836SJohn.Forte@Sun.COM } 2708*7836SJohn.Forte@Sun.COM if ((ret = cvt_enumerate_rsp_to_get_req((xmlChar *)darg.rbuf, 2709*7836SJohn.Forte@Sun.COM &e_doc, DiscoveryDomain, flag)) != 0) { 2710*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 2711*7836SJohn.Forte@Sun.COM (void) close(fd); 2712*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2713*7836SJohn.Forte@Sun.COM if (ret != SUCCESS_WITH_NO_OBJECT) { 2714*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 2715*7836SJohn.Forte@Sun.COM } else { 2716*7836SJohn.Forte@Sun.COM ret = SUBCOMMAND_SUCCESS; 2717*7836SJohn.Forte@Sun.COM } 2718*7836SJohn.Forte@Sun.COM return (ret); 2719*7836SJohn.Forte@Sun.COM } else { 2720*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 2721*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2722*7836SJohn.Forte@Sun.COM doc = e_doc; 2723*7836SJohn.Forte@Sun.COM } 2724*7836SJohn.Forte@Sun.COM } else { 2725*7836SJohn.Forte@Sun.COM if ((ret = build_get_xml_doc(operandLen, operand, 2726*7836SJohn.Forte@Sun.COM DiscoveryDomain, &doc)) != 0) { 2727*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 2728*7836SJohn.Forte@Sun.COM (void) close(fd); 2729*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2730*7836SJohn.Forte@Sun.COM return (ret); 2731*7836SJohn.Forte@Sun.COM } 2732*7836SJohn.Forte@Sun.COM } 2733*7836SJohn.Forte@Sun.COM 2734*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 2735*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 2736*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 2737*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 2738*7836SJohn.Forte@Sun.COM darg.rsize = 0; 2739*7836SJohn.Forte@Sun.COM 2740*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 2741*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 2742*7836SJohn.Forte@Sun.COM (void) close(fd); 2743*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2744*7836SJohn.Forte@Sun.COM return (ret); 2745*7836SJohn.Forte@Sun.COM } 2746*7836SJohn.Forte@Sun.COM 2747*7836SJohn.Forte@Sun.COM if ((ret = process_get_response(DiscoveryDomain, (xmlChar *)darg.rbuf, 2748*7836SJohn.Forte@Sun.COM flag)) != 0) { 2749*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 2750*7836SJohn.Forte@Sun.COM (void) close(fd); 2751*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2752*7836SJohn.Forte@Sun.COM return (ret); 2753*7836SJohn.Forte@Sun.COM } 2754*7836SJohn.Forte@Sun.COM 2755*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 2756*7836SJohn.Forte@Sun.COM 2757*7836SJohn.Forte@Sun.COM (void) close(fd); 2758*7836SJohn.Forte@Sun.COM xmlFree(doc); 2759*7836SJohn.Forte@Sun.COM 2760*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 2761*7836SJohn.Forte@Sun.COM } 2762*7836SJohn.Forte@Sun.COM 2763*7836SJohn.Forte@Sun.COM /* 2764*7836SJohn.Forte@Sun.COM * **************************************************************************** 2765*7836SJohn.Forte@Sun.COM * 2766*7836SJohn.Forte@Sun.COM * list_ddset_func - 2767*7836SJohn.Forte@Sun.COM * isnsadm list-dd-set [options] [<dd set name>, ...] 2768*7836SJohn.Forte@Sun.COM * 2769*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 2770*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 2771*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 2772*7836SJohn.Forte@Sun.COM * 2773*7836SJohn.Forte@Sun.COM * **************************************************************************** 2774*7836SJohn.Forte@Sun.COM */ 2775*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 2776*7836SJohn.Forte@Sun.COM static int 2777*7836SJohn.Forte@Sun.COM list_ddset_func(int operandLen, char *operand[], cmdOptions_t *options, 2778*7836SJohn.Forte@Sun.COM void *addarg) 2779*7836SJohn.Forte@Sun.COM { 2780*7836SJohn.Forte@Sun.COM cmdOptions_t *optionList = options; 2781*7836SJohn.Forte@Sun.COM xmlChar *doc, *e_doc; 2782*7836SJohn.Forte@Sun.COM msg_code_t ret; 2783*7836SJohn.Forte@Sun.COM door_arg_t darg; 2784*7836SJohn.Forte@Sun.COM int fd, flag = 0; 2785*7836SJohn.Forte@Sun.COM 2786*7836SJohn.Forte@Sun.COM for (; optionList->optval; optionList++) { 2787*7836SJohn.Forte@Sun.COM switch (optionList->optval) { 2788*7836SJohn.Forte@Sun.COM case 'v': 2789*7836SJohn.Forte@Sun.COM flag |= VERBOSE; 2790*7836SJohn.Forte@Sun.COM break; 2791*7836SJohn.Forte@Sun.COM } 2792*7836SJohn.Forte@Sun.COM } 2793*7836SJohn.Forte@Sun.COM 2794*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 2795*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 2796*7836SJohn.Forte@Sun.COM return (ret); 2797*7836SJohn.Forte@Sun.COM } 2798*7836SJohn.Forte@Sun.COM 2799*7836SJohn.Forte@Sun.COM /* No operand specified. Issue enumerate. */ 2800*7836SJohn.Forte@Sun.COM if (operandLen == 0) { 2801*7836SJohn.Forte@Sun.COM ret = build_enumerate_xml_doc(DiscoveryDomainSet, &doc); 2802*7836SJohn.Forte@Sun.COM if (ret != 0) { 2803*7836SJohn.Forte@Sun.COM (void) close(fd); 2804*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 2805*7836SJohn.Forte@Sun.COM return (ret); 2806*7836SJohn.Forte@Sun.COM } 2807*7836SJohn.Forte@Sun.COM /* get the enumerate resposne. */ 2808*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 2809*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 2810*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 2811*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 2812*7836SJohn.Forte@Sun.COM darg.rsize = 0; 2813*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 2814*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 2815*7836SJohn.Forte@Sun.COM (void) close(fd); 2816*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2817*7836SJohn.Forte@Sun.COM return (ret); 2818*7836SJohn.Forte@Sun.COM } 2819*7836SJohn.Forte@Sun.COM 2820*7836SJohn.Forte@Sun.COM if ((ret = cvt_enumerate_rsp_to_get_req((xmlChar *)darg.rbuf, 2821*7836SJohn.Forte@Sun.COM &e_doc, DiscoveryDomainSet, flag)) != 0) { 2822*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 2823*7836SJohn.Forte@Sun.COM (void) close(fd); 2824*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2825*7836SJohn.Forte@Sun.COM if (ret != SUCCESS_WITH_NO_OBJECT) { 2826*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 2827*7836SJohn.Forte@Sun.COM } else { 2828*7836SJohn.Forte@Sun.COM ret = SUBCOMMAND_SUCCESS; 2829*7836SJohn.Forte@Sun.COM } 2830*7836SJohn.Forte@Sun.COM return (ret); 2831*7836SJohn.Forte@Sun.COM } else { 2832*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 2833*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2834*7836SJohn.Forte@Sun.COM doc = e_doc; 2835*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 2836*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 2837*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 2838*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 2839*7836SJohn.Forte@Sun.COM darg.rsize = 0; 2840*7836SJohn.Forte@Sun.COM } 2841*7836SJohn.Forte@Sun.COM } else { 2842*7836SJohn.Forte@Sun.COM if ((ret = build_get_xml_doc(operandLen, operand, 2843*7836SJohn.Forte@Sun.COM DiscoveryDomainSet, &doc)) == 0) { 2844*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 2845*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 2846*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 2847*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 2848*7836SJohn.Forte@Sun.COM darg.rsize = 0; 2849*7836SJohn.Forte@Sun.COM } else { 2850*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 2851*7836SJohn.Forte@Sun.COM } 2852*7836SJohn.Forte@Sun.COM } 2853*7836SJohn.Forte@Sun.COM 2854*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 2855*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 2856*7836SJohn.Forte@Sun.COM (void) close(fd); 2857*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2858*7836SJohn.Forte@Sun.COM return (ret); 2859*7836SJohn.Forte@Sun.COM } 2860*7836SJohn.Forte@Sun.COM 2861*7836SJohn.Forte@Sun.COM /* 2862*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager that rbuf. 2863*7836SJohn.Forte@Sun.COM * indicate if munmap is required on rbuf. 2864*7836SJohn.Forte@Sun.COM */ 2865*7836SJohn.Forte@Sun.COM if ((ret = process_get_response(DiscoveryDomainSet, 2866*7836SJohn.Forte@Sun.COM (xmlChar *)darg.rbuf, flag)) != 0) { 2867*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 2868*7836SJohn.Forte@Sun.COM (void) close(fd); 2869*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2870*7836SJohn.Forte@Sun.COM return (ret); 2871*7836SJohn.Forte@Sun.COM } 2872*7836SJohn.Forte@Sun.COM 2873*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 2874*7836SJohn.Forte@Sun.COM (void) close(fd); 2875*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2876*7836SJohn.Forte@Sun.COM 2877*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 2878*7836SJohn.Forte@Sun.COM } 2879*7836SJohn.Forte@Sun.COM 2880*7836SJohn.Forte@Sun.COM /* 2881*7836SJohn.Forte@Sun.COM * **************************************************************************** 2882*7836SJohn.Forte@Sun.COM * 2883*7836SJohn.Forte@Sun.COM * create_dd_func - 2884*7836SJohn.Forte@Sun.COM * create a DiscoveryDomain create-dd <dd name>, ... 2885*7836SJohn.Forte@Sun.COM * 2886*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 2887*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 2888*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 2889*7836SJohn.Forte@Sun.COM * 2890*7836SJohn.Forte@Sun.COM * **************************************************************************** 2891*7836SJohn.Forte@Sun.COM */ 2892*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 2893*7836SJohn.Forte@Sun.COM static int 2894*7836SJohn.Forte@Sun.COM create_dd_func(int operandLen, char *operand[], cmdOptions_t *options, 2895*7836SJohn.Forte@Sun.COM void *addarg) 2896*7836SJohn.Forte@Sun.COM { 2897*7836SJohn.Forte@Sun.COM xmlChar *doc; 2898*7836SJohn.Forte@Sun.COM msg_code_t ret; 2899*7836SJohn.Forte@Sun.COM door_arg_t darg; 2900*7836SJohn.Forte@Sun.COM int fd; 2901*7836SJohn.Forte@Sun.COM 2902*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 2903*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 2904*7836SJohn.Forte@Sun.COM return (ret); 2905*7836SJohn.Forte@Sun.COM } 2906*7836SJohn.Forte@Sun.COM 2907*7836SJohn.Forte@Sun.COM if ((ret = build_create_xml_doc(operandLen, operand, 2908*7836SJohn.Forte@Sun.COM DiscoveryDomain, NULL, &doc)) == 0) { 2909*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 2910*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 2911*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 2912*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 2913*7836SJohn.Forte@Sun.COM darg.rsize = 0; 2914*7836SJohn.Forte@Sun.COM } else { 2915*7836SJohn.Forte@Sun.COM (void) close(fd); 2916*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 2917*7836SJohn.Forte@Sun.COM return (ret); 2918*7836SJohn.Forte@Sun.COM } 2919*7836SJohn.Forte@Sun.COM 2920*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 2921*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 2922*7836SJohn.Forte@Sun.COM (void) close(fd); 2923*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2924*7836SJohn.Forte@Sun.COM return (ret); 2925*7836SJohn.Forte@Sun.COM } 2926*7836SJohn.Forte@Sun.COM 2927*7836SJohn.Forte@Sun.COM /* 2928*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager that rbuf. 2929*7836SJohn.Forte@Sun.COM * indicate if munmap is required on rbuf. 2930*7836SJohn.Forte@Sun.COM */ 2931*7836SJohn.Forte@Sun.COM if ((ret = process_result_response((xmlChar *)darg.rbuf, 2932*7836SJohn.Forte@Sun.COM DiscoveryDomain)) != 0) { 2933*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 2934*7836SJohn.Forte@Sun.COM (void) close(fd); 2935*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2936*7836SJohn.Forte@Sun.COM return (ret); 2937*7836SJohn.Forte@Sun.COM } 2938*7836SJohn.Forte@Sun.COM 2939*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 2940*7836SJohn.Forte@Sun.COM (void) close(fd); 2941*7836SJohn.Forte@Sun.COM xmlFree(doc); 2942*7836SJohn.Forte@Sun.COM 2943*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 2944*7836SJohn.Forte@Sun.COM } 2945*7836SJohn.Forte@Sun.COM 2946*7836SJohn.Forte@Sun.COM /* 2947*7836SJohn.Forte@Sun.COM * **************************************************************************** 2948*7836SJohn.Forte@Sun.COM * 2949*7836SJohn.Forte@Sun.COM * create_ddset_func - 2950*7836SJohn.Forte@Sun.COM * create a DiscoveryDomainSet create-dd-set <dd set name>, ... 2951*7836SJohn.Forte@Sun.COM * 2952*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 2953*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 2954*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 2955*7836SJohn.Forte@Sun.COM * 2956*7836SJohn.Forte@Sun.COM * **************************************************************************** 2957*7836SJohn.Forte@Sun.COM */ 2958*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 2959*7836SJohn.Forte@Sun.COM static int 2960*7836SJohn.Forte@Sun.COM create_ddset_func(int operandLen, char *operand[], cmdOptions_t *options, 2961*7836SJohn.Forte@Sun.COM void *addarg) 2962*7836SJohn.Forte@Sun.COM { 2963*7836SJohn.Forte@Sun.COM xmlChar *doc; 2964*7836SJohn.Forte@Sun.COM msg_code_t ret; 2965*7836SJohn.Forte@Sun.COM door_arg_t darg; 2966*7836SJohn.Forte@Sun.COM int fd; 2967*7836SJohn.Forte@Sun.COM 2968*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 2969*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 2970*7836SJohn.Forte@Sun.COM return (ret); 2971*7836SJohn.Forte@Sun.COM } 2972*7836SJohn.Forte@Sun.COM 2973*7836SJohn.Forte@Sun.COM if ((ret = build_create_xml_doc(operandLen, operand, 2974*7836SJohn.Forte@Sun.COM DiscoveryDomainSet, NULL, &doc)) == 0) { 2975*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 2976*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 2977*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 2978*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 2979*7836SJohn.Forte@Sun.COM darg.rsize = 0; 2980*7836SJohn.Forte@Sun.COM } else { 2981*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 2982*7836SJohn.Forte@Sun.COM (void) close(fd); 2983*7836SJohn.Forte@Sun.COM return (ret); 2984*7836SJohn.Forte@Sun.COM } 2985*7836SJohn.Forte@Sun.COM 2986*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 2987*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 2988*7836SJohn.Forte@Sun.COM (void) close(fd); 2989*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 2990*7836SJohn.Forte@Sun.COM return (ret); 2991*7836SJohn.Forte@Sun.COM } 2992*7836SJohn.Forte@Sun.COM 2993*7836SJohn.Forte@Sun.COM /* 2994*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager that rbuf. 2995*7836SJohn.Forte@Sun.COM * indicate if munmap is required on rbuf. 2996*7836SJohn.Forte@Sun.COM */ 2997*7836SJohn.Forte@Sun.COM if ((ret = process_result_response((xmlChar *)darg.rbuf, 2998*7836SJohn.Forte@Sun.COM DiscoveryDomainSet)) != 0) { 2999*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3000*7836SJohn.Forte@Sun.COM (void) close(fd); 3001*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3002*7836SJohn.Forte@Sun.COM return (ret); 3003*7836SJohn.Forte@Sun.COM } 3004*7836SJohn.Forte@Sun.COM 3005*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3006*7836SJohn.Forte@Sun.COM 3007*7836SJohn.Forte@Sun.COM (void) close(fd); 3008*7836SJohn.Forte@Sun.COM xmlFree(doc); 3009*7836SJohn.Forte@Sun.COM 3010*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 3011*7836SJohn.Forte@Sun.COM } 3012*7836SJohn.Forte@Sun.COM 3013*7836SJohn.Forte@Sun.COM /* 3014*7836SJohn.Forte@Sun.COM * **************************************************************************** 3015*7836SJohn.Forte@Sun.COM * 3016*7836SJohn.Forte@Sun.COM * modify_dd_func - 3017*7836SJohn.Forte@Sun.COM * Modify a dd attr. currently rename function is supported 3018*7836SJohn.Forte@Sun.COM * modify-dd -n name <dd name> 3019*7836SJohn.Forte@Sun.COM * 3020*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 3021*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 3022*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 3023*7836SJohn.Forte@Sun.COM * 3024*7836SJohn.Forte@Sun.COM * **************************************************************************** 3025*7836SJohn.Forte@Sun.COM */ 3026*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 3027*7836SJohn.Forte@Sun.COM static int 3028*7836SJohn.Forte@Sun.COM modify_dd_func(int operandLen, char *operand[], cmdOptions_t *options, 3029*7836SJohn.Forte@Sun.COM void *addarg) 3030*7836SJohn.Forte@Sun.COM { 3031*7836SJohn.Forte@Sun.COM xmlChar *doc; 3032*7836SJohn.Forte@Sun.COM xmlTextReaderPtr reader; 3033*7836SJohn.Forte@Sun.COM msg_code_t ret; 3034*7836SJohn.Forte@Sun.COM door_arg_t darg; 3035*7836SJohn.Forte@Sun.COM int fd, m_flag = 0; 3036*7836SJohn.Forte@Sun.COM uint32_t id; 3037*7836SJohn.Forte@Sun.COM 3038*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 3039*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 3040*7836SJohn.Forte@Sun.COM return (ret); 3041*7836SJohn.Forte@Sun.COM } 3042*7836SJohn.Forte@Sun.COM 3043*7836SJohn.Forte@Sun.COM if ((ret = build_get_xml_doc(operandLen, operand, 3044*7836SJohn.Forte@Sun.COM DiscoveryDomain, &doc)) == 0) { 3045*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 3046*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 3047*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 3048*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 3049*7836SJohn.Forte@Sun.COM darg.rsize = 0; 3050*7836SJohn.Forte@Sun.COM } else { 3051*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 3052*7836SJohn.Forte@Sun.COM (void) close(fd); 3053*7836SJohn.Forte@Sun.COM return (ret); 3054*7836SJohn.Forte@Sun.COM } 3055*7836SJohn.Forte@Sun.COM 3056*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 3057*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 3058*7836SJohn.Forte@Sun.COM (void) close(fd); 3059*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3060*7836SJohn.Forte@Sun.COM return (ret); 3061*7836SJohn.Forte@Sun.COM } 3062*7836SJohn.Forte@Sun.COM 3063*7836SJohn.Forte@Sun.COM /* Free the request that is created by xmlStrnDup. */ 3064*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3065*7836SJohn.Forte@Sun.COM 3066*7836SJohn.Forte@Sun.COM /* 3067*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager that rbuf. 3068*7836SJohn.Forte@Sun.COM * indicate if munmap is required on rbuf. 3069*7836SJohn.Forte@Sun.COM */ 3070*7836SJohn.Forte@Sun.COM if ((ret = process_result_response((xmlChar *)darg.rbuf, 3071*7836SJohn.Forte@Sun.COM DiscoveryDomain)) != 0) { 3072*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3073*7836SJohn.Forte@Sun.COM (void) close(fd); 3074*7836SJohn.Forte@Sun.COM return (ret); 3075*7836SJohn.Forte@Sun.COM } 3076*7836SJohn.Forte@Sun.COM 3077*7836SJohn.Forte@Sun.COM /* setup xml parser on the response. */ 3078*7836SJohn.Forte@Sun.COM if ((reader = (xmlTextReaderPtr)xmlReaderForMemory 3079*7836SJohn.Forte@Sun.COM ((const char *)darg.rbuf, xmlStrlen((xmlChar *)darg.rbuf), 3080*7836SJohn.Forte@Sun.COM NULL, NULL, 0)) == NULL) { 3081*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3082*7836SJohn.Forte@Sun.COM (void) close(fd); 3083*7836SJohn.Forte@Sun.COM return (ERROR_XML_READER_NULL); 3084*7836SJohn.Forte@Sun.COM } 3085*7836SJohn.Forte@Sun.COM 3086*7836SJohn.Forte@Sun.COM if (reader = lookup_next_matching_elem(reader, &m_flag, DDOBJECT, 3087*7836SJohn.Forte@Sun.COM ISNSRESPONSE)) { 3088*7836SJohn.Forte@Sun.COM if (m_flag == READER_MATCH) { 3089*7836SJohn.Forte@Sun.COM if ((xmlTextReaderMoveToAttribute(reader, 3090*7836SJohn.Forte@Sun.COM (const xmlChar *)IDATTR)) == 1) { 3091*7836SJohn.Forte@Sun.COM id = atoi((const char *)xmlTextReaderConstValue(reader)); 3092*7836SJohn.Forte@Sun.COM } else { 3093*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 3094*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 3095*7836SJohn.Forte@Sun.COM return (ERROR_XML_ID_ATTR_NOT_FOUND); 3096*7836SJohn.Forte@Sun.COM } 3097*7836SJohn.Forte@Sun.COM } else { 3098*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 3099*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 3100*7836SJohn.Forte@Sun.COM return (ERROR_XML_DD_OBJECT_NOT_FOUND); 3101*7836SJohn.Forte@Sun.COM } 3102*7836SJohn.Forte@Sun.COM } else { 3103*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 3104*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_XML_READER_NULL)); 3105*7836SJohn.Forte@Sun.COM return (ERROR_XML_READER_NULL); 3106*7836SJohn.Forte@Sun.COM } 3107*7836SJohn.Forte@Sun.COM 3108*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 3109*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 3110*7836SJohn.Forte@Sun.COM 3111*7836SJohn.Forte@Sun.COM if ((ret = build_rename_xml_doc(options->optarg, DiscoveryDomain, 3112*7836SJohn.Forte@Sun.COM id, &doc)) == 0) { 3113*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 3114*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 3115*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 3116*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 3117*7836SJohn.Forte@Sun.COM darg.rsize = 0; 3118*7836SJohn.Forte@Sun.COM } else { 3119*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 3120*7836SJohn.Forte@Sun.COM (void) close(fd); 3121*7836SJohn.Forte@Sun.COM return (ret); 3122*7836SJohn.Forte@Sun.COM } 3123*7836SJohn.Forte@Sun.COM 3124*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 3125*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 3126*7836SJohn.Forte@Sun.COM (void) close(fd); 3127*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3128*7836SJohn.Forte@Sun.COM return (ret); 3129*7836SJohn.Forte@Sun.COM } 3130*7836SJohn.Forte@Sun.COM 3131*7836SJohn.Forte@Sun.COM /* 3132*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager that rbuf. 3133*7836SJohn.Forte@Sun.COM * indicate if munmap is required on rbuf. 3134*7836SJohn.Forte@Sun.COM */ 3135*7836SJohn.Forte@Sun.COM if ((ret = process_result_response((xmlChar *)darg.rbuf, 3136*7836SJohn.Forte@Sun.COM DiscoveryDomain)) != 0) { 3137*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3138*7836SJohn.Forte@Sun.COM (void) close(fd); 3139*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3140*7836SJohn.Forte@Sun.COM return (ret); 3141*7836SJohn.Forte@Sun.COM } 3142*7836SJohn.Forte@Sun.COM 3143*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3144*7836SJohn.Forte@Sun.COM (void) close(fd); 3145*7836SJohn.Forte@Sun.COM xmlFree(doc); 3146*7836SJohn.Forte@Sun.COM 3147*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 3148*7836SJohn.Forte@Sun.COM } 3149*7836SJohn.Forte@Sun.COM 3150*7836SJohn.Forte@Sun.COM /* 3151*7836SJohn.Forte@Sun.COM * **************************************************************************** 3152*7836SJohn.Forte@Sun.COM * 3153*7836SJohn.Forte@Sun.COM * modify_ddset_func - 3154*7836SJohn.Forte@Sun.COM * Modify a dd attr. currently rename function is supported 3155*7836SJohn.Forte@Sun.COM * modify-dd-set -n name <dd name> 3156*7836SJohn.Forte@Sun.COM * 3157*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 3158*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 3159*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 3160*7836SJohn.Forte@Sun.COM * 3161*7836SJohn.Forte@Sun.COM * **************************************************************************** 3162*7836SJohn.Forte@Sun.COM */ 3163*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 3164*7836SJohn.Forte@Sun.COM static int 3165*7836SJohn.Forte@Sun.COM modify_ddset_func(int operandLen, char *operand[], cmdOptions_t *options, 3166*7836SJohn.Forte@Sun.COM void *addarg) 3167*7836SJohn.Forte@Sun.COM { 3168*7836SJohn.Forte@Sun.COM xmlChar *doc; 3169*7836SJohn.Forte@Sun.COM xmlTextReaderPtr reader; 3170*7836SJohn.Forte@Sun.COM msg_code_t ret; 3171*7836SJohn.Forte@Sun.COM door_arg_t darg; 3172*7836SJohn.Forte@Sun.COM int fd, m_flag = 0; 3173*7836SJohn.Forte@Sun.COM uint32_t id; 3174*7836SJohn.Forte@Sun.COM 3175*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 3176*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 3177*7836SJohn.Forte@Sun.COM return (ret); 3178*7836SJohn.Forte@Sun.COM } 3179*7836SJohn.Forte@Sun.COM 3180*7836SJohn.Forte@Sun.COM if ((ret = build_get_xml_doc(operandLen, operand, 3181*7836SJohn.Forte@Sun.COM DiscoveryDomainSet, &doc)) == 0) { 3182*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 3183*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 3184*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 3185*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 3186*7836SJohn.Forte@Sun.COM darg.rsize = 0; 3187*7836SJohn.Forte@Sun.COM } else { 3188*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 3189*7836SJohn.Forte@Sun.COM (void) close(fd); 3190*7836SJohn.Forte@Sun.COM return (ret); 3191*7836SJohn.Forte@Sun.COM } 3192*7836SJohn.Forte@Sun.COM 3193*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 3194*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 3195*7836SJohn.Forte@Sun.COM (void) close(fd); 3196*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3197*7836SJohn.Forte@Sun.COM return (ret); 3198*7836SJohn.Forte@Sun.COM } 3199*7836SJohn.Forte@Sun.COM 3200*7836SJohn.Forte@Sun.COM /* Free the request that is created by xmlStrnDup. */ 3201*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3202*7836SJohn.Forte@Sun.COM 3203*7836SJohn.Forte@Sun.COM /* 3204*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager that rbuf. 3205*7836SJohn.Forte@Sun.COM * indicate if munmap is required on rbuf. 3206*7836SJohn.Forte@Sun.COM */ 3207*7836SJohn.Forte@Sun.COM if ((ret = process_result_response((xmlChar *)darg.rbuf, 3208*7836SJohn.Forte@Sun.COM DiscoveryDomainSet)) != 0) { 3209*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3210*7836SJohn.Forte@Sun.COM (void) close(fd); 3211*7836SJohn.Forte@Sun.COM return (ret); 3212*7836SJohn.Forte@Sun.COM } 3213*7836SJohn.Forte@Sun.COM 3214*7836SJohn.Forte@Sun.COM /* setup xml parser on the response. */ 3215*7836SJohn.Forte@Sun.COM if ((reader = (xmlTextReaderPtr)xmlReaderForMemory 3216*7836SJohn.Forte@Sun.COM ((const char *)darg.rbuf, xmlStrlen((xmlChar *)darg.rbuf), 3217*7836SJohn.Forte@Sun.COM NULL, NULL, 0)) == NULL) { 3218*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3219*7836SJohn.Forte@Sun.COM (void) close(fd); 3220*7836SJohn.Forte@Sun.COM return (ERROR_XML_READER_NULL); 3221*7836SJohn.Forte@Sun.COM } 3222*7836SJohn.Forte@Sun.COM 3223*7836SJohn.Forte@Sun.COM if (reader = lookup_next_matching_elem(reader, &m_flag, DDSETOBJECT, 3224*7836SJohn.Forte@Sun.COM ISNSRESPONSE)) { 3225*7836SJohn.Forte@Sun.COM if (m_flag == READER_MATCH) { 3226*7836SJohn.Forte@Sun.COM if ((xmlTextReaderMoveToAttribute(reader, 3227*7836SJohn.Forte@Sun.COM (const xmlChar *)IDATTR)) == 1) { 3228*7836SJohn.Forte@Sun.COM id = atoi((const char *)xmlTextReaderConstValue(reader)); 3229*7836SJohn.Forte@Sun.COM } else { 3230*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 3231*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 3232*7836SJohn.Forte@Sun.COM return (ERROR_XML_ID_ATTR_NOT_FOUND); 3233*7836SJohn.Forte@Sun.COM } 3234*7836SJohn.Forte@Sun.COM } else { 3235*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 3236*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 3237*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", 3238*7836SJohn.Forte@Sun.COM getTextMessage(ERROR_XML_NAME_ATTR_NOT_FOUND)); 3239*7836SJohn.Forte@Sun.COM return (ERROR_XML_DD_SET_OBJECT_NOT_FOUND); 3240*7836SJohn.Forte@Sun.COM } 3241*7836SJohn.Forte@Sun.COM } 3242*7836SJohn.Forte@Sun.COM 3243*7836SJohn.Forte@Sun.COM (void) xmlTextReaderClose(reader); 3244*7836SJohn.Forte@Sun.COM (void) xmlFreeTextReader(reader); 3245*7836SJohn.Forte@Sun.COM 3246*7836SJohn.Forte@Sun.COM if ((ret = build_rename_xml_doc(options->optarg, DiscoveryDomainSet, 3247*7836SJohn.Forte@Sun.COM id, &doc)) == 0) { 3248*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 3249*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 3250*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 3251*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 3252*7836SJohn.Forte@Sun.COM darg.rsize = 0; 3253*7836SJohn.Forte@Sun.COM } else { 3254*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 3255*7836SJohn.Forte@Sun.COM (void) close(fd); 3256*7836SJohn.Forte@Sun.COM return (ret); 3257*7836SJohn.Forte@Sun.COM } 3258*7836SJohn.Forte@Sun.COM 3259*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 3260*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 3261*7836SJohn.Forte@Sun.COM (void) close(fd); 3262*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3263*7836SJohn.Forte@Sun.COM return (ret); 3264*7836SJohn.Forte@Sun.COM } 3265*7836SJohn.Forte@Sun.COM 3266*7836SJohn.Forte@Sun.COM /* 3267*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager that rbuf. 3268*7836SJohn.Forte@Sun.COM * indicate if munmap is required on rbuf. 3269*7836SJohn.Forte@Sun.COM */ 3270*7836SJohn.Forte@Sun.COM if ((ret = process_result_response((xmlChar *)darg.rbuf, 3271*7836SJohn.Forte@Sun.COM DiscoveryDomainSet)) != 0) { 3272*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3273*7836SJohn.Forte@Sun.COM (void) close(fd); 3274*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3275*7836SJohn.Forte@Sun.COM return (ret); 3276*7836SJohn.Forte@Sun.COM } 3277*7836SJohn.Forte@Sun.COM 3278*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3279*7836SJohn.Forte@Sun.COM (void) close(fd); 3280*7836SJohn.Forte@Sun.COM xmlFree(doc); 3281*7836SJohn.Forte@Sun.COM 3282*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 3283*7836SJohn.Forte@Sun.COM } 3284*7836SJohn.Forte@Sun.COM 3285*7836SJohn.Forte@Sun.COM /* 3286*7836SJohn.Forte@Sun.COM * **************************************************************************** 3287*7836SJohn.Forte@Sun.COM * 3288*7836SJohn.Forte@Sun.COM * add_node_func - 3289*7836SJohn.Forte@Sun.COM * Add a node to a DiscoveryDomain add-node -d dd-name <node name>, ... 3290*7836SJohn.Forte@Sun.COM * 3291*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 3292*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 3293*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 3294*7836SJohn.Forte@Sun.COM * 3295*7836SJohn.Forte@Sun.COM * **************************************************************************** 3296*7836SJohn.Forte@Sun.COM */ 3297*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 3298*7836SJohn.Forte@Sun.COM static int 3299*7836SJohn.Forte@Sun.COM add_node_func(int operandLen, char *operand[], cmdOptions_t *options, 3300*7836SJohn.Forte@Sun.COM void *addarg) 3301*7836SJohn.Forte@Sun.COM { 3302*7836SJohn.Forte@Sun.COM xmlChar *doc; 3303*7836SJohn.Forte@Sun.COM msg_code_t ret; 3304*7836SJohn.Forte@Sun.COM door_arg_t darg; 3305*7836SJohn.Forte@Sun.COM int fd; 3306*7836SJohn.Forte@Sun.COM 3307*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 3308*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 3309*7836SJohn.Forte@Sun.COM return (ret); 3310*7836SJohn.Forte@Sun.COM } 3311*7836SJohn.Forte@Sun.COM 3312*7836SJohn.Forte@Sun.COM if ((ret = build_create_xml_doc(operandLen, operand, 3313*7836SJohn.Forte@Sun.COM DiscoveryDomainMember, options->optarg, &doc)) == 0) { 3314*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 3315*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 3316*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 3317*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 3318*7836SJohn.Forte@Sun.COM darg.rsize = 0; 3319*7836SJohn.Forte@Sun.COM } else { 3320*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 3321*7836SJohn.Forte@Sun.COM (void) close(fd); 3322*7836SJohn.Forte@Sun.COM return (ret); 3323*7836SJohn.Forte@Sun.COM } 3324*7836SJohn.Forte@Sun.COM 3325*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 3326*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 3327*7836SJohn.Forte@Sun.COM (void) close(fd); 3328*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3329*7836SJohn.Forte@Sun.COM return (ret); 3330*7836SJohn.Forte@Sun.COM } 3331*7836SJohn.Forte@Sun.COM 3332*7836SJohn.Forte@Sun.COM /* 3333*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager that rbuf. 3334*7836SJohn.Forte@Sun.COM * indicate if munmap is required on rbuf. 3335*7836SJohn.Forte@Sun.COM */ 3336*7836SJohn.Forte@Sun.COM if ((ret = process_result_response((xmlChar *)darg.rbuf, 3337*7836SJohn.Forte@Sun.COM DiscoveryDomainMember)) != 0) { 3338*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3339*7836SJohn.Forte@Sun.COM (void) close(fd); 3340*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3341*7836SJohn.Forte@Sun.COM return (ret); 3342*7836SJohn.Forte@Sun.COM } 3343*7836SJohn.Forte@Sun.COM 3344*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3345*7836SJohn.Forte@Sun.COM (void) close(fd); 3346*7836SJohn.Forte@Sun.COM xmlFree(doc); 3347*7836SJohn.Forte@Sun.COM 3348*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 3349*7836SJohn.Forte@Sun.COM } 3350*7836SJohn.Forte@Sun.COM 3351*7836SJohn.Forte@Sun.COM /* 3352*7836SJohn.Forte@Sun.COM * **************************************************************************** 3353*7836SJohn.Forte@Sun.COM * 3354*7836SJohn.Forte@Sun.COM * add_dd_func - 3355*7836SJohn.Forte@Sun.COM * Add a dd to a DiscoveryDomainSet add-dd -s dd-set name <dd name>, ... 3356*7836SJohn.Forte@Sun.COM * 3357*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 3358*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 3359*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 3360*7836SJohn.Forte@Sun.COM * 3361*7836SJohn.Forte@Sun.COM * **************************************************************************** 3362*7836SJohn.Forte@Sun.COM */ 3363*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 3364*7836SJohn.Forte@Sun.COM static int 3365*7836SJohn.Forte@Sun.COM add_dd_func(int operandLen, char *operand[], cmdOptions_t *options, 3366*7836SJohn.Forte@Sun.COM void *addarg) 3367*7836SJohn.Forte@Sun.COM { 3368*7836SJohn.Forte@Sun.COM xmlChar *doc; 3369*7836SJohn.Forte@Sun.COM msg_code_t ret; 3370*7836SJohn.Forte@Sun.COM door_arg_t darg; 3371*7836SJohn.Forte@Sun.COM int fd; 3372*7836SJohn.Forte@Sun.COM 3373*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 3374*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 3375*7836SJohn.Forte@Sun.COM return (ret); 3376*7836SJohn.Forte@Sun.COM } 3377*7836SJohn.Forte@Sun.COM 3378*7836SJohn.Forte@Sun.COM if ((ret = build_create_xml_doc(operandLen, operand, 3379*7836SJohn.Forte@Sun.COM DiscoveryDomainSetMember, options->optarg, &doc)) == 0) { 3380*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 3381*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 3382*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 3383*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 3384*7836SJohn.Forte@Sun.COM darg.rsize = 0; 3385*7836SJohn.Forte@Sun.COM } else { 3386*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 3387*7836SJohn.Forte@Sun.COM (void) close(fd); 3388*7836SJohn.Forte@Sun.COM return (ret); 3389*7836SJohn.Forte@Sun.COM } 3390*7836SJohn.Forte@Sun.COM 3391*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 3392*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 3393*7836SJohn.Forte@Sun.COM (void) close(fd); 3394*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3395*7836SJohn.Forte@Sun.COM return (ret); 3396*7836SJohn.Forte@Sun.COM } 3397*7836SJohn.Forte@Sun.COM 3398*7836SJohn.Forte@Sun.COM /* 3399*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager that rbuf. 3400*7836SJohn.Forte@Sun.COM * indicate if munmap is required on rbuf. 3401*7836SJohn.Forte@Sun.COM */ 3402*7836SJohn.Forte@Sun.COM if ((ret = process_result_response((xmlChar *)darg.rbuf, 3403*7836SJohn.Forte@Sun.COM DiscoveryDomainSetMember)) != 0) { 3404*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3405*7836SJohn.Forte@Sun.COM (void) close(fd); 3406*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3407*7836SJohn.Forte@Sun.COM return (ret); 3408*7836SJohn.Forte@Sun.COM } 3409*7836SJohn.Forte@Sun.COM 3410*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3411*7836SJohn.Forte@Sun.COM (void) close(fd); 3412*7836SJohn.Forte@Sun.COM xmlFree(doc); 3413*7836SJohn.Forte@Sun.COM 3414*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 3415*7836SJohn.Forte@Sun.COM } 3416*7836SJohn.Forte@Sun.COM 3417*7836SJohn.Forte@Sun.COM /* 3418*7836SJohn.Forte@Sun.COM * **************************************************************************** 3419*7836SJohn.Forte@Sun.COM * 3420*7836SJohn.Forte@Sun.COM * remove_node_func - 3421*7836SJohn.Forte@Sun.COM * Remove a node from DiscoveryDomain 3422*7836SJohn.Forte@Sun.COM * remov-node -d dd-name <node name>, ... 3423*7836SJohn.Forte@Sun.COM * 3424*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 3425*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 3426*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 3427*7836SJohn.Forte@Sun.COM * 3428*7836SJohn.Forte@Sun.COM * **************************************************************************** 3429*7836SJohn.Forte@Sun.COM */ 3430*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 3431*7836SJohn.Forte@Sun.COM static int 3432*7836SJohn.Forte@Sun.COM remove_node_func(int operandLen, char *operand[], cmdOptions_t *options, 3433*7836SJohn.Forte@Sun.COM void *addarg) 3434*7836SJohn.Forte@Sun.COM { 3435*7836SJohn.Forte@Sun.COM xmlChar *doc; 3436*7836SJohn.Forte@Sun.COM msg_code_t ret; 3437*7836SJohn.Forte@Sun.COM door_arg_t darg; 3438*7836SJohn.Forte@Sun.COM int fd; 3439*7836SJohn.Forte@Sun.COM 3440*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 3441*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 3442*7836SJohn.Forte@Sun.COM return (ret); 3443*7836SJohn.Forte@Sun.COM } 3444*7836SJohn.Forte@Sun.COM 3445*7836SJohn.Forte@Sun.COM if ((ret = build_delete_xml_doc(operandLen, operand, 3446*7836SJohn.Forte@Sun.COM DiscoveryDomainMember, options->optarg, &doc)) == 0) { 3447*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 3448*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 3449*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 3450*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 3451*7836SJohn.Forte@Sun.COM darg.rsize = 0; 3452*7836SJohn.Forte@Sun.COM } else { 3453*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 3454*7836SJohn.Forte@Sun.COM (void) close(fd); 3455*7836SJohn.Forte@Sun.COM return (ret); 3456*7836SJohn.Forte@Sun.COM } 3457*7836SJohn.Forte@Sun.COM 3458*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 3459*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 3460*7836SJohn.Forte@Sun.COM (void) close(fd); 3461*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3462*7836SJohn.Forte@Sun.COM return (ret); 3463*7836SJohn.Forte@Sun.COM } 3464*7836SJohn.Forte@Sun.COM 3465*7836SJohn.Forte@Sun.COM /* 3466*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager that rbuf. 3467*7836SJohn.Forte@Sun.COM * indicate if munmap is required on rbuf. 3468*7836SJohn.Forte@Sun.COM */ 3469*7836SJohn.Forte@Sun.COM if ((ret = process_result_response((xmlChar *)darg.rbuf, 3470*7836SJohn.Forte@Sun.COM DiscoveryDomainMember)) != 0) { 3471*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3472*7836SJohn.Forte@Sun.COM (void) close(fd); 3473*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3474*7836SJohn.Forte@Sun.COM return (ret); 3475*7836SJohn.Forte@Sun.COM } 3476*7836SJohn.Forte@Sun.COM 3477*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3478*7836SJohn.Forte@Sun.COM (void) close(fd); 3479*7836SJohn.Forte@Sun.COM xmlFree(doc); 3480*7836SJohn.Forte@Sun.COM 3481*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 3482*7836SJohn.Forte@Sun.COM } 3483*7836SJohn.Forte@Sun.COM 3484*7836SJohn.Forte@Sun.COM /* 3485*7836SJohn.Forte@Sun.COM * **************************************************************************** 3486*7836SJohn.Forte@Sun.COM * 3487*7836SJohn.Forte@Sun.COM * remove_dd_func - 3488*7836SJohn.Forte@Sun.COM * Remove a dd from DiscoveryDomainSet 3489*7836SJohn.Forte@Sun.COM * remove-dd -s dd-set name <dd name>, ... 3490*7836SJohn.Forte@Sun.COM * 3491*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 3492*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 3493*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 3494*7836SJohn.Forte@Sun.COM * 3495*7836SJohn.Forte@Sun.COM * **************************************************************************** 3496*7836SJohn.Forte@Sun.COM */ 3497*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 3498*7836SJohn.Forte@Sun.COM static int 3499*7836SJohn.Forte@Sun.COM remove_dd_func(int operandLen, char *operand[], cmdOptions_t *options, 3500*7836SJohn.Forte@Sun.COM void *addarg) 3501*7836SJohn.Forte@Sun.COM { 3502*7836SJohn.Forte@Sun.COM xmlChar *doc; 3503*7836SJohn.Forte@Sun.COM msg_code_t ret; 3504*7836SJohn.Forte@Sun.COM door_arg_t darg; 3505*7836SJohn.Forte@Sun.COM int fd; 3506*7836SJohn.Forte@Sun.COM 3507*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 3508*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 3509*7836SJohn.Forte@Sun.COM return (ret); 3510*7836SJohn.Forte@Sun.COM } 3511*7836SJohn.Forte@Sun.COM 3512*7836SJohn.Forte@Sun.COM if ((ret = build_delete_xml_doc(operandLen, operand, 3513*7836SJohn.Forte@Sun.COM DiscoveryDomainSetMember, options->optarg, &doc)) == 0) { 3514*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 3515*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 3516*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 3517*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 3518*7836SJohn.Forte@Sun.COM darg.rsize = 0; 3519*7836SJohn.Forte@Sun.COM } else { 3520*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 3521*7836SJohn.Forte@Sun.COM (void) close(fd); 3522*7836SJohn.Forte@Sun.COM return (ret); 3523*7836SJohn.Forte@Sun.COM } 3524*7836SJohn.Forte@Sun.COM 3525*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 3526*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 3527*7836SJohn.Forte@Sun.COM (void) close(fd); 3528*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3529*7836SJohn.Forte@Sun.COM return (ret); 3530*7836SJohn.Forte@Sun.COM } 3531*7836SJohn.Forte@Sun.COM 3532*7836SJohn.Forte@Sun.COM /* 3533*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager that rbuf. 3534*7836SJohn.Forte@Sun.COM * indicate if munmap is required on rbuf. 3535*7836SJohn.Forte@Sun.COM */ 3536*7836SJohn.Forte@Sun.COM if ((ret = process_result_response((xmlChar *)darg.rbuf, 3537*7836SJohn.Forte@Sun.COM DiscoveryDomainSetMember)) != 0) { 3538*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3539*7836SJohn.Forte@Sun.COM (void) close(fd); 3540*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3541*7836SJohn.Forte@Sun.COM return (ret); 3542*7836SJohn.Forte@Sun.COM } 3543*7836SJohn.Forte@Sun.COM 3544*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3545*7836SJohn.Forte@Sun.COM (void) close(fd); 3546*7836SJohn.Forte@Sun.COM xmlFree(doc); 3547*7836SJohn.Forte@Sun.COM 3548*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 3549*7836SJohn.Forte@Sun.COM } 3550*7836SJohn.Forte@Sun.COM 3551*7836SJohn.Forte@Sun.COM /* 3552*7836SJohn.Forte@Sun.COM * **************************************************************************** 3553*7836SJohn.Forte@Sun.COM * 3554*7836SJohn.Forte@Sun.COM * delete_dd_func - 3555*7836SJohn.Forte@Sun.COM * remove a DiscoveryDomain remove-dd <dd name>, ... 3556*7836SJohn.Forte@Sun.COM * 3557*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 3558*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 3559*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 3560*7836SJohn.Forte@Sun.COM * 3561*7836SJohn.Forte@Sun.COM * **************************************************************************** 3562*7836SJohn.Forte@Sun.COM */ 3563*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 3564*7836SJohn.Forte@Sun.COM static int 3565*7836SJohn.Forte@Sun.COM delete_dd_func(int operandLen, char *operand[], cmdOptions_t *options, 3566*7836SJohn.Forte@Sun.COM void *addarg) 3567*7836SJohn.Forte@Sun.COM { 3568*7836SJohn.Forte@Sun.COM xmlChar *doc; 3569*7836SJohn.Forte@Sun.COM msg_code_t ret; 3570*7836SJohn.Forte@Sun.COM door_arg_t darg; 3571*7836SJohn.Forte@Sun.COM int fd; 3572*7836SJohn.Forte@Sun.COM 3573*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 3574*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 3575*7836SJohn.Forte@Sun.COM return (ret); 3576*7836SJohn.Forte@Sun.COM } 3577*7836SJohn.Forte@Sun.COM 3578*7836SJohn.Forte@Sun.COM if ((ret = build_delete_xml_doc(operandLen, operand, 3579*7836SJohn.Forte@Sun.COM DiscoveryDomain, NULL, &doc)) == 0) { 3580*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 3581*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 3582*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 3583*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 3584*7836SJohn.Forte@Sun.COM darg.rsize = 0; 3585*7836SJohn.Forte@Sun.COM } else { 3586*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 3587*7836SJohn.Forte@Sun.COM (void) close(fd); 3588*7836SJohn.Forte@Sun.COM return (ret); 3589*7836SJohn.Forte@Sun.COM } 3590*7836SJohn.Forte@Sun.COM 3591*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 3592*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 3593*7836SJohn.Forte@Sun.COM (void) close(fd); 3594*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3595*7836SJohn.Forte@Sun.COM return (ret); 3596*7836SJohn.Forte@Sun.COM } 3597*7836SJohn.Forte@Sun.COM 3598*7836SJohn.Forte@Sun.COM /* 3599*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager that rbuf. 3600*7836SJohn.Forte@Sun.COM * indicate if munmap is required on rbuf. 3601*7836SJohn.Forte@Sun.COM */ 3602*7836SJohn.Forte@Sun.COM if ((ret = process_result_response((xmlChar *)darg.rbuf, 3603*7836SJohn.Forte@Sun.COM DiscoveryDomain)) != 0) { 3604*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3605*7836SJohn.Forte@Sun.COM (void) close(fd); 3606*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3607*7836SJohn.Forte@Sun.COM return (ret); 3608*7836SJohn.Forte@Sun.COM } 3609*7836SJohn.Forte@Sun.COM 3610*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3611*7836SJohn.Forte@Sun.COM 3612*7836SJohn.Forte@Sun.COM (void) close(fd); 3613*7836SJohn.Forte@Sun.COM xmlFree(doc); 3614*7836SJohn.Forte@Sun.COM 3615*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 3616*7836SJohn.Forte@Sun.COM } 3617*7836SJohn.Forte@Sun.COM 3618*7836SJohn.Forte@Sun.COM /* 3619*7836SJohn.Forte@Sun.COM * **************************************************************************** 3620*7836SJohn.Forte@Sun.COM * 3621*7836SJohn.Forte@Sun.COM * delete_ddset_func - 3622*7836SJohn.Forte@Sun.COM * delete DiscoveryDomainSet(s) delete-dd-set <dd set name>, ... 3623*7836SJohn.Forte@Sun.COM * 3624*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 3625*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 3626*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 3627*7836SJohn.Forte@Sun.COM * 3628*7836SJohn.Forte@Sun.COM * **************************************************************************** 3629*7836SJohn.Forte@Sun.COM */ 3630*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 3631*7836SJohn.Forte@Sun.COM static int 3632*7836SJohn.Forte@Sun.COM delete_ddset_func(int operandLen, char *operand[], cmdOptions_t *options, 3633*7836SJohn.Forte@Sun.COM void *addarg) 3634*7836SJohn.Forte@Sun.COM { 3635*7836SJohn.Forte@Sun.COM xmlChar *doc; 3636*7836SJohn.Forte@Sun.COM msg_code_t ret; 3637*7836SJohn.Forte@Sun.COM door_arg_t darg; 3638*7836SJohn.Forte@Sun.COM int fd; 3639*7836SJohn.Forte@Sun.COM 3640*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 3641*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 3642*7836SJohn.Forte@Sun.COM return (ret); 3643*7836SJohn.Forte@Sun.COM } 3644*7836SJohn.Forte@Sun.COM 3645*7836SJohn.Forte@Sun.COM if ((ret = build_delete_xml_doc(operandLen, operand, 3646*7836SJohn.Forte@Sun.COM DiscoveryDomainSet, NULL, &doc)) == 0) { 3647*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 3648*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 3649*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 3650*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 3651*7836SJohn.Forte@Sun.COM darg.rsize = 0; 3652*7836SJohn.Forte@Sun.COM } else { 3653*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 3654*7836SJohn.Forte@Sun.COM (void) close(fd); 3655*7836SJohn.Forte@Sun.COM return (ret); 3656*7836SJohn.Forte@Sun.COM } 3657*7836SJohn.Forte@Sun.COM 3658*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 3659*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 3660*7836SJohn.Forte@Sun.COM (void) close(fd); 3661*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3662*7836SJohn.Forte@Sun.COM return (ret); 3663*7836SJohn.Forte@Sun.COM } 3664*7836SJohn.Forte@Sun.COM 3665*7836SJohn.Forte@Sun.COM /* 3666*7836SJohn.Forte@Sun.COM * door frame work allocated a buffer when the date lager that rbuf. 3667*7836SJohn.Forte@Sun.COM * indicate if munmap is required on rbuf. 3668*7836SJohn.Forte@Sun.COM */ 3669*7836SJohn.Forte@Sun.COM if ((ret = process_result_response((xmlChar *)darg.rbuf, 3670*7836SJohn.Forte@Sun.COM DiscoveryDomainSet)) != 0) { 3671*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3672*7836SJohn.Forte@Sun.COM (void) close(fd); 3673*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3674*7836SJohn.Forte@Sun.COM return (ret); 3675*7836SJohn.Forte@Sun.COM } 3676*7836SJohn.Forte@Sun.COM 3677*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3678*7836SJohn.Forte@Sun.COM (void) close(fd); 3679*7836SJohn.Forte@Sun.COM xmlFree(doc); 3680*7836SJohn.Forte@Sun.COM 3681*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 3682*7836SJohn.Forte@Sun.COM } 3683*7836SJohn.Forte@Sun.COM 3684*7836SJohn.Forte@Sun.COM /* 3685*7836SJohn.Forte@Sun.COM * **************************************************************************** 3686*7836SJohn.Forte@Sun.COM * 3687*7836SJohn.Forte@Sun.COM * i_enableddset 3688*7836SJohn.Forte@Sun.COM * enables/disables DiscoveryDomainSet(s) 3689*7836SJohn.Forte@Sun.COM * 3690*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 3691*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 3692*7836SJohn.Forte@Sun.COM * enable - indication of enable/disable 3693*7836SJohn.Forte@Sun.COM * 3694*7836SJohn.Forte@Sun.COM * **************************************************************************** 3695*7836SJohn.Forte@Sun.COM */ 3696*7836SJohn.Forte@Sun.COM static int 3697*7836SJohn.Forte@Sun.COM i_enableddset(int operandLen, char *operand[], boolean_t enable) 3698*7836SJohn.Forte@Sun.COM { 3699*7836SJohn.Forte@Sun.COM xmlChar *doc; 3700*7836SJohn.Forte@Sun.COM door_arg_t darg; 3701*7836SJohn.Forte@Sun.COM int fd, ret = 0; 3702*7836SJohn.Forte@Sun.COM 3703*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 3704*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 3705*7836SJohn.Forte@Sun.COM return (ret); 3706*7836SJohn.Forte@Sun.COM } 3707*7836SJohn.Forte@Sun.COM 3708*7836SJohn.Forte@Sun.COM if ((ret = build_modify_xml_doc(operandLen, operand, 3709*7836SJohn.Forte@Sun.COM DiscoveryDomainSet, enable, &doc)) == 0) { 3710*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 3711*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 3712*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 3713*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 3714*7836SJohn.Forte@Sun.COM darg.rsize = 0; 3715*7836SJohn.Forte@Sun.COM } else { 3716*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 3717*7836SJohn.Forte@Sun.COM (void) close(fd); 3718*7836SJohn.Forte@Sun.COM return (ret); 3719*7836SJohn.Forte@Sun.COM } 3720*7836SJohn.Forte@Sun.COM 3721*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 3722*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 3723*7836SJohn.Forte@Sun.COM (void) close(fd); 3724*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3725*7836SJohn.Forte@Sun.COM return (ret); 3726*7836SJohn.Forte@Sun.COM } 3727*7836SJohn.Forte@Sun.COM 3728*7836SJohn.Forte@Sun.COM xmlFree(doc); 3729*7836SJohn.Forte@Sun.COM 3730*7836SJohn.Forte@Sun.COM if ((ret = process_result_response((xmlChar *)darg.rbuf, 3731*7836SJohn.Forte@Sun.COM DiscoveryDomainSet)) != 0) { 3732*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3733*7836SJohn.Forte@Sun.COM (void) close(fd); 3734*7836SJohn.Forte@Sun.COM return (ret); 3735*7836SJohn.Forte@Sun.COM } 3736*7836SJohn.Forte@Sun.COM 3737*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3738*7836SJohn.Forte@Sun.COM (void) close(fd); 3739*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 3740*7836SJohn.Forte@Sun.COM } 3741*7836SJohn.Forte@Sun.COM 3742*7836SJohn.Forte@Sun.COM /* 3743*7836SJohn.Forte@Sun.COM * **************************************************************************** 3744*7836SJohn.Forte@Sun.COM * 3745*7836SJohn.Forte@Sun.COM * enable_ddset_func - 3746*7836SJohn.Forte@Sun.COM * enables DiscoveryDomainSet(s) enable-dd-set <dd set name>, ... 3747*7836SJohn.Forte@Sun.COM * 3748*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 3749*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 3750*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 3751*7836SJohn.Forte@Sun.COM * 3752*7836SJohn.Forte@Sun.COM * **************************************************************************** 3753*7836SJohn.Forte@Sun.COM */ 3754*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 3755*7836SJohn.Forte@Sun.COM static int 3756*7836SJohn.Forte@Sun.COM enable_ddset_func(int operandLen, char *operand[], cmdOptions_t *options, 3757*7836SJohn.Forte@Sun.COM void *addarg) 3758*7836SJohn.Forte@Sun.COM { 3759*7836SJohn.Forte@Sun.COM return (i_enableddset(operandLen, operand, B_TRUE)); 3760*7836SJohn.Forte@Sun.COM } 3761*7836SJohn.Forte@Sun.COM 3762*7836SJohn.Forte@Sun.COM /* 3763*7836SJohn.Forte@Sun.COM * **************************************************************************** 3764*7836SJohn.Forte@Sun.COM * 3765*7836SJohn.Forte@Sun.COM * disabledsetFunc - 3766*7836SJohn.Forte@Sun.COM * disable DiscoveryDomainSet(s) disable-dd-set <dd set name>, ... 3767*7836SJohn.Forte@Sun.COM * 3768*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 3769*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 3770*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 3771*7836SJohn.Forte@Sun.COM * 3772*7836SJohn.Forte@Sun.COM * **************************************************************************** 3773*7836SJohn.Forte@Sun.COM */ 3774*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 3775*7836SJohn.Forte@Sun.COM static int 3776*7836SJohn.Forte@Sun.COM disable_ddset_func(int operandLen, char *operand[], cmdOptions_t *options, 3777*7836SJohn.Forte@Sun.COM void *addarg) 3778*7836SJohn.Forte@Sun.COM { 3779*7836SJohn.Forte@Sun.COM return (i_enableddset(operandLen, operand, B_FALSE)); 3780*7836SJohn.Forte@Sun.COM } 3781*7836SJohn.Forte@Sun.COM 3782*7836SJohn.Forte@Sun.COM /* 3783*7836SJohn.Forte@Sun.COM * **************************************************************************** 3784*7836SJohn.Forte@Sun.COM * 3785*7836SJohn.Forte@Sun.COM * show_config_func - 3786*7836SJohn.Forte@Sun.COM * isnsadm show-config 3787*7836SJohn.Forte@Sun.COM * 3788*7836SJohn.Forte@Sun.COM * operandLen - number of operands user passed into the cli 3789*7836SJohn.Forte@Sun.COM * operand - pointer to operand list from user 3790*7836SJohn.Forte@Sun.COM * options - pointer to option list from user 3791*7836SJohn.Forte@Sun.COM * 3792*7836SJohn.Forte@Sun.COM * **************************************************************************** 3793*7836SJohn.Forte@Sun.COM */ 3794*7836SJohn.Forte@Sun.COM /*ARGSUSED*/ 3795*7836SJohn.Forte@Sun.COM static int 3796*7836SJohn.Forte@Sun.COM show_config_func(int operandLen, char *operand[], cmdOptions_t *options, 3797*7836SJohn.Forte@Sun.COM void *addarg) 3798*7836SJohn.Forte@Sun.COM { 3799*7836SJohn.Forte@Sun.COM xmlChar *doc; 3800*7836SJohn.Forte@Sun.COM int ret; 3801*7836SJohn.Forte@Sun.COM door_arg_t darg; 3802*7836SJohn.Forte@Sun.COM int fd, flag = 0; 3803*7836SJohn.Forte@Sun.COM 3804*7836SJohn.Forte@Sun.COM if ((fd = open(ISNS_DOOR_NAME, 0)) == -1) { 3805*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_OPEN_FAILED, errno); 3806*7836SJohn.Forte@Sun.COM return (ret); 3807*7836SJohn.Forte@Sun.COM } 3808*7836SJohn.Forte@Sun.COM 3809*7836SJohn.Forte@Sun.COM if ((ret = build_get_xml_doc(operandLen, operand, 3810*7836SJohn.Forte@Sun.COM ServerConfig, &doc)) == 0) { 3811*7836SJohn.Forte@Sun.COM bzero(&darg, sizeof (darg)); 3812*7836SJohn.Forte@Sun.COM darg.data_ptr = (char *)doc; 3813*7836SJohn.Forte@Sun.COM darg.data_size = xmlStrlen(doc) + 1; 3814*7836SJohn.Forte@Sun.COM darg.rbuf = NULL; 3815*7836SJohn.Forte@Sun.COM darg.rsize = 0; 3816*7836SJohn.Forte@Sun.COM } else { 3817*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(ret)); 3818*7836SJohn.Forte@Sun.COM (void) close(fd); 3819*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3820*7836SJohn.Forte@Sun.COM return (ret); 3821*7836SJohn.Forte@Sun.COM } 3822*7836SJohn.Forte@Sun.COM 3823*7836SJohn.Forte@Sun.COM if ((door_call(fd, &darg)) == -1) { 3824*7836SJohn.Forte@Sun.COM ret = check_door_error(ERROR_DOOR_CALL_FAILED, errno); 3825*7836SJohn.Forte@Sun.COM (void) close(fd); 3826*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3827*7836SJohn.Forte@Sun.COM return (ret); 3828*7836SJohn.Forte@Sun.COM } 3829*7836SJohn.Forte@Sun.COM 3830*7836SJohn.Forte@Sun.COM if ((ret = process_get_response(ServerConfig, (xmlChar *)darg.rbuf, 3831*7836SJohn.Forte@Sun.COM flag)) != 0) { 3832*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3833*7836SJohn.Forte@Sun.COM (void) close(fd); 3834*7836SJohn.Forte@Sun.COM (void) xmlFree(doc); 3835*7836SJohn.Forte@Sun.COM return (ret); 3836*7836SJohn.Forte@Sun.COM } 3837*7836SJohn.Forte@Sun.COM 3838*7836SJohn.Forte@Sun.COM (void) munmap(darg.rbuf, darg.rsize); 3839*7836SJohn.Forte@Sun.COM (void) close(fd); 3840*7836SJohn.Forte@Sun.COM xmlFree(doc); 3841*7836SJohn.Forte@Sun.COM 3842*7836SJohn.Forte@Sun.COM return (SUBCOMMAND_SUCCESS); 3843*7836SJohn.Forte@Sun.COM } 3844*7836SJohn.Forte@Sun.COM 3845*7836SJohn.Forte@Sun.COM /* 3846*7836SJohn.Forte@Sun.COM * ************************************************************************* 3847*7836SJohn.Forte@Sun.COM * 3848*7836SJohn.Forte@Sun.COM * main 3849*7836SJohn.Forte@Sun.COM * 3850*7836SJohn.Forte@Sun.COM * ************************************************************************* 3851*7836SJohn.Forte@Sun.COM */ 3852*7836SJohn.Forte@Sun.COM int 3853*7836SJohn.Forte@Sun.COM main(int argc, char *argv[]) 3854*7836SJohn.Forte@Sun.COM { 3855*7836SJohn.Forte@Sun.COM synTables_t synTables; 3856*7836SJohn.Forte@Sun.COM char versionString[VERSION_STRING_MAX_LEN]; 3857*7836SJohn.Forte@Sun.COM int ret; 3858*7836SJohn.Forte@Sun.COM int funcRet; 3859*7836SJohn.Forte@Sun.COM void *subcommandArgs = NULL; 3860*7836SJohn.Forte@Sun.COM 3861*7836SJohn.Forte@Sun.COM (void) setlocale(LC_ALL, ""); 3862*7836SJohn.Forte@Sun.COM 3863*7836SJohn.Forte@Sun.COM (void) sprintf(versionString, "%2s.%2s", 3864*7836SJohn.Forte@Sun.COM VERSION_STRING_MAJOR, VERSION_STRING_MINOR); 3865*7836SJohn.Forte@Sun.COM synTables.versionString = versionString; 3866*7836SJohn.Forte@Sun.COM synTables.longOptionTbl = &longOptions[0]; 3867*7836SJohn.Forte@Sun.COM synTables.subCommandPropsTbl = &subcommands[0]; 3868*7836SJohn.Forte@Sun.COM 3869*7836SJohn.Forte@Sun.COM ret = cmdParse(argc, argv, synTables, subcommandArgs, &funcRet); 3870*7836SJohn.Forte@Sun.COM 3871*7836SJohn.Forte@Sun.COM if (ret == 1) { 3872*7836SJohn.Forte@Sun.COM return (COMMAND_SYNTAX_FAILED); 3873*7836SJohn.Forte@Sun.COM } else if (ret == -1) { 3874*7836SJohn.Forte@Sun.COM perror(argv[0]); 3875*7836SJohn.Forte@Sun.COM return (1); 3876*7836SJohn.Forte@Sun.COM } else if (ret == 0) { 3877*7836SJohn.Forte@Sun.COM /* 3878*7836SJohn.Forte@Sun.COM * strawman way to sort out the error code. 3879*7836SJohn.Forte@Sun.COM * isnsi server protocol error range 0 - 99 3880*7836SJohn.Forte@Sun.COM * isns server maangement op error range 100 -199 3881*7836SJohn.Forte@Sun.COM * isnsadm error range 200 -299 3882*7836SJohn.Forte@Sun.COM */ 3883*7836SJohn.Forte@Sun.COM if (funcRet == SUBCOMMAND_SUCCESS) { 3884*7836SJohn.Forte@Sun.COM return (0); 3885*7836SJohn.Forte@Sun.COM } else if (funcRet > SUBCOMMAND_SUCCESS) { 3886*7836SJohn.Forte@Sun.COM if (funcRet != ERROR_DOOR_CALL_FAILED && 3887*7836SJohn.Forte@Sun.COM funcRet != ERROR_DOOR_OPEN_FAILED) { 3888*7836SJohn.Forte@Sun.COM (void) fprintf(stderr, "%s\n", getTextMessage(funcRet)); 3889*7836SJohn.Forte@Sun.COM } 3890*7836SJohn.Forte@Sun.COM return (1); 3891*7836SJohn.Forte@Sun.COM } else { 3892*7836SJohn.Forte@Sun.COM return (1); 3893*7836SJohn.Forte@Sun.COM } 3894*7836SJohn.Forte@Sun.COM } 3895*7836SJohn.Forte@Sun.COM 3896*7836SJohn.Forte@Sun.COM return (0); 3897*7836SJohn.Forte@Sun.COM } /* end main */ 3898