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