1 /*********************************************************************
2 * RPC for the Windows NT Operating System
3 * 1993 by Martin F. Gergeleit
4 * Users may use, copy or modify Sun RPC for the Windows NT Operating
5 * System according to the Sun copyright below.
7 * RPC for the Windows NT Operating System COMES WITH ABSOLUTELY NO
8 * WARRANTY, NOR WILL I BE LIABLE FOR ANY DAMAGES INCURRED FROM THE
9 * USE OF. USE ENTIRELY AT YOUR OWN RISK!!!
10 *********************************************************************/
12 /* @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC */
14 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
15 * unrestricted use provided that this legend is included on all tape
16 * media and as a part of the software program in whole or part. Users
17 * may copy or modify Sun RPC without charge, but are not authorized
18 * to license or distribute it to anyone else except as part of a product or
19 * program developed by the user.
21 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
22 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
25 * Sun RPC is provided with no support and without any obligation on the
26 * part of Sun Microsystems, Inc. to assist in its use, correction,
27 * modification or enhancement.
29 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
30 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
31 * OR ANY PART THEREOF.
33 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
34 * or profits or other special, indirect and consequential damages, even if
35 * Sun has been advised of the possibility of such damages.
37 * Sun Microsystems, Inc.
39 * Mountain View, California 94043
41 #if !defined(lint) && defined(SCCSIDS)
42 static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
48 * Copyright (C) 1984, Sun Microsystems, Inc.
56 #include <rpc/types.h>
61 extern char *sys_errlist[];
63 extern char *sprintf();
66 static char *auth_errmsg();
68 extern char *strcpy();
77 buf = (char *)malloc(256);
82 * Print reply error info
97 CLNT_GETERR(rpch, &e);
99 (void) sprintf(str, "%s: ", s);
102 (void) strcpy(str, clnt_sperrno(e.re_status));
105 switch (e.re_status) {
107 case RPC_CANTENCODEARGS:
108 case RPC_CANTDECODERES:
110 case RPC_PROGUNAVAIL:
111 case RPC_PROCUNAVAIL:
112 case RPC_CANTDECODEARGS:
113 case RPC_SYSTEMERROR:
114 case RPC_UNKNOWNHOST:
115 case RPC_UNKNOWNPROTO:
116 case RPC_PMAPFAILURE:
117 case RPC_PROGNOTREGISTERED:
124 if (e.re_errno < sys_nerr)
126 (void) sprintf(str, "; errno = %s",
127 sys_errlist[e.re_errno]);
130 (void) sprintf(str, "Error %d, ", e.re_errno);
135 case RPC_VERSMISMATCH:
137 "; low version = %lu, high version = %lu",
138 e.re_vers.low, e.re_vers.high);
143 err = auth_errmsg(e.re_why);
144 (void) sprintf(str,"; why = ");
147 (void) sprintf(str, "%s",err);
150 "(unknown authentication error - %d)",
156 case RPC_PROGVERSMISMATCH:
158 "; low version = %lu, high version = %lu",
159 e.re_vers.low, e.re_vers.high);
163 default: /* unknown */
165 "; s1 = %lu, s2 = %lu",
166 e.re_lb.s1, e.re_lb.s2);
170 (void) sprintf(str, "\n");
180 nt_rpc_report(clnt_sperror(rpch,s));
182 (void) fprintf(stderr,"%s",clnt_sperror(rpch,s));
188 enum clnt_stat status;
192 static struct rpc_errtab rpc_errlist[] = {
195 { RPC_CANTENCODEARGS,
196 "RPC: Can't encode arguments" },
198 "RPC: Can't decode result" },
200 "RPC: Unable to send" },
202 "RPC: Unable to receive" },
206 "RPC: Incompatible versions of RPC" },
208 "RPC: Authentication error" },
210 "RPC: Program unavailable" },
211 { RPC_PROGVERSMISMATCH,
212 "RPC: Program/version mismatch" },
214 "RPC: Procedure unavailable" },
215 { RPC_CANTDECODEARGS,
216 "RPC: Server can't decode arguments" },
218 "RPC: Remote system error" },
220 "RPC: Unknown host" },
222 "RPC: Unknown protocol" },
224 "RPC: Port mapper failure" },
225 { RPC_PROGNOTREGISTERED,
226 "RPC: Program not registered"},
228 "RPC: Failed (unspecified error)"}
233 * This interface for use by clntrpc
241 for (i = 0; i < sizeof(rpc_errlist)/sizeof(struct rpc_errtab); i++) {
242 if (rpc_errlist[i].status == stat) {
243 return (rpc_errlist[i].message);
246 return ("RPC: (unknown error code)");
254 nt_rpc_report(clnt_sperrno(num));
256 (void) fprintf(stderr,"%s",clnt_sperrno(num));
262 clnt_spcreateerror(s)
267 extern char *sys_errlist[];
273 (void) sprintf(str, "%s: ", s);
274 (void) strcat(str, clnt_sperrno(rpc_createerr.cf_stat));
275 switch (rpc_createerr.cf_stat) {
276 case RPC_PMAPFAILURE:
277 (void) strcat(str, " - ");
279 clnt_sperrno(rpc_createerr.cf_error.re_status));
282 case RPC_SYSTEMERROR:
283 (void) strcat(str, " - ");
284 if (rpc_createerr.cf_error.re_errno > 0
285 && rpc_createerr.cf_error.re_errno < sys_nerr)
288 "internal rpc error");
290 sys_errlist[rpc_createerr.cf_error.re_errno]);
293 (void) sprintf(&str[strlen(str)], "Error %d",
294 rpc_createerr.cf_error.re_errno);
297 (void) strcat(str, "\n");
306 nt_rpc_report(clnt_spcreateerror(s));
308 (void) fprintf(stderr,"%s",clnt_spcreateerror(s));
313 enum auth_stat status;
317 static struct auth_errtab auth_errlist[] = {
319 "Authentication OK" },
321 "Invalid client credential" },
323 "Server rejected credential" },
325 "Invalid client verifier" },
327 "Server rejected verifier" },
329 "Client credential too weak" },
331 "Invalid server verifier" },
333 "Failed (unspecified error)" },
342 for (i = 0; i < sizeof(auth_errlist)/sizeof(struct auth_errtab); i++) {
343 if (auth_errlist[i].status == stat) {
344 return(auth_errlist[i].message);