1 /*********************************************************************
2 * RPC for the Windows NT Operating System
3 * 1993 by Martin F. Gergeleit
4 * Users may use, copy or modify Sun RPC for the Windows NT Operating
5 * System according to the Sun copyright below.
7 * RPC for the Windows NT Operating System COMES WITH ABSOLUTELY NO
8 * WARRANTY, NOR WILL I BE LIABLE FOR ANY DAMAGES INCURRED FROM THE
9 * USE OF. USE ENTIRELY AT YOUR OWN RISK!!!
10 *********************************************************************/
12 /* @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/
14 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
15 * unrestricted use provided that this legend is included on all tape
16 * media and as a part of the software program in whole or part. Users
17 * may copy or modify Sun RPC without charge, but are not authorized
18 * to license or distribute it to anyone else except as part of a product or
19 * program developed by the user.
21 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
22 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
25 * Sun RPC is provided with no support and without any obligation on the
26 * part of Sun Microsystems, Inc. to assist in its use, correction,
27 * modification or enhancement.
29 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
30 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
31 * OR ANY PART THEREOF.
33 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
34 * or profits or other special, indirect and consequential damages, even if
35 * Sun has been advised of the possibility of such damages.
37 * Sun Microsystems, Inc.
39 * Mountain View, California 94043
43 * clnt.h - Client side remote procedure call interface.
45 * Copyright (C) 1984, Sun Microsystems, Inc.
59 * Rpc calls return an enum clnt_stat. This should be looked at more,
60 * since each implementation is required to live with this (implementation
61 * independent) list of errors.
64 RPC_SUCCESS=0, /* call succeeded */
68 RPC_CANTENCODEARGS=1, /* can't encode arguments */
69 RPC_CANTDECODERES=2, /* can't decode results */
70 RPC_CANTSEND=3, /* failure in sending call */
71 RPC_CANTRECV=4, /* failure in receiving result */
72 RPC_TIMEDOUT=5, /* call timed out */
76 RPC_VERSMISMATCH=6, /* rpc versions not compatible */
77 RPC_AUTHERROR=7, /* authentication error */
78 RPC_PROGUNAVAIL=8, /* program not available */
79 RPC_PROGVERSMISMATCH=9, /* program version mismatched */
80 RPC_PROCUNAVAIL=10, /* procedure unavailable */
81 RPC_CANTDECODEARGS=11, /* decode arguments error */
82 RPC_SYSTEMERROR=12, /* generic "other problem" */
85 * callrpc & clnt_create errors
87 RPC_UNKNOWNHOST=13, /* unknown host name */
88 RPC_UNKNOWNPROTO=17, /* unkown protocol */
93 RPC_PMAPFAILURE=14, /* the pmapper failed in its call */
94 RPC_PROGNOTREGISTERED=15, /* remote program is not registered */
106 enum clnt_stat re_status;
108 int RE_errno; /* realated system error */
109 enum auth_stat RE_why; /* why the auth error occurred */
111 u_long low; /* lowest verion supported */
112 u_long high; /* highest verion supported */
114 struct { /* maybe meaningful if RPC_FAILED */
117 } RE_lb; /* life boot & debugging only */
119 #define re_errno ru.RE_errno
120 #define re_why ru.RE_why
121 #define re_vers ru.RE_vers
122 #define re_lb ru.RE_lb
128 * Created by individual implementations, see e.g. rpc_udp.c.
129 * Client is responsible for initializing auth, see e.g. auth_none.c.
132 AUTH *cl_auth; /* authenticator */
134 enum clnt_stat (*cl_call)(DOTS); /* call remote procedure */
135 void (*cl_abort)(DOTS); /* abort a call */
136 void (*cl_geterr)(DOTS); /* get specific error code */
137 bool_t (*cl_freeres)(DOTS); /* frees results */
138 void (*cl_destroy)(DOTS);/* destroy this structure */
139 bool_t (*cl_control)(DOTS);/* the ioctl() of rpc */
141 caddr_t cl_private; /* private stuff */
146 * client side rpc interface ops
148 * Parameter types are:
154 * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
161 * struct timeval timeout;
163 #define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \
164 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
165 #define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \
166 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, 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 both udp and tcp transports
208 #define CLSET_TIMEOUT 1 /* set timeout (timeval) */
209 #define CLGET_TIMEOUT 2 /* get timeout (timeval) */
210 #define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */
212 * udp only control operations
214 #define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */
215 #define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */
222 #define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
223 #define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
227 * RPCTEST is a test program which is accessable on every rpc
228 * transport/port. It is used for testing, performance evaluation,
229 * and network administration.
232 #define RPCTEST_PROGRAM ((u_long)1)
233 #define RPCTEST_VERSION ((u_long)1)
234 #define RPCTEST_NULL_PROC ((u_long)2)
235 #define RPCTEST_NULL_BATCH_PROC ((u_long)3)
238 * By convention, procedure 0 takes null arguments and returns them
241 #define NULLPROC ((u_long)0)
244 * Below are the client handle creation routines for the various
245 * implementations of client side rpc. They can return NULL if a
246 * creation failure occurs.
250 * Memory based rpc (for speed check and testing)
252 * clntraw_create(prog, vers)
256 extern CLIENT *clntraw_create(DOTS);
260 * Generic client creation routine. Supported protocols are "udp" and "tcp"
263 clnt_create(/*host, prog, vers, prot*/DOTS); /*
264 char *host; -- hostname
265 u_long prog; -- program number
266 u_long vers; -- version number
267 char *prot; -- protocol
276 * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
277 * struct sockaddr_in *raddr;
280 * register int *sockp;
284 extern CLIENT *clnttcp_create(DOTS);
289 * clntudp_create(raddr, program, version, wait, sockp)
290 * struct sockaddr_in *raddr;
293 * struct timeval wait;
296 * Same as above, but you specify max packet sizes.
298 * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
299 * struct sockaddr_in *raddr;
302 * struct timeval wait;
307 extern CLIENT *clntudp_create(DOTS);
308 extern CLIENT *clntudp_bufcreate(DOTS);
311 * Print why creation failed
313 void clnt_pcreateerror(/* char *msg */DOTS); /* stderr */
314 char *clnt_spcreateerror(/* char *msg */DOTS); /* string */
317 * Like clnt_perror(), but is more verbose in its output
319 void clnt_perrno(/* enum clnt_stat num */DOTS); /* stderr */
322 * Print an English error message, given the client error code
324 void clnt_perror(/* CLIENT *clnt, char *msg */DOTS); /* stderr */
325 char *clnt_sperror(/* CLIENT *clnt, char *msg */DOTS); /* string */
328 * If a creation fails, the following allows the user to figure out why.
330 struct rpc_createerr_t {
331 enum clnt_stat cf_stat;
332 struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */
338 extern struct rpc_createerr rpc_createerr;
341 extern __declspec(dllimport) struct rpc_createerr rpc_createerr;
343 _declspec(dllimport) struct rpc_createerr rpc_createerr;
347 extern struct rpc_createerr rpc_createerr;
350 #define rpc_createerr (*_thr_rpc_createerr())
353 * Copy error message to buffer.
355 char *clnt_sperrno(/* enum clnt_stat num */DOTS); /* string */
359 #define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */
360 #define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */