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