xref: /titanic_51/usr/src/cmd/isns/isnsd/utils.c (revision c10c16dec587a0662068f6e2991c29ed3a9db943)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #include <libintl.h>
28 
29 #include "isns_utils.h"
30 #include "isns_protocol.h"
31 
32 char *
33 result_code_to_str(int code)
34 {
35 	switch (code) {
36 	    case ISNS_RSP_SUCCESSFUL:
37 		return ((char *)gettext("Successful Operation"));
38 	    case ISNS_RSP_UNKNOWN_ERROR:
39 		return ((char *)gettext("Unknown Error"));
40 	    case ISNS_RSP_MSG_FORMAT_ERROR:
41 		return ((char *)gettext("Message Format Error"));
42 	    case ISNS_RSP_INVALID_REGIS:
43 		return ((char *)gettext("Invalid Registration"));
44 	    case ISNS_RSP_INVALID_QRY:
45 		return ((char *)gettext("Invalid Query"));
46 	    case ISNS_RSP_SRC_UNKNOWN:
47 		return ((char *)gettext("Source Unknown"));
48 	    case ISNS_RSP_SRC_ABSENT:
49 		return ((char *)gettext("Source Absent"));
50 	    case ISNS_RSP_SRC_UNAUTHORIZED:
51 		return ((char *)gettext("Source Unauthorized"));
52 	    case ISNS_RSP_NO_SUCH_ENTRY:
53 		return ((char *)gettext("No Such Entry"));
54 	    case ISNS_RSP_VER_NOT_SUPPORTED:
55 		return ((char *)gettext("Version Not Supported"));
56 	    case ISNS_RSP_INTERNAL_ERROR:
57 		return ((char *)gettext("Internal Error"));
58 	    case ISNS_RSP_BUSY:
59 		return ((char *)gettext("Busy"));
60 	    case ISNS_RSP_OPTION_NOT_UNDERSTOOD:
61 		return ((char *)gettext("Option Not Understood"));
62 	    case ISNS_RSP_INVALID_UPDATE:
63 		return ((char *)gettext("Invalid Update"));
64 	    case ISNS_RSP_MSG_NOT_SUPPORTED:
65 		return ((char *)gettext("Message Not Supported"));
66 	    case ISNS_RSP_SCN_EVENT_REJECTED:
67 		return ((char *)gettext("SCN Event Rejected"));
68 	    case ISNS_RSP_SCN_REGIS_REJECTED:
69 		return ((char *)gettext("SCN Registration Rejected"));
70 	    case ISNS_RSP_ATTR_NOT_IMPL:
71 		return ((char *)gettext("Attribute Not Implemented"));
72 	    case ISNS_RSP_ESI_NOT_AVAILABLE:
73 		return ((char *)gettext("ESI Not Available"));
74 	    case ISNS_RSP_INVALID_DEREGIS:
75 		return ((char *)gettext("Invalid Deregistration"));
76 	    case ISNS_RSP_REGIS_NOT_SUPPORTED:
77 		return ((char *)gettext("Registration Not Supported"));
78 	    case PARTIAL_SUCCESS:
79 		return ((char *)gettext("Partial_success"));
80 	    case PARTIAL_FAILURE:
81 		return ((char *)gettext("Partial failure"));
82 	    case ERR_DOOR_ALREADY_RUNNING:
83 		return ((char *)gettext("iSNS managemnet door is already "
84 		    "running"));
85 	    case ERR_DOOR_CREATE_FAILED:
86 		return ((char *)gettext("Failed to create iSNS managemnet "
87 		    "door"));
88 	    case ERR_DOOR_MORE_SPACE:
89 		return ((char *)gettext("More space needed to return the "
90 		    "response"));
91 	    case ERR_INVALID_MGMT_REQUEST:
92 		return ((char *)gettext("Invalid managmenet request"));
93 	    case ERR_NULL_XML_MESSAGE:
94 		return ((char *)gettext("Null XML request"));
95 	    case ERR_XML_VALID_OPERATION_NOT_FOUND:
96 		return ((char *)gettext("XML Doc error: no valid operation "
97 		    "found"));
98 	    case ERR_XML_VALID_OBJECT_NOT_FOUND:
99 		return ((char *)gettext("XML Doc error: no valid object "
100 		    "found"));
101 	    case ERR_XML_FAIL_TO_CREATE_WRITE_BUFFER:
102 		return ((char *)gettext("failed to create XML witer buffer."));
103 	    case ERR_XML_FAIL_TO_GET_WRITEPTR:
104 		return ((char *)gettext("failed to get XML writer pointer."));
105 	    case ERR_XML_INIT_READER_FAILED:
106 		return ((char *)gettext("failed to initialize XML reader."));
107 	    case ERR_XML_PARSE_MEMORY_FAILED:
108 		return ((char *)gettext("failed to parse XML doc in memory."));
109 	    case ERR_XML_FAILED_TO_SET_XPATH_CONTEXT:
110 		return ((char *)gettext("failed to get XPATH context."));
111 	    case ERR_XML_FAILED_TO_REGISTER_NAMESPACE:
112 		return ((char *)gettext("failed to register name space."));
113 	    case ERR_SYNTAX_MISSING_ROOT:
114 		return ((char *)gettext("XML Syntax error: "
115 		    "isnsRequest root element missing"));
116 	    case ERR_SYNTAX_MISSING_NAME_ATTR:
117 		return ((char *)gettext("XML Syntax error: missing a required "
118 		    " name attribute"));
119 	    case ERR_XML_OP_FAILED:
120 		return ((char *)gettext("XML operation failed."));
121 	    case ERR_XML_STRDUP_FAILED:
122 		return ((char *)gettext("XML strndup operation failed."));
123 	    case ERR_MALLOC_FAILED:
124 		return ((char *)gettext("malloc failed."));
125 	    case ERR_DOOR_SERVER_DETECTED_INVALID_USER:
126 		return ((char *)gettext("Door server detected invalid user."));
127 	    case ERR_DOOR_SERVER_DETECTED_NOT_AUTHORIZED_USER:
128 		return ((char *)gettext("Door server detected unauthorized "
129 		    "user."));
130 	    case ERR_MATCHING_ISCSI_NODE_NOT_FOUND:
131 		return ((char *)gettext("Matching iSCSI Node not found."));
132 	    case ERR_MATCHING_NETWORK_ENTITY_NOT_FOUND:
133 		return ((char *)gettext("Network Entity not found."));
134 	    case ERR_NO_PORTAL_GROUP_FOUND:
135 		return ((char *)gettext("No Portal Group not found."));
136 	    case ERR_MATCHING_PORTAL_NOT_FOUND:
137 		return ((char *)gettext("Matching Portal not found."));
138 	    case ERR_MATCHING_DD_NOT_FOUND:
139 		return ((char *)gettext("Matching Discovery Domain not "
140 		    "found."));
141 	    case ERR_MATCHING_DDSET_NOT_FOUND:
142 		return ((char *)gettext("Matching Discovery Domain Set "
143 		    "not found."));
144 	    case ERR_NO_ASSOCIATED_DD_FOUND:
145 		return ((char *)gettext("No associated Discovery Domain "
146 		    "found."));
147 	    case ERR_NO_ASSOCIATED_DDSET_FOUND:
148 		return ((char *)gettext("No associated Discovery Domain Set "
149 		    "found."));
150 	    case ERR_NO_SUCH_ASSOCIATION:
151 		return ((char *)gettext("No such association."));
152 	    case ERR_ALREADY_ASSOCIATED:
153 		return ((char *)gettext("Member is already created."));
154 	    case ERR_NAME_IN_USE:
155 		return ((char *)gettext("Name is already in use."));
156 	    case ERR_DOOR_UCRED_FAILED:
157 		return ((char *)gettext("Failed to acquire user credentials "
158 		    "of management door caller"));
159 	    default:
160 		return ((char *)gettext("Unknown error code"));
161 	}
162 }
163