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

4.115
Last change on this file since bc38915 was bc38915, checked in by Ralf Corsepius <ralf.corsepius@…>, on 05/05/11 at 12:30:09

Make self-contained.

  • Property mode set to 100644
File size: 8.9 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 94/04/29 SMI
49 *      from: @(#)clnt.h        2.1 88/07/29 4.0 RPCSRC
50 * $FreeBSD: src/include/rpc/clnt.h,v 1.21 2003/01/24 01:47:55 fjoe Exp $
51 */
52
53/*
54 * clnt.h - Client side remote procedure call interface.
55 *
56 * Copyright (c) 1986-1991,1994-1999 by Sun Microsystems, Inc.
57 * All rights reserved.
58 */
59
60/*
61 * $Id$
62 */
63
64#ifndef _RPC_CLNT_H_
65#define _RPC_CLNT_H_
66#include <rpc/clnt_stat.h>
67#include <sys/cdefs.h>
68#include <sys/un.h>
69#include <rpc/auth.h> /* auth_stat */
70
71/*
72 * Error info.
73 */
74struct rpc_err {
75        enum clnt_stat re_status;
76        union {
77                int RE_errno;           /* related system error */
78                enum auth_stat RE_why;  /* why the auth error occurred */
79                struct {
80                        rpcvers_t low;  /* lowest version supported */
81                        rpcvers_t high; /* highest version supported */
82                } RE_vers;
83                struct {                /* maybe meaningful if RPC_FAILED */
84                        int32_t s1;
85                        int32_t s2;
86                } RE_lb;                /* life boot & debugging only */
87        } ru;
88#define re_errno        ru.RE_errno
89#define re_why          ru.RE_why
90#define re_vers         ru.RE_vers
91#define re_lb           ru.RE_lb
92};
93
94
95/*
96 * Client rpc handle.
97 * Created by individual implementations
98 * Client is responsible for initializing auth, see e.g. auth_none.c.
99 */
100typedef struct __rpc_client {
101        AUTH    *cl_auth;                       /* authenticator */
102        struct clnt_ops {
103                /* call remote procedure */
104                enum clnt_stat  (*cl_call)(struct __rpc_client *,
105                                    rpcproc_t, xdrproc_t, void *, xdrproc_t,
106                                        void *, struct timeval);
107                /* abort a call */
108                void            (*cl_abort)(void);
109                /* get specific error code */
110                void            (*cl_geterr)(struct __rpc_client *,
111                                        struct rpc_err *);
112                /* frees results */
113                bool_t          (*cl_freeres)(struct __rpc_client *,
114                                        xdrproc_t, void *);
115                /* destroy this structure */
116                void            (*cl_destroy)(struct __rpc_client *);
117                /* the ioctl() of rpc */
118                bool_t          (*cl_control)(struct __rpc_client *, int,
119                                        char *);
120        } *cl_ops;
121        void                    *cl_private;    /* private stuff */
122} CLIENT;
123
124#define RPCSMALLMSGSIZE 400     /* a more reasonable packet size */
125
126/*
127 * client side rpc interface ops
128 *
129 * Parameter types are:
130 *
131 */
132
133/*
134 * enum clnt_stat
135 * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
136 *      CLIENT *rh;
137 *      rpcproc_t proc;
138 *      xdrproc_t xargs;
139 *      void *argsp;
140 *      xdrproc_t xres;
141 *      void *resp;
142 *      struct timeval timeout;
143 */
144#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs)     \
145        ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \
146                argsp, xres, resp, secs))
147#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs)     \
148        ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \
149                argsp, xres, resp, secs))
150
151/*
152 * void
153 * CLNT_ABORT(rh);
154 *      CLIENT *rh;
155 */
156#define CLNT_ABORT(rh)  ((*(rh)->cl_ops->cl_abort)(rh))
157#define clnt_abort(rh)  ((*(rh)->cl_ops->cl_abort)(rh))
158
159/*
160 * struct rpc_err
161 * CLNT_GETERR(rh);
162 *      CLIENT *rh;
163 */
164#define CLNT_GETERR(rh,errp)    ((*(rh)->cl_ops->cl_geterr)(rh, errp))
165#define clnt_geterr(rh,errp)    ((*(rh)->cl_ops->cl_geterr)(rh, errp))
166
167
168/*
169 * bool_t
170 * CLNT_FREERES(rh, xres, resp);
171 *      CLIENT *rh;
172 *      xdrproc_t xres;
173 *      void *resp;
174 */
175#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
176#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
177
178/*
179 * bool_t
180 * CLNT_CONTROL(cl, request, info)
181 *      CLIENT *cl;
182 *      u_int request;
183 *      char *info;
184 */
185#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
186#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
187
188/*
189 * control operations that apply to udp, tcp and unix transports
190 *
191 * Note: options marked XXX are no-ops in this implementation of RPC.
192 * The are present in TI-RPC but can't be implemented here since they
193 * depend on the presence of STREAMS/TLI, which we don't have.
194 *
195 */
196#define CLSET_TIMEOUT       1   /* set timeout (timeval) */
197#define CLGET_TIMEOUT       2   /* get timeout (timeval) */
198#define CLGET_SERVER_ADDR   3   /* get server's address (sockaddr) */
199#define CLGET_FD            6   /* get connections file descriptor */
200#define CLGET_SVC_ADDR      7   /* get server's address (netbuf) */
201#define CLSET_FD_CLOSE      8   /* close fd while clnt_destroy */
202#define CLSET_FD_NCLOSE     9   /* Do not close fd while clnt_destroy */
203#define CLGET_XID           10  /* Get xid */
204#define CLSET_XID           11  /* Set xid */
205#define CLGET_VERS          12  /* Get version number */
206#define CLSET_VERS          13  /* Set version number */
207#define CLGET_PROG          14  /* Get program number */
208#define CLSET_PROG          15  /* Set program number */
209#define CLSET_SVC_ADDR      16  /* get server's address (netbuf)         XXX */
210#define CLSET_PUSH_TIMOD    17  /* push timod if not already present     XXX */
211#define CLSET_POP_TIMOD     18  /* pop timod                             XXX */
212
213/*
214 * Connectionless only control operations
215 */
216#define CLSET_RETRY_TIMEOUT 4   /* set retry timeout (timeval) */
217#define CLGET_RETRY_TIMEOUT 5   /* get retry timeout (timeval) */
218
219/*
220 * Operations which GSSAPI needs. (Bletch.)
221 */
222#define CLGET_LOCAL_ADDR    19  /* get local addr (sockaddr) */
223
224
225/*
226 * void
227 * CLNT_DESTROY(rh);
228 *      CLIENT *rh;
229 */
230#define CLNT_DESTROY(rh)        ((*(rh)->cl_ops->cl_destroy)(rh))
231#define clnt_destroy(rh)        ((*(rh)->cl_ops->cl_destroy)(rh))
232
233
234/*
235 * RPCTEST is a test program which is accessible on every rpc
236 * transport/port.  It is used for testing, performance evaluation,
237 * and network administration.
238 */
239
240#define RPCTEST_PROGRAM         ((rpcprog_t)1)
241#define RPCTEST_VERSION         ((rpcvers_t)1)
242#define RPCTEST_NULL_PROC       ((rpcproc_t)2)
243#define RPCTEST_NULL_BATCH_PROC ((rpcproc_t)3)
244
245/*
246 * By convention, procedure 0 takes null arguments and returns them
247 */
248
249#define NULLPROC ((rpcproc_t)0)
250
251/*
252 * Below are the client handle creation routines for the various
253 * implementations of client side rpc.  They can return NULL if a
254 * creation failure occurs.
255 */
256
257/*
258 * Generic client creation routine. Supported protocols are "udp", "tcp"
259 * and "unix".
260 */
261__BEGIN_DECLS
262extern CLIENT *clnt_create(const char *, const rpcprog_t, const rpcvers_t,
263        const char *);
264__END_DECLS
265
266/*
267 * Added for compatibility to old rpc 4.0. Obsoleted by clnt_vc_create().
268 */
269__BEGIN_DECLS
270extern CLIENT *clntunix_create(struct sockaddr_un *,
271                               u_long, u_long, int *, u_int, u_int);
272__END_DECLS
273
274
275/*
276 * Print why creation failed
277 */
278__BEGIN_DECLS
279extern void clnt_pcreateerror(const char *);                    /* stderr */
280extern char *clnt_spcreateerror(const char *);          /* string */
281__END_DECLS
282
283/*
284 * Like clnt_perror(), but is more verbose in its output
285 */
286__BEGIN_DECLS
287extern void clnt_perrno(enum clnt_stat);                /* stderr */
288extern char *clnt_sperrno(enum clnt_stat);              /* string */
289__END_DECLS
290
291/*
292 * Print an English error message, given the client error code
293 */
294__BEGIN_DECLS
295extern void clnt_perror(CLIENT *, const char *);                /* stderr */
296extern char *clnt_sperror(CLIENT *, const char *);              /* string */
297__END_DECLS
298
299
300/*
301 * If a creation fails, the following allows the user to figure out why.
302 */
303struct rpc_createerr {
304        enum clnt_stat cf_stat;
305        struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */
306};
307
308extern struct rpc_createerr rpc_createerr;
309
310/* For backward compatibility */
311#include <rpc/clnt_soc.h>
312
313#endif /* !_RPC_CLNT_H_ */
Note: See TracBrowser for help on using the repository browser.