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