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.
38 #include <sys/types.h>
39 #include <sys/t_lock.h>
40 #include <rpc/types.h>
43 #include <sys/systm.h>
44 #include <sys/cmn_err.h>
45 #include <sys/inttypes.h>
48 * Return an ascii string which matches the RPC clnt stat passed in.
51 clnt_sperrno(const enum clnt_stat stat
)
55 return ("RPC: Success");
56 case RPC_CANTENCODEARGS
:
57 return ("RPC: Can't encode arguments");
58 case RPC_CANTDECODERES
:
59 return ("RPC: Can't decode result");
61 return ("RPC: Unable to send");
63 return ("RPC: Unable to receive");
65 return ("RPC: Timed out");
67 return ("RPC: Interrupted");
69 return ("RPC: Unitdata error");
70 case RPC_VERSMISMATCH
:
71 return ("RPC: Incompatible versions of RPC");
73 return ("RPC: Authentication error");
75 return ("RPC: Program unavailable");
76 case RPC_PROGVERSMISMATCH
:
77 return ("RPC: Program/version mismatch");
79 return ("RPC: Procedure unavailable");
80 case RPC_CANTDECODEARGS
:
81 return ("RPC: Server can't decode arguments");
83 return ("RPC: Remote system error");
85 return ("RPC: Unknown host");
86 case RPC_UNKNOWNPROTO
:
87 return ("RPC: Unknown protocol");
89 return ("RPC: Remote address unknown");
91 return ("RPC: Broadcasting not supported");
93 return ("RPC: Port mapper failure");
94 case RPC_PROGNOTREGISTERED
:
95 return ("RPC: Program not registered");
96 case RPC_N2AXLATEFAILURE
:
97 return ("RPC: Name to address translation failed");
99 return ("RPC: TLI error");
101 return ("RPC: Failed (unspecified error)");
103 return ("RPC: Operation in progress");
104 case RPC_STALERACHANDLE
:
105 return ("RPC: Stale RAC handle");
106 case RPC_CANTCONNECT
:
107 return ("RPC: Couldn't make connection");
109 return ("RPC: Received disconnect from remote");
110 case RPC_CANTCREATESTREAM
:
111 return ("RPC: Can't push RPC module");
113 return ("RPC: Can't store pending message");
115 return ("RPC: (unknown error code)");
119 * Return string reply error info. For use after clnt_call().
120 * It allocates the buffer of size MAXPATHLEN and assumes
121 * caller's responsibility to free the memory after use.
124 clnt_sperror(const CLIENT
*cl
, const char *s
)
133 str
= kmem_alloc(MAXPATHLEN
, KM_SLEEP
);
136 CLNT_GETERR((CLIENT
*) cl
, &e
);
138 (void) sprintf(str
, "%s: ", s
);
141 (void) strcpy(str
, clnt_sperrno(e
.re_status
));
144 switch (e
.re_status
) {
146 case RPC_CANTENCODEARGS
:
147 case RPC_CANTDECODERES
:
149 case RPC_PROGUNAVAIL
:
150 case RPC_PROCUNAVAIL
:
151 case RPC_CANTDECODEARGS
:
152 case RPC_SYSTEMERROR
:
153 case RPC_UNKNOWNHOST
:
154 case RPC_UNKNOWNPROTO
:
155 case RPC_UNKNOWNADDR
:
156 case RPC_NOBROADCAST
:
157 case RPC_RPCBFAILURE
:
158 case RPC_PROGNOTREGISTERED
:
164 case RPC_N2AXLATEFAILURE
:
165 (void) sprintf(str
, "; %s", netdir_sperror());
171 (void) sprintf(str
, "; %s", t_errlist
[e
.re_terrno
]);
173 (void) sprintf(str
, "; %d", e
.re_terrno
);
178 (void) sprintf(str
, "; %s", strerror(e
.re_errno
));
180 (void) sprintf(str
, "; %d", e
.re_errno
);
189 (void) sprintf(str
, "; errno = %s",
190 strerror(e
.re_errno
));
192 (void) sprintf(str
, "; errno = %d", e
.re_errno
);
198 (void) sprintf(str
, "; %s", t_errlist
[e
.re_terrno
]);
200 (void) sprintf(str
, "; %d", e
.re_terrno
);
205 case RPC_VERSMISMATCH
:
207 "; low version = %" PRIu32
", high version = %" PRIu32
,
208 e
.re_vers
.low
, e
.re_vers
.high
);
213 err
= auth_errmsg(e
.re_why
);
214 (void) sprintf(str
, "; why = ");
217 (void) sprintf(str
, "%s", err
);
220 "(unknown authentication error - %d)",
226 case RPC_PROGVERSMISMATCH
:
228 "; low version = %" PRIu32
", high version = %" PRIu32
,
229 e
.re_vers
.low
, e
.re_vers
.high
);
232 default: /* unknown */
233 (void) sprintf(str
, "; s1 = %" PRIu32
", s2 = %" PRIu32
,
234 e
.re_lb
.s1
, e
.re_lb
.s2
);