2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3 * unrestricted use provided that this legend is included on all tape
4 * media and as a part of the software program in whole or part. Users
5 * may copy or modify Sun RPC without charge, but are not authorized
6 * to license or distribute it to anyone else except as part of a product or
7 * program developed by the user.
9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10 * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
13 * Sun RPC is provided with no support and without any obligation on the
14 * part of Sun Microsystems, Inc. to assist in its use, correction,
15 * modification or enhancement.
17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19 * OR ANY PART THEREOF.
21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22 * or profits or other special, indirect and consequential damages, even if
23 * Sun has been advised of the possibility of such damages.
25 * Sun Microsystems, Inc.
27 * Mountain View, California 94043
29 * from: @(#)clnt.h 1.31 88/02/08 SMI
30 * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC
31 * $FreeBSD: src/include/rpc/clnt.h,v 1.11.2.1 2001/06/28 21:44:09 iedowse Exp $
35 * clnt.h - Client side remote procedure call interface.
37 * Copyright (C) 1984, Sun Microsystems, Inc.
42 #include <sys/cdefs.h>
46 * Rpc calls return an enum clnt_stat. This should be looked at more,
47 * since each implementation is required to live with this (implementation
48 * independent) list of errors.
51 RPC_SUCCESS=0, /* call succeeded */
55 RPC_CANTENCODEARGS=1, /* can't encode arguments */
56 RPC_CANTDECODERES=2, /* can't decode results */
57 RPC_CANTSEND=3, /* failure in sending call */
58 RPC_CANTRECV=4, /* failure in receiving result */
59 RPC_TIMEDOUT=5, /* call timed out */
63 RPC_VERSMISMATCH=6, /* rpc versions not compatible */
64 RPC_AUTHERROR=7, /* authentication error */
65 RPC_PROGUNAVAIL=8, /* program not available */
66 RPC_PROGVERSMISMATCH=9, /* program version mismatched */
67 RPC_PROCUNAVAIL=10, /* procedure unavailable */
68 RPC_CANTDECODEARGS=11, /* decode arguments error */
69 RPC_SYSTEMERROR=12, /* generic "other problem" */
72 * callrpc & clnt_create errors
74 RPC_UNKNOWNHOST=13, /* unknown host name */
75 RPC_UNKNOWNPROTO=17, /* unkown protocol */
80 RPC_PMAPFAILURE=14, /* the pmapper failed in its call */
81 RPC_PROGNOTREGISTERED=15, /* remote program is not registered */
93 enum clnt_stat re_status;
95 int RE_errno; /* related system error */
96 enum auth_stat RE_why; /* why the auth error occurred */
98 u_int32_t low; /* lowest verion supported */
99 u_int32_t high; /* highest verion supported */
101 struct { /* maybe meaningful if RPC_FAILED */
104 } RE_lb; /* life boot & debugging only */
106 #define re_errno ru.RE_errno
107 #define re_why ru.RE_why
108 #define re_vers ru.RE_vers
109 #define re_lb ru.RE_lb
115 * Created by individual implementations, see e.g. rpc_udp.c.
116 * Client is responsible for initializing auth, see e.g. auth_none.c.
118 typedef struct __rpc_client {
119 AUTH *cl_auth; /* authenticator */
121 /* call remote procedure */
122 enum clnt_stat (*cl_call) __P((struct __rpc_client *,
123 u_long, xdrproc_t, caddr_t, xdrproc_t,
124 caddr_t, struct timeval));
126 void (*cl_abort) __P((struct __rpc_client *));
127 /* get specific error code */
128 void (*cl_geterr) __P((struct __rpc_client *,
131 bool_t (*cl_freeres) __P((struct __rpc_client *,
132 xdrproc_t, caddr_t));
133 /* destroy this structure */
134 void (*cl_destroy) __P((struct __rpc_client *));
135 /* the ioctl() of rpc */
136 bool_t (*cl_control) __P((struct __rpc_client *, u_int,
139 caddr_t cl_private; /* private stuff */
144 * client side rpc interface ops
146 * Parameter types are:
152 * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
159 * struct timeval timeout;
161 #define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \
162 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, (caddr_t)argsp, \
163 xres, (caddr_t)resp, secs))
164 #define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \
165 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, (caddr_t)argsp, \
166 xres, (caddr_t)resp, secs))
173 #define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh))
174 #define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh))
181 #define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
182 #define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
187 * CLNT_FREERES(rh, xres, resp);
192 #define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
193 #define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
197 * CLNT_CONTROL(cl, request, info)
202 #define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
203 #define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
206 * control operations that apply to udp, tcp and unix transports
208 * Note: options marked XXX are no-ops in this implementation of RPC.
209 * The are present in TI-RPC but can't be implemented here since they
210 * depend on the presence of STREAMS/TLI, which we don't have.
213 #define CLSET_TIMEOUT 1 /* set timeout (timeval) */
214 #define CLGET_TIMEOUT 2 /* get timeout (timeval) */
215 #define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */
216 #define CLGET_FD 6 /* get connections file descriptor */
217 #define CLGET_SVC_ADDR 7 /* get server's address (netbuf) XXX */
218 #define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */
219 #define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */
220 #define CLGET_XID 10 /* Get xid */
221 #define CLSET_XID 11 /* Set xid */
222 #define CLGET_VERS 12 /* Get version number */
223 #define CLSET_VERS 13 /* Set version number */
224 #define CLGET_PROG 14 /* Get program number */
225 #define CLSET_PROG 15 /* Set program number */
226 #define CLSET_SVC_ADDR 16 /* get server's address (netbuf) XXX */
227 #define CLSET_PUSH_TIMOD 17 /* push timod if not already present XXX */
228 #define CLSET_POP_TIMOD 18 /* pop timod XXX */
231 * udp only control operations
233 #define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */
234 #define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */
235 #define CLSET_CONNECT 20 /* Use connect() for UDP. (int) */
238 * Operations which GSSAPI needs. (Bletch.)
240 #define CLGET_LOCAL_ADDR 19 /* get local addr (sockaddr) */
248 #define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
249 #define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
253 * RPCTEST is a test program which is accessible on every rpc
254 * transport/port. It is used for testing, performance evaluation,
255 * and network administration.
258 #define RPCTEST_PROGRAM ((u_long)1)
259 #define RPCTEST_VERSION ((u_long)1)
260 #define RPCTEST_NULL_PROC ((u_long)2)
261 #define RPCTEST_NULL_BATCH_PROC ((u_long)3)
264 * By convention, procedure 0 takes null arguments and returns them
267 #define NULLPROC ((u_long)0)
270 * Below are the client handle creation routines for the various
271 * implementations of client side rpc. They can return NULL if a
272 * creation failure occurs.
276 * Memory based rpc (for speed check and testing)
278 * clntraw_create(prog, vers)
283 extern CLIENT *clntraw_create __P((u_long, u_long));
288 * Generic client creation routine. Supported protocols are "udp", "tcp"
291 * clnt_create(host, prog, vers, prot);
292 * char *host; -- hostname
293 * u_long prog; -- program number
294 * u_long vers; -- version number
295 * char *prot; -- protocol
298 extern CLIENT *clnt_create __P((char *, u_long, u_long, char *));
305 * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
306 * struct sockaddr_in *raddr;
309 * register int *sockp;
314 extern CLIENT *clnttcp_create __P((struct sockaddr_in *,
326 * clntudp_create(raddr, program, version, wait, sockp)
327 * struct sockaddr_in *raddr;
330 * struct timeval wait;
333 * Same as above, but you specify max packet sizes.
335 * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
336 * struct sockaddr_in *raddr;
339 * struct timeval wait;
345 extern CLIENT *clntudp_create __P((struct sockaddr_in *,
350 extern CLIENT *clntudp_bufcreate __P((struct sockaddr_in *,
363 * clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz)
364 * struct sockaddr_un *raddr;
367 * register int *sockp;
372 extern CLIENT *clntunix_create __P((struct sockaddr_un *,
382 * Print why creation failed
385 extern void clnt_pcreateerror __P((char *)); /* stderr */
386 extern char *clnt_spcreateerror __P((char *)); /* string */
390 * Like clnt_perror(), but is more verbose in its output
393 extern void clnt_perrno __P((enum clnt_stat)); /* stderr */
394 extern char *clnt_sperrno __P((enum clnt_stat)); /* string */
398 * Print an English error message, given the client error code
401 extern void clnt_perror __P((CLIENT *, char *)); /* stderr */
402 extern char *clnt_sperror __P((CLIENT *, char *)); /* string */
407 * If a creation fails, the following allows the user to figure out why.
409 struct rpc_createerr {
410 enum clnt_stat cf_stat;
411 struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */
414 extern struct rpc_createerr rpc_createerr;
417 #define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */
418 #define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */
420 #endif /* !_RPC_CLNT_H */