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 static char *auth_errmsg (enum auth_stat stat) internal_function;
54 buf = (char *) malloc (256);
59 * Print reply error info
62 clnt_sperror (CLIENT * rpch, const char *msg)
73 CLNT_GETERR (rpch, &e);
75 len = sprintf (str, "%s: ", msg);
78 str = stpcpy (str, clnt_sperrno (e.re_status));
83 case RPC_CANTENCODEARGS:
84 case RPC_CANTDECODERES:
88 case RPC_CANTDECODEARGS:
91 case RPC_UNKNOWNPROTO:
93 case RPC_PROGNOTREGISTERED:
99 len = sprintf (str, "; errno = %s", strerror_r (e.re_errno,
104 case RPC_VERSMISMATCH:
105 len= sprintf (str, _("; low version = %lu, high version = %lu"),
106 e.re_vers.low, e.re_vers.high);
111 err = auth_errmsg (e.re_why);
112 str = stpcpy (str, _ ("; why = "));
115 str = stpcpy (str, err);
119 len = sprintf (str, _("(unknown authentication error - %d)"),
125 case RPC_PROGVERSMISMATCH:
126 len = sprintf (str, _("; low version = %lu, high version = %lu"),
127 e.re_vers.low, e.re_vers.high);
131 default: /* unknown */
132 len = sprintf (str, "; s1 = %lu, s2 = %lu", e.re_lb.s1, e.re_lb.s2);
142 clnt_perror (CLIENT * rpch, const char *msg)
144 (void) fputs (clnt_sperror (rpch, msg), stderr);
150 enum clnt_stat status;
154 static const struct rpc_errtab rpc_errlist[] =
159 N_("RPC: Can't encode arguments")},
161 N_("RPC: Can't decode result")},
163 N_("RPC: Unable to send")},
165 N_("RPC: Unable to receive")},
167 N_("RPC: Timed out")},
169 N_("RPC: Incompatible versions of RPC")},
171 N_("RPC: Authentication error")},
173 N_("RPC: Program unavailable")},
174 {RPC_PROGVERSMISMATCH,
175 N_("RPC: Program/version mismatch")},
177 N_("RPC: Procedure unavailable")},
179 N_("RPC: Server can't decode arguments")},
181 N_("RPC: Remote system error")},
183 N_("RPC: Unknown host")},
185 N_("RPC: Unknown protocol")},
187 N_("RPC: Port mapper failure")},
188 {RPC_PROGNOTREGISTERED,
189 N_("RPC: Program not registered")},
191 N_("RPC: Failed (unspecified error)")}
196 * This interface for use by clntrpc
199 clnt_sperrno (enum clnt_stat stat)
203 for (i = 0; i < sizeof (rpc_errlist) / sizeof (struct rpc_errtab); i++)
205 if (rpc_errlist[i].status == stat)
207 return _(rpc_errlist[i].message);
210 return _("RPC: (unknown error code)");
214 clnt_perrno (enum clnt_stat num)
216 (void) fputs (clnt_sperrno (num), stderr);
221 clnt_spcreateerror (const char *msg)
230 len = sprintf (str, "%s: ", msg);
232 cp = stpcpy (cp, clnt_sperrno (rpc_createerr.cf_stat));
233 switch (rpc_createerr.cf_stat)
235 case RPC_PMAPFAILURE:
236 cp = stpcpy (cp, " - ");
237 cp = stpcpy (cp, clnt_sperrno (rpc_createerr.cf_error.re_status));
240 case RPC_SYSTEMERROR:
241 cp = stpcpy (str, " - ");
242 if (rpc_createerr.cf_error.re_errno > 0
243 && rpc_createerr.cf_error.re_errno < sys_nerr)
244 cp = stpcpy (str, strerror_r (rpc_createerr.cf_error.re_errno,
248 len = sprintf (cp, _("Error %d"), rpc_createerr.cf_error.re_errno);
261 clnt_pcreateerror (const char *msg)
263 (void) fputs (clnt_spcreateerror (msg), stderr);
268 enum auth_stat status;
272 static const struct auth_errtab auth_errlist[] =
275 N_("Authentication OK")},
277 N_("Invalid client credential")},
279 N_("Server rejected credential")},
281 N_("Invalid client verifier")},
283 N_("Server rejected verifier")},
285 N_("Client credential too weak")},
287 N_("Invalid server verifier")},
289 N_("Failed (unspecified error)")},
294 auth_errmsg (enum auth_stat stat)
298 for (i = 0; i < sizeof (auth_errlist) / sizeof (struct auth_errtab); i++)
300 if (auth_errlist[i].status == stat)
302 return _(auth_errlist[i].message);