source: rtems/cpukit/librpc/include/rpc/clnt.h @ fd6a994

4.104.114.84.95
Last change on this file since fd6a994 was fd6a994, checked in by Ralf Corsepius <ralf.corsepius@…>, on 05/25/05 at 13:02:40

More updates from FreeBSD.

  • Property mode set to 100644
File size: 10.3 KB
Line 
1/*      $NetBSD: clnt.h,v 1.14 2000/06/02 22:57:55 fvdl Exp $   */
2
3/*
4 * The contents of this file are subject to the Sun Standards
5 * License Version 1.0 the (the "License";) You may not use
6 * this file except in compliance with the License.  You may
7 * obtain a copy of the License at lib/libc/rpc/LICENSE
8 *
9 * Software distributed under the License is distributed on
10 * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
11 * express or implied.  See the License for the specific
12 * language governing rights and limitations under the License.
13 *
14 * The Original Code is Copyright 1998 by Sun Microsystems, Inc
15 *
16 * The Initial Developer of the Original Code is:  Sun
17 * Microsystems, Inc.
18 *
19 * All Rights Reserved.
20 *
21 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
22 * unrestricted use provided that this legend is included on all tape
23 * media and as a part of the software program in whole or part.  Users
24 * may copy or modify Sun RPC without charge, but are not authorized
25 * to license or distribute it to anyone else except as part of a product or
26 * program developed by the user.
27 *
28 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
29 * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
31 *
32 * Sun RPC is provided with no support and without any obligation on the
33 * part of Sun Microsystems, Inc. to assist in its use, correction,
34 * modification or enhancement.
35 *
36 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
37 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
38 * OR ANY PART THEREOF.
39 *
40 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
41 * or profits or other special, indirect and consequential damages, even if
42 * Sun has been advised of the possibility of such damages.
43 *
44 * Sun Microsystems, Inc.
45 * 2550 Garcia Avenue
46 * Mountain View, California  94043
47 *
48 *      from: @(#)clnt.h 1.31 88/02/08 SMI
49 *      from: @(#)clnt.h        2.1 88/07/29 4.0 RPCSRC
50 * $FreeBSD: src/include/rpc/clnt.h,v 1.11 1999/08/27 23:45:03 peter Exp $
51 */
52
53/*
54 * clnt.h - Client side remote procedure call interface.
55 *
56 * Copyright (C) 1984, Sun Microsystems, Inc.
57 */
58
59#ifndef _RPC_CLNT_H_
60#define _RPC_CLNT_H_
61#include <sys/cdefs.h>
62#include <sys/un.h>
63
64/*
65 * Rpc calls return an enum clnt_stat.  This should be looked at more,
66 * since each implementation is required to live with this (implementation
67 * independent) list of errors.
68 */
69enum clnt_stat {
70        RPC_SUCCESS=0,                  /* call succeeded */
71        /*
72         * local errors
73         */
74        RPC_CANTENCODEARGS=1,           /* can't encode arguments */
75        RPC_CANTDECODERES=2,            /* can't decode results */
76        RPC_CANTSEND=3,                 /* failure in sending call */
77        RPC_CANTRECV=4,                 /* failure in receiving result */
78        RPC_TIMEDOUT=5,                 /* call timed out */
79        /*
80         * remote errors
81         */
82        RPC_VERSMISMATCH=6,             /* rpc versions not compatible */
83        RPC_AUTHERROR=7,                /* authentication error */
84        RPC_PROGUNAVAIL=8,              /* program not available */
85        RPC_PROGVERSMISMATCH=9,         /* program version mismatched */
86        RPC_PROCUNAVAIL=10,             /* procedure unavailable */
87        RPC_CANTDECODEARGS=11,          /* decode arguments error */
88        RPC_SYSTEMERROR=12,             /* generic "other problem" */
89
90        /*
91         * callrpc & clnt_create errors
92         */
93        RPC_UNKNOWNHOST=13,             /* unknown host name */
94        RPC_UNKNOWNPROTO=17,            /* unkown protocol */
95
96        /*
97         * _ create errors
98         */
99        RPC_PMAPFAILURE=14,             /* the pmapper failed in its call */
100        RPC_PROGNOTREGISTERED=15,       /* remote program is not registered */
101        /*
102         * unspecified error
103         */
104        RPC_FAILED=16
105};
106
107
108/*
109 * Error info.
110 */
111struct rpc_err {
112        enum clnt_stat re_status;
113        union {
114                int RE_errno;           /* related system error */
115                enum auth_stat RE_why;  /* why the auth error occurred */
116                struct {
117                        rpcvers_t low;  /* lowest version supported */
118                        rpcvers_t high; /* highest version supported */
119                } RE_vers;
120                struct {                /* maybe meaningful if RPC_FAILED */
121                        int32_t s1;
122                        int32_t s2;
123                } RE_lb;                /* life boot & debugging only */
124        } ru;
125#define re_errno        ru.RE_errno
126#define re_why          ru.RE_why
127#define re_vers         ru.RE_vers
128#define re_lb           ru.RE_lb
129};
130
131
132/*
133 * Client rpc handle.
134 * Created by individual implementations
135 * Client is responsible for initializing auth, see e.g. auth_none.c.
136 */
137typedef struct __rpc_client {
138        AUTH    *cl_auth;                       /* authenticator */
139        struct clnt_ops {
140                /* call remote procedure */
141                enum clnt_stat  (*cl_call)(struct __rpc_client *,
142                                    rpcproc_t, xdrproc_t, void *, xdrproc_t,
143                                        void *, struct timeval);
144                /* abort a call */
145                void            (*cl_abort)(struct __rpc_client *);
146                /* get specific error code */
147                void            (*cl_geterr)(struct __rpc_client *,
148                                        struct rpc_err *);
149                /* frees results */
150                bool_t          (*cl_freeres)(struct __rpc_client *,
151                                        xdrproc_t, caddr_t);
152                /* destroy this structure */
153                void            (*cl_destroy)(struct __rpc_client *);
154                /* the ioctl() of rpc */
155                bool_t          (*cl_control)(struct __rpc_client *, u_int,
156                                        void *);
157        } *cl_ops;
158        caddr_t                 cl_private;     /* private stuff */
159} CLIENT;
160
161
162/*
163 * client side rpc interface ops
164 *
165 * Parameter types are:
166 *
167 */
168
169/*
170 * enum clnt_stat
171 * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
172 *      CLIENT *rh;
173 *      u_long proc;
174 *      xdrproc_t xargs;
175 *      caddr_t argsp;
176 *      xdrproc_t xres;
177 *      caddr_t resp;
178 *      struct timeval timeout;
179 */
180#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs)     \
181        ((*(rh)->cl_ops->cl_call)(rh, proc, (xdrproc_t)xargs, (caddr_t)argsp, \
182                (xdrproc_t) xres, (caddr_t)resp, secs))
183#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs)     \
184        ((*(rh)->cl_ops->cl_call)(rh, proc, (xdrproc_t) xargs, (caddr_t)argsp, \
185                (xdrproc_t) xres, (caddr_t)resp, secs))
186
187/*
188 * void
189 * CLNT_ABORT(rh);
190 *      CLIENT *rh;
191 */
192#define CLNT_ABORT(rh)  ((*(rh)->cl_ops->cl_abort)(rh))
193#define clnt_abort(rh)  ((*(rh)->cl_ops->cl_abort)(rh))
194
195/*
196 * struct rpc_err
197 * CLNT_GETERR(rh);
198 *      CLIENT *rh;
199 */
200#define CLNT_GETERR(rh,errp)    ((*(rh)->cl_ops->cl_geterr)(rh, errp))
201#define clnt_geterr(rh,errp)    ((*(rh)->cl_ops->cl_geterr)(rh, errp))
202
203
204/*
205 * bool_t
206 * CLNT_FREERES(rh, xres, resp);
207 *      CLIENT *rh;
208 *      xdrproc_t xres;
209 *      caddr_t resp;
210 */
211#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,(xdrproc_t)xres,resp))
212#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,(xdrproc_t)xres,resp))
213
214/*
215 * bool_t
216 * CLNT_CONTROL(cl, request, info)
217 *      CLIENT *cl;
218 *      u_int request;
219 *      char *info;
220 */
221#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
222#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
223
224/*
225 * control operations that apply to udp, tcp and unix transports
226 *
227 * Note: options marked XXX are no-ops in this implementation of RPC.
228 * The are present in TI-RPC but can't be implemented here since they
229 * depend on the presence of STREAMS/TLI, which we don't have.
230 *
231 */
232#define CLSET_TIMEOUT       1   /* set timeout (timeval) */
233#define CLGET_TIMEOUT       2   /* get timeout (timeval) */
234#define CLGET_SERVER_ADDR   3   /* get server's address (sockaddr) */
235#define CLGET_FD            6   /* get connections file descriptor */
236#define CLGET_SVC_ADDR      7   /* get server's address (netbuf) */
237#define CLSET_FD_CLOSE      8   /* close fd while clnt_destroy */
238#define CLSET_FD_NCLOSE     9   /* Do not close fd while clnt_destroy */
239#define CLGET_XID           10  /* Get xid */
240#define CLSET_XID           11  /* Set xid */
241#define CLGET_VERS          12  /* Get version number */
242#define CLSET_VERS          13  /* Set version number */
243#define CLGET_PROG          14  /* Get program number */
244#define CLSET_PROG          15  /* Set program number */
245#define CLSET_SVC_ADDR      16  /* get server's address (netbuf)         XXX */
246#define CLSET_PUSH_TIMOD    17  /* push timod if not already present     XXX */
247#define CLSET_POP_TIMOD     18  /* pop timod                             XXX */
248
249/*
250 * Connectionless only control operations
251 */
252#define CLSET_RETRY_TIMEOUT 4   /* set retry timeout (timeval) */
253#define CLGET_RETRY_TIMEOUT 5   /* get retry timeout (timeval) */
254
255/*
256 * Operations which GSSAPI needs. (Bletch.)
257 */
258#define CLGET_LOCAL_ADDR    19  /* get local addr (sockaddr) */
259
260
261/*
262 * void
263 * CLNT_DESTROY(rh);
264 *      CLIENT *rh;
265 */
266#define CLNT_DESTROY(rh)        ((*(rh)->cl_ops->cl_destroy)(rh))
267#define clnt_destroy(rh)        ((*(rh)->cl_ops->cl_destroy)(rh))
268
269
270/*
271 * RPCTEST is a test program which is accessible on every rpc
272 * transport/port.  It is used for testing, performance evaluation,
273 * and network administration.
274 */
275
276#define RPCTEST_PROGRAM         ((rpcprog_t)1)
277#define RPCTEST_VERSION         ((rpcvers_t)1)
278#define RPCTEST_NULL_PROC       ((rpcproc_t)2)
279#define RPCTEST_NULL_BATCH_PROC ((rpcproc_t)3)
280
281/*
282 * By convention, procedure 0 takes null arguments and returns them
283 */
284
285#define NULLPROC ((rpcproc_t)0)
286
287/*
288 * Below are the client handle creation routines for the various
289 * implementations of client side rpc.  They can return NULL if a
290 * creation failure occurs.
291 */
292
293/*
294 * Generic client creation routine. Supported protocols are "udp", "tcp"
295 * and "unix".
296 * CLIENT *
297 * clnt_create(host, prog, vers, prot);
298 *      char *host;     -- hostname
299 *      u_long prog;    -- program number
300 *      u_long vers;    -- version number
301 *      char *prot;     -- protocol
302 */
303__BEGIN_DECLS
304extern CLIENT *clnt_create(char *, u_long, u_long, char *);
305__END_DECLS
306
307
308/*
309 * Added for compatibility to old rpc 4.0. Obsoleted by clnt_vc_create().
310 */
311extern CLIENT *clntunix_create(struct sockaddr_un *,
312                               u_long, u_long, int *, u_int, u_int);
313__END_DECLS
314
315
316/*
317 * Print why creation failed
318 */
319__BEGIN_DECLS
320extern void clnt_pcreateerror(const char *);                    /* stderr */
321extern char *clnt_spcreateerror(const char *);          /* string */
322__END_DECLS
323
324/*
325 * Like clnt_perror(), but is more verbose in its output
326 */
327__BEGIN_DECLS
328extern void clnt_perrno(enum clnt_stat);                /* stderr */
329extern char *clnt_sperrno(enum clnt_stat);              /* string */
330__END_DECLS
331
332/*
333 * Print an English error message, given the client error code
334 */
335__BEGIN_DECLS
336extern void clnt_perror(CLIENT *, const char *);                /* stderr */
337extern char *clnt_sperror(CLIENT *, const char *);              /* string */
338__END_DECLS
339
340
341/*
342 * If a creation fails, the following allows the user to figure out why.
343 */
344struct rpc_createerr {
345        enum clnt_stat cf_stat;
346        struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */
347};
348
349extern struct rpc_createerr rpc_createerr;
350
351
352#define UDPMSGSIZE      8800    /* rpc imposed limit on udp msg size */
353#define RPCSMALLMSGSIZE 400     /* a more reasonable packet size */
354
355/* For backward compatibility */
356#include <rpc/clnt_soc.h>
357
358#endif /* !_RPC_CLNT_H_ */
Note: See TracBrowser for help on using the repository browser.