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[];
47 static char *auth_errmsg();
49 extern char *strcpy();
58 buf = (char *)malloc(256);
63 * 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");
155 (void) fprintf(stderr,"%s",clnt_sperror(rpch,s));
160 enum clnt_stat status;
164 static struct rpc_errtab rpc_errlist[] = {
167 { RPC_CANTENCODEARGS,
168 "RPC: Can't encode arguments" },
170 "RPC: Can't decode result" },
172 "RPC: Unable to send" },
174 "RPC: Unable to receive" },
178 "RPC: Incompatible versions of RPC" },
180 "RPC: Authentication error" },
182 "RPC: Program unavailable" },
183 { RPC_PROGVERSMISMATCH,
184 "RPC: Program/version mismatch" },
186 "RPC: Procedure unavailable" },
187 { RPC_CANTDECODEARGS,
188 "RPC: Server can't decode arguments" },
190 "RPC: Remote system error" },
192 "RPC: Unknown host" },
194 "RPC: Unknown protocol" },
196 "RPC: Port mapper failure" },
197 { RPC_PROGNOTREGISTERED,
198 "RPC: Program not registered"},
200 "RPC: Failed (unspecified error)"}
205 * This interface for use by clntrpc
214 for (i = 0; i < sizeof(rpc_errlist)/sizeof(struct rpc_errtab); i++) {
215 if (rpc_errlist[i].status == stat) {
216 return (rpc_errlist[i].message);
220 return ("RPC: (unknown error code)");
227 (void) fprintf(stderr,"%s",clnt_sperrno(num));
232 clnt_spcreateerror(s)
237 extern char *sys_errlist[];
242 (void) sprintf(str, "%s: ", s);
243 (void) strcat(str, clnt_sperrno(rpc_createerr.cf_stat));
244 switch (rpc_createerr.cf_stat) {
245 case RPC_PMAPFAILURE:
246 (void) strcat(str, " - ");
248 clnt_sperrno(rpc_createerr.cf_error.re_status));
251 case RPC_SYSTEMERROR:
252 (void) strcat(str, " - ");
253 if (rpc_createerr.cf_error.re_errno > 0
254 && rpc_createerr.cf_error.re_errno < sys_nerr)
256 sys_errlist[rpc_createerr.cf_error.re_errno]);
258 (void) sprintf(&str[strlen(str)], "Error %d",
259 rpc_createerr.cf_error.re_errno);
262 (void) strcat(str, "\n");
271 (void) fprintf(stderr,"%s",clnt_spcreateerror(s));
275 enum auth_stat status;
279 static struct auth_errtab auth_errlist[] = {
281 "Authentication OK" },
283 "Invalid client credential" },
285 "Server rejected credential" },
287 "Invalid client verifier" },
289 "Server rejected verifier" },
291 "Client credential too weak" },
293 "Invalid server verifier" },
295 "Failed (unspecified error)" },
304 for (i = 0; i < sizeof(auth_errlist)/sizeof(struct auth_errtab); i++) {
305 if (auth_errlist[i].status == stat) {
306 return(auth_errlist[i].message);