4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 #pragma ident "%Z%%M% %I% %E% SMI"
25 * clnt.h - Client side remote procedure call interface.
27 * Copyright (C) 1984, Sun Microsystems, Inc.
34 * Rpc calls return an enum clnt_stat. This should be looked at more,
35 * since each implementation is required to live with this (implementation
36 * independent) list of errors.
39 RPC_SUCCESS
=0, /* call succeeded */
43 RPC_CANTENCODEARGS
=1, /* can't encode arguments */
44 RPC_CANTDECODERES
=2, /* can't decode results */
45 RPC_CANTSEND
=3, /* failure in sending call */
46 RPC_CANTRECV
=4, /* failure in receiving result */
47 RPC_TIMEDOUT
=5, /* call timed out */
48 RPC_INTR
=18, /* call interrupted */
52 RPC_VERSMISMATCH
=6, /* rpc versions not compatible */
53 RPC_AUTHERROR
=7, /* authentication error */
54 RPC_PROGUNAVAIL
=8, /* program not available */
55 RPC_PROGVERSMISMATCH
=9, /* program version mismatched */
56 RPC_PROCUNAVAIL
=10, /* procedure unavailable */
57 RPC_CANTDECODEARGS
=11, /* decode arguments error */
58 RPC_SYSTEMERROR
=12, /* generic "other problem" */
61 * callrpc & clnt_create errors
63 RPC_UNKNOWNHOST
=13, /* unknown host name */
64 RPC_UNKNOWNPROTO
=17, /* unkown protocol */
69 RPC_PMAPFAILURE
=14, /* the pmapper failed in its call */
70 RPC_PROGNOTREGISTERED
=15, /* remote program is not registered */
82 enum clnt_stat re_status
;
84 int RE_errno
; /* realated system error */
85 enum auth_stat RE_why
; /* why the auth error occurred */
87 u_long low
; /* lowest verion supported */
88 u_long high
; /* highest verion supported */
90 struct { /* maybe meaningful if RPC_FAILED */
93 } RE_lb
; /* life boot & debugging only */
95 #define re_errno ru.RE_errno
96 #define re_why ru.RE_why
97 #define re_vers ru.RE_vers
98 #define re_lb ru.RE_lb
104 * Created by individual implementations, see e.g. rpc_udp.c.
105 * Client is responsible for initializing auth, see e.g. auth_none.c.
108 AUTH
*cl_auth
; /* authenticator */
110 enum clnt_stat (*cl_call
)(); /* call remote procedure */
111 void (*cl_abort
)(); /* abort a call */
112 void (*cl_geterr
)(); /* get specific error code */
113 bool_t (*cl_freeres
)(); /* frees results */
114 void (*cl_destroy
)(); /* destroy this structure */
115 bool_t (*cl_control
)(); /* the ioctl() of rpc */
117 caddr_t cl_private
; /* private stuff */
122 * client side rpc interface ops
124 * Parameter types are:
130 * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
137 * struct timeval timeout;
139 #define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \
140 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
141 #define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \
142 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
149 #define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh))
150 #define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh))
157 #define CLNT_GETERR(rh, errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
158 #define clnt_geterr(rh, errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
163 * CLNT_FREERES(rh, xres, resp);
168 #define CLNT_FREERES(rh, xres, resp) ((*(rh)->cl_ops->cl_freeres)\
170 #define clnt_freeres(rh, xres, resp) ((*(rh)->cl_ops->cl_freeres)\
175 * CLNT_CONTROL(cl, request, info)
180 #define CLNT_CONTROL(cl, rq, in) ((*(cl)->cl_ops->cl_control)(cl, rq, in))
181 #define clnt_control(cl, rq, in) ((*(cl)->cl_ops->cl_control)(cl, rq, in))
184 * control operations that apply to both udp and tcp transports
186 #define CLSET_TIMEOUT 1 /* set timeout (timeval) */
187 #define CLGET_TIMEOUT 2 /* get timeout (timeval) */
188 #define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */
189 #define CLGET_FD 6 /* get connections file descriptor */
190 #define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */
191 #define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */
193 * udp only control operations
195 #define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */
196 #define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */
203 #define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
204 #define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
208 * RPCTEST is a test program which is accessable on every rpc
209 * transport/port. It is used for testing, performance evaluation,
210 * and network administration.
213 #define RPCTEST_PROGRAM ((u_long)1)
214 #define RPCTEST_VERSION ((u_long)1)
215 #define RPCTEST_NULL_PROC ((u_long)2)
216 #define RPCTEST_NULL_BATCH_PROC ((u_long)3)
219 * By convention, procedure 0 takes null arguments and returns them
222 #define NULLPROC ((u_long)0)
225 * Below are the client handle creation routines for the various
226 * implementations of client side rpc. They can return NULL if a
227 * creation failure occurs.
232 * Memory based rpc (for speed check and testing)
234 * clntraw_create(prog, vers)
238 extern CLIENT
*clntraw_create();
242 * Generic client creation routine. Supported protocols are "udp" and "tcp"
245 clnt_create(/*host, prog, vers, prot*/); /*
246 char *host; -- hostname
247 u_long prog; -- program number
248 u_long vers; -- version number
249 char *prot; -- protocol
253 * Generic client creation routine. Supported protocols are "udp" and "tcp"
256 clnt_create_vers(/*host, prog, vers_out, vers_low, vers_high, prot*/);
258 char *host; -- hostname
259 u_long prog; -- program number
260 u_long *vers_out; -- servers best version number
261 u_long vers_low; -- low version number
262 u_long vers_high; -- high version number
263 char *prot; -- protocol
271 * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
272 * struct sockaddr_in *raddr;
275 * register int *sockp;
279 extern CLIENT
*clnttcp_create();
284 * clntudp_create(raddr, program, version, wait, sockp)
285 * struct sockaddr_in *raddr;
288 * struct timeval wait;
291 * Same as above, but you specify max packet sizes.
293 * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
294 * struct sockaddr_in *raddr;
297 * struct timeval wait;
302 extern CLIENT
*clntudp_create();
303 extern CLIENT
*clntudp_bufcreate();
306 * Print why creation failed
308 void clnt_pcreateerror(/* char *msg */); /* stderr */
309 char *clnt_spcreateerror(/* char *msg */); /* string */
312 * Like clnt_perror(), but is more verbose in its output
314 void clnt_perrno(/* enum clnt_stat num */); /* stderr */
317 * Print an English error message, given the client error code
319 void clnt_perror(/* CLIENT *clnt, char *msg */); /* stderr */
320 char *clnt_sperror(/* CLIENT *clnt, char *msg */); /* string */
323 * If a creation fails, the following allows the user to figure out why.
325 struct rpc_createerr
{
326 enum clnt_stat cf_stat
;
327 struct rpc_err cf_error
; /* useful when cf_stat == RPC_PMAPFAILURE */
330 extern struct rpc_createerr rpc_createerr
;
336 * Copy error message to buffer.
338 char *clnt_sperrno(/* enum clnt_stat num */); /* string */
343 * Kernel udp based rpc
345 * clntkudp_create(addr, pgm, vers)
346 * struct sockaddr_in *addr;
350 extern CLIENT
*clntkudp_create();
354 * Timers used for the pseudo-transport protocol when using datagrams
357 u_short rt_srtt
; /* smoothed round-trip time */
358 u_short rt_deviate
; /* estimated deviation */
359 u_long rt_rtxcur
; /* current (backed-off) rto */
363 * Feedback values used for possible congestion and rate control
365 #define FEEDBACK_REXMIT1 1 /* first retransmit */
366 #define FEEDBACK_OK 2 /* no retransmits */
368 #define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */
369 #define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */
373 * Alloc_xid presents an interface which kernel RPC clients
374 * should use to allocate their XIDs. Its implementation
375 * may change over time (for example, to allow sharing of
376 * XIDs between the kernel and user-level applications, so
377 * all XID allocation should be done by calling alloc_xid().
379 extern u_long clntxid
;
380 #define alloc_xid() (clntxid++)
383 #endif /*!_rpc_clnt_h*/