2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
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
52 * from: @(#)clnt.h 1.31 88/02/08 SMI
53 * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC
54 * $Id: clnt.h,v 1.2 1999/10/14 21:56:52 wsanchez Exp $
58 * clnt.h - Client side remote procedure call interface.
60 * Copyright (C) 1984, Sun Microsystems, Inc.
65 #include <sys/cdefs.h>
68 * Rpc calls return an enum clnt_stat. This should be looked at more,
69 * since each implementation is required to live with this (implementation
70 * independent) list of errors.
73 /* Avoid collision with mach definition */
74 #if defined(RPC_SUCCESS)
79 RPC_SUCCESS
=0, /* call succeeded */
83 RPC_CANTENCODEARGS
=1, /* can't encode arguments */
84 RPC_CANTDECODERES
=2, /* can't decode results */
85 RPC_CANTSEND
=3, /* failure in sending call */
86 RPC_CANTRECV
=4, /* failure in receiving result */
87 RPC_TIMEDOUT
=5, /* call timed out */
91 RPC_VERSMISMATCH
=6, /* rpc versions not compatible */
92 RPC_AUTHERROR
=7, /* authentication error */
93 RPC_PROGUNAVAIL
=8, /* program not available */
94 RPC_PROGVERSMISMATCH
=9, /* program version mismatched */
95 RPC_PROCUNAVAIL
=10, /* procedure unavailable */
96 RPC_CANTDECODEARGS
=11, /* decode arguments error */
97 RPC_SYSTEMERROR
=12, /* generic "other problem" */
100 * callrpc & clnt_create errors
102 RPC_UNKNOWNHOST
=13, /* unknown host name */
103 RPC_UNKNOWNPROTO
=17, /* unkown protocol */
108 RPC_PMAPFAILURE
=14, /* the pmapper failed in its call */
109 RPC_PROGNOTREGISTERED
=15, /* remote program is not registered */
121 enum clnt_stat re_status
;
123 int RE_errno
; /* realated system error */
124 enum auth_stat RE_why
; /* why the auth error occurred */
126 u_long low
; /* lowest verion supported */
127 u_long high
; /* highest verion supported */
129 struct { /* maybe meaningful if RPC_FAILED */
132 } RE_lb
; /* life boot & debugging only */
134 #define re_errno ru.RE_errno
135 #define re_why ru.RE_why
136 #define re_vers ru.RE_vers
137 #define re_lb ru.RE_lb
143 * Created by individual implementations, see e.g. rpc_udp.c.
144 * Client is responsible for initializing auth, see e.g. auth_none.c.
147 AUTH
*cl_auth
; /* authenticator */
149 enum clnt_stat (*cl_call
)(); /* call remote procedure */
150 void (*cl_abort
)(); /* abort a call */
151 void (*cl_geterr
)(); /* get specific error code */
152 bool_t (*cl_freeres
)(); /* frees results */
153 void (*cl_destroy
)();/* destroy this structure */
154 bool_t (*cl_control
)();/* the ioctl() of rpc */
156 caddr_t cl_private
; /* private stuff */
161 * client side rpc interface ops
163 * Parameter types are:
169 * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
176 * struct timeval timeout;
178 #define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \
179 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
180 #define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \
181 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
188 #define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh))
189 #define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh))
196 #define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
197 #define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
202 * CLNT_FREERES(rh, xres, resp);
207 #define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
208 #define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
212 * CLNT_CONTROL(cl, request, info)
217 #define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
218 #define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
221 * control operations that apply to both udp and tcp transports
223 #define CLSET_TIMEOUT 1 /* set timeout (timeval) */
224 #define CLGET_TIMEOUT 2 /* get timeout (timeval) */
225 #define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */
227 * udp only control operations
229 #define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */
230 #define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */
237 #define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
238 #define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
242 * RPCTEST is a test program which is accessable on every rpc
243 * transport/port. It is used for testing, performance evaluation,
244 * and network administration.
247 #define RPCTEST_PROGRAM ((u_long)1)
248 #define RPCTEST_VERSION ((u_long)1)
249 #define RPCTEST_NULL_PROC ((u_long)2)
250 #define RPCTEST_NULL_BATCH_PROC ((u_long)3)
253 * By convention, procedure 0 takes null arguments and returns them
256 #define NULLPROC ((u_long)0)
259 * Below are the client handle creation routines for the various
260 * implementations of client side rpc. They can return NULL if a
261 * creation failure occurs.
265 * Memory based rpc (for speed check and testing)
267 * clntraw_create(prog, vers)
272 extern CLIENT
*clntraw_create
__P((u_long
, u_long
));
277 * Generic client creation routine. Supported protocols are "udp" and "tcp"
279 * clnt_create(host, prog, vers, prot);
280 * char *host; -- hostname
281 * u_long prog; -- program number
282 * u_long vers; -- version number
283 * char *prot; -- protocol
286 extern CLIENT
*clnt_create
__P((char *, u_long
, u_long
, char *));
293 * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
294 * struct sockaddr_in *raddr;
297 * register int *sockp;
302 extern CLIENT
*clnttcp_create
__P((struct sockaddr_in
*,
314 * clntudp_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 * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
324 * struct sockaddr_in *raddr;
327 * struct timeval wait;
333 extern CLIENT
*clntudp_create
__P((struct sockaddr_in
*,
338 extern CLIENT
*clntudp_bufcreate
__P((struct sockaddr_in
*,
349 * Print why creation failed
352 extern void clnt_pcreateerror
__P((char *)); /* stderr */
353 extern char *clnt_spcreateerror
__P((char *)); /* string */
357 * Like clnt_perror(), but is more verbose in its output
360 extern void clnt_perrno
__P((enum clnt_stat
)); /* stderr */
361 extern char *clnt_sperrno
__P((enum clnt_stat
)); /* string */
365 * Print an English error message, given the client error code
368 extern void clnt_perror
__P((CLIENT
*, char *)); /* stderr */
369 extern char *clnt_sperror
__P((CLIENT
*, char *)); /* string */
374 * If a creation fails, the following allows the user to figure out why.
376 struct rpc_createerr
{
377 enum clnt_stat cf_stat
;
378 struct rpc_err cf_error
; /* useful when cf_stat == RPC_PMAPFAILURE */
381 extern struct rpc_createerr rpc_createerr
;
384 #define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */
385 #define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */
387 #endif /* !_RPC_CLNT_H */