4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 * isnsadm.c : isnsadm CL
31 #include <sys/types.h>
41 #include <libxml/xmlreader.h>
42 #include <libxml/xmlwriter.h>
43 #include <libxml/parser.h>
44 #include <libxml/xpath.h>
45 #include <libxml/tree.h>
48 #include "isns_mgmt.h"
49 #include "isns_utils.h"
50 #include "isns_protocol.h"
54 /* object functions per subcommand */
55 static int list_node_func(int, char **, cmdOptions_t
*, void *);
56 static int list_dd_func(int, char **, cmdOptions_t
*, void *);
57 static int list_ddset_func(int, char **, cmdOptions_t
*, void *);
58 static int add_node_func(int, char **, cmdOptions_t
*, void *);
59 static int add_dd_func(int, char **, cmdOptions_t
*, void *);
60 static int delete_dd_func(int, char **, cmdOptions_t
*, void *);
61 static int delete_ddset_func(int, char **, cmdOptions_t
*, void *);
62 static int create_dd_func(int, char **, cmdOptions_t
*, void *);
63 static int create_ddset_func(int, char **, cmdOptions_t
*, void *);
64 static int remove_node_func(int, char **, cmdOptions_t
*, void *);
65 static int remove_dd_func(int, char **, cmdOptions_t
*, void *);
66 static int modify_dd_func(int, char **, cmdOptions_t
*, void *);
67 static int modify_ddset_func(int, char **, cmdOptions_t
*, void *);
68 static int enable_ddset_func(int, char **, cmdOptions_t
*, void *);
69 static int disable_ddset_func(int, char **, cmdOptions_t
*, void *);
70 static int show_config_func(int, char **, cmdOptions_t
*, void *);
71 static int i_enableddset(int, char **, boolean_t
);
72 static xmlTextReaderPtr
lookup_next_matching_elem(xmlTextReaderPtr
, int *,
73 const char *, const char *);
74 static int handle_association_info(xmlChar
*, association_t
);
75 static int process_result_response(xmlChar
*, int obj
);
76 static int process_get_assoc_response(xmlChar
*, association_t
);
77 static int process_get_response(object_type
, xmlChar
*, uint32_t);
78 static int cvt_enumerate_rsp_to_get_req(xmlChar
*, xmlChar
**, object_type
,
80 static int build_get_xml_doc(int, char **, object_type
, xmlChar
**);
81 static int build_delete_xml_doc(int, char **, object_type
, char *, xmlChar
**);
82 static int build_create_xml_doc(int, char **, object_type
, char *, xmlChar
**);
83 static int build_modify_xml_doc(int, char **, object_type
, boolean_t
,
85 static int build_rename_xml_doc(char *, object_type
, uint32_t, xmlChar
**);
86 static int build_assoc_xml_doc(xmlChar
*, association_t
, xmlChar
**);
87 static int build_assoc_xml_doc(xmlChar
*, association_t
, xmlChar
**);
88 static int build_enumerate_xml_doc(object_type
, xmlChar
**);
90 #define NEW_XMLARGV(old, n) (xmlChar **)reallocarray((old), \
91 (n) + 2, sizeof (xmlChar *))
93 #define XML_SFREE(x) (((x) != NULL) ? (xmlFree(x), (x) = NULL) : NULL)
95 #define VERSION_STRING_MAX_LEN 10
97 #define OPTIONSTRING_NAME "name"
98 #define OPTIONSTRING_DDNAME "Discovery Domain name"
99 #define OPTIONSTRING_DDSETNAME "Discovery Domain Set name"
100 #define OPTIONSTRING_TARGET "target"
101 #define OPTIONSTRING_INITIATOR "initiator"
102 #define OPTIONSTRING_VERBOSE "verbose"
104 #define VERBOSE 0x00000001
105 #define INITIATOR_ONLY 0x00000010
106 #define TARGET_ONLY 0x00000100
108 #if LIBXML_VERSION >= 20904
109 #define XMLSTRING_CAST (const char *)
111 #define XMLSTRING_CAST (const xmlChar *)
114 /* object table based on definitions in isns_mgmt.h. */
115 static obj_table_entry_t obj_table
[] = {
117 {DDOBJECT
, DiscoveryDomain
},
118 {DDSETOBJECT
, DiscoveryDomainSet
},
119 {DDOBJECTMEMBER
, DiscoveryDomainMember
},
120 {DDSETOBJECTMEMBER
, DiscoveryDomainSetMember
},
121 {ISNSSERVER
, ServerConfig
},
126 * MAJOR - This should only change when there is an incompatible change made
127 * to the interfaces or the output.
129 * MINOR - This should change whenever there is a new command or new feature
130 * with no incompatible change.
132 #define VERSION_STRING_MAJOR "1"
133 #define VERSION_STRING_MINOR "0"
134 static char *ISNS_FMRI
= "network/isns_server:default";
137 * Add new options here
140 /* tables set up based on cmdparse instructions */
141 optionTbl_t longOptions
[] = {
142 {"target", no_arg
, 't', OPTIONSTRING_TARGET
},
143 {"initiator", no_arg
, 'i', OPTIONSTRING_INITIATOR
},
144 {"verbose", no_arg
, 'v', OPTIONSTRING_VERBOSE
},
145 {"name", required_arg
, 'n', OPTIONSTRING_NAME
},
146 {"dd", required_arg
, 'd', OPTIONSTRING_DDNAME
},
147 {"dd-set", required_arg
, 's', OPTIONSTRING_DDSETNAME
},
153 * Add new subcommands here
155 subCommandProps_t subcommands
[] = {
156 {"list-node", LISTNODE
, list_node_func
, "itv", B_FALSE
, NULL
,
157 OPERAND_OPTIONAL_MULTIPLE
, "node-name"},
158 {"list-dd", LISTDD
, list_dd_func
, "v", B_FALSE
, NULL
,
159 OPERAND_OPTIONAL_MULTIPLE
, OPTIONSTRING_DDNAME
},
160 {"list-dd-set", LISTDDSET
, list_ddset_func
, "v", B_FALSE
, NULL
,
161 OPERAND_OPTIONAL_MULTIPLE
, OPTIONSTRING_DDSETNAME
},
162 {"create-dd", CREATEDD
, create_dd_func
, NULL
, B_FALSE
, NULL
,
163 OPERAND_MANDATORY_MULTIPLE
, OPTIONSTRING_DDNAME
},
164 {"create-dd-set", CREATEDDSET
, create_ddset_func
, NULL
, B_FALSE
, NULL
,
165 OPERAND_MANDATORY_MULTIPLE
, OPTIONSTRING_DDSETNAME
},
166 {"delete-dd", DELETEDD
, delete_dd_func
, NULL
, B_FALSE
, NULL
,
167 OPERAND_MANDATORY_MULTIPLE
, OPTIONSTRING_DDNAME
},
168 {"delete-dd-set", DELETEDDSET
, delete_ddset_func
, NULL
, B_FALSE
, NULL
,
169 OPERAND_MANDATORY_MULTIPLE
, OPTIONSTRING_DDSETNAME
},
170 {"add-node", ADDNODE
, add_node_func
, "d", B_TRUE
, NULL
,
171 OPERAND_MANDATORY_MULTIPLE
, "node-name"},
172 {"add-dd", ADDDD
, add_dd_func
, "s", B_TRUE
, NULL
,
173 OPERAND_MANDATORY_MULTIPLE
, OPTIONSTRING_DDNAME
},
174 {"remove-node", REMOVENODE
, remove_node_func
, "d", B_TRUE
, NULL
,
175 OPERAND_MANDATORY_MULTIPLE
, "node-name"},
176 {"remove-dd", REMOVEDD
, remove_dd_func
, "s", B_TRUE
, NULL
,
177 OPERAND_MANDATORY_MULTIPLE
, OPTIONSTRING_DDNAME
},
178 {"modify-dd", MODIFYDD
, modify_dd_func
, "n", B_TRUE
, NULL
,
179 OPERAND_MANDATORY_SINGLE
, OPTIONSTRING_NAME
},
180 {"modify-dd-set", MODIFYDDSET
, modify_ddset_func
, "n", B_TRUE
, NULL
,
181 OPERAND_MANDATORY_SINGLE
, OPTIONSTRING_NAME
},
182 {"enable-dd-set", ENABLEDDSET
, enable_ddset_func
, NULL
, B_FALSE
, NULL
,
183 OPERAND_MANDATORY_MULTIPLE
, OPTIONSTRING_DDSETNAME
},
184 {"disable-dd-set", DISABLEDDSET
, disable_ddset_func
, NULL
, B_FALSE
,
185 NULL
, OPERAND_MANDATORY_MULTIPLE
, OPTIONSTRING_DDSETNAME
},
186 {"show-config", SHOWCONFIG
, show_config_func
, NULL
, B_FALSE
, NULL
,
188 {NULL
, 0, NULL
, NULL
, 0, NULL
, 0, NULL
}
192 * ****************************************************************************
197 * errno from the door call.
200 * either door error or smf service error.
202 * ****************************************************************************
205 check_door_error(int door_err
, int err
)
210 if (((state
= smf_get_state(ISNS_FMRI
)) != NULL
) &&
211 (strcmp(state
, SCF_STATE_STRING_ONLINE
) != 0)) {
212 ret
= ERROR_ISNS_SMF_SERVICE_NOT_ONLINE
;
214 (void) fprintf(stderr
, "%s\n",
215 (door_err
== ERROR_DOOR_CALL_FAILED
) ?
216 getTextMessage(ERROR_DOOR_CALL_FAILED
) :
217 getTextMessage(ERROR_DOOR_OPEN_FAILED
));
218 (void) fprintf(stderr
, "\terrno: %s\n", strerror(err
));
228 * ****************************************************************************
230 * lookup an element based on the element name.
232 * reader - current xmlReaderReadPtr
233 * m_falg - indicate lookup result
234 * elem - name of element to look up.
235 * endelem - name of end element to look up.
237 * ****************************************************************************
239 static xmlTextReaderPtr
240 lookup_next_matching_elem(xmlTextReaderPtr reader
, int *m_flag
,
241 const char *elem
, const char *endelem
)
244 if (reader
== NULL
) {
251 * if (xmlTextReaderName(reader) != NULL) {
252 * printf("%s ", xmlTextReaderName(reader));
254 * printf("%d %d %d\n",
255 * xmlTextReaderDepth(reader),
256 * xmlTextReaderNodeType(reader),
257 * xmlTextReaderIsEmptyElement(reader));
260 * if match with elem, return the reader with READER_MATCH flag.
261 * if match with end elem, return the reader wtih
262 * END_READER_MATCH flag.
264 if (xmlTextReaderNodeType(reader
) == XML_READER_TYPE_ELEMENT
) {
265 if (XMLNCMP(reader
, elem
) == 0) {
266 *m_flag
= READER_MATCH
;
269 } else if (xmlTextReaderNodeType(reader
) ==
270 XML_READER_TYPE_END_ELEMENT
) {
271 if (XMLNCMP(reader
, endelem
) == 0) {
272 *m_flag
= END_READER_MATCH
;
276 } while (xmlTextReaderRead(reader
) == 1);
283 * ****************************************************************************
285 * Routine for getAssociated operation
286 * Construct association request based on the name and calls door
289 * name - name attributes of an object for getting an association
290 * assoc - association type
292 * ****************************************************************************
295 handle_association_info(xmlChar
*name
, association_t assoc
)
303 if ((ret
= build_assoc_xml_doc(name
, assoc
, &doc
)) != 0) {
307 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
308 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
312 (void) bzero(&darg
, sizeof (darg
));
313 bzero(&darg
, sizeof (darg
));
314 darg
.data_ptr
= (char *)doc
;
315 darg
.data_size
= xmlStrlen(doc
) + 1;
318 if ((door_call(fd
, &darg
)) == -1) {
319 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
325 if ((ret
= process_get_assoc_response((xmlChar
*)darg
.rbuf
,
328 * door frame work allocated a buffer when the date lager
329 * that rbuf. indicate if munmap is required on rbuf.
331 (void) munmap(darg
.rbuf
, darg
.rsize
);
337 (void) munmap(darg
.rbuf
, darg
.rsize
);
346 * ****************************************************************************
348 * process_error_status
349 * The routine process non 0 status and print out error message.
351 * status - status code
352 * reader - reader that points to the message element.
354 * ****************************************************************************
357 print_error_status(int status
, int obj
, xmlTextReaderPtr reader
)
363 (void) fprintf(stderr
, "%s\n",
364 getTextMessage(ERROR_SERVER_BUSY
));
366 case ISNS_RSP_INTERNAL_ERROR
:
367 (void) fprintf(stderr
, "%s\n",
368 getTextMessage(ERROR_SERVER_INTERNAL_ERROR
));
370 case ISNS_RSP_OPTION_NOT_UNDERSTOOD
:
371 if ((obj
== DiscoveryDomain
) ||
372 (obj
== DiscoveryDomainMember
)) {
373 (void) fprintf(stderr
, "%s\n",
374 getTextMessage(ERROR_OPERATION_NOT_ALLOWED_FOR_DEFAULT_DD
));
376 (void) fprintf(stderr
, "%s\n",
377 getTextMessage(ERROR_OPERATION_NOT_ALLOWED_FOR_DEFAULT_DDSET
));
380 case PARTIAL_FAILURE
:
381 (void) fprintf(stderr
, "%s\n",
382 getTextMessage(ERROR_PARTIAL_FAILURE
));
384 case ERR_NO_SUCH_ASSOCIATION
:
385 if ((obj
== DiscoveryDomain
) ||
386 (obj
== DiscoveryDomainMember
)) {
387 (void) fprintf(stderr
, "%s\n",
388 getTextMessage(ERROR_DDMEMBER_NOT_FOUND
));
390 (void) fprintf(stderr
, "%s\n",
391 getTextMessage(ERROR_DDSETMEMBER_NOT_FOUND
));
394 case ERR_ALREADY_ASSOCIATED
:
395 if ((obj
== DiscoveryDomain
) ||
396 (obj
== DiscoveryDomainMember
)) {
397 (void) fprintf(stderr
, "%s\n",
398 getTextMessage(ERROR_DDMEMBER_ALREADY_EXIST
));
400 (void) fprintf(stderr
, "%s\n",
401 getTextMessage(ERROR_DDSETMEMBER_ALREADY_EXIST
));
404 case ERR_NAME_IN_USE
:
405 if ((obj
== DiscoveryDomain
) ||
406 (obj
== DiscoveryDomainMember
)) {
407 (void) fprintf(stderr
, "%s\n",
408 getTextMessage(ERROR_DD_NAME_IN_USE
));
410 (void) fprintf(stderr
, "%s\n",
411 getTextMessage(ERROR_DDSET_NAME_IN_USE
));
415 reader
= lookup_next_matching_elem(reader
, &m_flag
,
416 MESSAGEELEMENT
, RESULTELEMENT
);
417 if (m_flag
== READER_MATCH
) {
418 (void) xmlTextReaderRead(reader
);
419 (void) fprintf(stderr
, "Error: %s\n",
420 (const char *) xmlTextReaderConstValue(reader
));
422 (void) fprintf(stderr
, "Error: %s\n",
423 getTextMessage(ERROR_XML_MESSAGE_ELEM_NOT_FOUND
));
429 * ****************************************************************************
431 * print_partial_failure_info
432 * The routine prints partial failure info.
434 * status - status code
435 * reader - reader that points to the message element.
437 * ****************************************************************************
440 print_partial_failure_info(xmlChar
*doc
)
442 xmlChar expr
[ISNS_MAX_LABEL_LEN
+ 13];
444 xmlXPathContextPtr ctext
= NULL
;
445 xmlXPathObjectPtr xpath_obj
= NULL
;
446 xmlNodeSetPtr r_nodes
= NULL
;
447 xmlAttrPtr attr
= NULL
;
450 if ((x_doc
= xmlParseMemory((const char *)doc
, xmlStrlen(doc
))) ==
452 (void) fprintf(stderr
, "%s\n",
453 getTextMessage(ERROR_NO_ADDITIONAL_PARTIAL_FAILIRE_INFO
));
456 ctext
= xmlXPathNewContext(x_doc
);
458 (void) fprintf(stderr
, "%s\n",
459 getTextMessage(ERROR_NO_ADDITIONAL_PARTIAL_FAILIRE_INFO
));
462 for (i
= 0; obj_table
[i
].obj_str
!= NULL
; i
++) {
463 (void) xmlStrPrintf(expr
, ISNS_MAX_LABEL_LEN
+ 13,
464 XMLSTRING_CAST
"%s\"%s\"]", "//*[name()=",
465 obj_table
[i
].obj_str
);
466 xpath_obj
= xmlXPathEvalExpression(expr
, ctext
);
467 if ((xpath_obj
) && (xpath_obj
->nodesetval
) &&
468 (xpath_obj
->nodesetval
->nodeNr
> 0) &&
469 (xpath_obj
->nodesetval
->nodeTab
)) {
470 obj
= obj_table
[i
].obj_id
;
476 if (xpath_obj
) xmlXPathFreeObject(xpath_obj
);
477 (void) fprintf(stderr
, "%s\n",
478 getTextMessage(ERROR_NO_ADDITIONAL_PARTIAL_FAILIRE_INFO
));
482 case DiscoveryDomainMember
:
483 r_nodes
= xpath_obj
->nodesetval
;
484 cnt
= r_nodes
->nodeNr
;
485 for (i
= 0; i
< cnt
; i
++) {
486 attr
= r_nodes
->nodeTab
[i
]->properties
;
487 for (; attr
!= NULL
; attr
= attr
->next
) {
488 if (xmlStrncmp(attr
->name
, (xmlChar
*)DDNAMEATTR
,
489 xmlStrlen((xmlChar
*)DDNAMEATTR
)) == 0) {
490 (void) fprintf(stderr
, "DD Name: %s\t",
491 xmlNodeGetContent(attr
->children
));
493 if (xmlStrncmp(attr
->name
, (xmlChar
*)NODENAMEATTR
,
494 xmlStrlen((xmlChar
*)NODENAMEATTR
)) == 0) {
495 (void) fprintf(stderr
, "Node Name: %s\t",
496 xmlNodeGetContent(attr
->children
));
499 (void) fprintf(stderr
, "\n");
501 if (xpath_obj
) xmlXPathFreeObject(xpath_obj
);
503 case DiscoveryDomainSetMember
:
504 r_nodes
= xpath_obj
->nodesetval
;
505 cnt
= r_nodes
->nodeNr
;
506 for (i
= 0; i
< cnt
; i
++) {
507 attr
= r_nodes
->nodeTab
[i
]->properties
;
508 for (; attr
!= NULL
; attr
= attr
->next
) {
509 if (xmlStrncmp(attr
->name
, (xmlChar
*)DDSETNAMEATTR
,
510 xmlStrlen((xmlChar
*)DDNAMEATTR
)) == 0) {
511 (void) fprintf(stderr
, "DD Set Name: %s\t",
512 xmlNodeGetContent(attr
->children
));
514 if (xmlStrncmp(attr
->name
, (xmlChar
*)DDNAMEATTR
,
515 xmlStrlen((xmlChar
*)NODENAMEATTR
)) == 0) {
516 (void) fprintf(stderr
, "DD Name: %s\t",
517 xmlNodeGetContent(attr
->children
));
520 (void) fprintf(stderr
, "\n");
522 if (xpath_obj
) xmlXPathFreeObject(xpath_obj
);
525 case DiscoveryDomain
:
526 case DiscoveryDomainSet
:
527 r_nodes
= xpath_obj
->nodesetval
;
528 cnt
= r_nodes
->nodeNr
;
529 for (i
= 0; i
< cnt
; i
++) {
530 attr
= r_nodes
->nodeTab
[i
]->properties
;
531 for (; attr
!= NULL
; attr
= attr
->next
) {
532 if ((xmlStrncmp(attr
->name
, (xmlChar
*)NAMEATTR
,
533 xmlStrlen((xmlChar
*)NAMEATTR
))) == 0) {
534 (void) fprintf(stderr
, "Object Name: %s\n",
535 xmlNodeGetContent(attr
->children
));
539 if (xpath_obj
) xmlXPathFreeObject(xpath_obj
);
545 * ****************************************************************************
547 * process_result_response
548 * The routine process association data based on the association type.
551 * obj - associated object type
553 * ****************************************************************************
556 process_result_response(xmlChar
*doc
, int obj
)
558 xmlTextReaderPtr reader
;
559 int m_flag
= 0, status
;
561 if ((reader
= (xmlTextReaderPtr
)xmlReaderForMemory((const char *)doc
,
562 xmlStrlen(doc
), NULL
, NULL
, 0)) == NULL
) {
563 return (ERROR_XML_READER_NULL
);
566 /* if status is 0, continue on. Otherwise return an error. */
567 if (reader
= lookup_next_matching_elem(reader
, &m_flag
, STATUSELEMENT
,
569 if (m_flag
== READER_MATCH
) {
570 if (xmlTextReaderRead(reader
) == 1) {
572 atoi((const char *)xmlTextReaderConstValue(reader
));
574 print_error_status(status
, obj
, reader
);
575 (void) xmlTextReaderClose(reader
);
576 (void) xmlFreeTextReader(reader
);
577 if (status
== PARTIAL_FAILURE
) {
578 print_partial_failure_info(doc
);
583 (void) xmlTextReaderClose(reader
);
584 (void) xmlFreeTextReader(reader
);
585 return (ERROR_XML_STATUS_ELEM_NOT_FOUND
);
588 (void) xmlTextReaderClose(reader
);
589 (void) xmlFreeTextReader(reader
);
590 return (ERROR_XML_STATUS_ELEM_NOT_FOUND
);
593 (void) fprintf(stderr
, "%s\n",
594 getTextMessage(ERROR_XML_READER_NULL
));
595 return (ERROR_XML_READER_NULL
);
598 (void) xmlTextReaderClose(reader
);
599 (void) xmlFreeTextReader(reader
);
604 * ****************************************************************************
606 * process_get_assoc_response
607 * The routine process association data based on the association type.
609 * doc - association data
610 * assoc - associatiion type
612 * ****************************************************************************
615 process_get_assoc_response(xmlChar
*doc
, association_t assoc
)
617 xmlTextReaderPtr reader
;
618 xmlChar
*ddsname
, *ddname
, *nodename
;
619 wchar_t wc_name
[ISNS_MAX_NAME_LEN
];
620 int m_flag
= 0, h_printed
= 0, status
;
622 if ((reader
= (xmlTextReaderPtr
)xmlReaderForMemory((const char *)doc
,
623 xmlStrlen(doc
), NULL
, NULL
, 0)) == NULL
) {
624 return (ERROR_XML_READER_NULL
);
627 /* if status is 0, continue on. Otherwise return an error. */
628 if (reader
= lookup_next_matching_elem(reader
, &m_flag
, STATUSELEMENT
,
630 if (m_flag
== READER_MATCH
) {
631 if (xmlTextReaderRead(reader
) == 1) {
633 atoi((const char *)xmlTextReaderConstValue(reader
));
634 if ((status
!= 0) && (status
!= PARTIAL_SUCCESS
)) {
636 if ((status
!= ERR_NO_SUCH_ASSOCIATION
) &&
637 (status
!= ERR_NO_ASSOCIATED_DD_FOUND
) &&
638 (status
!= ERR_NO_ASSOCIATED_DDSET_FOUND
)) {
639 (void) xmlTextReaderClose(reader
);
640 (void) xmlFreeTextReader(reader
);
643 print_error_status(status
,
644 ((assoc
== node_to_dd
) || (dd_to_node
)) ?
645 DiscoveryDomain
: DiscoveryDomainSet
, reader
);
646 (void) xmlTextReaderClose(reader
);
647 (void) xmlFreeTextReader(reader
);
652 (void) xmlTextReaderClose(reader
);
653 (void) xmlFreeTextReader(reader
);
654 return (ERROR_XML_STATUS_ELEM_NOT_FOUND
);
657 return (ERROR_XML_STATUS_ELEM_NOT_FOUND
);
660 return (ERROR_XML_READER_NULL
);
667 /* process DD elements */
668 while (reader
= lookup_next_matching_elem(reader
, &m_flag
,
669 DDOBJECTMEMBER
, ISNSRESPONSE
)) {
670 if (m_flag
== END_READER_MATCH
) {
671 (void) xmlTextReaderNext(reader
);
673 } else if (m_flag
== READER_MATCH
) {
674 if ((ddname
= (xmlTextReaderGetAttribute(reader
,
675 (const xmlChar
*)DDNAMEATTR
))) != NULL
) {
676 if (mbstowcs(wc_name
, (const char *)ddname
,
677 ISNS_MAX_NAME_LEN
) == (size_t)-1) {
678 (void) wcscpy(wc_name
, L
"-");
681 (void) printf("\tDD Name: %ws\n", wc_name
);
683 (void) printf("\tDD Name: %ws\n", wc_name
);
689 (void) printf("\t %s\n", "-");
691 (void) printf("\tDD Name: %s\n", "-");
697 (void) xmlTextReaderRead(reader
);
701 /* process the DiscoveryDoamin elements */
702 while (reader
= lookup_next_matching_elem(reader
, &m_flag
,
703 DDOBJECTMEMBER
, ISNSRESPONSE
)) {
704 if (m_flag
== END_READER_MATCH
) {
705 (void) xmlTextReaderNext(reader
);
707 } else if (m_flag
== READER_MATCH
) {
708 if ((nodename
= (xmlTextReaderGetAttribute(reader
,
709 (const xmlChar
*)NODENAMEATTR
))) != NULL
) {
710 if (mbstowcs(wc_name
, (const char *)nodename
,
711 ISNS_MAX_NAME_LEN
) == (size_t)-1) {
712 (void) wcscpy(wc_name
, L
"-");
714 (void) printf("\tiSCSI name: %ws\n", wc_name
);
717 (void) printf("\tiSCSI name: %s\n", "-");
721 (void) xmlTextReaderRead(reader
);
725 /* process the DiscoveryDoaminSet elements */
726 while (reader
= lookup_next_matching_elem(reader
, &m_flag
,
727 DDSETOBJECTMEMBER
, ISNSRESPONSE
)) {
728 if (m_flag
== END_READER_MATCH
) {
729 (void) xmlTextReaderNext(reader
);
731 } else if (m_flag
== READER_MATCH
) {
732 if ((ddsname
= (xmlTextReaderGetAttribute(reader
,
733 (const xmlChar
*)DDSETNAMEATTR
))) != NULL
) {
734 if (mbstowcs(wc_name
, (const char *)ddsname
,
735 ISNS_MAX_NAME_LEN
) == (size_t)-1) {
736 (void) wcscpy(wc_name
, L
"-");
739 (void) printf("\t %ws\n", wc_name
);
741 (void) printf("\tDD set(s): %ws\n", wc_name
);
746 (void) printf("\tDD set(s): %s\n", "-");
750 (void) xmlTextReaderRead(reader
);
754 /* process the DiscoveryDoaminSet elements */
755 while (reader
= lookup_next_matching_elem(reader
, &m_flag
,
756 DDSETOBJECTMEMBER
, ISNSRESPONSE
)) {
757 if (m_flag
== END_READER_MATCH
) {
758 (void) xmlTextReaderNext(reader
);
760 } else if (m_flag
== READER_MATCH
) {
761 if ((ddname
= (xmlTextReaderGetAttribute(reader
,
762 (const xmlChar
*)DDNAMEATTR
))) != NULL
) {
763 if (mbstowcs(wc_name
, (const char *)ddname
,
764 ISNS_MAX_NAME_LEN
) == (size_t)-1) {
765 (void) wcscpy(wc_name
, L
"-");
767 (void) printf("\tDD Name: %ws\n", wc_name
);
770 (void) printf("\tDD Name: %s\n", "-");
774 (void) xmlTextReaderRead(reader
);
778 (void) xmlTextReaderClose(reader
);
779 (void) xmlFreeTextReader(reader
);
783 if (status
== PARTIAL_SUCCESS
) {
784 (void) fprintf(stderr
, "%s\n",
785 getTextMessage(ERROR_PARTIAL_SUCCESS
));
787 (void) xmlTextReaderClose(reader
);
788 (void) xmlFreeTextReader(reader
);
793 * ****************************************************************************
795 * process_get_response :
796 * display data from the get response doc based on flag.
799 * doc - docuemet to process
800 * flag - options from the subcommand
802 * ****************************************************************************
805 process_get_response(object_type obj
, xmlChar
*doc
, uint32_t flag
)
807 xmlTextReaderPtr reader
;
808 int m_flag
= 0, ret
= 0, status
;
809 xmlChar
*name
= NULL
;
810 wchar_t wc_name
[ISNS_MAX_NAME_LEN
];
813 if ((reader
= (xmlTextReaderPtr
)xmlReaderForMemory((const char *)doc
,
814 xmlStrlen(doc
), NULL
, NULL
, 0)) == NULL
) {
815 return (ERROR_XML_READER_NULL
);
818 /* if status is 0, continue on. Otherwise return an error. */
819 if (reader
= lookup_next_matching_elem(reader
, &m_flag
, STATUSELEMENT
,
821 if (m_flag
== READER_MATCH
) {
822 if (xmlTextReaderRead(reader
) == 1) {
824 atoi((const char *)xmlTextReaderConstValue(reader
));
825 if ((status
!= 0) && (status
!= PARTIAL_SUCCESS
)) {
826 print_error_status(status
, obj
, reader
);
827 (void) xmlTextReaderClose(reader
);
828 (void) xmlFreeTextReader(reader
);
832 (void) xmlTextReaderClose(reader
);
833 (void) xmlFreeTextReader(reader
);
834 return (ERROR_XML_STATUS_ELEM_NOT_FOUND
);
837 (void) xmlTextReaderClose(reader
);
838 (void) xmlFreeTextReader(reader
);
839 return (ERROR_XML_STATUS_ELEM_NOT_FOUND
);
842 return (ERROR_XML_READER_NULL
);
849 /* process the node elements */
850 while (reader
= lookup_next_matching_elem(reader
, &m_flag
,
851 NODEOBJECT
, ISNSRESPONSE
)) {
852 if (m_flag
== END_READER_MATCH
) {
857 if ((xmlTextReaderMoveToAttribute(reader
,
858 (const xmlChar
*)TYPEATTR
)) == 1) {
859 if (((flag
& TARGET_ONLY
) == TARGET_ONLY
) &&
860 (XMLNCMPVAL(reader
, TARGETTYPE
) != 0)) {
861 /* move to next node object. */
862 (void) xmlTextReaderMoveToElement(reader
);
863 (void) xmlTextReaderNext(reader
);
866 if (((flag
& INITIATOR_ONLY
) == INITIATOR_ONLY
) &&
867 (XMLNCMPVAL(reader
, INITIATORTYPE
) != 0)) {
868 /* move to next node object. */
869 (void) xmlTextReaderMoveToElement(reader
);
870 (void) xmlTextReaderNext(reader
);
874 ret
= ERROR_XML_TYPE_ATTR_NOT_FOUND
;
878 if (((xmlTextReaderMoveToAttribute(reader
,
879 (const xmlChar
*)NAMEATTR
)) == 1) &&
880 (const char *)xmlTextReaderConstValue(reader
)) {
881 if (mbstowcs(wc_name
,
882 (const char *)xmlTextReaderConstValue(reader
),
883 ISNS_MAX_NAME_LEN
) == (size_t)-1) {
884 (void) wcscpy(wc_name
, L
"-");
886 if ((flag
& VERBOSE
) == VERBOSE
) {
887 name
= xmlTextReaderValue(reader
);
888 (void) printf("iSCSI Name: %ws\n", wc_name
);
890 (void) printf("iSCSI Name: %ws\n", wc_name
);
894 ret
= ERROR_XML_TYPE_ATTR_NOT_FOUND
;
897 if ((xmlTextReaderMoveToAttribute(reader
,
898 (const xmlChar
*)ALIASATTR
)) == 1) {
899 if (xmlStrcmp(xmlTextReaderConstValue(reader
),
900 (xmlChar
*)"") == 0) {
901 (void) printf("\tAlias: %s\n", "-");
903 if (mbstowcs(wc_name
,
904 (const char *)xmlTextReaderConstValue(reader
),
905 ISNS_MAX_NAME_LEN
) == (size_t)-1) {
906 (void) wcscpy(wc_name
, L
"-");
908 (void) printf("\tAlias: %ws\n", wc_name
);
912 /* type attribute exist based on the previous checking. */
913 (void) xmlTextReaderMoveToAttribute(reader
,
914 (const xmlChar
*)TYPEATTR
);
915 (void) printf("\tType: %s\n",
916 (const char *)xmlTextReaderConstValue(reader
) ?
917 (const char *)xmlTextReaderConstValue(reader
) : "-");
919 if ((flag
& VERBOSE
) == VERBOSE
) {
920 /* print more details */
923 * No details for deregistered node.
924 * skip to next isns object.
926 if ((reader
= lookup_next_matching_elem(reader
,
927 &m_flag
, ENTITYID
, ISNSOBJECT
))) {
928 if (m_flag
== READER_MATCH
) {
929 /* move to entity id value. */
930 if ((xmlTextReaderRead(reader
) == 1) &&
931 xmlTextReaderConstValue(reader
)) {
932 if (mbstowcs(wc_name
,
934 xmlTextReaderConstValue(reader
),
935 ISNS_MAX_NAME_LEN
) == (size_t)-1) {
936 (void) wcscpy(wc_name
,
939 (void) printf("\tNetwork Entity: %ws\n",
942 (void) printf("\tNework Entity: -\n");
944 } else if (m_flag
== END_READER_MATCH
) {
945 (void) xmlTextReaderRead(reader
);
951 /* print portal info */
953 while ((reader
= lookup_next_matching_elem(reader
,
954 &m_flag
, IPADDR
, NODEOBJECT
))) {
955 if (m_flag
== END_READER_MATCH
) {
956 (void) xmlTextReaderRead(reader
);
959 /* move to the value of IP addr. */
960 if ((xmlTextReaderRead(reader
) == 1) &&
961 xmlTextReaderConstValue(reader
)) {
962 (void) printf("\tPortal: %s",
963 xmlTextReaderConstValue(reader
));
964 /* get port number */
966 if (reader
= lookup_next_matching_elem(reader
,
967 &m_flag
, PORTNUMBER
, UDPTCPPORT
)) {
968 if ((xmlTextReaderRead(reader
) == 1) &&
969 xmlTextReaderConstValue(reader
)) {
970 (void) printf(":%d\n",
972 xmlTextReaderConstValue(reader
)));
974 (void) printf(":-\n");
978 if (reader
= lookup_next_matching_elem(reader
,
979 &m_flag
, GROUPTAG
, GROUPTAG
)) {
980 if ((xmlTextReaderRead(reader
) == 1) &&
981 xmlTextReaderConstValue(reader
)) {
982 (void) printf("\t\tPortal Group: %s\n",
983 xmlTextReaderConstValue(reader
));
985 (void) printf(":-\n");
990 if ((ret
= handle_association_info(name
,
997 (void) xmlTextReaderRead(reader
);
999 } /* end for node while */
1001 case DiscoveryDomain
:
1002 /* process the DiscoveryDoamin elements */
1003 while (reader
= lookup_next_matching_elem(reader
, &m_flag
,
1004 DDOBJECT
, ISNSRESPONSE
)) {
1005 if (m_flag
== END_READER_MATCH
) {
1006 (void) xmlTextReaderNext(reader
);
1010 if (((xmlTextReaderMoveToAttribute(reader
,
1011 (const xmlChar
*)NAMEATTR
)) == 1) &&
1012 (name
= xmlTextReaderValue(reader
))) {
1013 if (mbstowcs(wc_name
, (const char *)name
,
1014 ISNS_MAX_NAME_LEN
) == (size_t)-1) {
1015 (void) wcscpy(wc_name
, L
"-");
1017 (void) printf("DD name: %ws\n", wc_name
);
1019 ret
= ERROR_XML_NAME_ATTR_NOT_FOUND
;
1023 if ((ret
= handle_association_info(name
, dd_to_ddset
)) !=
1028 /* handle verbose */
1029 if ((flag
& VERBOSE
) == VERBOSE
) {
1030 if ((ret
= handle_association_info(name
,
1031 dd_to_node
)) != 0) {
1040 case DiscoveryDomainSet
:
1041 /* process the DiscoveryDoaminSet elements */
1042 while (reader
= lookup_next_matching_elem(reader
, &m_flag
,
1043 DDSETOBJECT
, ISNSRESPONSE
)) {
1044 if (m_flag
== END_READER_MATCH
) {
1045 (void) xmlTextReaderNext(reader
);
1049 if (((xmlTextReaderMoveToAttribute(reader
,
1050 (const xmlChar
*)NAMEATTR
)) == 1) &&
1051 (const char *)xmlTextReaderConstValue(reader
)) {
1052 if (mbstowcs(wc_name
,
1053 (const char *)xmlTextReaderConstValue(reader
),
1054 ISNS_MAX_NAME_LEN
) == (size_t)-1) {
1055 (void) wcscpy(wc_name
, L
"-");
1057 if ((flag
& VERBOSE
) == VERBOSE
) {
1058 name
= xmlTextReaderValue(reader
);
1059 (void) printf("DD Set name: %ws\n", wc_name
);
1061 (void) printf("DD Set name: %ws\n", wc_name
);
1064 ret
= ERROR_XML_NAME_ATTR_NOT_FOUND
;
1069 if ((reader
= lookup_next_matching_elem(reader
,
1070 &m_flag
, ENABLEDELEM
, ISNSOBJECT
))) {
1071 if (m_flag
== READER_MATCH
) {
1072 /* move to entity id value. */
1073 if ((xmlTextReaderRead(reader
) == 1) &&
1074 (XMLNCMPVAL(reader
, XMLTRUE
) == 0)) {
1075 (void) printf("\tState: Enabled\n");
1077 (void) printf("\tState: Disabled\n");
1079 } else if (m_flag
== END_READER_MATCH
) {
1080 (void) xmlTextReaderRead(reader
);
1084 /* handle verbose */
1085 if ((flag
& VERBOSE
) == VERBOSE
) {
1086 if ((ret
= handle_association_info(name
,
1087 ddset_to_dd
)) != 0) {
1097 /* process the DiscoveryDoaminSet elements */
1099 reader
= lookup_next_matching_elem(reader
, &m_flag
,
1100 ISNSSERVER
, ISNSRESPONSE
);
1101 if (m_flag
== END_READER_MATCH
) {
1102 ret
= ERROR_XML_ISNSSERVER_ELEM_NOT_FOUND
;
1106 if ((reader
= lookup_next_matching_elem(reader
,
1107 &m_flag
, DATASTORELOCATION
, ISNSRESPONSE
))) {
1108 if (m_flag
== READER_MATCH
) {
1109 (void) xmlTextReaderRead(reader
);
1110 (void) printf("\tData Store Location: %s\n",
1111 (const char *)xmlTextReaderConstValue(reader
) ?
1112 (const char *)xmlTextReaderConstValue(reader
) : "-");
1116 if ((reader
= lookup_next_matching_elem(reader
,
1117 &m_flag
, ESIRETRYTHRESHOLD
, ISNSRESPONSE
))) {
1118 if (m_flag
== READER_MATCH
) {
1119 (void) xmlTextReaderRead(reader
);
1120 (void) printf("\tEntity Status Inquiry Non-Response ");
1121 (void) printf("Threshold: %d\n",
1122 xmlTextReaderConstValue(reader
) ?
1123 atoi((const char *)xmlTextReaderConstValue(reader
))
1128 if ((reader
= lookup_next_matching_elem(reader
,
1129 &m_flag
, MANAGEMENTSCNENABLED
, ISNSRESPONSE
))) {
1130 if (m_flag
== READER_MATCH
) {
1131 (void) xmlTextReaderRead(reader
);
1132 (void) printf("\tManagement SCN Enabled: %s\n",
1133 (XMLNCMPVAL(reader
, XMLTRUE
) == 0) ?
1138 while ((reader
= lookup_next_matching_elem(reader
,
1139 &m_flag
, CONTROLNODENAME
, ISNSSERVER
))) {
1140 if (m_flag
== READER_MATCH
) {
1141 if (!xmlTextReaderIsEmptyElement(reader
)) {
1142 (void) xmlTextReaderRead(reader
);
1143 if (mbstowcs(wc_name
,
1144 (const char *)xmlTextReaderConstValue(reader
),
1145 ISNS_MAX_NAME_LEN
) == (size_t)-1) {
1146 (void) wcscpy(wc_name
, L
"-");
1149 if (xmlTextReaderConstValue(reader
)) {
1150 if (mbstowcs(wc_name
,
1152 xmlTextReaderConstValue(reader
),
1153 ISNS_MAX_NAME_LEN
) == (size_t)-1) {
1154 (void) wcscpy(wc_name
, L
"-");
1165 if (xmlTextReaderConstValue(reader
)) {
1166 if (mbstowcs(wc_name
,
1168 xmlTextReaderConstValue(reader
),
1169 ISNS_MAX_NAME_LEN
) == (size_t)-1) {
1170 (void) wcscpy(wc_name
, L
"-");
1173 "\tAuthorized Control Node Names: %ws\n",
1177 "\tAuthorized Control Node Names: %s\n",
1184 "\tAuthorized Control Node Names: %s\n", "-");
1197 (void) xmlTextReaderClose(reader
);
1198 (void) xmlFreeTextReader(reader
);
1199 if (status
== PARTIAL_SUCCESS
) {
1200 (void) fprintf(stderr
, "%s\n",
1201 getTextMessage(ERROR_PARTIAL_SUCCESS
));
1202 if (ret
== 0) ret
= status
;
1209 * ****************************************************************************
1211 * cvt_enumerate_rsp_to_get_req:
1212 * pull out object info from enumerate response and calls
1213 * build_get_xml_doc based on object type.
1215 * doc - enumerate resonse from the server.
1216 * req_do - pointer to get request doc.
1217 * object_type - isns object type.
1218 * flag - user options
1220 * ****************************************************************************
1223 cvt_enumerate_rsp_to_get_req(xmlChar
*doc
, xmlChar
**req_doc
,
1224 object_type obj
, uint32_t flag
)
1226 xmlTextReaderPtr reader
;
1228 int ret
= 0, status
;
1229 int i
, argxmlc
= 0, m_flag
= 0;
1231 if ((reader
= (xmlTextReaderPtr
)xmlReaderForMemory((const char *)doc
,
1232 xmlStrlen(doc
), NULL
, NULL
, 0)) == NULL
) {
1233 return (ERROR_XML_READER_NULL
);
1236 /* if status is 0, continue on. Otherwise return an error. */
1237 if (reader
= lookup_next_matching_elem(reader
, &m_flag
, STATUSELEMENT
,
1239 if (m_flag
== READER_MATCH
) {
1240 if (xmlTextReaderRead(reader
) == 1) {
1242 atoi((const char *)xmlTextReaderConstValue(reader
));
1244 print_error_status(status
, obj
, reader
);
1245 (void) xmlTextReaderClose(reader
);
1246 (void) xmlFreeTextReader(reader
);
1250 (void) xmlTextReaderClose(reader
);
1251 xmlFreeTextReader(reader
);
1252 return (ERROR_XML_STATUS_ELEM_NOT_FOUND
);
1255 return (ERROR_XML_STATUS_ELEM_NOT_FOUND
);
1258 return (ERROR_XML_READER_NULL
);
1263 argxmlv
= (xmlChar
**)malloc(sizeof (xmlChar
*));
1265 /* XXX - validate isnsResponse element from response doc. */
1268 /* process the node elements */
1269 while (reader
= lookup_next_matching_elem(reader
, &m_flag
,
1270 NODEOBJECT
, ISNSRESPONSE
)) {
1271 if (m_flag
== END_READER_MATCH
) {
1272 (void) xmlTextReaderNext(reader
);
1276 /* check the type */
1277 if ((xmlTextReaderMoveToAttribute(reader
,
1278 (const xmlChar
*)TYPEATTR
)) == 1) {
1279 if (((flag
& TARGET_ONLY
) == TARGET_ONLY
) &&
1280 (XMLNCMPVAL(reader
, TARGETTYPE
) != 0)) {
1281 /* move to next node object. */
1282 (void) xmlTextReaderMoveToElement(reader
);
1283 (void) xmlTextReaderNext(reader
);
1286 if (((flag
& INITIATOR_ONLY
) == INITIATOR_ONLY
) &&
1287 (XMLNCMPVAL(reader
, INITIATORTYPE
) != 0)) {
1288 /* move to next node object. */
1289 (void) xmlTextReaderMoveToElement(reader
);
1290 (void) xmlTextReaderNext(reader
);
1294 ret
= ERROR_XML_TYPE_ATTR_NOT_FOUND
;
1298 if (((xmlTextReaderMoveToAttribute(reader
,
1299 (const xmlChar
*)NAMEATTR
)) == 1) &&
1300 xmlTextReaderConstValue(reader
)) {
1301 argxmlv
= NEW_XMLARGV(argxmlv
, argxmlc
);
1302 if (argxmlv
== (xmlChar
**)NULL
) {
1303 ret
= ERROR_MALLOC_FAILED
;
1306 argxmlv
[argxmlc
++] =
1307 xmlStrdup(xmlTextReaderConstValue(reader
));
1308 argxmlv
[argxmlc
] = NULL
;
1310 ret
= ERROR_XML_NAME_ATTR_NOT_FOUND
;
1313 (void) xmlTextReaderRead(reader
);
1315 } /* end for node while */
1317 case DiscoveryDomain
:
1318 /* process the DiscoveryDoamin elements */
1319 while (reader
= lookup_next_matching_elem(reader
, &m_flag
,
1320 DDOBJECT
, ISNSRESPONSE
)) {
1321 if (m_flag
== END_READER_MATCH
) {
1322 (void) xmlTextReaderNext(reader
);
1326 if (((xmlTextReaderMoveToAttribute(reader
,
1327 (const xmlChar
*)NAMEATTR
)) == 1) &&
1328 xmlTextReaderConstValue(reader
)) {
1329 argxmlv
= NEW_XMLARGV(argxmlv
, argxmlc
);
1330 if (argxmlv
== (xmlChar
**)NULL
) {
1331 ret
= ERROR_MALLOC_FAILED
;
1334 argxmlv
[argxmlc
++] =
1335 xmlStrdup(xmlTextReaderConstValue(reader
));
1336 argxmlv
[argxmlc
] = NULL
;
1338 ret
= ERROR_XML_NAME_ATTR_NOT_FOUND
;
1342 (void) xmlTextReaderRead(reader
);
1345 case DiscoveryDomainSet
:
1346 /* process the DiscoveryDoaminSet elements */
1347 while (reader
= lookup_next_matching_elem(reader
, &m_flag
,
1348 DDSETOBJECT
, ISNSRESPONSE
)) {
1349 if (m_flag
== END_READER_MATCH
) {
1350 (void) xmlTextReaderNext(reader
);
1354 if (((xmlTextReaderMoveToAttribute(reader
,
1355 (const xmlChar
*)NAMEATTR
)) == 1) &&
1356 (const char *)xmlTextReaderConstValue(reader
)) {
1357 argxmlv
= NEW_XMLARGV(argxmlv
, argxmlc
);
1358 if (argxmlv
== (xmlChar
**)NULL
) {
1359 ret
= ERROR_MALLOC_FAILED
;
1362 argxmlv
[argxmlc
++] =
1363 xmlStrdup(xmlTextReaderConstValue(reader
));
1364 argxmlv
[argxmlc
] = NULL
;
1366 ret
= ERROR_XML_NAME_ATTR_NOT_FOUND
;
1370 (void) xmlTextReaderRead(reader
);
1378 /* if no object found, stop here. The status can be still 0. */
1380 if ((ret
= build_get_xml_doc(argxmlc
, (char **)argxmlv
, obj
,
1386 /* indicate there is no error but not object is found. */
1387 ret
= SUCCESS_WITH_NO_OBJECT
;
1392 (void) xmlTextReaderClose(reader
);
1393 (void) xmlFreeTextReader(reader
);
1395 for (i
= 0; i
< argxmlc
; i
++) {
1396 xmlFree(argxmlv
[i
]);
1398 (void) free(argxmlv
);
1405 * ****************************************************************************
1407 * build_delete_xml_doc -
1408 * build remove request doc based the name.
1409 * the resulted doc is passed in the doc ptr.
1411 * name - object type
1412 * assoc - association type
1413 * doc - ptr to the resulted doc
1415 * ****************************************************************************
1418 build_delete_xml_doc(int operandLen
, char **operand
, object_type obj
,
1419 char *container
, xmlChar
**doc
)
1421 xmlTextWriterPtr writer
;
1425 if ((xbuf
= xmlBufferCreate()) == NULL
) {
1426 return (ERROR_XML_CREATE_BUFFER_FAILED
);
1429 if ((writer
= xmlNewTextWriterMemory(xbuf
, 0)) == NULL
) {
1430 return (ERROR_XML_CREATE_WRITER_FAILED
);
1433 if (xmlTextWriterStartDocument(writer
, "1.0", NULL
, NULL
) < 0) {
1434 return (ERROR_XML_START_DOC_FAILED
);
1437 /* Start element "isnsRequest". */
1438 if (xmlTextWriterStartElement(writer
, (xmlChar
*)ISNSREQUEST
) < 0) {
1439 return (ERROR_XML_START_ELEMENT_FAILED
);
1442 if ((xmlTextWriterWriteAttribute(writer
,
1443 (xmlChar
*)XMLNSATTR
, (xmlChar
*)XMLNSATTRVAL
)) < 0) {
1444 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1447 /* request delete operation to get the entire list of obejct. */
1448 if (xmlTextWriterStartElement(writer
, (xmlChar
*)DELETE
) < 0) {
1449 return (ERROR_XML_START_ELEMENT_FAILED
);
1453 case DiscoveryDomain
:
1454 for (i
= 0; i
< operandLen
; i
++) {
1455 /* start Discovery Domain element. */
1456 if (xmlTextWriterStartElement(writer
,
1457 (xmlChar
*)DDOBJECT
) < 0) {
1458 return (ERROR_XML_START_ELEMENT_FAILED
);
1461 /* Start attr "name". */
1462 if ((xmlTextWriterWriteAttribute(writer
,
1463 (xmlChar
*)NAMEATTR
, (xmlChar
*)operand
[i
])) < 0) {
1464 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1467 /* End element "DiscoveryDomain". */
1468 if (xmlTextWriterEndElement(writer
) < 0) {
1469 return (ERROR_XML_END_ELEMENT_FAILED
);
1473 case DiscoveryDomainSet
:
1474 for (i
= 0; i
< operandLen
; i
++) {
1475 /* start Discovery DomainSet element. */
1476 if (xmlTextWriterStartElement(writer
,
1477 (xmlChar
*)DDSETOBJECT
) < 0) {
1478 return (ERROR_XML_START_ELEMENT_FAILED
);
1481 /* Start attr "name". */
1482 if (xmlTextWriterWriteAttribute(writer
,
1483 (xmlChar
*)NAMEATTR
, (xmlChar
*)operand
[i
]) < 0) {
1484 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1487 /* End element "DiscoveryDomainSet". */
1488 if (xmlTextWriterEndElement(writer
) < 0) {
1489 return (ERROR_XML_END_ELEMENT_FAILED
);
1493 case DiscoveryDomainMember
:
1494 for (i
= 0; i
< operandLen
; i
++) {
1495 /* start Discovery Domain Member element. */
1496 if (xmlTextWriterStartElement(writer
,
1497 (xmlChar
*)DDOBJECTMEMBER
) < 0) {
1498 return (ERROR_XML_START_ELEMENT_FAILED
);
1501 /* Start attr "DD Name". */
1502 if (xmlTextWriterWriteAttribute(writer
,
1503 (xmlChar
*)DDNAMEATTR
, (xmlChar
*)container
) < 0) {
1504 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1507 /* Start attr "Node Name". */
1508 if (xmlTextWriterWriteAttribute(writer
,
1509 (xmlChar
*)NODENAMEATTR
, (xmlChar
*)operand
[i
]) < 0) {
1510 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1513 /* End element "DiscoveryDomainMember. */
1514 if (xmlTextWriterEndElement(writer
) < 0) {
1515 return (ERROR_XML_END_ELEMENT_FAILED
);
1519 case DiscoveryDomainSetMember
:
1520 for (i
= 0; i
< operandLen
; i
++) {
1521 /* start Discovery Domain Member element. */
1522 if (xmlTextWriterStartElement(writer
,
1523 (xmlChar
*)DDSETOBJECTMEMBER
) < 0) {
1524 return (ERROR_XML_START_ELEMENT_FAILED
);
1527 /* Start attr "DD Set Name". */
1528 if (xmlTextWriterWriteAttribute(writer
,
1529 (xmlChar
*)DDSETNAMEATTR
, (xmlChar
*)(container
)) < 0) {
1530 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1533 /* Start attr "DD Name". */
1534 if (xmlTextWriterWriteAttribute(writer
,
1535 (xmlChar
*)DDNAMEATTR
, (xmlChar
*)(operand
[i
])) < 0) {
1536 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1539 /* End element "DiscoveryDomainSetMember. */
1540 if (xmlTextWriterEndElement(writer
) < 0) {
1541 return (ERROR_XML_END_ELEMENT_FAILED
);
1546 xmlFreeTextWriter(writer
);
1550 /* end createModify */
1551 if (xmlTextWriterEndElement(writer
) < 0) {
1552 xmlFreeTextWriter(writer
);
1553 return (ERROR_XML_END_ELEMENT_FAILED
);
1556 /* End element "isnsRequest". */
1557 if (xmlTextWriterEndElement(writer
) < 0) {
1558 xmlFreeTextWriter(writer
);
1559 return (ERROR_XML_END_ELEMENT_FAILED
);
1561 if (xmlTextWriterEndDocument(writer
) < 0) {
1562 xmlFreeTextWriter(writer
);
1563 return (ERROR_XML_END_DOC_FAILED
);
1566 xmlFreeTextWriter(writer
);
1568 len
= xmlStrlen(xbuf
->content
) + 1;
1569 /* XXX - copy NULL at the end by having one more extra byte */
1570 if ((*doc
= xmlStrndup(xbuf
->content
, len
)) == NULL
) {
1571 return (ERROR_XML_STRDUP_FAILED
);
1574 xmlBufferFree(xbuf
);
1580 * ****************************************************************************
1582 * build_modify_xml_doc -
1583 * build create request doc based the name.
1584 * the resulted doc is passed in the doc ptr.
1586 * operannLen - number of objects
1587 * operand - object list
1588 * enabled - indication of enable and disable boolean type element.
1589 * doc - ptr to the resulted doc
1591 * ****************************************************************************
1594 build_modify_xml_doc(int operandLen
, char **operand
, object_type obj
,
1595 boolean_t enabled
, xmlChar
**doc
)
1597 xmlTextWriterPtr writer
;
1601 if ((xbuf
= xmlBufferCreate()) == NULL
) {
1602 return (ERROR_XML_CREATE_BUFFER_FAILED
);
1605 if ((writer
= xmlNewTextWriterMemory(xbuf
, 0)) == NULL
) {
1606 return (ERROR_XML_CREATE_WRITER_FAILED
);
1609 if (xmlTextWriterStartDocument(writer
, "1.0", NULL
, NULL
) < 0) {
1610 return (ERROR_XML_START_DOC_FAILED
);
1613 /* Start element "isnsRequest". */
1614 if (xmlTextWriterStartElement(writer
, (xmlChar
*)ISNSREQUEST
) < 0) {
1615 return (ERROR_XML_START_ELEMENT_FAILED
);
1618 if ((xmlTextWriterWriteAttribute(writer
,
1619 (xmlChar
*)XMLNSATTR
, (xmlChar
*)XMLNSATTRVAL
)) < 0) {
1620 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1623 /* request createModify operation to get the entire list of obejct. */
1624 if (xmlTextWriterStartElement(writer
, (xmlChar
*)CREATEMODIFY
) < 0) {
1625 return (ERROR_XML_START_ELEMENT_FAILED
);
1629 case DiscoveryDomain
:
1630 for (i
= 0; i
< operandLen
; i
++) {
1631 /* start Discovery Domain element. */
1632 if (xmlTextWriterStartElement(writer
,
1633 (xmlChar
*)DDOBJECT
) < 0) {
1634 return (ERROR_XML_START_ELEMENT_FAILED
);
1637 /* write attr "name". */
1638 if ((xmlTextWriterWriteAttribute(writer
,
1639 (xmlChar
*)NAMEATTR
, (xmlChar
*)operand
[i
])) < 0) {
1640 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1643 /* write bootlist_enabled elem */
1644 if (xmlTextWriterWriteElement(writer
,
1645 (xmlChar
*)BOOTLISTENABLEDELEM
, (enabled
)?
1646 (xmlChar
*)XMLTRUE
: (xmlChar
*)XMLFALSE
) < 0) {
1647 return (ERROR_XML_WRITE_ELEMENT_FAILED
);
1650 /* End element "DiscoveryDomain". */
1651 if (xmlTextWriterEndElement(writer
) < 0) {
1652 return (ERROR_XML_END_ELEMENT_FAILED
);
1656 case DiscoveryDomainSet
:
1657 for (i
= 0; i
< operandLen
; i
++) {
1658 /* start Discovery DomainSet element. */
1659 if (xmlTextWriterStartElement(writer
,
1660 (xmlChar
*)DDSETOBJECT
) < 0) {
1661 return (ERROR_XML_START_ELEMENT_FAILED
);
1664 /* Start attr "name". */
1665 if (xmlTextWriterWriteAttribute(writer
,
1666 (xmlChar
*)NAMEATTR
, (xmlChar
*)operand
[i
]) < 0) {
1667 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1670 /* write enabled elem */
1671 if (xmlTextWriterWriteElement(writer
,
1672 (xmlChar
*)ENABLEDELEM
, (enabled
) ?
1673 (xmlChar
*)XMLTRUE
: (xmlChar
*)XMLFALSE
) < 0) {
1674 return (ERROR_XML_WRITE_ELEMENT_FAILED
);
1677 /* End element "DiscoveryDomainSet". */
1678 if (xmlTextWriterEndElement(writer
) < 0) {
1679 return (ERROR_XML_END_ELEMENT_FAILED
);
1684 xmlFreeTextWriter(writer
);
1688 /* end createModify */
1689 if (xmlTextWriterEndElement(writer
) < 0) {
1690 xmlFreeTextWriter(writer
);
1691 return (ERROR_XML_END_ELEMENT_FAILED
);
1694 /* End element "isnsRequest". */
1695 if (xmlTextWriterEndElement(writer
) < 0) {
1696 xmlFreeTextWriter(writer
);
1697 return (ERROR_XML_END_ELEMENT_FAILED
);
1699 if (xmlTextWriterEndDocument(writer
) < 0) {
1700 xmlFreeTextWriter(writer
);
1701 return (ERROR_XML_END_DOC_FAILED
);
1704 xmlFreeTextWriter(writer
);
1706 len
= xmlStrlen(xbuf
->content
) + 1;
1707 /* XXX - copy NULL at the end by having one more extra byte */
1708 if ((*doc
= xmlStrndup(xbuf
->content
, len
)) == NULL
) {
1709 return (ERROR_XML_STRDUP_FAILED
);
1712 xmlBufferFree(xbuf
);
1718 * ****************************************************************************
1720 * build_rename_xml_doc -
1721 * build create request doc based the name.
1722 * the resulted doc is passed in the doc ptr.
1724 * assoc - a new name
1725 * id - index of the object of which name to be changed
1726 * doc - ptr to the resulted doc
1728 * ****************************************************************************
1731 build_rename_xml_doc(char *name
, object_type obj
, uint32_t id
, xmlChar
**doc
)
1733 xmlTextWriterPtr writer
;
1738 if ((xbuf
= xmlBufferCreate()) == NULL
) {
1739 return (ERROR_XML_CREATE_BUFFER_FAILED
);
1742 if ((writer
= xmlNewTextWriterMemory(xbuf
, 0)) == NULL
) {
1743 return (ERROR_XML_CREATE_WRITER_FAILED
);
1746 if (xmlTextWriterStartDocument(writer
, "1.0", NULL
, NULL
) < 0) {
1747 return (ERROR_XML_START_DOC_FAILED
);
1750 /* Start element "isnsRequest". */
1751 if (xmlTextWriterStartElement(writer
, (xmlChar
*)ISNSREQUEST
) < 0) {
1752 return (ERROR_XML_START_ELEMENT_FAILED
);
1755 if ((xmlTextWriterWriteAttribute(writer
,
1756 (xmlChar
*)XMLNSATTR
, (xmlChar
*)XMLNSATTRVAL
)) < 0) {
1757 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1760 /* request createModify operation to get the entire list of obejct. */
1761 if (xmlTextWriterStartElement(writer
, (xmlChar
*)CREATEMODIFY
) < 0) {
1762 return (ERROR_XML_START_ELEMENT_FAILED
);
1766 case DiscoveryDomain
:
1767 /* start Discovery Domain element. */
1768 if (xmlTextWriterStartElement(writer
,
1769 (xmlChar
*)DDOBJECT
) < 0) {
1770 return (ERROR_XML_START_ELEMENT_FAILED
);
1773 /* write attr "name". */
1774 if ((xmlTextWriterWriteAttribute(writer
,
1775 (xmlChar
*)NAMEATTR
, (xmlChar
*)name
)) < 0) {
1776 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1779 /* write attr "id". */
1780 (void) sprintf(namebuf
, "%d", id
);
1781 if ((xmlTextWriterWriteAttribute(writer
,
1782 (xmlChar
*)IDATTR
, (xmlChar
*)namebuf
)) < 0) {
1783 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1786 /* End element "DiscoveryDomain". */
1787 if (xmlTextWriterEndElement(writer
) < 0) {
1788 return (ERROR_XML_END_ELEMENT_FAILED
);
1791 case DiscoveryDomainSet
:
1792 /* start Discovery DomainSet element. */
1793 if (xmlTextWriterStartElement(writer
,
1794 (xmlChar
*)DDSETOBJECT
) < 0) {
1795 return (ERROR_XML_START_ELEMENT_FAILED
);
1798 /* Start attr "name". */
1799 if (xmlTextWriterWriteAttribute(writer
,
1800 (xmlChar
*)NAMEATTR
, (xmlChar
*)name
) < 0) {
1801 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1804 /* write attr "id". */
1805 (void) sprintf(namebuf
, "%d", id
);
1806 if ((xmlTextWriterWriteAttribute(writer
,
1807 (xmlChar
*)IDATTR
, (xmlChar
*)namebuf
)) < 0) {
1808 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1811 /* End element "DiscoveryDomainSet". */
1812 if (xmlTextWriterEndElement(writer
) < 0) {
1813 return (ERROR_XML_END_ELEMENT_FAILED
);
1817 xmlFreeTextWriter(writer
);
1821 /* end createModify */
1822 if (xmlTextWriterEndElement(writer
) < 0) {
1823 xmlFreeTextWriter(writer
);
1824 return (ERROR_XML_END_ELEMENT_FAILED
);
1827 /* End element "isnsRequest". */
1828 if (xmlTextWriterEndElement(writer
) < 0) {
1829 xmlFreeTextWriter(writer
);
1830 return (ERROR_XML_END_ELEMENT_FAILED
);
1832 if (xmlTextWriterEndDocument(writer
) < 0) {
1833 xmlFreeTextWriter(writer
);
1834 return (ERROR_XML_END_DOC_FAILED
);
1837 xmlFreeTextWriter(writer
);
1839 len
= xmlStrlen(xbuf
->content
) + 1;
1840 /* XXX - copy NULL at the end by having one more extra byte */
1841 if ((*doc
= xmlStrndup(xbuf
->content
, len
)) == NULL
) {
1842 return (ERROR_XML_STRDUP_FAILED
);
1845 xmlBufferFree(xbuf
);
1851 * ****************************************************************************
1853 * build_create_xml_doc -
1854 * build create request doc based the name.
1855 * the resulted doc is passed in the doc ptr.
1857 * name - object type
1858 * assoc - association type
1859 * doc - ptr to the resulted doc
1861 * ****************************************************************************
1864 build_create_xml_doc(int operandLen
, char **operand
, object_type obj
,
1865 char *container
, xmlChar
**doc
)
1867 xmlTextWriterPtr writer
;
1871 if ((xbuf
= xmlBufferCreate()) == NULL
) {
1872 return (ERROR_XML_CREATE_BUFFER_FAILED
);
1875 if ((writer
= xmlNewTextWriterMemory(xbuf
, 0)) == NULL
) {
1876 return (ERROR_XML_CREATE_WRITER_FAILED
);
1879 if (xmlTextWriterStartDocument(writer
, "1.0", NULL
, NULL
) < 0) {
1880 return (ERROR_XML_START_DOC_FAILED
);
1883 /* Start element "isnsRequest". */
1884 if (xmlTextWriterStartElement(writer
, (xmlChar
*)ISNSREQUEST
) < 0) {
1885 return (ERROR_XML_START_ELEMENT_FAILED
);
1888 /* request createModify operation to get the entire list of obejct. */
1889 if (xmlTextWriterStartElement(writer
, (xmlChar
*)CREATEMODIFY
) < 0) {
1890 return (ERROR_XML_START_ELEMENT_FAILED
);
1894 case DiscoveryDomain
:
1895 for (i
= 0; i
< operandLen
; i
++) {
1896 /* start Discovery Domain element. */
1897 if (xmlTextWriterStartElement(writer
,
1898 (xmlChar
*)DDOBJECT
) < 0) {
1899 return (ERROR_XML_START_ELEMENT_FAILED
);
1902 /* Start attr "name". */
1903 if ((xmlTextWriterWriteAttribute(writer
,
1904 (xmlChar
*)NAMEATTR
, (xmlChar
*)operand
[i
])) < 0) {
1905 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1908 /* End element "DiscoveryDomain". */
1909 if (xmlTextWriterEndElement(writer
) < 0) {
1910 return (ERROR_XML_END_ELEMENT_FAILED
);
1914 case DiscoveryDomainSet
:
1915 for (i
= 0; i
< operandLen
; i
++) {
1916 /* start Discovery DomainSet element. */
1917 if (xmlTextWriterStartElement(writer
,
1918 (xmlChar
*)DDSETOBJECT
) < 0) {
1919 return (ERROR_XML_START_ELEMENT_FAILED
);
1922 /* Start attr "name". */
1923 if (xmlTextWriterWriteAttribute(writer
,
1924 (xmlChar
*)NAMEATTR
, (xmlChar
*)operand
[i
]) < 0) {
1925 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1928 /* End element "DiscoveryDomainSet". */
1929 if (xmlTextWriterEndElement(writer
) < 0) {
1930 return (ERROR_XML_END_ELEMENT_FAILED
);
1934 case DiscoveryDomainMember
:
1935 for (i
= 0; i
< operandLen
; i
++) {
1936 /* start Discovery Domain Member element. */
1937 if (xmlTextWriterStartElement(writer
,
1938 (xmlChar
*)DDOBJECTMEMBER
) < 0) {
1939 return (ERROR_XML_START_ELEMENT_FAILED
);
1942 /* Start attr "DD Name". */
1943 if (xmlTextWriterWriteAttribute(writer
,
1944 (xmlChar
*)DDNAMEATTR
, (xmlChar
*)container
) < 0) {
1945 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1948 /* Start attr "Node Name". */
1949 if (xmlTextWriterWriteAttribute(writer
,
1950 (xmlChar
*)NODENAMEATTR
, (xmlChar
*)operand
[i
]) < 0) {
1951 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1954 /* End element "DiscoveryDomainMember. */
1955 if (xmlTextWriterEndElement(writer
) < 0) {
1956 return (ERROR_XML_END_ELEMENT_FAILED
);
1960 case DiscoveryDomainSetMember
:
1961 for (i
= 0; i
< operandLen
; i
++) {
1962 /* start Discovery Domain Member element. */
1963 if (xmlTextWriterStartElement(writer
,
1964 (xmlChar
*)DDSETOBJECTMEMBER
) < 0) {
1965 return (ERROR_XML_START_ELEMENT_FAILED
);
1968 /* Start attr "DD Set Name". */
1969 if (xmlTextWriterWriteAttribute(writer
,
1970 (xmlChar
*)DDSETNAMEATTR
, (xmlChar
*)(container
)) < 0) {
1971 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1974 /* Start attr "DD Name". */
1975 if (xmlTextWriterWriteAttribute(writer
,
1976 (xmlChar
*)DDNAMEATTR
, (xmlChar
*)(operand
[i
])) < 0) {
1977 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
1980 /* End element "DiscoveryDomainSetMember. */
1981 if (xmlTextWriterEndElement(writer
) < 0) {
1982 return (ERROR_XML_END_ELEMENT_FAILED
);
1987 xmlFreeTextWriter(writer
);
1991 /* end createModify */
1992 if (xmlTextWriterEndElement(writer
) < 0) {
1993 xmlFreeTextWriter(writer
);
1994 return (ERROR_XML_END_ELEMENT_FAILED
);
1997 /* End element "isnsRequest". */
1998 if (xmlTextWriterEndElement(writer
) < 0) {
1999 xmlFreeTextWriter(writer
);
2000 return (ERROR_XML_END_ELEMENT_FAILED
);
2002 if (xmlTextWriterEndDocument(writer
) < 0) {
2003 xmlFreeTextWriter(writer
);
2004 return (ERROR_XML_END_DOC_FAILED
);
2007 xmlFreeTextWriter(writer
);
2009 len
= xmlStrlen(xbuf
->content
) + 1;
2010 /* XXX - copy NULL at the end by having one more extra byte */
2011 if ((*doc
= xmlStrndup(xbuf
->content
, len
)) == NULL
) {
2012 return (ERROR_XML_STRDUP_FAILED
);
2015 xmlBufferFree(xbuf
);
2021 * ****************************************************************************
2023 * build_assoc_xml_doc -
2024 * build association request doc based the name.
2025 * the resulted doc is passed in the doc ptr.
2027 * name - object type
2028 * assoc - association type
2029 * doc - ptr to the resulted doc
2031 * ****************************************************************************
2034 build_assoc_xml_doc(xmlChar
*name
, association_t assoc
, xmlChar
**doc
)
2036 xmlTextWriterPtr writer
;
2040 if ((xbuf
= xmlBufferCreate()) == NULL
) {
2041 return (ERROR_XML_CREATE_BUFFER_FAILED
);
2044 if ((writer
= xmlNewTextWriterMemory(xbuf
, 0)) == NULL
) {
2045 return (ERROR_XML_CREATE_WRITER_FAILED
);
2048 if (xmlTextWriterStartDocument(writer
, "1.0", NULL
, NULL
) < 0) {
2049 return (ERROR_XML_START_DOC_FAILED
);
2052 /* Start element "isnsRequest". */
2053 if (xmlTextWriterStartElement(writer
, (xmlChar
*)ISNSREQUEST
) < 0) {
2054 return (ERROR_XML_START_ELEMENT_FAILED
);
2057 /* request getAssociated operation to get the entire list of obejct. */
2058 if (xmlTextWriterStartElement(writer
, (xmlChar
*)GETASSOCIATED
) < 0) {
2059 return (ERROR_XML_START_ELEMENT_FAILED
);
2064 /* write association type. */
2065 if (xmlTextWriterWriteElement(writer
,
2066 (xmlChar
*)ASSOCIATIONTYPE
,
2067 (xmlChar
*)DDOBJECTMEMBER
) < 0) {
2068 return (ERROR_XML_WRITE_ELEMENT_FAILED
);
2071 if (xmlTextWriterStartElement(writer
,
2072 (xmlChar
*)ISNSOBJECT
) < 0) {
2073 return (ERROR_XML_START_ELEMENT_FAILED
);
2076 if (xmlTextWriterStartElement(writer
,
2077 (xmlChar
*)NODEOBJECT
) < 0) {
2078 return (ERROR_XML_START_ELEMENT_FAILED
);
2081 /* Start attr "name". */
2082 if (xmlTextWriterWriteAttribute(writer
,
2083 (xmlChar
*)NAMEATTR
, name
) < 0) {
2084 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
2086 if (xmlTextWriterWriteAttribute(writer
,
2087 (xmlChar
*)TYPEATTR
, (xmlChar
*)EMPTYSTR
) < 0) {
2088 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
2090 if (xmlTextWriterWriteAttribute(writer
,
2091 (xmlChar
*)ALIASATTR
, (xmlChar
*)EMPTYSTR
) < 0) {
2092 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
2095 /* End element "Node". */
2096 if (xmlTextWriterEndElement(writer
) < 0) {
2097 return (ERROR_XML_END_ELEMENT_FAILED
);
2100 /* End element "isnsObject". */
2101 if (xmlTextWriterEndElement(writer
) < 0) {
2102 return (ERROR_XML_END_ELEMENT_FAILED
);
2106 /* write association type. */
2107 if (xmlTextWriterWriteElement(writer
,
2108 (xmlChar
*)ASSOCIATIONTYPE
,
2109 (xmlChar
*)DDOBJECTMEMBER
) < 0) {
2110 return (ERROR_XML_WRITE_ELEMENT_FAILED
);
2113 /* start isnsObject */
2114 if (xmlTextWriterStartElement(writer
,
2115 (xmlChar
*)ISNSOBJECT
) < 0) {
2116 return (ERROR_XML_START_ELEMENT_FAILED
);
2119 /* start DiscoveryDomain */
2120 if (xmlTextWriterStartElement(writer
,
2121 (xmlChar
*)DDOBJECT
) < 0) {
2122 return (ERROR_XML_START_ELEMENT_FAILED
);
2125 /* Start attr "name". */
2126 if (xmlTextWriterWriteAttribute(writer
,
2127 (xmlChar
*)NAMEATTR
, name
) < 0) {
2128 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
2131 /* End element "DiscoveryDomain". */
2132 if (xmlTextWriterEndElement(writer
) < 0) {
2133 return (ERROR_XML_END_ELEMENT_FAILED
);
2136 /* End element "isnsObject". */
2137 if (xmlTextWriterEndElement(writer
) < 0) {
2138 return (ERROR_XML_END_ELEMENT_FAILED
);
2142 /* write association type. */
2143 if (xmlTextWriterWriteElement(writer
,
2144 (xmlChar
*)ASSOCIATIONTYPE
,
2145 (xmlChar
*)DDSETOBJECTMEMBER
) < 0) {
2146 return (ERROR_XML_WRITE_ELEMENT_FAILED
);
2149 /* start isnsObject */
2150 if (xmlTextWriterStartElement(writer
,
2151 (xmlChar
*)ISNSOBJECT
) < 0) {
2152 return (ERROR_XML_START_ELEMENT_FAILED
);
2155 /* start DiscoveryDomainSet */
2156 if (xmlTextWriterStartElement(writer
,
2157 (xmlChar
*)DDSETOBJECT
) < 0) {
2158 return (ERROR_XML_START_ELEMENT_FAILED
);
2161 /* Start attr "name". */
2162 if (xmlTextWriterWriteAttribute(writer
,
2163 (xmlChar
*)NAMEATTR
, name
) < 0) {
2164 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
2167 /* End element "DiscoveryDomain". */
2168 if (xmlTextWriterEndElement(writer
) < 0) {
2169 return (ERROR_XML_END_ELEMENT_FAILED
);
2172 /* End element "isnsObject". */
2173 if (xmlTextWriterEndElement(writer
) < 0) {
2174 return (ERROR_XML_END_ELEMENT_FAILED
);
2178 /* write association type. */
2179 if (xmlTextWriterWriteElement(writer
,
2180 (xmlChar
*)ASSOCIATIONTYPE
,
2181 (xmlChar
*)DDSETOBJECTMEMBER
) < 0) {
2182 return (ERROR_XML_WRITE_ELEMENT_FAILED
);
2185 /* start isnsObject */
2186 if (xmlTextWriterStartElement(writer
,
2187 (xmlChar
*)ISNSOBJECT
) < 0) {
2188 return (ERROR_XML_START_ELEMENT_FAILED
);
2191 /* start DiscoveryDomain */
2192 if (xmlTextWriterStartElement(writer
,
2193 (xmlChar
*)DDOBJECT
) < 0) {
2194 return (ERROR_XML_START_ELEMENT_FAILED
);
2197 /* Start attr "name". */
2198 if (xmlTextWriterWriteAttribute(writer
,
2199 (xmlChar
*)NAMEATTR
, name
) < 0) {
2200 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
2203 /* End element "DiscoveryDomain". */
2204 if (xmlTextWriterEndElement(writer
) < 0) {
2205 return (ERROR_XML_END_ELEMENT_FAILED
);
2208 /* End element "isnsObject". */
2209 if (xmlTextWriterEndElement(writer
) < 0) {
2210 return (ERROR_XML_END_ELEMENT_FAILED
);
2217 /* end getAssociated */
2218 if (xmlTextWriterEndElement(writer
) < 0) {
2219 return (ERROR_XML_END_ELEMENT_FAILED
);
2222 /* End element "isnsRequest". */
2223 if (xmlTextWriterEndElement(writer
) < 0) {
2224 return (ERROR_XML_END_ELEMENT_FAILED
);
2226 if (xmlTextWriterEndDocument(writer
) < 0) {
2227 return (ERROR_XML_END_DOC_FAILED
);
2230 xmlFreeTextWriter(writer
);
2232 len
= xmlStrlen(xbuf
->content
) + 1;
2233 /* XXX - copy NULL at the end by having one more extra byte */
2234 if ((*doc
= xmlStrndup(xbuf
->content
, len
)) == NULL
) {
2235 return (ERROR_XML_STRDUP_FAILED
);
2238 xmlBufferFree(xbuf
);
2243 * ****************************************************************************
2245 * build_enumerate_xml_doc -
2246 * build association request doc based the name.
2247 * the resulted doc is passed in the doc ptr.
2249 * name - object type
2250 * doc - ptr to the resulted doc
2252 * ****************************************************************************
2255 build_enumerate_xml_doc(object_type obj
, xmlChar
**doc
)
2257 xmlTextWriterPtr writer
;
2261 if ((xbuf
= xmlBufferCreate()) == NULL
) {
2262 return (ERROR_XML_CREATE_BUFFER_FAILED
);
2265 if ((writer
= xmlNewTextWriterMemory(xbuf
, 0)) == NULL
) {
2266 return (ERROR_XML_CREATE_WRITER_FAILED
);
2269 if (xmlTextWriterStartDocument(writer
, "1.0", NULL
, NULL
) < 0) {
2270 return (ERROR_XML_START_DOC_FAILED
);
2273 /* Start element "isnsRequest". */
2274 if (xmlTextWriterStartElement(writer
, (xmlChar
*)ISNSREQUEST
) < 0) {
2275 return (ERROR_XML_START_ELEMENT_FAILED
);
2278 /* Start attr "xmlns". */
2279 if (xmlTextWriterWriteAttribute(writer
,
2281 (xmlChar
*)"http://www.sun.com/schema/isnsmanagement")) {
2282 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
2285 /* request enumerate operation to get the entire list of obejct. */
2286 if (xmlTextWriterStartElement(writer
, (xmlChar
*)ENUMERATE
) < 0) {
2287 return (ERROR_XML_START_ELEMENT_FAILED
);
2292 if (xmlTextWriterWriteElement(writer
,
2293 (xmlChar
*)ISNSOBJECTTYPE
, (xmlChar
*)NODEOBJECT
) < 0) {
2294 return (ERROR_XML_WRITE_ELEMENT_FAILED
);
2297 case (DiscoveryDomain
):
2298 if (xmlTextWriterWriteElement(writer
,
2299 (xmlChar
*)ISNSOBJECTTYPE
,
2300 (xmlChar
*)DDOBJECT
) < 0) {
2301 return (ERROR_XML_WRITE_ELEMENT_FAILED
);
2304 case (DiscoveryDomainSet
):
2305 if (xmlTextWriterWriteElement(writer
,
2306 (xmlChar
*)ISNSOBJECTTYPE
,
2307 (xmlChar
*)DDSETOBJECT
) < 0) {
2308 return (ERROR_XML_WRITE_ELEMENT_FAILED
);
2315 /* end isns object type */
2316 if (xmlTextWriterEndElement(writer
) < 0) {
2317 return (ERROR_XML_END_ELEMENT_FAILED
);
2320 /* End element "isnsRequest". */
2321 if (xmlTextWriterEndElement(writer
) < 0) {
2322 return (ERROR_XML_END_ELEMENT_FAILED
);
2324 if (xmlTextWriterEndDocument(writer
) < 0) {
2325 return (ERROR_XML_END_DOC_FAILED
);
2328 xmlFreeTextWriter(writer
);
2330 len
= xmlStrlen(xbuf
->content
) + 1;
2331 /* XXX - copy NULL at the end by having one more extra byte */
2332 if ((*doc
= xmlStrndup(xbuf
->content
, len
)) == NULL
) {
2333 return (ERROR_XML_STRDUP_FAILED
);
2336 xmlBufferFree(xbuf
);
2341 * ****************************************************************************
2343 * build_get_xml_doc -
2344 * build association request doc based the name.
2345 * the resulted doc is passed in the doc ptr.
2347 * name - object type
2348 * assoc - association type
2349 * doc - ptr to the resulted doc
2351 * ****************************************************************************
2354 build_get_xml_doc(int operandLen
, char **operand
, object_type obj
,
2357 xmlTextWriterPtr writer
;
2361 if ((xbuf
= xmlBufferCreate()) == NULL
) {
2362 return (ERROR_XML_CREATE_BUFFER_FAILED
);
2365 if ((writer
= xmlNewTextWriterMemory(xbuf
, 0)) == NULL
) {
2366 return (ERROR_XML_CREATE_WRITER_FAILED
);
2369 if (xmlTextWriterStartDocument(writer
, "1.0", NULL
, NULL
) < 0) {
2370 return (ERROR_XML_START_DOC_FAILED
);
2373 /* Start element "isnsRequest". */
2374 if (xmlTextWriterStartElement(writer
, (xmlChar
*)ISNSREQUEST
) < 0) {
2375 return (ERROR_XML_START_ELEMENT_FAILED
);
2378 /* Start attr "xmlns". */
2379 if (xmlTextWriterWriteAttribute(writer
,
2381 (xmlChar
*)"http://www.sun.com/schema/isnsmanagement")) {
2382 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
2385 /* Start element "get". */
2386 if (xmlTextWriterStartElement(writer
, (xmlChar
*)GET
) < 0) {
2387 return (ERROR_XML_START_ELEMENT_FAILED
);
2392 for (i
= 0; i
< operandLen
; i
++) {
2393 /* Start element "isnsObject". */
2394 if (xmlTextWriterStartElement(writer
,
2395 (xmlChar
*)ISNSOBJECT
) < 0) {
2396 return (ERROR_XML_START_ELEMENT_FAILED
);
2399 /* Start element Node. */
2400 if (xmlTextWriterStartElement(writer
,
2401 (xmlChar
*)NODEOBJECT
) < 0) {
2402 return (ERROR_XML_START_ELEMENT_FAILED
);
2405 /* Start attr "name". */
2406 if (xmlTextWriterWriteAttribute(writer
,
2407 (xmlChar
*)NAMEATTR
, (xmlChar
*)operand
[i
]) < 0) {
2408 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
2410 if (xmlTextWriterWriteAttribute(writer
,
2411 (xmlChar
*)TYPEATTR
, (xmlChar
*)EMPTYSTR
) < 0) {
2412 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
2414 if (xmlTextWriterWriteAttribute(writer
,
2415 (xmlChar
*)ALIASATTR
, (xmlChar
*)EMPTYSTR
) < 0) {
2416 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
2419 /* End element "Node". */
2420 if (xmlTextWriterEndElement(writer
) < 0) {
2421 return (ERROR_XML_END_ELEMENT_FAILED
);
2424 /* End element "isnsObject". */
2425 if (xmlTextWriterEndElement(writer
) < 0) {
2426 return (ERROR_XML_END_ELEMENT_FAILED
);
2430 case (DiscoveryDomain
):
2431 for (i
= 0; i
< operandLen
; i
++) {
2432 /* Start element "isnsObject". */
2433 if (xmlTextWriterStartElement(writer
,
2434 (xmlChar
*)ISNSOBJECT
) < 0) {
2435 return (ERROR_XML_START_ELEMENT_FAILED
);
2438 if (xmlTextWriterStartElement(writer
,
2439 (xmlChar
*)DDOBJECT
) < 0) {
2440 return (ERROR_XML_START_ELEMENT_FAILED
);
2443 /* Start attr "name". */
2444 if (xmlTextWriterWriteAttribute(writer
,
2445 (xmlChar
*)NAMEATTR
, (xmlChar
*)operand
[i
]) < 0) {
2446 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
2449 /* End element "DiscoveryDomain". */
2450 if (xmlTextWriterEndElement(writer
) < 0) {
2451 return (ERROR_XML_END_ELEMENT_FAILED
);
2454 /* End element "isnsObject". */
2455 if (xmlTextWriterEndElement(writer
) < 0) {
2456 return (ERROR_XML_END_ELEMENT_FAILED
);
2460 case (DiscoveryDomainSet
):
2461 for (i
= 0; i
< operandLen
; i
++) {
2462 /* Start element "isnsObject". */
2463 if (xmlTextWriterStartElement(writer
,
2464 (xmlChar
*)ISNSOBJECT
) < 0) {
2465 return (ERROR_XML_START_ELEMENT_FAILED
);
2468 if (xmlTextWriterStartElement(writer
,
2469 (xmlChar
*)DDSETOBJECT
) < 0) {
2470 return (ERROR_XML_START_ELEMENT_FAILED
);
2473 /* Start attr "name". */
2474 if (xmlTextWriterWriteAttribute(writer
,
2475 (xmlChar
*)NAMEATTR
, (xmlChar
*)operand
[i
]) < 0) {
2476 return (ERROR_XML_WRITE_ATTRIBUTE_FAILED
);
2479 /* End element "DiscoveryDomain". */
2480 if (xmlTextWriterEndElement(writer
) < 0) {
2481 return (ERROR_XML_END_ELEMENT_FAILED
);
2484 /* End element "isnsObject". */
2485 if (xmlTextWriterEndElement(writer
) < 0) {
2486 return (ERROR_XML_END_ELEMENT_FAILED
);
2490 case (ServerConfig
):
2491 if (xmlTextWriterStartElement(writer
,
2492 (xmlChar
*)ISNSSERVER
) < 0) {
2493 return (ERROR_XML_START_ELEMENT_FAILED
);
2495 if (xmlTextWriterEndElement(writer
) < 0) {
2496 return (ERROR_XML_END_ELEMENT_FAILED
);
2503 /* End element "get". */
2504 if (xmlTextWriterEndElement(writer
) < 0) {
2505 return (ERROR_XML_END_ELEMENT_FAILED
);
2507 /* End element "isnsRequest". */
2508 if (xmlTextWriterEndElement(writer
) < 0) {
2509 return (ERROR_XML_END_ELEMENT_FAILED
);
2511 if (xmlTextWriterEndDocument(writer
) < 0) {
2512 return (ERROR_XML_END_DOC_FAILED
);
2515 xmlFreeTextWriter(writer
);
2517 len
= xmlStrlen(xbuf
->content
) + 1;
2518 /* XXX - copy NULL at the end by having one more extra byte */
2519 if ((*doc
= xmlStrndup(xbuf
->content
, len
)) == NULL
) {
2520 return (ERROR_XML_STRDUP_FAILED
);
2523 xmlBufferFree(xbuf
);
2528 * ****************************************************************************
2531 * isnsadm list-node [options] [<node name>, ...]
2533 * operandLen - number of operands user passed into the cli
2534 * operand - pointer to operand list from user
2535 * options - pointer to option list from user
2537 * ****************************************************************************
2541 list_node_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
2545 cmdOptions_t
*optionList
= options
;
2546 xmlChar
*doc
, *e_doc
;
2551 for (; optionList
->optval
; optionList
++) {
2552 switch (optionList
->optval
) {
2554 flag
|= INITIATOR_ONLY
;
2557 flag
|= TARGET_ONLY
;
2567 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
2568 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
2572 /* No operand specified. Issue enumerate. */
2573 if (operandLen
== 0) {
2574 ret
= build_enumerate_xml_doc(Node
, &doc
);
2577 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
2580 bzero(&darg
, sizeof (darg
));
2581 darg
.data_ptr
= (char *)doc
;
2582 darg
.data_size
= xmlStrlen(doc
) + 1;
2586 if ((flag
& VERBOSE
) == VERBOSE
) {
2587 if ((door_call(fd
, &darg
)) == -1) {
2588 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
2590 (void) xmlFree(doc
);
2594 if ((ret
= cvt_enumerate_rsp_to_get_req((xmlChar
*)darg
.rbuf
,
2595 &e_doc
, Node
, flag
)) != 0) {
2596 (void) munmap(darg
.rbuf
, darg
.rsize
);
2598 (void) xmlFree(doc
);
2599 if (ret
!= SUCCESS_WITH_NO_OBJECT
) {
2600 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
2602 ret
= SUBCOMMAND_SUCCESS
;
2606 (void) munmap(darg
.rbuf
, darg
.rsize
);
2607 (void) xmlFree(doc
);
2609 bzero(&darg
, sizeof (door_arg_t
));
2610 darg
.data_ptr
= (char *)doc
;
2611 darg
.data_size
= xmlStrlen(doc
) + 1;
2617 if ((ret
= build_get_xml_doc(operandLen
, operand
, Node
, &doc
)) ==
2619 bzero(&darg
, sizeof (darg
));
2620 darg
.data_ptr
= (char *)doc
;
2621 darg
.data_size
= xmlStrlen(doc
) + 1;
2625 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
2627 (void) xmlFree(doc
);
2632 if ((door_call(fd
, &darg
)) == -1) {
2633 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
2635 (void) xmlFree(doc
);
2639 if ((ret
= process_get_response(Node
, (xmlChar
*)darg
.rbuf
, flag
)) !=
2642 * door frame work allocated a buffer when the date lager that rbuf.
2643 * indicate if munmap is required on rbuf.
2645 (void) munmap(darg
.rbuf
, darg
.rsize
);
2646 (void) xmlFree(doc
);
2651 (void) munmap(darg
.rbuf
, darg
.rsize
);
2655 return (SUBCOMMAND_SUCCESS
);
2659 * ****************************************************************************
2662 * isnsadm list-dd [options] [<dd name>, ...]
2664 * operandLen - number of operands user passed into the cli
2665 * operand - pointer to operand list from user
2666 * options - pointer to option list from user
2668 * ****************************************************************************
2672 list_dd_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
2675 cmdOptions_t
*optionList
= options
;
2676 xmlChar
*doc
, *e_doc
;
2681 for (; optionList
->optval
; optionList
++) {
2682 switch (optionList
->optval
) {
2689 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
2690 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
2694 /* No operand specified. Issue enumerate. */
2695 if (operandLen
== 0) {
2696 ret
= build_enumerate_xml_doc(DiscoveryDomain
, &doc
);
2699 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
2702 /* get the enumerate resposne first. */
2703 bzero(&darg
, sizeof (darg
));
2704 darg
.data_ptr
= (char *)doc
;
2705 darg
.data_size
= xmlStrlen(doc
) + 1;
2708 if ((door_call(fd
, &darg
)) == -1) {
2709 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
2711 (void) xmlFree(doc
);
2714 if ((ret
= cvt_enumerate_rsp_to_get_req((xmlChar
*)darg
.rbuf
,
2715 &e_doc
, DiscoveryDomain
, flag
)) != 0) {
2716 (void) munmap(darg
.rbuf
, darg
.rsize
);
2718 (void) xmlFree(doc
);
2719 if (ret
!= SUCCESS_WITH_NO_OBJECT
) {
2720 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
2722 ret
= SUBCOMMAND_SUCCESS
;
2726 (void) munmap(darg
.rbuf
, darg
.rsize
);
2727 (void) xmlFree(doc
);
2731 if ((ret
= build_get_xml_doc(operandLen
, operand
,
2732 DiscoveryDomain
, &doc
)) != 0) {
2733 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
2735 (void) xmlFree(doc
);
2740 bzero(&darg
, sizeof (darg
));
2741 darg
.data_ptr
= (char *)doc
;
2742 darg
.data_size
= xmlStrlen(doc
) + 1;
2746 if ((door_call(fd
, &darg
)) == -1) {
2747 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
2749 (void) xmlFree(doc
);
2753 if ((ret
= process_get_response(DiscoveryDomain
, (xmlChar
*)darg
.rbuf
,
2755 (void) munmap(darg
.rbuf
, darg
.rsize
);
2757 (void) xmlFree(doc
);
2761 (void) munmap(darg
.rbuf
, darg
.rsize
);
2766 return (SUBCOMMAND_SUCCESS
);
2770 * ****************************************************************************
2773 * isnsadm list-dd-set [options] [<dd set name>, ...]
2775 * operandLen - number of operands user passed into the cli
2776 * operand - pointer to operand list from user
2777 * options - pointer to option list from user
2779 * ****************************************************************************
2783 list_ddset_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
2786 cmdOptions_t
*optionList
= options
;
2787 xmlChar
*doc
, *e_doc
;
2792 for (; optionList
->optval
; optionList
++) {
2793 switch (optionList
->optval
) {
2800 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
2801 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
2805 /* No operand specified. Issue enumerate. */
2806 if (operandLen
== 0) {
2807 ret
= build_enumerate_xml_doc(DiscoveryDomainSet
, &doc
);
2810 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
2813 /* get the enumerate resposne. */
2814 bzero(&darg
, sizeof (darg
));
2815 darg
.data_ptr
= (char *)doc
;
2816 darg
.data_size
= xmlStrlen(doc
) + 1;
2819 if ((door_call(fd
, &darg
)) == -1) {
2820 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
2822 (void) xmlFree(doc
);
2826 if ((ret
= cvt_enumerate_rsp_to_get_req((xmlChar
*)darg
.rbuf
,
2827 &e_doc
, DiscoveryDomainSet
, flag
)) != 0) {
2828 (void) munmap(darg
.rbuf
, darg
.rsize
);
2830 (void) xmlFree(doc
);
2831 if (ret
!= SUCCESS_WITH_NO_OBJECT
) {
2832 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
2834 ret
= SUBCOMMAND_SUCCESS
;
2838 (void) munmap(darg
.rbuf
, darg
.rsize
);
2839 (void) xmlFree(doc
);
2841 bzero(&darg
, sizeof (darg
));
2842 darg
.data_ptr
= (char *)doc
;
2843 darg
.data_size
= xmlStrlen(doc
) + 1;
2848 if ((ret
= build_get_xml_doc(operandLen
, operand
,
2849 DiscoveryDomainSet
, &doc
)) == 0) {
2850 bzero(&darg
, sizeof (darg
));
2851 darg
.data_ptr
= (char *)doc
;
2852 darg
.data_size
= xmlStrlen(doc
) + 1;
2856 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
2860 if ((door_call(fd
, &darg
)) == -1) {
2861 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
2863 (void) xmlFree(doc
);
2868 * door frame work allocated a buffer when the date lager that rbuf.
2869 * indicate if munmap is required on rbuf.
2871 if ((ret
= process_get_response(DiscoveryDomainSet
,
2872 (xmlChar
*)darg
.rbuf
, flag
)) != 0) {
2873 (void) munmap(darg
.rbuf
, darg
.rsize
);
2875 (void) xmlFree(doc
);
2879 (void) munmap(darg
.rbuf
, darg
.rsize
);
2881 (void) xmlFree(doc
);
2883 return (SUBCOMMAND_SUCCESS
);
2887 * ****************************************************************************
2890 * create a DiscoveryDomain create-dd <dd name>, ...
2892 * operandLen - number of operands user passed into the cli
2893 * operand - pointer to operand list from user
2894 * options - pointer to option list from user
2896 * ****************************************************************************
2900 create_dd_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
2908 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
2909 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
2913 if ((ret
= build_create_xml_doc(operandLen
, operand
,
2914 DiscoveryDomain
, NULL
, &doc
)) == 0) {
2915 bzero(&darg
, sizeof (darg
));
2916 darg
.data_ptr
= (char *)doc
;
2917 darg
.data_size
= xmlStrlen(doc
) + 1;
2922 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
2926 if ((door_call(fd
, &darg
)) == -1) {
2927 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
2929 (void) xmlFree(doc
);
2934 * door frame work allocated a buffer when the date lager that rbuf.
2935 * indicate if munmap is required on rbuf.
2937 if ((ret
= process_result_response((xmlChar
*)darg
.rbuf
,
2938 DiscoveryDomain
)) != 0) {
2939 (void) munmap(darg
.rbuf
, darg
.rsize
);
2941 (void) xmlFree(doc
);
2945 (void) munmap(darg
.rbuf
, darg
.rsize
);
2949 return (SUBCOMMAND_SUCCESS
);
2953 * ****************************************************************************
2955 * create_ddset_func -
2956 * create a DiscoveryDomainSet create-dd-set <dd set name>, ...
2958 * operandLen - number of operands user passed into the cli
2959 * operand - pointer to operand list from user
2960 * options - pointer to option list from user
2962 * ****************************************************************************
2966 create_ddset_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
2974 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
2975 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
2979 if ((ret
= build_create_xml_doc(operandLen
, operand
,
2980 DiscoveryDomainSet
, NULL
, &doc
)) == 0) {
2981 bzero(&darg
, sizeof (darg
));
2982 darg
.data_ptr
= (char *)doc
;
2983 darg
.data_size
= xmlStrlen(doc
) + 1;
2987 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
2992 if ((door_call(fd
, &darg
)) == -1) {
2993 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
2995 (void) xmlFree(doc
);
3000 * door frame work allocated a buffer when the date lager that rbuf.
3001 * indicate if munmap is required on rbuf.
3003 if ((ret
= process_result_response((xmlChar
*)darg
.rbuf
,
3004 DiscoveryDomainSet
)) != 0) {
3005 (void) munmap(darg
.rbuf
, darg
.rsize
);
3007 (void) xmlFree(doc
);
3011 (void) munmap(darg
.rbuf
, darg
.rsize
);
3016 return (SUBCOMMAND_SUCCESS
);
3020 * ****************************************************************************
3023 * Modify a dd attr. currently rename function is supported
3024 * modify-dd -n name <dd name>
3026 * operandLen - number of operands user passed into the cli
3027 * operand - pointer to operand list from user
3028 * options - pointer to option list from user
3030 * ****************************************************************************
3034 modify_dd_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
3038 xmlTextReaderPtr reader
;
3044 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
3045 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
3049 if ((ret
= build_get_xml_doc(operandLen
, operand
,
3050 DiscoveryDomain
, &doc
)) == 0) {
3051 bzero(&darg
, sizeof (darg
));
3052 darg
.data_ptr
= (char *)doc
;
3053 darg
.data_size
= xmlStrlen(doc
) + 1;
3057 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
3062 if ((door_call(fd
, &darg
)) == -1) {
3063 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
3065 (void) xmlFree(doc
);
3069 /* Free the request that is created by xmlStrnDup. */
3070 (void) xmlFree(doc
);
3073 * door frame work allocated a buffer when the date lager that rbuf.
3074 * indicate if munmap is required on rbuf.
3076 if ((ret
= process_result_response((xmlChar
*)darg
.rbuf
,
3077 DiscoveryDomain
)) != 0) {
3078 (void) munmap(darg
.rbuf
, darg
.rsize
);
3083 /* setup xml parser on the response. */
3084 if ((reader
= (xmlTextReaderPtr
)xmlReaderForMemory
3085 ((const char *)darg
.rbuf
, xmlStrlen((xmlChar
*)darg
.rbuf
),
3086 NULL
, NULL
, 0)) == NULL
) {
3087 (void) munmap(darg
.rbuf
, darg
.rsize
);
3089 return (ERROR_XML_READER_NULL
);
3092 if (reader
= lookup_next_matching_elem(reader
, &m_flag
, DDOBJECT
,
3094 if (m_flag
== READER_MATCH
) {
3095 if ((xmlTextReaderMoveToAttribute(reader
,
3096 (const xmlChar
*)IDATTR
)) == 1) {
3097 id
= atoi((const char *)xmlTextReaderConstValue(reader
));
3099 (void) xmlTextReaderClose(reader
);
3100 (void) xmlFreeTextReader(reader
);
3101 return (ERROR_XML_ID_ATTR_NOT_FOUND
);
3104 (void) xmlTextReaderClose(reader
);
3105 (void) xmlFreeTextReader(reader
);
3106 return (ERROR_XML_DD_OBJECT_NOT_FOUND
);
3109 (void) fprintf(stderr
, "%s\n",
3110 getTextMessage(ERROR_XML_READER_NULL
));
3111 return (ERROR_XML_READER_NULL
);
3114 (void) xmlTextReaderClose(reader
);
3115 (void) xmlFreeTextReader(reader
);
3117 if ((ret
= build_rename_xml_doc(options
->optarg
, DiscoveryDomain
,
3119 bzero(&darg
, sizeof (darg
));
3120 darg
.data_ptr
= (char *)doc
;
3121 darg
.data_size
= xmlStrlen(doc
) + 1;
3125 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
3130 if ((door_call(fd
, &darg
)) == -1) {
3131 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
3133 (void) xmlFree(doc
);
3138 * door frame work allocated a buffer when the date lager that rbuf.
3139 * indicate if munmap is required on rbuf.
3141 if ((ret
= process_result_response((xmlChar
*)darg
.rbuf
,
3142 DiscoveryDomain
)) != 0) {
3143 (void) munmap(darg
.rbuf
, darg
.rsize
);
3145 (void) xmlFree(doc
);
3149 (void) munmap(darg
.rbuf
, darg
.rsize
);
3153 return (SUBCOMMAND_SUCCESS
);
3157 * ****************************************************************************
3159 * modify_ddset_func -
3160 * Modify a dd attr. currently rename function is supported
3161 * modify-dd-set -n name <dd name>
3163 * operandLen - number of operands user passed into the cli
3164 * operand - pointer to operand list from user
3165 * options - pointer to option list from user
3167 * ****************************************************************************
3171 modify_ddset_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
3175 xmlTextReaderPtr reader
;
3181 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
3182 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
3186 if ((ret
= build_get_xml_doc(operandLen
, operand
,
3187 DiscoveryDomainSet
, &doc
)) == 0) {
3188 bzero(&darg
, sizeof (darg
));
3189 darg
.data_ptr
= (char *)doc
;
3190 darg
.data_size
= xmlStrlen(doc
) + 1;
3194 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
3199 if ((door_call(fd
, &darg
)) == -1) {
3200 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
3202 (void) xmlFree(doc
);
3206 /* Free the request that is created by xmlStrnDup. */
3207 (void) xmlFree(doc
);
3210 * door frame work allocated a buffer when the date lager that rbuf.
3211 * indicate if munmap is required on rbuf.
3213 if ((ret
= process_result_response((xmlChar
*)darg
.rbuf
,
3214 DiscoveryDomainSet
)) != 0) {
3215 (void) munmap(darg
.rbuf
, darg
.rsize
);
3220 /* setup xml parser on the response. */
3221 if ((reader
= (xmlTextReaderPtr
)xmlReaderForMemory
3222 ((const char *)darg
.rbuf
, xmlStrlen((xmlChar
*)darg
.rbuf
),
3223 NULL
, NULL
, 0)) == NULL
) {
3224 (void) munmap(darg
.rbuf
, darg
.rsize
);
3226 return (ERROR_XML_READER_NULL
);
3229 if (reader
= lookup_next_matching_elem(reader
, &m_flag
, DDSETOBJECT
,
3231 if (m_flag
== READER_MATCH
) {
3232 if ((xmlTextReaderMoveToAttribute(reader
,
3233 (const xmlChar
*)IDATTR
)) == 1) {
3234 id
= atoi((const char *)xmlTextReaderConstValue(reader
));
3236 (void) xmlTextReaderClose(reader
);
3237 (void) xmlFreeTextReader(reader
);
3238 return (ERROR_XML_ID_ATTR_NOT_FOUND
);
3241 (void) xmlTextReaderClose(reader
);
3242 (void) xmlFreeTextReader(reader
);
3243 (void) fprintf(stderr
, "%s\n",
3244 getTextMessage(ERROR_XML_NAME_ATTR_NOT_FOUND
));
3245 return (ERROR_XML_DD_SET_OBJECT_NOT_FOUND
);
3249 (void) xmlTextReaderClose(reader
);
3250 (void) xmlFreeTextReader(reader
);
3252 if ((ret
= build_rename_xml_doc(options
->optarg
, DiscoveryDomainSet
,
3254 bzero(&darg
, sizeof (darg
));
3255 darg
.data_ptr
= (char *)doc
;
3256 darg
.data_size
= xmlStrlen(doc
) + 1;
3260 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
3265 if ((door_call(fd
, &darg
)) == -1) {
3266 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
3268 (void) xmlFree(doc
);
3273 * door frame work allocated a buffer when the date lager that rbuf.
3274 * indicate if munmap is required on rbuf.
3276 if ((ret
= process_result_response((xmlChar
*)darg
.rbuf
,
3277 DiscoveryDomainSet
)) != 0) {
3278 (void) munmap(darg
.rbuf
, darg
.rsize
);
3280 (void) xmlFree(doc
);
3284 (void) munmap(darg
.rbuf
, darg
.rsize
);
3288 return (SUBCOMMAND_SUCCESS
);
3292 * ****************************************************************************
3295 * Add a node to a DiscoveryDomain add-node -d dd-name <node name>, ...
3297 * operandLen - number of operands user passed into the cli
3298 * operand - pointer to operand list from user
3299 * options - pointer to option list from user
3301 * ****************************************************************************
3305 add_node_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
3313 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
3314 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
3318 if ((ret
= build_create_xml_doc(operandLen
, operand
,
3319 DiscoveryDomainMember
, options
->optarg
, &doc
)) == 0) {
3320 bzero(&darg
, sizeof (darg
));
3321 darg
.data_ptr
= (char *)doc
;
3322 darg
.data_size
= xmlStrlen(doc
) + 1;
3326 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
3331 if ((door_call(fd
, &darg
)) == -1) {
3332 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
3334 (void) xmlFree(doc
);
3339 * door frame work allocated a buffer when the date lager that rbuf.
3340 * indicate if munmap is required on rbuf.
3342 if ((ret
= process_result_response((xmlChar
*)darg
.rbuf
,
3343 DiscoveryDomainMember
)) != 0) {
3344 (void) munmap(darg
.rbuf
, darg
.rsize
);
3346 (void) xmlFree(doc
);
3350 (void) munmap(darg
.rbuf
, darg
.rsize
);
3354 return (SUBCOMMAND_SUCCESS
);
3358 * ****************************************************************************
3361 * Add a dd to a DiscoveryDomainSet add-dd -s dd-set name <dd name>, ...
3363 * operandLen - number of operands user passed into the cli
3364 * operand - pointer to operand list from user
3365 * options - pointer to option list from user
3367 * ****************************************************************************
3371 add_dd_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
3379 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
3380 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
3384 if ((ret
= build_create_xml_doc(operandLen
, operand
,
3385 DiscoveryDomainSetMember
, options
->optarg
, &doc
)) == 0) {
3386 bzero(&darg
, sizeof (darg
));
3387 darg
.data_ptr
= (char *)doc
;
3388 darg
.data_size
= xmlStrlen(doc
) + 1;
3392 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
3397 if ((door_call(fd
, &darg
)) == -1) {
3398 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
3400 (void) xmlFree(doc
);
3405 * door frame work allocated a buffer when the date lager that rbuf.
3406 * indicate if munmap is required on rbuf.
3408 if ((ret
= process_result_response((xmlChar
*)darg
.rbuf
,
3409 DiscoveryDomainSetMember
)) != 0) {
3410 (void) munmap(darg
.rbuf
, darg
.rsize
);
3412 (void) xmlFree(doc
);
3416 (void) munmap(darg
.rbuf
, darg
.rsize
);
3420 return (SUBCOMMAND_SUCCESS
);
3424 * ****************************************************************************
3426 * remove_node_func -
3427 * Remove a node from DiscoveryDomain
3428 * remov-node -d dd-name <node name>, ...
3430 * operandLen - number of operands user passed into the cli
3431 * operand - pointer to operand list from user
3432 * options - pointer to option list from user
3434 * ****************************************************************************
3438 remove_node_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
3446 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
3447 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
3451 if ((ret
= build_delete_xml_doc(operandLen
, operand
,
3452 DiscoveryDomainMember
, options
->optarg
, &doc
)) == 0) {
3453 bzero(&darg
, sizeof (darg
));
3454 darg
.data_ptr
= (char *)doc
;
3455 darg
.data_size
= xmlStrlen(doc
) + 1;
3459 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
3464 if ((door_call(fd
, &darg
)) == -1) {
3465 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
3467 (void) xmlFree(doc
);
3472 * door frame work allocated a buffer when the date lager that rbuf.
3473 * indicate if munmap is required on rbuf.
3475 if ((ret
= process_result_response((xmlChar
*)darg
.rbuf
,
3476 DiscoveryDomainMember
)) != 0) {
3477 (void) munmap(darg
.rbuf
, darg
.rsize
);
3479 (void) xmlFree(doc
);
3483 (void) munmap(darg
.rbuf
, darg
.rsize
);
3487 return (SUBCOMMAND_SUCCESS
);
3491 * ****************************************************************************
3494 * Remove a dd from DiscoveryDomainSet
3495 * remove-dd -s dd-set name <dd name>, ...
3497 * operandLen - number of operands user passed into the cli
3498 * operand - pointer to operand list from user
3499 * options - pointer to option list from user
3501 * ****************************************************************************
3505 remove_dd_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
3513 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
3514 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
3518 if ((ret
= build_delete_xml_doc(operandLen
, operand
,
3519 DiscoveryDomainSetMember
, options
->optarg
, &doc
)) == 0) {
3520 bzero(&darg
, sizeof (darg
));
3521 darg
.data_ptr
= (char *)doc
;
3522 darg
.data_size
= xmlStrlen(doc
) + 1;
3526 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
3531 if ((door_call(fd
, &darg
)) == -1) {
3532 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
3534 (void) xmlFree(doc
);
3539 * door frame work allocated a buffer when the date lager that rbuf.
3540 * indicate if munmap is required on rbuf.
3542 if ((ret
= process_result_response((xmlChar
*)darg
.rbuf
,
3543 DiscoveryDomainSetMember
)) != 0) {
3544 (void) munmap(darg
.rbuf
, darg
.rsize
);
3546 (void) xmlFree(doc
);
3550 (void) munmap(darg
.rbuf
, darg
.rsize
);
3554 return (SUBCOMMAND_SUCCESS
);
3558 * ****************************************************************************
3561 * remove a DiscoveryDomain remove-dd <dd name>, ...
3563 * operandLen - number of operands user passed into the cli
3564 * operand - pointer to operand list from user
3565 * options - pointer to option list from user
3567 * ****************************************************************************
3571 delete_dd_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
3579 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
3580 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
3584 if ((ret
= build_delete_xml_doc(operandLen
, operand
,
3585 DiscoveryDomain
, NULL
, &doc
)) == 0) {
3586 bzero(&darg
, sizeof (darg
));
3587 darg
.data_ptr
= (char *)doc
;
3588 darg
.data_size
= xmlStrlen(doc
) + 1;
3592 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
3597 if ((door_call(fd
, &darg
)) == -1) {
3598 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
3600 (void) xmlFree(doc
);
3605 * door frame work allocated a buffer when the date lager that rbuf.
3606 * indicate if munmap is required on rbuf.
3608 if ((ret
= process_result_response((xmlChar
*)darg
.rbuf
,
3609 DiscoveryDomain
)) != 0) {
3610 (void) munmap(darg
.rbuf
, darg
.rsize
);
3612 (void) xmlFree(doc
);
3616 (void) munmap(darg
.rbuf
, darg
.rsize
);
3621 return (SUBCOMMAND_SUCCESS
);
3625 * ****************************************************************************
3627 * delete_ddset_func -
3628 * delete DiscoveryDomainSet(s) delete-dd-set <dd set name>, ...
3630 * operandLen - number of operands user passed into the cli
3631 * operand - pointer to operand list from user
3632 * options - pointer to option list from user
3634 * ****************************************************************************
3638 delete_ddset_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
3646 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
3647 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
3651 if ((ret
= build_delete_xml_doc(operandLen
, operand
,
3652 DiscoveryDomainSet
, NULL
, &doc
)) == 0) {
3653 bzero(&darg
, sizeof (darg
));
3654 darg
.data_ptr
= (char *)doc
;
3655 darg
.data_size
= xmlStrlen(doc
) + 1;
3659 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
3664 if ((door_call(fd
, &darg
)) == -1) {
3665 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
3667 (void) xmlFree(doc
);
3672 * door frame work allocated a buffer when the date lager that rbuf.
3673 * indicate if munmap is required on rbuf.
3675 if ((ret
= process_result_response((xmlChar
*)darg
.rbuf
,
3676 DiscoveryDomainSet
)) != 0) {
3677 (void) munmap(darg
.rbuf
, darg
.rsize
);
3679 (void) xmlFree(doc
);
3683 (void) munmap(darg
.rbuf
, darg
.rsize
);
3687 return (SUBCOMMAND_SUCCESS
);
3691 * ****************************************************************************
3694 * enables/disables DiscoveryDomainSet(s)
3696 * operandLen - number of operands user passed into the cli
3697 * operand - pointer to operand list from user
3698 * enable - indication of enable/disable
3700 * ****************************************************************************
3703 i_enableddset(int operandLen
, char *operand
[], boolean_t enable
)
3709 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
3710 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
3714 if ((ret
= build_modify_xml_doc(operandLen
, operand
,
3715 DiscoveryDomainSet
, enable
, &doc
)) == 0) {
3716 bzero(&darg
, sizeof (darg
));
3717 darg
.data_ptr
= (char *)doc
;
3718 darg
.data_size
= xmlStrlen(doc
) + 1;
3722 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
3727 if ((door_call(fd
, &darg
)) == -1) {
3728 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
3730 (void) xmlFree(doc
);
3736 if ((ret
= process_result_response((xmlChar
*)darg
.rbuf
,
3737 DiscoveryDomainSet
)) != 0) {
3738 (void) munmap(darg
.rbuf
, darg
.rsize
);
3743 (void) munmap(darg
.rbuf
, darg
.rsize
);
3745 return (SUBCOMMAND_SUCCESS
);
3749 * ****************************************************************************
3751 * enable_ddset_func -
3752 * enables DiscoveryDomainSet(s) enable-dd-set <dd set name>, ...
3754 * operandLen - number of operands user passed into the cli
3755 * operand - pointer to operand list from user
3756 * options - pointer to option list from user
3758 * ****************************************************************************
3762 enable_ddset_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
3765 return (i_enableddset(operandLen
, operand
, B_TRUE
));
3769 * ****************************************************************************
3772 * disable DiscoveryDomainSet(s) disable-dd-set <dd set name>, ...
3774 * operandLen - number of operands user passed into the cli
3775 * operand - pointer to operand list from user
3776 * options - pointer to option list from user
3778 * ****************************************************************************
3782 disable_ddset_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
3785 return (i_enableddset(operandLen
, operand
, B_FALSE
));
3789 * ****************************************************************************
3791 * show_config_func -
3792 * isnsadm show-config
3794 * operandLen - number of operands user passed into the cli
3795 * operand - pointer to operand list from user
3796 * options - pointer to option list from user
3798 * ****************************************************************************
3802 show_config_func(int operandLen
, char *operand
[], cmdOptions_t
*options
,
3810 if ((fd
= open(ISNS_DOOR_NAME
, O_RDONLY
)) == -1) {
3811 ret
= check_door_error(ERROR_DOOR_OPEN_FAILED
, errno
);
3815 if ((ret
= build_get_xml_doc(operandLen
, operand
,
3816 ServerConfig
, &doc
)) == 0) {
3817 bzero(&darg
, sizeof (darg
));
3818 darg
.data_ptr
= (char *)doc
;
3819 darg
.data_size
= xmlStrlen(doc
) + 1;
3823 (void) fprintf(stderr
, "%s\n", getTextMessage(ret
));
3825 (void) xmlFree(doc
);
3829 if ((door_call(fd
, &darg
)) == -1) {
3830 ret
= check_door_error(ERROR_DOOR_CALL_FAILED
, errno
);
3832 (void) xmlFree(doc
);
3836 if ((ret
= process_get_response(ServerConfig
, (xmlChar
*)darg
.rbuf
,
3838 (void) munmap(darg
.rbuf
, darg
.rsize
);
3840 (void) xmlFree(doc
);
3844 (void) munmap(darg
.rbuf
, darg
.rsize
);
3848 return (SUBCOMMAND_SUCCESS
);
3852 * *************************************************************************
3856 * *************************************************************************
3859 main(int argc
, char *argv
[])
3861 synTables_t synTables
;
3862 char versionString
[VERSION_STRING_MAX_LEN
];
3865 void *subcommandArgs
= NULL
;
3867 (void) setlocale(LC_ALL
, "");
3869 (void) sprintf(versionString
, "%2s.%2s",
3870 VERSION_STRING_MAJOR
, VERSION_STRING_MINOR
);
3871 synTables
.versionString
= versionString
;
3872 synTables
.longOptionTbl
= &longOptions
[0];
3873 synTables
.subCommandPropsTbl
= &subcommands
[0];
3875 ret
= cmdParse(argc
, argv
, synTables
, subcommandArgs
, &funcRet
);
3878 return (COMMAND_SYNTAX_FAILED
);
3879 } else if (ret
== -1) {
3882 } else if (ret
== 0) {
3884 * strawman way to sort out the error code.
3885 * isnsi server protocol error range 0 - 99
3886 * isns server maangement op error range 100 -199
3887 * isnsadm error range 200 -299
3889 if (funcRet
== SUBCOMMAND_SUCCESS
) {
3891 } else if (funcRet
> SUBCOMMAND_SUCCESS
) {
3892 if (funcRet
!= ERROR_DOOR_CALL_FAILED
&&
3893 funcRet
!= ERROR_DOOR_OPEN_FAILED
) {
3894 (void) fprintf(stderr
, "%s\n", getTextMessage(funcRet
));