4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * Portions of this source code were derived from Berkeley 4.3 BSD
32 * under license from the Regents of the University of California.
35 #pragma ident "%Z%%M% %I% %E% SMI"
40 #include <sys/types.h>
41 #include <sys/t_lock.h>
42 #include <rpc/types.h>
45 #include <sys/systm.h>
46 #include <sys/cmn_err.h>
47 #include <sys/inttypes.h>
50 * Return an ascii string which matches the RPC clnt stat passed in.
53 clnt_sperrno(const enum clnt_stat stat
)
57 return ("RPC: Success");
58 case RPC_CANTENCODEARGS
:
59 return ("RPC: Can't encode arguments");
60 case RPC_CANTDECODERES
:
61 return ("RPC: Can't decode result");
63 return ("RPC: Unable to send");
65 return ("RPC: Unable to receive");
67 return ("RPC: Timed out");
69 return ("RPC: Interrupted");
71 return ("RPC: Unitdata error");
72 case RPC_VERSMISMATCH
:
73 return ("RPC: Incompatible versions of RPC");
75 return ("RPC: Authentication error");
77 return ("RPC: Program unavailable");
78 case RPC_PROGVERSMISMATCH
:
79 return ("RPC: Program/version mismatch");
81 return ("RPC: Procedure unavailable");
82 case RPC_CANTDECODEARGS
:
83 return ("RPC: Server can't decode arguments");
85 return ("RPC: Remote system error");
87 return ("RPC: Unknown host");
88 case RPC_UNKNOWNPROTO
:
89 return ("RPC: Unknown protocol");
91 return ("RPC: Remote address unknown");
93 return ("RPC: Broadcasting not supported");
95 return ("RPC: Port mapper failure");
96 case RPC_PROGNOTREGISTERED
:
97 return ("RPC: Program not registered");
98 case RPC_N2AXLATEFAILURE
:
99 return ("RPC: Name to address translation failed");
101 return ("RPC: TLI error");
103 return ("RPC: Failed (unspecified error)");
105 return ("RPC: Operation in progress");
106 case RPC_STALERACHANDLE
:
107 return ("RPC: Stale RAC handle");
108 case RPC_CANTCONNECT
:
109 return ("RPC: Couldn't make connection");
111 return ("RPC: Received disconnect from remote");
112 case RPC_CANTCREATESTREAM
:
113 return ("RPC: Can't push RPC module");
115 return ("RPC: Can't store pending message");
117 return ("RPC: (unknown error code)");
121 * Return string reply error info. For use after clnt_call().
122 * It allocates the buffer of size MAXPATHLEN and assumes
123 * caller's responsibility to free the memory after use.
126 clnt_sperror(const CLIENT
*cl
, const char *s
)
135 str
= kmem_alloc(MAXPATHLEN
, KM_SLEEP
);
138 CLNT_GETERR((CLIENT
*) cl
, &e
);
140 (void) sprintf(str
, "%s: ", s
);
143 (void) strcpy(str
, clnt_sperrno(e
.re_status
));
146 switch (e
.re_status
) {
148 case RPC_CANTENCODEARGS
:
149 case RPC_CANTDECODERES
:
151 case RPC_PROGUNAVAIL
:
152 case RPC_PROCUNAVAIL
:
153 case RPC_CANTDECODEARGS
:
154 case RPC_SYSTEMERROR
:
155 case RPC_UNKNOWNHOST
:
156 case RPC_UNKNOWNPROTO
:
157 case RPC_UNKNOWNADDR
:
158 case RPC_NOBROADCAST
:
159 case RPC_RPCBFAILURE
:
160 case RPC_PROGNOTREGISTERED
:
166 case RPC_N2AXLATEFAILURE
:
167 (void) sprintf(str
, "; %s", netdir_sperror());
173 (void) sprintf(str
, "; %s", t_errlist
[e
.re_terrno
]);
175 (void) sprintf(str
, "; %d", e
.re_terrno
);
180 (void) sprintf(str
, "; %s", strerror(e
.re_errno
));
182 (void) sprintf(str
, "; %d", e
.re_errno
);
191 (void) sprintf(str
, "; errno = %s",
192 strerror(e
.re_errno
));
194 (void) sprintf(str
, "; errno = %d", e
.re_errno
);
200 (void) sprintf(str
, "; %s", t_errlist
[e
.re_terrno
]);
202 (void) sprintf(str
, "; %d", e
.re_terrno
);
207 case RPC_VERSMISMATCH
:
209 "; low version = %" PRIu32
", high version = %" PRIu32
,
210 e
.re_vers
.low
, e
.re_vers
.high
);
215 err
= auth_errmsg(e
.re_why
);
216 (void) sprintf(str
, "; why = ");
219 (void) sprintf(str
, "%s", err
);
222 "(unknown authentication error - %d)",
228 case RPC_PROGVERSMISMATCH
:
230 "; low version = %" PRIu32
", high version = %" PRIu32
,
231 e
.re_vers
.low
, e
.re_vers
.high
);
234 default: /* unknown */
235 (void) sprintf(str
, "; s1 = %" PRIu32
", s2 = %" PRIu32
,
236 e
.re_lb
.s1
, e
.re_lb
.s2
);