source: rtems-libbsd/services/librpc/include/rpc/clnt.h @ 20ec9e6

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since 20ec9e6 was 20ec9e6, checked in by Joel Sherrill <joel.sherrill@…>, on 08/03/12 at 19:19:49

librpc: Initial addition

This does not currently compile. There is an include file
issue and int32_t is not defined even though stdint.h is included
before its use.

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