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

4.104.11
Last change on this file since 1f5986b was 1f5986b, checked in by Ralf Corsepius <ralf.corsepius@…>, on May 27, 2010 at 7:36:24 AM

2010-05-27 Ralf Corsépius <ralf.corsepius@…>

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