2 static char sfs_clnt_perror_c_id[] = "@(#)clnt_perror.c 2.1 97/10/23";
4 /* @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC */
6 * Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
8 * Standard Performance Evaluation Corporation (SPEC)
9 * 6585 Merchant Place, Suite 100
12 * This product contains benchmarks acquired from several sources who
13 * understand and agree with SPEC's goal of creating fair and objective
14 * benchmarks to measure computer performance.
16 * This copyright notice is placed here only to protect SPEC in the
17 * event the source is misused in any manner that is contrary to the
18 * spirit, the goals and the intent of SPEC.
20 * The source code is provided to the user or company under the license
21 * agreement for the SPEC Benchmark Suite for this product.
24 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
25 * unrestricted use provided that this legend is included on all tape
26 * media and as a part of the software program in whole or part. Users
27 * may copy or modify Sun RPC without charge, but are not authorized
28 * to license or distribute it to anyone else except as part of a product or
29 * program developed by the user.
31 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
32 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
33 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
35 * Sun RPC is provided with no support and without any obligation on the
36 * part of Sun Microsystems, Inc. to assist in its use, correction,
37 * modification or enhancement.
39 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
40 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
41 * OR ANY PART THEREOF.
43 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
44 * or profits or other special, indirect and consequential damages, even if
45 * Sun has been advised of the possibility of such damages.
47 * Sun Microsystems, Inc.
49 * Mountain View, California 94043
51 #if !defined(lint) && defined(SCCSIDS)
52 static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
58 * Copyright (C) 1984, Sun Microsystems, Inc.
67 static char *auth_errmsg(enum auth_stat);
72 static char *buf = NULL;
74 buf = (char *)malloc(256);
79 * Print reply error info
93 CLNT_GETERR(rpch, &e);
95 (void) sprintf(str, "%s: ", s);
98 (void) strcpy(str, clnt_sperrno(e.re_status));
101 switch (e.re_status) {
103 case RPC_CANTENCODEARGS:
104 case RPC_CANTDECODERES:
106 case RPC_PROGUNAVAIL:
107 case RPC_PROCUNAVAIL:
108 case RPC_CANTDECODEARGS:
109 case RPC_SYSTEMERROR:
110 case RPC_UNKNOWNHOST:
111 case RPC_UNKNOWNPROTO:
112 case RPC_PMAPFAILURE:
113 case RPC_PROGNOTREGISTERED:
119 (void) sprintf(str, "; errno = %s",
120 strerror(e.re_errno));
124 case RPC_VERSMISMATCH:
126 "; low version = %lu, high version = %lu",
127 e.re_vers.low, e.re_vers.high);
132 err = auth_errmsg(e.re_why);
133 (void) sprintf(str,"; why = ");
136 (void) sprintf(str, "%s",err);
139 "(unknown authentication error - %d)",
145 case RPC_PROGVERSMISMATCH:
147 "; low version = %lu, high version = %lu",
148 e.re_vers.low, e.re_vers.high);
152 default: /* unknown */
154 "; s1 = %lu, s2 = %lu",
155 e.re_lb.s1, e.re_lb.s2);
159 (void) sprintf(str, "\n");
168 (void) fprintf(stderr,"%s",clnt_sperror(rpch,s));
173 enum clnt_stat status;
177 static struct rpc_errtab rpc_errlist[] = {
180 { RPC_CANTENCODEARGS,
181 "RPC: Can't encode arguments" },
183 "RPC: Can't decode result" },
185 "RPC: Unable to send" },
187 "RPC: Unable to receive" },
191 "RPC: Incompatible versions of RPC" },
193 "RPC: Authentication error" },
195 "RPC: Program unavailable" },
196 { RPC_PROGVERSMISMATCH,
197 "RPC: Program/version mismatch" },
199 "RPC: Procedure unavailable" },
200 { RPC_CANTDECODEARGS,
201 "RPC: Server can't decode arguments" },
203 "RPC: Remote system error" },
205 "RPC: Unknown host" },
207 "RPC: Unknown protocol" },
209 "RPC: Port mapper failure" },
210 { RPC_PROGNOTREGISTERED,
211 "RPC: Program not registered"},
213 "RPC: Failed (unspecified error)"}
218 * This interface for use by clntrpc
226 for (i = 0; i < sizeof(rpc_errlist)/sizeof(struct rpc_errtab); i++) {
227 if (rpc_errlist[i].status == stat) {
228 return (rpc_errlist[i].message);
231 return ("RPC: (unknown error code)");
238 (void) fprintf(stderr,"%s",clnt_sperrno(num));
243 clnt_spcreateerror(char *s)
250 (void) sprintf(str, "%s: ", s);
251 (void) strcat(str, clnt_sperrno(rpc_createerr.cf_stat));
252 switch (rpc_createerr.cf_stat) {
253 case RPC_PMAPFAILURE:
254 (void) strcat(str, " - ");
256 clnt_sperrno(rpc_createerr.cf_error.re_status));
259 case RPC_SYSTEMERROR:
260 sp = strerror(rpc_createerr.cf_error.re_errno);
261 (void) strcat(str, " - ");
262 if (rpc_createerr.cf_error.re_errno > 0
264 (void) strcat(str, sp);
266 (void) sprintf(&str[strlen(str)], "Error %d",
267 rpc_createerr.cf_error.re_errno);
270 (void) strcat(str, "\n");
275 clnt_pcreateerror(char *s)
277 (void) fprintf(stderr, "%s", clnt_spcreateerror(s));
281 enum auth_stat status;
285 static struct auth_errtab auth_errlist[] = {
287 "Authentication OK" },
289 "Invalid client credential" },
291 "Server rejected credential" },
293 "Invalid client verifier" },
295 "Server rejected verifier" },
297 "Client credential too weak" },
299 "Invalid server verifier" },
301 "Failed (unspecified error)" },
310 for (i = 0; i < sizeof(auth_errlist)/sizeof(struct auth_errtab); i++) {
311 if (auth_errlist[i].status == stat) {
312 return(auth_errlist[i].message);