xref: /freebsd/sys/rpc/clnt.h (revision 397e83df75e0fcd0d3fcb95ae4d794cb7600fc89)
1 /*	$NetBSD: clnt.h,v 1.14 2000/06/02 22:57:55 fvdl Exp $	*/
2 
3 /*-
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  * Copyright (c) 2010, Oracle America, Inc.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  * - Redistributions of source code must retain the above copyright notice,
12  *   this list of conditions and the following disclaimer.
13  * - Redistributions in binary form must reproduce the above copyright notice,
14  *   this list of conditions and the following disclaimer in the documentation
15  *   and/or other materials provided with the distribution.
16  * - Neither the name of the "Oracle America, Inc." nor the names of its
17  *   contributors may be used to endorse or promote products derived
18  *   from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /*
34  * clnt.h - Client side remote procedure call interface.
35  *
36  * Copyright (c) 1986-1991,1994-1999 by Sun Microsystems, Inc.
37  * All rights reserved.
38  */
39 
40 #ifndef _RPC_CLNT_H_
41 #define _RPC_CLNT_H_
42 #include <rpc/clnt_stat.h>
43 #include <sys/cdefs.h>
44 #ifdef _KERNEL
45 #include <sys/refcount.h>
46 #include <rpc/netconfig.h>
47 #else
48 #include <netconfig.h>
49 #endif
50 #include <sys/un.h>
51 
52 /*
53  * Well-known IPV6 RPC broadcast address.
54  */
55 #define RPCB_MULTICAST_ADDR "ff02::202"
56 
57 /*
58  * the following errors are in general unrecoverable.  The caller
59  * should give up rather than retry.
60  */
61 #define IS_UNRECOVERABLE_RPC(s) (((s) == RPC_AUTHERROR) || \
62 	((s) == RPC_CANTENCODEARGS) || \
63 	((s) == RPC_CANTDECODERES) || \
64 	((s) == RPC_VERSMISMATCH) || \
65 	((s) == RPC_PROCUNAVAIL) || \
66 	((s) == RPC_PROGUNAVAIL) || \
67 	((s) == RPC_PROGVERSMISMATCH) || \
68 	((s) == RPC_CANTDECODEARGS))
69 
70 /*
71  * Error info.
72  */
73 struct rpc_err {
74 	enum clnt_stat re_status;
75 	union {
76 		int RE_errno;		/* related system error */
77 		enum auth_stat RE_why;	/* why the auth error occurred */
78 		struct {
79 			rpcvers_t low;	/* lowest version supported */
80 			rpcvers_t high;	/* highest version supported */
81 		} RE_vers;
82 		struct {		/* maybe meaningful if RPC_FAILED */
83 			int32_t s1;
84 			int32_t s2;
85 		} RE_lb;		/* life boot & debugging only */
86 	} ru;
87 #define	re_errno	ru.RE_errno
88 #define	re_why		ru.RE_why
89 #define	re_vers		ru.RE_vers
90 #define	re_lb		ru.RE_lb
91 };
92 
93 #ifdef _KERNEL
94 /*
95  * Functions of this type may be used to receive notification when RPC
96  * calls have to be re-transmitted etc.
97  */
98 typedef void rpc_feedback(int cmd, int procnum, void *);
99 
100 /*
101  * Timers used for the pseudo-transport protocol when using datagrams
102  */
103 struct rpc_timers {
104 	u_short		rt_srtt;	/* smoothed round-trip time */
105 	u_short		rt_deviate;	/* estimated deviation */
106 	u_long		rt_rtxcur;	/* current (backed-off) rto */
107 };
108 
109 /*
110  * A structure used with CLNT_CALL_EXT to pass extra information used
111  * while processing an RPC call.
112  */
113 struct rpc_callextra {
114 	AUTH		*rc_auth;	/* auth handle to use for this call */
115 	rpc_feedback	*rc_feedback;	/* callback for retransmits etc. */
116 	void		*rc_feedback_arg; /* argument for callback */
117 	struct rpc_timers *rc_timers;	  /* optional RTT timers */
118 	struct rpc_err	rc_err;		/* detailed call status */
119 };
120 #endif
121 
122 /*
123  * Client rpc handle.
124  * Created by individual implementations
125  * Client is responsible for initializing auth, see e.g. auth_none.c.
126  */
127 typedef struct __rpc_client {
128 #ifdef _KERNEL
129 	volatile u_int cl_refs;			/* reference count */
130 	AUTH	*cl_auth;			/* authenticator */
131 	const struct clnt_ops {
132 		/* call remote procedure */
133 		enum clnt_stat	(*cl_call)(struct __rpc_client *,
134 		    struct rpc_callextra *, rpcproc_t,
135 		    struct mbuf *, struct mbuf **, struct timeval);
136 		/* abort a call */
137 		void		(*cl_abort)(struct __rpc_client *);
138 		/* get specific error code */
139 		void		(*cl_geterr)(struct __rpc_client *,
140 					struct rpc_err *);
141 		/* frees results */
142 		bool_t		(*cl_freeres)(struct __rpc_client *,
143 					xdrproc_t, void *);
144 		/* close the connection and terminate pending RPCs */
145 		void		(*cl_close)(struct __rpc_client *);
146 		/* destroy this structure */
147 		void		(*cl_destroy)(struct __rpc_client *);
148 		/* the ioctl() of rpc */
149 		bool_t          (*cl_control)(struct __rpc_client *, u_int,
150 				    void *);
151 	} *cl_ops;
152 #else
153 	AUTH	*cl_auth;			/* authenticator */
154 	struct clnt_ops {
155 		/* call remote procedure */
156 		enum clnt_stat	(*cl_call)(struct __rpc_client *,
157 		    rpcproc_t, xdrproc_t, void *, xdrproc_t,
158 		    void *, struct timeval);
159 		/* abort a call */
160 		void		(*cl_abort)(struct __rpc_client *);
161 		/* get specific error code */
162 		void		(*cl_geterr)(struct __rpc_client *,
163 					struct rpc_err *);
164 		/* frees results */
165 		bool_t		(*cl_freeres)(struct __rpc_client *,
166 					xdrproc_t, void *);
167 		/* destroy this structure */
168 		void		(*cl_destroy)(struct __rpc_client *);
169 		/* the ioctl() of rpc */
170 		bool_t          (*cl_control)(struct __rpc_client *, u_int,
171 				    void *);
172 	} *cl_ops;
173 #endif
174 	void 			*cl_private;	/* private stuff */
175 	char			*cl_netid;	/* network token */
176 	char			*cl_tp;		/* device name */
177 } CLIENT;
178 
179 /*
180  * Feedback values used for possible congestion and rate control
181  */
182 #define FEEDBACK_OK		1	/* no retransmits */
183 #define FEEDBACK_REXMIT1	2	/* first retransmit */
184 #define FEEDBACK_REXMIT2	3	/* second and subsequent retransmit */
185 #define FEEDBACK_RECONNECT	4	/* client reconnect */
186 
187 /* Used to set version of portmapper used in broadcast */
188 
189 #define CLCR_SET_LOWVERS	3
190 #define CLCR_GET_LOWVERS	4
191 
192 #define RPCSMALLMSGSIZE 400	/* a more reasonable packet size */
193 
194 /*
195  * client side rpc interface ops
196  *
197  * Parameter types are:
198  *
199  */
200 
201 #ifdef _KERNEL
202 #define CLNT_ACQUIRE(rh)			\
203 	refcount_acquire(&(rh)->cl_refs)
204 #define CLNT_RELEASE(rh)			\
205 	if (refcount_release(&(rh)->cl_refs))	\
206 		CLNT_DESTROY(rh)
207 
208 /*
209  * void
210  * CLNT_CLOSE(rh);
211  * 	CLIENT *rh;
212  */
213 #define	CLNT_CLOSE(rh)	((*(rh)->cl_ops->cl_close)(rh))
214 
215 enum clnt_stat clnt_call_private(CLIENT *, struct rpc_callextra *, rpcproc_t,
216     xdrproc_t, void *, xdrproc_t, void *, struct timeval);
217 
218 /*
219  * enum clnt_stat
220  * CLNT_CALL_MBUF(rh, ext, proc, mreq, mrepp, timeout)
221  * 	CLIENT *rh;
222  *	struct rpc_callextra *ext;
223  *	rpcproc_t proc;
224  *	struct mbuf *mreq;
225  *	struct mbuf **mrepp;
226  *	struct timeval timeout;
227  *
228  * Call arguments in mreq which is consumed by the call (even if there
229  * is an error). Results returned in *mrepp.
230  */
231 #define	CLNT_CALL_MBUF(rh, ext, proc, mreq, mrepp, secs)	\
232 	((*(rh)->cl_ops->cl_call)(rh, ext, proc, mreq, mrepp, secs))
233 
234 /*
235  * enum clnt_stat
236  * CLNT_CALL_EXT(rh, ext, proc, xargs, argsp, xres, resp, timeout)
237  * 	CLIENT *rh;
238  *	struct rpc_callextra *ext;
239  *	rpcproc_t proc;
240  *	xdrproc_t xargs;
241  *	void *argsp;
242  *	xdrproc_t xres;
243  *	void *resp;
244  *	struct timeval timeout;
245  */
246 #define	CLNT_CALL_EXT(rh, ext, proc, xargs, argsp, xres, resp, secs)	\
247 	clnt_call_private(rh, ext, proc, xargs,				\
248 		argsp, xres, resp, secs)
249 #endif
250 
251 /*
252  * enum clnt_stat
253  * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
254  * 	CLIENT *rh;
255  *	rpcproc_t proc;
256  *	xdrproc_t xargs;
257  *	void *argsp;
258  *	xdrproc_t xres;
259  *	void *resp;
260  *	struct timeval timeout;
261  */
262 #ifdef _KERNEL
263 #define	CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs)	\
264 	clnt_call_private(rh, NULL, proc, xargs,		\
265 		argsp, xres, resp, secs)
266 #define	clnt_call(rh, proc, xargs, argsp, xres, resp, secs)	\
267 	clnt_call_private(rh, NULL, proc, xargs,		\
268 		argsp, xres, resp, secs)
269 #else
270 #define	CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs)		\
271 	((*(rh)->cl_ops->cl_call)(rh, proc, xargs,	\
272 		argsp, xres, resp, secs))
273 #define	clnt_call(rh, proc, xargs, argsp, xres, resp, secs)		\
274 	((*(rh)->cl_ops->cl_call)(rh, proc, xargs,	\
275 		argsp, xres, resp, secs))
276 #endif
277 
278 /*
279  * void
280  * CLNT_ABORT(rh);
281  * 	CLIENT *rh;
282  */
283 #define	CLNT_ABORT(rh)	((*(rh)->cl_ops->cl_abort)(rh))
284 #define	clnt_abort(rh)	((*(rh)->cl_ops->cl_abort)(rh))
285 
286 /*
287  * struct rpc_err
288  * CLNT_GETERR(rh);
289  * 	CLIENT *rh;
290  */
291 #define	CLNT_GETERR(rh,errp)	((*(rh)->cl_ops->cl_geterr)(rh, errp))
292 #define	clnt_geterr(rh,errp)	((*(rh)->cl_ops->cl_geterr)(rh, errp))
293 
294 
295 /*
296  * bool_t
297  * CLNT_FREERES(rh, xres, resp);
298  * 	CLIENT *rh;
299  *	xdrproc_t xres;
300  *	void *resp;
301  */
302 #define	CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
303 #define	clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
304 
305 /*
306  * bool_t
307  * CLNT_CONTROL(cl, request, info)
308  *      CLIENT *cl;
309  *      u_int request;
310  *      char *info;
311  */
312 #define	CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
313 #define	clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
314 
315 /*
316  * control operations that apply to both udp and tcp transports
317  */
318 #define CLSET_TIMEOUT		1	/* set timeout (timeval) */
319 #define CLGET_TIMEOUT		2	/* get timeout (timeval) */
320 #define CLGET_SERVER_ADDR	3	/* get server's address (sockaddr) */
321 #define CLGET_FD		6	/* get connections file descriptor */
322 #define CLGET_SVC_ADDR		7	/* get server's address (netbuf) */
323 #define CLSET_FD_CLOSE		8	/* close fd while clnt_destroy */
324 #define CLSET_FD_NCLOSE		9	/* Do not close fd while clnt_destroy */
325 #define CLGET_XID 		10	/* Get xid */
326 #define CLSET_XID		11	/* Set xid */
327 #define CLGET_VERS		12	/* Get version number */
328 #define CLSET_VERS		13	/* Set version number */
329 #define CLGET_PROG		14	/* Get program number */
330 #define CLSET_PROG		15	/* Set program number */
331 #define CLSET_SVC_ADDR		16	/* get server's address (netbuf) */
332 #define CLSET_PUSH_TIMOD	17	/* push timod if not already present */
333 #define CLSET_POP_TIMOD		18	/* pop timod */
334 /*
335  * Connectionless only control operations
336  */
337 #define CLSET_RETRY_TIMEOUT 4   /* set retry timeout (timeval) */
338 #define CLGET_RETRY_TIMEOUT 5   /* get retry timeout (timeval) */
339 #define CLSET_ASYNC		19
340 #define CLSET_CONNECT		20	/* Use connect() for UDP. (int) */
341 
342 #ifdef _KERNEL
343 /*
344  * Kernel control operations. The default msleep string is "rpcrecv",
345  * and sleeps are non-interruptible by default.
346  */
347 #define CLSET_WAITCHAN		21	/* set string to use in msleep call */
348 #define CLGET_WAITCHAN		22	/* get string used in msleep call */
349 #define CLSET_INTERRUPTIBLE	23	/* set interruptible flag */
350 #define CLGET_INTERRUPTIBLE	24	/* set interruptible flag */
351 #define CLSET_RETRIES		25	/* set retry count for reconnect */
352 #define CLGET_RETRIES		26	/* get retry count for reconnect */
353 #define CLSET_PRIVPORT		27	/* set privileged source port flag */
354 #define CLGET_PRIVPORT		28	/* get privileged source port flag */
355 #define CLSET_BACKCHANNEL	29	/* set backchannel for socket */
356 #define	CLSET_TLS		30	/* set TLS for socket */
357 #define	CLSET_BLOCKRCV		31	/* Temporarily block reception */
358 #define	CLSET_TLSCERTNAME	32	/* TLS certificate file name */
359 /* Structure used as the argument for CLSET_RECONUPCALL. */
360 struct rpc_reconupcall {
361 	void	(*call)(CLIENT *, void *, struct ucred *);
362 	void	*arg;
363 };
364 #define	CLSET_RECONUPCALL	33	/* Reconnect upcall */
365 #endif
366 
367 
368 /*
369  * void
370  * CLNT_DESTROY(rh);
371  * 	CLIENT *rh;
372  */
373 #define	CLNT_DESTROY(rh)	((*(rh)->cl_ops->cl_destroy)(rh))
374 #define	clnt_destroy(rh)	((*(rh)->cl_ops->cl_destroy)(rh))
375 
376 
377 /*
378  * RPCTEST is a test program which is accessible on every rpc
379  * transport/port.  It is used for testing, performance evaluation,
380  * and network administration.
381  */
382 
383 #define RPCTEST_PROGRAM		((rpcprog_t)1)
384 #define RPCTEST_VERSION		((rpcvers_t)1)
385 #define RPCTEST_NULL_PROC	((rpcproc_t)2)
386 #define RPCTEST_NULL_BATCH_PROC	((rpcproc_t)3)
387 
388 /*
389  * By convention, procedure 0 takes null arguments and returns them
390  */
391 
392 #define NULLPROC ((rpcproc_t)0)
393 
394 /*
395  * Below are the client handle creation routines for the various
396  * implementations of client side rpc.  They can return NULL if a
397  * creation failure occurs.
398  */
399 
400 /*
401  * Generic client creation routine. Supported protocols are those that
402  * belong to the nettype namespace (/etc/netconfig).
403  */
404 __BEGIN_DECLS
405 #ifdef _KERNEL
406 
407 /*
408  *	struct socket *so;			-- socket
409  *	struct sockaddr *svcaddr;		-- servers address
410  *	rpcprog_t prog;				-- program number
411  *	rpcvers_t vers;				-- version number
412  *	size_t sendsz;				-- buffer recv size
413  *	size_t recvsz;				-- buffer send size
414  */
415 extern CLIENT *clnt_dg_create(struct socket *so,
416     struct sockaddr *svcaddr, rpcprog_t program, rpcvers_t version,
417     size_t sendsz, size_t recvsz);
418 
419 /*
420  *	struct socket *so;			-- socket
421  *	struct sockaddr *svcaddr;		-- servers address
422  *	rpcprog_t prog;				-- program number
423  *	rpcvers_t vers;				-- version number
424  *	size_t sendsz;				-- buffer recv size
425  *	size_t recvsz;				-- buffer send size
426  *	int intrflag;				-- is it interruptible
427  */
428 extern CLIENT *clnt_vc_create(struct socket *so,
429     struct sockaddr *svcaddr, rpcprog_t program, rpcvers_t version,
430     size_t sendsz, size_t recvsz, int intrflag);
431 
432 /*
433  *	struct netconfig *nconf;		-- network type
434  *	struct sockaddr *svcaddr;		-- servers address
435  *	rpcprog_t prog;				-- program number
436  *	rpcvers_t vers;				-- version number
437  *	size_t sendsz;				-- buffer recv size
438  *	size_t recvsz;				-- buffer send size
439  */
440 extern CLIENT *clnt_reconnect_create(struct netconfig *nconf,
441     struct sockaddr *svcaddr, rpcprog_t program, rpcvers_t version,
442     size_t sendsz, size_t recvsz);
443 
444 #else
445 
446 extern CLIENT *clnt_create(const char *, const rpcprog_t, const rpcvers_t,
447 			   const char *);
448 /*
449  *
450  * 	const char *hostname;			-- hostname
451  *	const rpcprog_t prog;			-- program number
452  *	const rpcvers_t vers;			-- version number
453  *	const char *nettype;			-- network type
454  */
455 
456  /*
457  * Generic client creation routine. Just like clnt_create(), except
458  * it takes an additional timeout parameter.
459  */
460 extern CLIENT * clnt_create_timed(const char *, const rpcprog_t,
461 	const rpcvers_t, const char *, const struct timeval *);
462 /*
463  *
464  *	const char *hostname;			-- hostname
465  *	const rpcprog_t prog;			-- program number
466  *	const rpcvers_t vers;			-- version number
467  *	const char *nettype;			-- network type
468  *	const struct timeval *tp;		-- timeout
469  */
470 
471 /*
472  * Generic client creation routine. Supported protocols are which belong
473  * to the nettype name space.
474  */
475 extern CLIENT *clnt_create_vers(const char *, const rpcprog_t, rpcvers_t *,
476 				const rpcvers_t, const rpcvers_t,
477 				const char *);
478 /*
479  *	const char *host;		-- hostname
480  *	const rpcprog_t prog;		-- program number
481  *	rpcvers_t *vers_out;		-- servers highest available version
482  *	const rpcvers_t vers_low;	-- low version number
483  *	const rpcvers_t vers_high;	-- high version number
484  *	const char *nettype;		-- network type
485  */
486 
487 /*
488  * Generic client creation routine. Supported protocols are which belong
489  * to the nettype name space.
490  */
491 extern CLIENT * clnt_create_vers_timed(const char *, const rpcprog_t,
492 	rpcvers_t *, const rpcvers_t, const rpcvers_t, const char *,
493 	const struct timeval *);
494 /*
495  *	const char *host;		-- hostname
496  *	const rpcprog_t prog;		-- program number
497  *	rpcvers_t *vers_out;		-- servers highest available version
498  *	const rpcvers_t vers_low;	-- low version number
499  *	const rpcvers_t vers_high;	-- high version number
500  *	const char *nettype;		-- network type
501  *	const struct timeval *tp	-- timeout
502  */
503 
504 /*
505  * Generic client creation routine. It takes a netconfig structure
506  * instead of nettype
507  */
508 extern CLIENT *clnt_tp_create(const char *, const rpcprog_t,
509 			      const rpcvers_t, const struct netconfig *);
510 /*
511  *	const char *hostname;			-- hostname
512  *	const rpcprog_t prog;			-- program number
513  *	const rpcvers_t vers;			-- version number
514  *	const struct netconfig *netconf; 	-- network config structure
515  */
516 
517 /*
518  * Generic client creation routine. Just like clnt_tp_create(), except
519  * it takes an additional timeout parameter.
520  */
521 extern CLIENT * clnt_tp_create_timed(const char *, const rpcprog_t,
522 	const rpcvers_t, const struct netconfig *, const struct timeval *);
523 /*
524  *	const char *hostname;			-- hostname
525  *	const rpcprog_t prog;			-- program number
526  *	const rpcvers_t vers;			-- version number
527  *	const struct netconfig *netconf; 	-- network config structure
528  *	const struct timeval *tp		-- timeout
529  */
530 
531 /*
532  * Generic TLI create routine. Only provided for compatibility.
533  */
534 
535 extern CLIENT *clnt_tli_create(const int, const struct netconfig *,
536 			       struct netbuf *, const rpcprog_t,
537 			       const rpcvers_t, const u_int, const u_int);
538 /*
539  *	const int fd;			-- fd
540  *	const struct netconfig *nconf;	-- netconfig structure
541  *	struct netbuf *svcaddr;		-- servers address
542  *	const u_long prog;			-- program number
543  *	const u_long vers;			-- version number
544  *	const u_int sendsz;			-- send size
545  *	const u_int recvsz;			-- recv size
546  */
547 
548 /*
549  * Low level clnt create routine for connectionful transports, e.g. tcp.
550  */
551 extern CLIENT *clnt_vc_create(const int, const struct netbuf *,
552 			      const rpcprog_t, const rpcvers_t,
553 			      u_int, u_int);
554 /*
555  * Added for compatibility to old rpc 4.0. Obsoleted by clnt_vc_create().
556  */
557 extern CLIENT *clntunix_create(struct sockaddr_un *,
558 			       u_long, u_long, int *, u_int, u_int);
559 /*
560  *	const int fd;				-- open file descriptor
561  *	const struct netbuf *svcaddr;		-- servers address
562  *	const rpcprog_t prog;			-- program number
563  *	const rpcvers_t vers;			-- version number
564  *	const u_int sendsz;			-- buffer recv size
565  *	const u_int recvsz;			-- buffer send size
566  */
567 
568 /*
569  * Low level clnt create routine for connectionless transports, e.g. udp.
570  */
571 extern CLIENT *clnt_dg_create(const int, const struct netbuf *,
572 			      const rpcprog_t, const rpcvers_t,
573 			      const u_int, const u_int);
574 /*
575  *	const int fd;				-- open file descriptor
576  *	const struct netbuf *svcaddr;		-- servers address
577  *	const rpcprog_t program;		-- program number
578  *	const rpcvers_t version;		-- version number
579  *	const u_int sendsz;			-- buffer recv size
580  *	const u_int recvsz;			-- buffer send size
581  */
582 
583 /*
584  * Memory based rpc (for speed check and testing)
585  * CLIENT *
586  * clnt_raw_create(prog, vers)
587  *	u_long prog;
588  *	u_long vers;
589  */
590 extern CLIENT *clnt_raw_create(rpcprog_t, rpcvers_t);
591 #endif
592 
593 __END_DECLS
594 
595 
596 /*
597  * Print why creation failed
598  */
599 __BEGIN_DECLS
600 extern void clnt_pcreateerror(const char *);			/* stderr */
601 extern char *clnt_spcreateerror(const char *);			/* string */
602 __END_DECLS
603 
604 /*
605  * Like clnt_perror(), but is more verbose in its output
606  */
607 __BEGIN_DECLS
608 extern void clnt_perrno(enum clnt_stat);		/* stderr */
609 extern char *clnt_sperrno(enum clnt_stat);		/* string */
610 __END_DECLS
611 
612 /*
613  * Print an English error message, given the client error code
614  */
615 __BEGIN_DECLS
616 extern void clnt_perror(CLIENT *, const char *);	 	/* stderr */
617 extern char *clnt_sperror(CLIENT *, const char *);		/* string */
618 __END_DECLS
619 
620 
621 /*
622  * If a creation fails, the following allows the user to figure out why.
623  */
624 struct rpc_createerr {
625 	enum clnt_stat cf_stat;
626 	struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */
627 };
628 
629 #ifdef _KERNEL
630 extern struct rpc_createerr rpc_createerr;
631 #else
632 __BEGIN_DECLS
633 extern struct rpc_createerr	*__rpc_createerr(void);
634 __END_DECLS
635 #define rpc_createerr		(*(__rpc_createerr()))
636 #endif
637 
638 #ifndef _KERNEL
639 /*
640  * The simplified interface:
641  * enum clnt_stat
642  * rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype)
643  *	const char *host;
644  *	const rpcprog_t prognum;
645  *	const rpcvers_t versnum;
646  *	const rpcproc_t procnum;
647  *	const xdrproc_t inproc, outproc;
648  *	const char *in;
649  *	char *out;
650  *	const char *nettype;
651  */
652 __BEGIN_DECLS
653 extern enum clnt_stat rpc_call(const char *, const rpcprog_t,
654 			       const rpcvers_t, const rpcproc_t,
655 			       const xdrproc_t, const char *,
656 			       const xdrproc_t, char *, const char *);
657 __END_DECLS
658 
659 /*
660  * RPC broadcast interface
661  * The call is broadcasted to all locally connected nets.
662  *
663  * extern enum clnt_stat
664  * rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp,
665  *			eachresult, nettype)
666  *	const rpcprog_t		prog;		-- program number
667  *	const rpcvers_t		vers;		-- version number
668  *	const rpcproc_t		proc;		-- procedure number
669  *	const xdrproc_t	xargs;		-- xdr routine for args
670  *	caddr_t		argsp;		-- pointer to args
671  *	const xdrproc_t	xresults;	-- xdr routine for results
672  *	caddr_t		resultsp;	-- pointer to results
673  *	const resultproc_t	eachresult;	-- call with each result
674  *	const char		*nettype;	-- Transport type
675  *
676  * For each valid response received, the procedure eachresult is called.
677  * Its form is:
678  *		done = eachresult(resp, raddr, nconf)
679  *			bool_t done;
680  *			caddr_t resp;
681  *			struct netbuf *raddr;
682  *			struct netconfig *nconf;
683  * where resp points to the results of the call and raddr is the
684  * address if the responder to the broadcast.  nconf is the transport
685  * on which the response was received.
686  *
687  * extern enum clnt_stat
688  * rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
689  *			eachresult, inittime, waittime, nettype)
690  *	const rpcprog_t		prog;		-- program number
691  *	const rpcvers_t		vers;		-- version number
692  *	const rpcproc_t		proc;		-- procedure number
693  *	const xdrproc_t	xargs;		-- xdr routine for args
694  *	caddr_t		argsp;		-- pointer to args
695  *	const xdrproc_t	xresults;	-- xdr routine for results
696  *	caddr_t		resultsp;	-- pointer to results
697  *	const resultproc_t	eachresult;	-- call with each result
698  *	const int 		inittime;	-- how long to wait initially
699  *	const int 		waittime;	-- maximum time to wait
700  *	const char		*nettype;	-- Transport type
701  */
702 
703 typedef bool_t (*resultproc_t)(caddr_t, ...);
704 
705 __BEGIN_DECLS
706 extern enum clnt_stat rpc_broadcast(const rpcprog_t, const rpcvers_t,
707 				    const rpcproc_t, const xdrproc_t,
708 				    caddr_t, const xdrproc_t, caddr_t,
709 				    const resultproc_t, const char *);
710 extern enum clnt_stat rpc_broadcast_exp(const rpcprog_t, const rpcvers_t,
711 					const rpcproc_t, const xdrproc_t,
712 					caddr_t, const xdrproc_t, caddr_t,
713 					const resultproc_t, const int,
714 					const int, const char *);
715 __END_DECLS
716 
717 /* For backward compatibility */
718 #include <rpc/clnt_soc.h>
719 #endif
720 
721 #endif /* !_RPC_CLNT_H_ */
722