1 /* @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC */
3 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
4 * unrestricted use provided that this legend is included on all tape
5 * media and as a part of the software program in whole or part. Users
6 * may copy or modify Sun RPC without charge, but are not authorized
7 * to license or distribute it to anyone else except as part of a product or
8 * program developed by the user.
10 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
11 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
12 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14 * Sun RPC is provided with no support and without any obligation on the
15 * part of Sun Microsystems, Inc. to assist in its use, correction,
16 * modification or enhancement.
18 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
19 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
20 * OR ANY PART THEREOF.
22 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
23 * or profits or other special, indirect and consequential damages, even if
24 * Sun has been advised of the possibility of such damages.
26 * Sun Microsystems, Inc.
28 * Mountain View, California 94043
30 #if !defined(lint) && defined(SCCSIDS)
31 static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
37 * Copyright (C) 1984, Sun Microsystems, Inc.
42 #include <rpc/types.h>
46 /* extern char *sys_errlist[]; --drepper@gnu */
47 /* extern char *sprintf(); --roland@gnu */
48 static char *auth_errmsg();
50 extern char *strcpy();
59 buf = (char *)malloc(256);
64 * Print reply error info
79 CLNT_GETERR(rpch, &e);
81 (void) sprintf(str, "%s: ", s);
84 (void) strcpy(str, clnt_sperrno(e.re_status));
87 switch (e.re_status) {
89 case RPC_CANTENCODEARGS:
90 case RPC_CANTDECODERES:
94 case RPC_CANTDECODEARGS:
97 case RPC_UNKNOWNPROTO:
99 case RPC_PROGNOTREGISTERED:
105 (void) sprintf(str, "; errno = %s",
106 sys_errlist[e.re_errno]);
110 case RPC_VERSMISMATCH:
112 "; low version = %lu, high version = %lu",
113 e.re_vers.low, e.re_vers.high);
118 err = auth_errmsg(e.re_why);
119 (void) sprintf(str,"; why = ");
122 (void) sprintf(str, "%s",err);
125 "(unknown authentication error - %d)",
131 case RPC_PROGVERSMISMATCH:
133 "; low version = %lu, high version = %lu",
134 e.re_vers.low, e.re_vers.high);
138 default: /* unknown */
140 "; s1 = %lu, s2 = %lu",
141 e.re_lb.s1, e.re_lb.s2);
145 (void) sprintf(str, "\n");
154 (void) fprintf(stderr,"%s",clnt_sperror(rpch,s));
159 enum clnt_stat status;
163 static struct rpc_errtab rpc_errlist[] = {
166 { RPC_CANTENCODEARGS,
167 "RPC: Can't encode arguments" },
169 "RPC: Can't decode result" },
171 "RPC: Unable to send" },
173 "RPC: Unable to receive" },
177 "RPC: Incompatible versions of RPC" },
179 "RPC: Authentication error" },
181 "RPC: Program unavailable" },
182 { RPC_PROGVERSMISMATCH,
183 "RPC: Program/version mismatch" },
185 "RPC: Procedure unavailable" },
186 { RPC_CANTDECODEARGS,
187 "RPC: Server can't decode arguments" },
189 "RPC: Remote system error" },
191 "RPC: Unknown host" },
193 "RPC: Unknown protocol" },
195 "RPC: Port mapper failure" },
196 { RPC_PROGNOTREGISTERED,
197 "RPC: Program not registered"},
199 "RPC: Failed (unspecified error)"}
204 * This interface for use by clntrpc
212 for (i = 0; i < sizeof(rpc_errlist)/sizeof(struct rpc_errtab); i++) {
213 if (rpc_errlist[i].status == stat) {
214 return (rpc_errlist[i].message);
217 return ("RPC: (unknown error code)");
224 (void) fprintf(stderr,"%s",clnt_sperrno(num));
229 clnt_spcreateerror(s)
233 /* extern char *sys_errlist[]; --drepper@gnu */
238 (void) sprintf(str, "%s: ", s);
239 (void) strcat(str, clnt_sperrno(rpc_createerr.cf_stat));
240 switch (rpc_createerr.cf_stat) {
241 case RPC_PMAPFAILURE:
242 (void) strcat(str, " - ");
244 clnt_sperrno(rpc_createerr.cf_error.re_status));
247 case RPC_SYSTEMERROR:
248 (void) strcat(str, " - ");
249 if (rpc_createerr.cf_error.re_errno > 0
250 && rpc_createerr.cf_error.re_errno < sys_nerr)
252 sys_errlist[rpc_createerr.cf_error.re_errno]);
254 (void) sprintf(&str[strlen(str)], "Error %d",
255 rpc_createerr.cf_error.re_errno);
258 (void) strcat(str, "\n");
266 (void) fprintf(stderr,"%s",clnt_spcreateerror(s));
270 enum auth_stat status;
274 static struct auth_errtab auth_errlist[] = {
276 "Authentication OK" },
278 "Invalid client credential" },
280 "Server rejected credential" },
282 "Invalid client verifier" },
284 "Server rejected verifier" },
286 "Client credential too weak" },
288 "Invalid server verifier" },
290 "Failed (unspecified error)" },
299 for (i = 0; i < sizeof(auth_errlist)/sizeof(struct auth_errtab); i++) {
300 if (auth_errlist[i].status == stat) {
301 return(auth_errlist[i].message);