OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [librpc/] [src/] [rpc/] [clnt_perror.c] - Blame information for rev 587

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3
 * unrestricted use provided that this legend is included on all tape
4
 * media and as a part of the software program in whole or part.  Users
5
 * may copy or modify Sun RPC without charge, but are not authorized
6
 * to license or distribute it to anyone else except as part of a product or
7
 * program developed by the user.
8
 *
9
 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10
 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
11
 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
12
 *
13
 * Sun RPC is provided with no support and without any obligation on the
14
 * part of Sun Microsystems, Inc. to assist in its use, correction,
15
 * modification or enhancement.
16
 *
17
 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18
 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19
 * OR ANY PART THEREOF.
20
 *
21
 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22
 * or profits or other special, indirect and consequential damages, even if
23
 * Sun has been advised of the possibility of such damages.
24
 *
25
 * Sun Microsystems, Inc.
26
 * 2550 Garcia Avenue
27
 * Mountain View, California  94043
28
 */
29
 
30
#if defined(LIBC_SCCS) && !defined(lint)
31
/*static char *sccsid = "from: @(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";*/
32
/*static char *sccsid = "from: @(#)clnt_perror.c        2.1 88/07/29 4.0 RPCSRC";*/
33
static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_perror.c,v 1.11 1999/08/28 00:00:35 peter Exp $";
34
#endif
35
 
36
/*
37
 * clnt_perror.c
38
 *
39
 * Copyright (C) 1984, Sun Microsystems, Inc.
40
 *
41
 */
42
#include <stdio.h>
43
#include <stdlib.h>
44
#include <string.h>
45
#include <rpc/rpc.h>
46
#include <rpc/types.h>
47
#include <rpc/auth.h>
48
#include <rpc/clnt.h>
49
 
50
static char *auth_errmsg();
51
#define CLNT_PERROR_BUFLEN 256
52
 
53
#define buf ((char  *)((struct rtems_rpc_task_variables *)rtems_rpc_task_variables)->clnt_perror_buf)
54
 
55
static char *
56
_buf()
57
{
58
 
59
        if (buf == 0)
60
                buf = (char *)malloc(CLNT_PERROR_BUFLEN);
61
        return (buf);
62
}
63
 
64
/*
65
 * Print reply error info
66
 */
67
char *
68
clnt_sperror(rpch, s)
69
        CLIENT *rpch;
70
        char *s;
71
{
72
        struct rpc_err e;
73
        char *err;
74
        char *str = _buf();
75
        char *strstart = str;
76
 
77
        if (str == 0)
78
                return (0);
79
        CLNT_GETERR(rpch, &e);
80
 
81
        (void) sprintf(str, "%s: %s", s, clnt_sperrno(e.re_status));
82
        str += strlen(str);
83
 
84
        switch (e.re_status) {
85
        case RPC_SUCCESS:
86
        case RPC_CANTENCODEARGS:
87
        case RPC_CANTDECODERES:
88
        case RPC_TIMEDOUT:
89
        case RPC_PROGUNAVAIL:
90
        case RPC_PROCUNAVAIL:
91
        case RPC_CANTDECODEARGS:
92
        case RPC_SYSTEMERROR:
93
        case RPC_UNKNOWNHOST:
94
        case RPC_UNKNOWNPROTO:
95
        case RPC_PMAPFAILURE:
96
        case RPC_PROGNOTREGISTERED:
97
        case RPC_FAILED:
98
                break;
99
 
100
        case RPC_CANTSEND:
101
        case RPC_CANTRECV:
102
                (void) snprintf(str, CLNT_PERROR_BUFLEN - (str - strstart),
103
                        "; errno = %s\n", strerror(e.re_errno));
104
                break;
105
 
106
        case RPC_VERSMISMATCH:
107
                (void) sprintf(str,
108
                        "; low version = %lu, high version = %lu\n",
109
                        (u_long)e.re_vers.low, (u_long)e.re_vers.high);
110
                break;
111
 
112
        case RPC_AUTHERROR:
113
                err = auth_errmsg(e.re_why);
114
                (void) sprintf(str,"; why = ");
115
                str += strlen(str);
116
                if (err != NULL) {
117
                        (void) sprintf(str, "%s\n",err);
118
                } else {
119
                        (void) sprintf(str,
120
                                "(unknown authentication error - %d)\n",
121
                                (int) e.re_why);
122
                }
123
                break;
124
 
125
        case RPC_PROGVERSMISMATCH:
126
                (void) sprintf(str,
127
                        "; low version = %lu, high version = %lu\n",
128
                        (u_long)e.re_vers.low, (u_long)e.re_vers.high);
129
                break;
130
 
131
        default:        /* unknown */
132
                (void) sprintf(str,
133
                        "; s1 = %lu, s2 = %lu\n",
134
                        (long)e.re_lb.s1, (long)e.re_lb.s2);
135
                break;
136
        }
137
        strstart[CLNT_PERROR_BUFLEN-2] = '\n';
138
        strstart[CLNT_PERROR_BUFLEN-1] = '\0';
139
        return(strstart) ;
140
}
141
 
142
void
143
clnt_perror(rpch, s)
144
        CLIENT *rpch;
145
        char *s;
146
{
147
        (void) fprintf(stderr,"%s\n",clnt_sperror(rpch,s));
148
}
149
 
150
 
151
static const char *const rpc_errlist[] = {
152
        "RPC: Success",                         /*  0 - RPC_SUCCESS */
153
        "RPC: Can't encode arguments",          /*  1 - RPC_CANTENCODEARGS */
154
        "RPC: Can't decode result",             /*  2 - RPC_CANTDECODERES */
155
        "RPC: Unable to send",                  /*  3 - RPC_CANTSEND */
156
        "RPC: Unable to receive",               /*  4 - RPC_CANTRECV */
157
        "RPC: Timed out",                       /*  5 - RPC_TIMEDOUT */
158
        "RPC: Incompatible versions of RPC",    /*  6 - RPC_VERSMISMATCH */
159
        "RPC: Authentication error",            /*  7 - RPC_AUTHERROR */
160
        "RPC: Program unavailable",             /*  8 - RPC_PROGUNAVAIL */
161
        "RPC: Program/version mismatch",        /*  9 - RPC_PROGVERSMISMATCH */
162
        "RPC: Procedure unavailable",           /* 10 - RPC_PROCUNAVAIL */
163
        "RPC: Server can't decode arguments",   /* 11 - RPC_CANTDECODEARGS */
164
        "RPC: Remote system error",             /* 12 - RPC_SYSTEMERROR */
165
        "RPC: Unknown host",                    /* 13 - RPC_UNKNOWNHOST */
166
        "RPC: Port mapper failure",             /* 14 - RPC_PMAPFAILURE */
167
        "RPC: Program not registered",          /* 15 - RPC_PROGNOTREGISTERED */
168
        "RPC: Failed (unspecified error)",      /* 16 - RPC_FAILED */
169
        "RPC: Unknown protocol"                 /* 17 - RPC_UNKNOWNPROTO */
170
};
171
 
172
 
173
/*
174
 * This interface for use by clntrpc
175
 */
176
char *
177
clnt_sperrno(stat)
178
        enum clnt_stat stat;
179
{
180
        unsigned int errnum = stat;
181
 
182
        if (errnum < (sizeof(rpc_errlist)/sizeof(rpc_errlist[0])))
183
                return (char *)rpc_errlist[errnum];
184
 
185
        return ("RPC: (unknown error code)");
186
}
187
 
188
void
189
clnt_perrno(num)
190
        enum clnt_stat num;
191
{
192
        (void) fprintf(stderr,"%s\n",clnt_sperrno(num));
193
}
194
 
195
 
196
char *
197
clnt_spcreateerror(s)
198
        char *s;
199
{
200
        char *str = _buf();
201
 
202
        if (str == 0)
203
                return(0);
204
        switch (rpc_createerr.cf_stat) {
205
        case RPC_PMAPFAILURE:
206
                (void) snprintf(str, CLNT_PERROR_BUFLEN, "%s: %s - %s\n", s,
207
                    clnt_sperrno(rpc_createerr.cf_stat),
208
                    clnt_sperrno(rpc_createerr.cf_error.re_status));
209
                break;
210
 
211
        case RPC_SYSTEMERROR:
212
                (void) snprintf(str, CLNT_PERROR_BUFLEN, "%s: %s - %s\n", s,
213
                    clnt_sperrno(rpc_createerr.cf_stat),
214
                    strerror(rpc_createerr.cf_error.re_errno));
215
                break;
216
        default:
217
                (void) snprintf(str, CLNT_PERROR_BUFLEN, "%s: %s\n", s,
218
                clnt_sperrno(rpc_createerr.cf_stat));
219
                break;
220
        }
221
        str[CLNT_PERROR_BUFLEN-2] = '\n';
222
        str[CLNT_PERROR_BUFLEN-1] = '\0';
223
        return (str);
224
}
225
 
226
void
227
clnt_pcreateerror(s)
228
        char *s;
229
{
230
        (void) fprintf(stderr,"%s\n",clnt_spcreateerror(s));
231
}
232
 
233
static const char *const auth_errlist[] = {
234
        "Authentication OK",                    /* 0 - AUTH_OK */
235
        "Invalid client credential",            /* 1 - AUTH_BADCRED */
236
        "Server rejected credential",           /* 2 - AUTH_REJECTEDCRED */
237
        "Invalid client verifier",              /* 3 - AUTH_BADVERF */
238
        "Server rejected verifier",             /* 4 - AUTH_REJECTEDVERF */
239
        "Client credential too weak",           /* 5 - AUTH_TOOWEAK */
240
        "Invalid server verifier",              /* 6 - AUTH_INVALIDRESP */
241
        "Failed (unspecified error)"            /* 7 - AUTH_FAILED */
242
};
243
 
244
static char *
245
auth_errmsg(stat)
246
        enum auth_stat stat;
247
{
248
        unsigned int errnum = stat;
249
 
250
        if (errnum < (sizeof(auth_errlist)/sizeof(auth_errlist[0])))
251
                return (char *)auth_errlist[errnum];
252
 
253
        return(NULL);
254
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.