2 * @(#)clnt.h 2.1 97/10/23
5 /* @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/
7 * Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
9 * Standard Performance Evaluation Corporation (SPEC)
10 * 6585 Merchant Place, Suite 100
13 * This product contains benchmarks acquired from several sources who
14 * understand and agree with SPEC's goal of creating fair and objective
15 * benchmarks to measure computer performance.
17 * This copyright notice is placed here only to protect SPEC in the
18 * event the source is misused in any manner that is contrary to the
19 * spirit, the goals and the intent of SPEC.
21 * The source code is provided to the user or company under the license
22 * agreement for the SPEC Benchmark Suite for this product.
25 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
26 * unrestricted use provided that this legend is included on all tape
27 * media and as a part of the software program in whole or part. Users
28 * may copy or modify Sun RPC without charge, but are not authorized
29 * to license or distribute it to anyone else except as part of a product or
30 * program developed by the user.
32 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
33 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
34 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
36 * Sun RPC is provided with no support and without any obligation on the
37 * part of Sun Microsystems, Inc. to assist in its use, correction,
38 * modification or enhancement.
40 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
41 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
42 * OR ANY PART THEREOF.
44 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
45 * or profits or other special, indirect and consequential damages, even if
46 * Sun has been advised of the possibility of such damages.
48 * Sun Microsystems, Inc.
50 * Mountain View, California 94043
54 * clnt.h - Client side remote procedure call interface.
56 * Copyright (C) 1984, Sun Microsystems, Inc.
64 * Rpc calls return an enum clnt_stat. This should be looked at more,
65 * since each implementation is required to live with this (implementation
66 * independent) list of errors.
69 RPC_SUCCESS=0, /* call succeeded */
73 RPC_CANTENCODEARGS=1, /* can't encode arguments */
74 RPC_CANTDECODERES=2, /* can't decode results */
75 RPC_CANTSEND=3, /* failure in sending call */
76 RPC_CANTRECV=4, /* failure in receiving result */
77 RPC_TIMEDOUT=5, /* call timed out */
81 RPC_VERSMISMATCH=6, /* rpc versions not compatible */
82 RPC_AUTHERROR=7, /* authentication error */
83 RPC_PROGUNAVAIL=8, /* program not available */
84 RPC_PROGVERSMISMATCH=9, /* program version mismatched */
85 RPC_PROCUNAVAIL=10, /* procedure unavailable */
86 RPC_CANTDECODEARGS=11, /* decode arguments error */
87 RPC_SYSTEMERROR=12, /* generic "other problem" */
90 * callrpc & clnt_create errors
92 RPC_UNKNOWNHOST=13, /* unknown host name */
93 RPC_UNKNOWNPROTO=17, /* unkown protocol */
98 RPC_PMAPFAILURE=14, /* the pmapper failed in its call */
99 RPC_PROGNOTREGISTERED=15, /* remote program is not registered */
111 enum clnt_stat re_status;
113 int RE_errno; /* realated system error */
114 enum auth_stat RE_why; /* why the auth error occurred */
116 uint32_t low; /* lowest verion supported */
117 uint32_t high; /* highest verion supported */
119 struct { /* maybe meaningful if RPC_FAILED */
122 } RE_lb; /* life boot & debugging only */
124 #define re_errno ru.RE_errno
125 #define re_why ru.RE_why
126 #define re_vers ru.RE_vers
127 #define re_lb ru.RE_lb
133 * Created by individual implementations, see e.g. rpc_udp.c.
134 * Client is responsible for initializing auth, see e.g. auth_none.c.
137 AUTH *cl_auth; /* authenticator */
138 struct clnt_ops *cl_ops;
139 void *cl_private; /* private stuff */
143 enum clnt_stat (*cl_call)(CLIENT *, uint32_t, xdrproc_t, void *, xdrproc_t, void *, struct timeval);
144 void (*cl_abort)(CLIENT *);
145 void (*cl_geterr)(CLIENT *, struct rpc_err *);
146 bool_t (*cl_freeres)(CLIENT *, xdrproc_t, void *);
147 void (*cl_destroy)(CLIENT *);
148 bool_t (*cl_control)(CLIENT *, uint_t, void *);
149 bool_t (*cl_getreply)(CLIENT *, xdrproc_t, void *, int,
150 uint32_t *, uint32_t *, struct timeval *);
151 int (*cl_poll)(CLIENT *, uint32_t);
155 * client side rpc interface ops
157 * Parameter types are:
163 * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
170 * struct timeval timeout;
172 #define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \
173 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
174 #define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \
175 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
182 #define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh))
183 #define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh))
190 #define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
191 #define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
196 * CLNT_FREERES(rh, xres, resp);
201 #define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
202 #define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
206 * CLNT_CONTROL(cl, request, info)
211 #define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
212 #define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
215 * control operations that apply to both udp and tcp transports
217 #define CLSET_TIMEOUT 1 /* set timeout (timeval) */
218 #define CLGET_TIMEOUT 2 /* get timeout (timeval) */
219 #define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */
221 * udp only control operations
223 #define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */
224 #define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */
231 #define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
232 #define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
236 * CLNT_GETREPLY(rh,xres,xresp,xid,tv)
243 * struct timeval *tv;
245 #define CLNT_GETREPLY(rh,xres,xresp,cnt,xids,xid,tv) ((*(rh)->cl_ops->cl_getreply)(rh,xres,xresp,cnt,xids,xid,tv))
246 #define clnt_getreply(rh,xres,xresp,cnt,xids,xid,tv) ((*(rh)->cl_ops->cl_getreply)(rh,xres,xresp,cnt,xids,xid,tv))
250 * CLNT_POLL(rh,xusec)
254 #define CLNT_POLL(rh,xid) ((*(rh)->cl_ops->cl_poll)(rh,xid))
255 #define clnt_poll(rh,xid) ((*(rh)->cl_ops->cl_poll)(rh,xid))
258 * RPCTEST is a test program which is accessable on every rpc
259 * transport/port. It is used for testing, performance evaluation,
260 * and network administration.
263 #define RPCTEST_PROGRAM ((uint32_t)1)
264 #define RPCTEST_VERSION ((uint32_t)1)
265 #define RPCTEST_NULL_PROC ((uint32_t)2)
266 #define RPCTEST_NULL_BATCH_PROC ((uint32_t)3)
269 * By convention, procedure 0 takes null arguments and returns them
272 #define NULLPROC ((uint32_t)0)
275 * Below are the client handle creation routines for the various
276 * implementations of client side rpc. They can return NULL if a
277 * creation failure occurs.
281 * Memory based rpc (for speed check and testing)
283 * clntraw_create(prog, vers)
287 extern CLIENT *clntraw_create(uint32_t, uint32_t);
290 * Generic client creation routine. Supported protocols are "udp" and "tcp"
292 extern CLIENT *clnt_create(char *, uint32_t, uint32_t, char *);
298 * sfs_ctcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
299 * struct sockaddr_in *raddr;
302 * register int *sockp;
306 extern CLIENT *sfs_ctcp_create(struct sockaddr_in *, uint32_t, uint32_t,
307 int *, uint_t, uint_t);
308 extern CLIENT *clnttcp_create(struct sockaddr_in *, uint32_t, uint32_t,
309 int *, uint_t, uint_t);
314 * sfs_cudp_create(raddr, program, version, wait, sockp)
315 * struct sockaddr_in *raddr;
318 * struct timeval wait;
321 * Same as above, but you specify max packet sizes.
323 * sfs_cudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
324 * struct sockaddr_in *raddr;
327 * struct timeval wait;
332 extern CLIENT *clntudp_create(struct sockaddr_in *, uint32_t, uint32_t,
333 struct timeval, int *);
334 extern CLIENT *clntudp_bufcreate(struct sockaddr_in *, uint32_t, uint32_t,
335 struct timeval, int *, uint_t, uint_t);
336 extern CLIENT *sfs_cudp_create(struct sockaddr_in *, uint32_t, uint32_t,
337 struct timeval, int *);
338 extern CLIENT *sfs_cudp_bufcreate(struct sockaddr_in *, uint32_t, uint32_t,
339 struct timeval, int *, uint_t, uint_t);
342 * Print why creation failed
344 extern void clnt_pcreateerror(char *);
345 extern char *clnt_spcreateerror(char *);
348 * Like clnt_perror(), but is more verbose in its output
350 extern void clnt_perrno(enum clnt_stat);
353 * Print an English error message, given the client error code
355 extern void clnt_perror(CLIENT *, char *);
356 extern char *clnt_sperror(CLIENT *, char *);
359 * If a creation fails, the following allows the user to figure out why.
361 struct rpc_createerr {
362 enum clnt_stat cf_stat;
363 struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */
366 extern struct rpc_createerr rpc_createerr;
369 * Copy error message to buffer.
371 extern char *clnt_sperrno(enum clnt_stat);
373 extern int callrpc(char *, int, int, int, xdrproc_t, char *, xdrproc_t, char *);
375 extern int bindresvport(int sd, struct sockaddr_in *sin);
377 #define UDPMSGSIZE (63 * 1024) /* rpc imposed limit on udp msg size */
378 #define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */
380 #if !defined(RPC_ANYSOCK)
381 #define RPC_ANYSOCK -1