1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24*0Sstevel@tonic-gate * Use is subject to license terms.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28*0Sstevel@tonic-gate /* All Rights Reserved */
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gate /*
31*0Sstevel@tonic-gate * Portions of this source code were derived from Berkeley 4.3 BSD
32*0Sstevel@tonic-gate * under license from the Regents of the University of California.
33*0Sstevel@tonic-gate */
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
36*0Sstevel@tonic-gate
37*0Sstevel@tonic-gate /*
38*0Sstevel@tonic-gate * clnt_perror.c
39*0Sstevel@tonic-gate */
40*0Sstevel@tonic-gate #include <sys/types.h>
41*0Sstevel@tonic-gate #include <sys/t_lock.h>
42*0Sstevel@tonic-gate #include <rpc/types.h>
43*0Sstevel@tonic-gate #include <rpc/auth.h>
44*0Sstevel@tonic-gate #include <rpc/clnt.h>
45*0Sstevel@tonic-gate #include <sys/systm.h>
46*0Sstevel@tonic-gate #include <sys/cmn_err.h>
47*0Sstevel@tonic-gate #include <sys/inttypes.h>
48*0Sstevel@tonic-gate
49*0Sstevel@tonic-gate /*
50*0Sstevel@tonic-gate * Return an ascii string which matches the RPC clnt stat passed in.
51*0Sstevel@tonic-gate */
52*0Sstevel@tonic-gate const char *
clnt_sperrno(const enum clnt_stat stat)53*0Sstevel@tonic-gate clnt_sperrno(const enum clnt_stat stat)
54*0Sstevel@tonic-gate {
55*0Sstevel@tonic-gate switch (stat) {
56*0Sstevel@tonic-gate case RPC_SUCCESS:
57*0Sstevel@tonic-gate return ("RPC: Success");
58*0Sstevel@tonic-gate case RPC_CANTENCODEARGS:
59*0Sstevel@tonic-gate return ("RPC: Can't encode arguments");
60*0Sstevel@tonic-gate case RPC_CANTDECODERES:
61*0Sstevel@tonic-gate return ("RPC: Can't decode result");
62*0Sstevel@tonic-gate case RPC_CANTSEND:
63*0Sstevel@tonic-gate return ("RPC: Unable to send");
64*0Sstevel@tonic-gate case RPC_CANTRECV:
65*0Sstevel@tonic-gate return ("RPC: Unable to receive");
66*0Sstevel@tonic-gate case RPC_TIMEDOUT:
67*0Sstevel@tonic-gate return ("RPC: Timed out");
68*0Sstevel@tonic-gate case RPC_INTR:
69*0Sstevel@tonic-gate return ("RPC: Interrupted");
70*0Sstevel@tonic-gate case RPC_UDERROR:
71*0Sstevel@tonic-gate return ("RPC: Unitdata error");
72*0Sstevel@tonic-gate case RPC_VERSMISMATCH:
73*0Sstevel@tonic-gate return ("RPC: Incompatible versions of RPC");
74*0Sstevel@tonic-gate case RPC_AUTHERROR:
75*0Sstevel@tonic-gate return ("RPC: Authentication error");
76*0Sstevel@tonic-gate case RPC_PROGUNAVAIL:
77*0Sstevel@tonic-gate return ("RPC: Program unavailable");
78*0Sstevel@tonic-gate case RPC_PROGVERSMISMATCH:
79*0Sstevel@tonic-gate return ("RPC: Program/version mismatch");
80*0Sstevel@tonic-gate case RPC_PROCUNAVAIL:
81*0Sstevel@tonic-gate return ("RPC: Procedure unavailable");
82*0Sstevel@tonic-gate case RPC_CANTDECODEARGS:
83*0Sstevel@tonic-gate return ("RPC: Server can't decode arguments");
84*0Sstevel@tonic-gate case RPC_SYSTEMERROR:
85*0Sstevel@tonic-gate return ("RPC: Remote system error");
86*0Sstevel@tonic-gate case RPC_UNKNOWNHOST:
87*0Sstevel@tonic-gate return ("RPC: Unknown host");
88*0Sstevel@tonic-gate case RPC_UNKNOWNPROTO:
89*0Sstevel@tonic-gate return ("RPC: Unknown protocol");
90*0Sstevel@tonic-gate case RPC_UNKNOWNADDR:
91*0Sstevel@tonic-gate return ("RPC: Remote address unknown");
92*0Sstevel@tonic-gate case RPC_NOBROADCAST:
93*0Sstevel@tonic-gate return ("RPC: Broadcasting not supported");
94*0Sstevel@tonic-gate case RPC_PMAPFAILURE:
95*0Sstevel@tonic-gate return ("RPC: Port mapper failure");
96*0Sstevel@tonic-gate case RPC_PROGNOTREGISTERED:
97*0Sstevel@tonic-gate return ("RPC: Program not registered");
98*0Sstevel@tonic-gate case RPC_N2AXLATEFAILURE:
99*0Sstevel@tonic-gate return ("RPC: Name to address translation failed");
100*0Sstevel@tonic-gate case RPC_TLIERROR:
101*0Sstevel@tonic-gate return ("RPC: TLI error");
102*0Sstevel@tonic-gate case RPC_FAILED:
103*0Sstevel@tonic-gate return ("RPC: Failed (unspecified error)");
104*0Sstevel@tonic-gate case RPC_INPROGRESS:
105*0Sstevel@tonic-gate return ("RPC: Operation in progress");
106*0Sstevel@tonic-gate case RPC_STALERACHANDLE:
107*0Sstevel@tonic-gate return ("RPC: Stale RAC handle");
108*0Sstevel@tonic-gate case RPC_CANTCONNECT:
109*0Sstevel@tonic-gate return ("RPC: Couldn't make connection");
110*0Sstevel@tonic-gate case RPC_XPRTFAILED:
111*0Sstevel@tonic-gate return ("RPC: Received disconnect from remote");
112*0Sstevel@tonic-gate case RPC_CANTCREATESTREAM:
113*0Sstevel@tonic-gate return ("RPC: Can't push RPC module");
114*0Sstevel@tonic-gate case RPC_CANTSTORE:
115*0Sstevel@tonic-gate return ("RPC: Can't store pending message");
116*0Sstevel@tonic-gate }
117*0Sstevel@tonic-gate return ("RPC: (unknown error code)");
118*0Sstevel@tonic-gate }
119*0Sstevel@tonic-gate
120*0Sstevel@tonic-gate /*
121*0Sstevel@tonic-gate * Return string reply error info. For use after clnt_call().
122*0Sstevel@tonic-gate * It allocates the buffer of size MAXPATHLEN and assumes
123*0Sstevel@tonic-gate * caller's responsibility to free the memory after use.
124*0Sstevel@tonic-gate */
125*0Sstevel@tonic-gate char *
clnt_sperror(const CLIENT * cl,const char * s)126*0Sstevel@tonic-gate clnt_sperror(const CLIENT *cl, const char *s)
127*0Sstevel@tonic-gate {
128*0Sstevel@tonic-gate struct rpc_err e;
129*0Sstevel@tonic-gate #ifdef notyet
130*0Sstevel@tonic-gate char *err;
131*0Sstevel@tonic-gate #endif
132*0Sstevel@tonic-gate char *str;
133*0Sstevel@tonic-gate char *strstart;
134*0Sstevel@tonic-gate
135*0Sstevel@tonic-gate str = kmem_alloc(MAXPATHLEN, KM_SLEEP);
136*0Sstevel@tonic-gate strstart = str;
137*0Sstevel@tonic-gate
138*0Sstevel@tonic-gate CLNT_GETERR((CLIENT *) cl, &e);
139*0Sstevel@tonic-gate
140*0Sstevel@tonic-gate (void) sprintf(str, "%s: ", s);
141*0Sstevel@tonic-gate str += strlen(str);
142*0Sstevel@tonic-gate
143*0Sstevel@tonic-gate (void) strcpy(str, clnt_sperrno(e.re_status));
144*0Sstevel@tonic-gate str += strlen(str);
145*0Sstevel@tonic-gate
146*0Sstevel@tonic-gate switch (e.re_status) {
147*0Sstevel@tonic-gate case RPC_SUCCESS:
148*0Sstevel@tonic-gate case RPC_CANTENCODEARGS:
149*0Sstevel@tonic-gate case RPC_CANTDECODERES:
150*0Sstevel@tonic-gate case RPC_TIMEDOUT:
151*0Sstevel@tonic-gate case RPC_PROGUNAVAIL:
152*0Sstevel@tonic-gate case RPC_PROCUNAVAIL:
153*0Sstevel@tonic-gate case RPC_CANTDECODEARGS:
154*0Sstevel@tonic-gate case RPC_SYSTEMERROR:
155*0Sstevel@tonic-gate case RPC_UNKNOWNHOST:
156*0Sstevel@tonic-gate case RPC_UNKNOWNPROTO:
157*0Sstevel@tonic-gate case RPC_UNKNOWNADDR:
158*0Sstevel@tonic-gate case RPC_NOBROADCAST:
159*0Sstevel@tonic-gate case RPC_RPCBFAILURE:
160*0Sstevel@tonic-gate case RPC_PROGNOTREGISTERED:
161*0Sstevel@tonic-gate case RPC_FAILED:
162*0Sstevel@tonic-gate case RPC_INPROGRESS:
163*0Sstevel@tonic-gate break;
164*0Sstevel@tonic-gate
165*0Sstevel@tonic-gate #ifdef notyet
166*0Sstevel@tonic-gate case RPC_N2AXLATEFAILURE:
167*0Sstevel@tonic-gate (void) sprintf(str, "; %s", netdir_sperror());
168*0Sstevel@tonic-gate break;
169*0Sstevel@tonic-gate #endif
170*0Sstevel@tonic-gate
171*0Sstevel@tonic-gate case RPC_TLIERROR:
172*0Sstevel@tonic-gate #ifdef notyet
173*0Sstevel@tonic-gate (void) sprintf(str, "; %s", t_errlist[e.re_terrno]);
174*0Sstevel@tonic-gate #else
175*0Sstevel@tonic-gate (void) sprintf(str, "; %d", e.re_terrno);
176*0Sstevel@tonic-gate #endif
177*0Sstevel@tonic-gate str += strlen(str);
178*0Sstevel@tonic-gate if (e.re_errno) {
179*0Sstevel@tonic-gate #ifdef notyet
180*0Sstevel@tonic-gate (void) sprintf(str, "; %s", strerror(e.re_errno));
181*0Sstevel@tonic-gate #else
182*0Sstevel@tonic-gate (void) sprintf(str, "; %d", e.re_errno);
183*0Sstevel@tonic-gate #endif
184*0Sstevel@tonic-gate }
185*0Sstevel@tonic-gate break;
186*0Sstevel@tonic-gate
187*0Sstevel@tonic-gate case RPC_CANTSEND:
188*0Sstevel@tonic-gate case RPC_CANTRECV:
189*0Sstevel@tonic-gate if (e.re_errno) {
190*0Sstevel@tonic-gate #ifdef notyet
191*0Sstevel@tonic-gate (void) sprintf(str, "; errno = %s",
192*0Sstevel@tonic-gate strerror(e.re_errno));
193*0Sstevel@tonic-gate #else
194*0Sstevel@tonic-gate (void) sprintf(str, "; errno = %d", e.re_errno);
195*0Sstevel@tonic-gate #endif
196*0Sstevel@tonic-gate str += strlen(str);
197*0Sstevel@tonic-gate }
198*0Sstevel@tonic-gate if (e.re_terrno) {
199*0Sstevel@tonic-gate #ifdef notyet
200*0Sstevel@tonic-gate (void) sprintf(str, "; %s", t_errlist[e.re_terrno]);
201*0Sstevel@tonic-gate #else
202*0Sstevel@tonic-gate (void) sprintf(str, "; %d", e.re_terrno);
203*0Sstevel@tonic-gate #endif
204*0Sstevel@tonic-gate }
205*0Sstevel@tonic-gate break;
206*0Sstevel@tonic-gate
207*0Sstevel@tonic-gate case RPC_VERSMISMATCH:
208*0Sstevel@tonic-gate (void) sprintf(str,
209*0Sstevel@tonic-gate "; low version = %" PRIu32 ", high version = %" PRIu32,
210*0Sstevel@tonic-gate e.re_vers.low, e.re_vers.high);
211*0Sstevel@tonic-gate break;
212*0Sstevel@tonic-gate
213*0Sstevel@tonic-gate #ifdef notyet
214*0Sstevel@tonic-gate case RPC_AUTHERROR:
215*0Sstevel@tonic-gate err = auth_errmsg(e.re_why);
216*0Sstevel@tonic-gate (void) sprintf(str, "; why = ");
217*0Sstevel@tonic-gate str += strlen(str);
218*0Sstevel@tonic-gate if (err != NULL) {
219*0Sstevel@tonic-gate (void) sprintf(str, "%s", err);
220*0Sstevel@tonic-gate } else {
221*0Sstevel@tonic-gate (void) sprintf(str,
222*0Sstevel@tonic-gate "(unknown authentication error - %d)",
223*0Sstevel@tonic-gate (int)e.re_why);
224*0Sstevel@tonic-gate }
225*0Sstevel@tonic-gate break;
226*0Sstevel@tonic-gate #endif
227*0Sstevel@tonic-gate
228*0Sstevel@tonic-gate case RPC_PROGVERSMISMATCH:
229*0Sstevel@tonic-gate (void) sprintf(str,
230*0Sstevel@tonic-gate "; low version = %" PRIu32 ", high version = %" PRIu32,
231*0Sstevel@tonic-gate e.re_vers.low, e.re_vers.high);
232*0Sstevel@tonic-gate break;
233*0Sstevel@tonic-gate
234*0Sstevel@tonic-gate default: /* unknown */
235*0Sstevel@tonic-gate (void) sprintf(str, "; s1 = %" PRIu32 ", s2 = %" PRIu32,
236*0Sstevel@tonic-gate e.re_lb.s1, e.re_lb.s2);
237*0Sstevel@tonic-gate break;
238*0Sstevel@tonic-gate }
239*0Sstevel@tonic-gate return (strstart);
240*0Sstevel@tonic-gate }
241