xref: /titanic_53/usr/src/uts/common/rpc/clnt.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */
28*7c478bd9Sstevel@tonic-gate /*
29*7c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley
30*7c478bd9Sstevel@tonic-gate  * 4.3 BSD under license from the Regents of the University of
31*7c478bd9Sstevel@tonic-gate  * California.
32*7c478bd9Sstevel@tonic-gate  */
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate /*
35*7c478bd9Sstevel@tonic-gate  * clnt.h - Client side remote procedure call interface.
36*7c478bd9Sstevel@tonic-gate  */
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #ifndef	_RPC_CLNT_H
39*7c478bd9Sstevel@tonic-gate #define	_RPC_CLNT_H
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
44*7c478bd9Sstevel@tonic-gate #include <rpc/rpc_com.h>
45*7c478bd9Sstevel@tonic-gate #include <rpc/clnt_stat.h>
46*7c478bd9Sstevel@tonic-gate #include <rpc/auth.h>
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate /*
49*7c478bd9Sstevel@tonic-gate  * rpc calls return an enum clnt_stat.  This should be looked at more,
50*7c478bd9Sstevel@tonic-gate  * since each implementation is required to live with this (implementation
51*7c478bd9Sstevel@tonic-gate  * independent) list of errors.
52*7c478bd9Sstevel@tonic-gate  */
53*7c478bd9Sstevel@tonic-gate #include <sys/netconfig.h>
54*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
55*7c478bd9Sstevel@tonic-gate #include <sys/t_kuser.h>
56*7c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
59*7c478bd9Sstevel@tonic-gate extern "C" {
60*7c478bd9Sstevel@tonic-gate #endif
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate /*
63*7c478bd9Sstevel@tonic-gate  * Following defines the multicast group address used by IPV6 enabled
64*7c478bd9Sstevel@tonic-gate  * client to do the broadcast. IPv6 doesn't have any broadcast support
65*7c478bd9Sstevel@tonic-gate  * as IPv4 provides, thus it used this reserved address which is joined
66*7c478bd9Sstevel@tonic-gate  * by all rpc clients.
67*7c478bd9Sstevel@tonic-gate  */
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate #define	RPCB_MULTICAST_ADDR "FF02::202"
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate /*
72*7c478bd9Sstevel@tonic-gate  * the following errors are in general unrecoverable.  The caller
73*7c478bd9Sstevel@tonic-gate  * should give up rather than retry.
74*7c478bd9Sstevel@tonic-gate  */
75*7c478bd9Sstevel@tonic-gate #define	IS_UNRECOVERABLE_RPC(s)	(((s) == RPC_AUTHERROR) || \
76*7c478bd9Sstevel@tonic-gate 	((s) == RPC_CANTENCODEARGS) || \
77*7c478bd9Sstevel@tonic-gate 	((s) == RPC_CANTDECODERES) || \
78*7c478bd9Sstevel@tonic-gate 	((s) == RPC_VERSMISMATCH) || \
79*7c478bd9Sstevel@tonic-gate 	((s) == RPC_PROCUNAVAIL) || \
80*7c478bd9Sstevel@tonic-gate 	((s) == RPC_PROGUNAVAIL) || \
81*7c478bd9Sstevel@tonic-gate 	((s) == RPC_PROGVERSMISMATCH) || \
82*7c478bd9Sstevel@tonic-gate 	((s) == RPC_CANTDECODEARGS))
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate /* Maximum rpc backoff time */
85*7c478bd9Sstevel@tonic-gate #define	RPC_MAX_BACKOFF	30
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate /*
88*7c478bd9Sstevel@tonic-gate  * Error info.
89*7c478bd9Sstevel@tonic-gate  */
90*7c478bd9Sstevel@tonic-gate struct rpc_err {
91*7c478bd9Sstevel@tonic-gate 	enum clnt_stat re_status;
92*7c478bd9Sstevel@tonic-gate 	union {
93*7c478bd9Sstevel@tonic-gate 		struct {
94*7c478bd9Sstevel@tonic-gate 			int RE_errno;	/* related system error */
95*7c478bd9Sstevel@tonic-gate 			int RE_t_errno;	/* related tli error number */
96*7c478bd9Sstevel@tonic-gate 		} RE_err;
97*7c478bd9Sstevel@tonic-gate 		enum auth_stat RE_why;	/* why the auth error occurred */
98*7c478bd9Sstevel@tonic-gate 		struct {
99*7c478bd9Sstevel@tonic-gate 			rpcvers_t low;	/* lowest verion supported */
100*7c478bd9Sstevel@tonic-gate 			rpcvers_t high;	/* highest verion supported */
101*7c478bd9Sstevel@tonic-gate 		} RE_vers;
102*7c478bd9Sstevel@tonic-gate 		struct {		/* maybe meaningful if RPC_FAILED */
103*7c478bd9Sstevel@tonic-gate 			int32_t s1;
104*7c478bd9Sstevel@tonic-gate 			int32_t s2;
105*7c478bd9Sstevel@tonic-gate 		} RE_lb;		/* life boot & debugging only */
106*7c478bd9Sstevel@tonic-gate 	} ru;
107*7c478bd9Sstevel@tonic-gate #define	re_errno	ru.RE_err.RE_errno
108*7c478bd9Sstevel@tonic-gate #define	re_terrno	ru.RE_err.RE_t_errno
109*7c478bd9Sstevel@tonic-gate #define	re_why		ru.RE_why
110*7c478bd9Sstevel@tonic-gate #define	re_vers		ru.RE_vers
111*7c478bd9Sstevel@tonic-gate #define	re_lb		ru.RE_lb
112*7c478bd9Sstevel@tonic-gate };
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate /*
116*7c478bd9Sstevel@tonic-gate  * Timers used for the pseudo-transport protocol when using datagrams
117*7c478bd9Sstevel@tonic-gate  */
118*7c478bd9Sstevel@tonic-gate struct rpc_timers {
119*7c478bd9Sstevel@tonic-gate 	clock_t		rt_srtt;	/* smoothed round-trip time */
120*7c478bd9Sstevel@tonic-gate 	clock_t		rt_deviate;	/* estimated deviation */
121*7c478bd9Sstevel@tonic-gate 	clock_t		rt_rtxcur;	/* current (backed-off) rto */
122*7c478bd9Sstevel@tonic-gate };
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate /*
125*7c478bd9Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
126*7c478bd9Sstevel@tonic-gate  * CLIENT
127*7c478bd9Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
128*7c478bd9Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
129*7c478bd9Sstevel@tonic-gate  *
130*7c478bd9Sstevel@tonic-gate  * Client rpc handle.
131*7c478bd9Sstevel@tonic-gate  * Created by individual implementations
132*7c478bd9Sstevel@tonic-gate  * Client is responsible for initializing auth, see e.g. auth_none.c.
133*7c478bd9Sstevel@tonic-gate  */
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate typedef struct __client {
136*7c478bd9Sstevel@tonic-gate 	AUTH	*cl_auth;			/* authenticator */
137*7c478bd9Sstevel@tonic-gate 	struct clnt_ops {
138*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
139*7c478bd9Sstevel@tonic-gate 		/* call remote procedure */
140*7c478bd9Sstevel@tonic-gate 		enum clnt_stat	(*cl_call)(struct __client *, rpcproc_t,
141*7c478bd9Sstevel@tonic-gate 				    xdrproc_t, caddr_t, xdrproc_t,
142*7c478bd9Sstevel@tonic-gate 				    caddr_t, struct timeval);
143*7c478bd9Sstevel@tonic-gate 		/* abort a call */
144*7c478bd9Sstevel@tonic-gate 		void		(*cl_abort)(/* various */);
145*7c478bd9Sstevel@tonic-gate 		/* get specific error code */
146*7c478bd9Sstevel@tonic-gate 		void		(*cl_geterr)(struct __client *,
147*7c478bd9Sstevel@tonic-gate 				    struct rpc_err *);
148*7c478bd9Sstevel@tonic-gate 		/* frees results */
149*7c478bd9Sstevel@tonic-gate 		bool_t		(*cl_freeres)(struct __client *, xdrproc_t,
150*7c478bd9Sstevel@tonic-gate 				    caddr_t);
151*7c478bd9Sstevel@tonic-gate 		/* destroy this structure */
152*7c478bd9Sstevel@tonic-gate 		void		(*cl_destroy)(struct __client *);
153*7c478bd9Sstevel@tonic-gate 		/* the ioctl() of rpc */
154*7c478bd9Sstevel@tonic-gate 		bool_t		(*cl_control)(struct __client *, int, char *);
155*7c478bd9Sstevel@tonic-gate 		/* set rpc level timers */
156*7c478bd9Sstevel@tonic-gate 		int		(*cl_settimers)(struct __client *,
157*7c478bd9Sstevel@tonic-gate 				    struct rpc_timers *, struct rpc_timers *,
158*7c478bd9Sstevel@tonic-gate 				    int, void (*)(), caddr_t, uint32_t);
159*7c478bd9Sstevel@tonic-gate #ifndef _KERNEL
160*7c478bd9Sstevel@tonic-gate 		/* send a one-way asynchronous call to remote procedure */
161*7c478bd9Sstevel@tonic-gate 		enum clnt_stat	(*cl_send)(struct __client *, rpcproc_t,
162*7c478bd9Sstevel@tonic-gate 				    xdrproc_t, caddr_t);
163*7c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */
164*7c478bd9Sstevel@tonic-gate #else
165*7c478bd9Sstevel@tonic-gate 		enum clnt_stat	(*cl_call)();	/* call remote procedure */
166*7c478bd9Sstevel@tonic-gate 		void		(*cl_abort)();	/* abort a call */
167*7c478bd9Sstevel@tonic-gate 		void		(*cl_geterr)();	/* get specific error code */
168*7c478bd9Sstevel@tonic-gate 		bool_t		(*cl_freeres)(); /* frees results */
169*7c478bd9Sstevel@tonic-gate 		void		(*cl_destroy)(); /* destroy this structure */
170*7c478bd9Sstevel@tonic-gate 		bool_t		(*cl_control)(); /* the ioctl() of rpc */
171*7c478bd9Sstevel@tonic-gate 		int		(*cl_settimers)(); /* set rpc level timers */
172*7c478bd9Sstevel@tonic-gate #ifndef _KERNEL
173*7c478bd9Sstevel@tonic-gate 		enum clnt_stat  (*cl_send)();   /* send one-way request */
174*7c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */
175*7c478bd9Sstevel@tonic-gate #endif
176*7c478bd9Sstevel@tonic-gate 	} *cl_ops;
177*7c478bd9Sstevel@tonic-gate 	caddr_t			cl_private;	/* private stuff */
178*7c478bd9Sstevel@tonic-gate #ifndef _KERNEL
179*7c478bd9Sstevel@tonic-gate 	char			*cl_netid;	/* network token */
180*7c478bd9Sstevel@tonic-gate 	char			*cl_tp;		/* device name */
181*7c478bd9Sstevel@tonic-gate #else
182*7c478bd9Sstevel@tonic-gate 	bool_t			cl_nosignal;  /* to handle NOINTR */
183*7c478bd9Sstevel@tonic-gate #endif
184*7c478bd9Sstevel@tonic-gate } CLIENT;
185*7c478bd9Sstevel@tonic-gate 
186*7c478bd9Sstevel@tonic-gate /*
187*7c478bd9Sstevel@tonic-gate  * Feedback values used for possible congestion and rate control
188*7c478bd9Sstevel@tonic-gate  */
189*7c478bd9Sstevel@tonic-gate #define	FEEDBACK_REXMIT1	1	/* first retransmit */
190*7c478bd9Sstevel@tonic-gate #define	FEEDBACK_OK		2	/* no retransmits */
191*7c478bd9Sstevel@tonic-gate 
192*7c478bd9Sstevel@tonic-gate /*
193*7c478bd9Sstevel@tonic-gate  * The following defines the control routines
194*7c478bd9Sstevel@tonic-gate  * for rpcbind.
195*7c478bd9Sstevel@tonic-gate  */
196*7c478bd9Sstevel@tonic-gate 
197*7c478bd9Sstevel@tonic-gate #define	CLCR_GET_RPCB_TIMEOUT	1
198*7c478bd9Sstevel@tonic-gate #define	CLCR_SET_RPCB_TIMEOUT	2
199*7c478bd9Sstevel@tonic-gate #define	CLCR_SET_LOWVERS	3
200*7c478bd9Sstevel@tonic-gate #define	CLCR_GET_LOWVERS	4
201*7c478bd9Sstevel@tonic-gate #define	CLCR_SET_RPCB_RMTTIME	5
202*7c478bd9Sstevel@tonic-gate #define	CLCR_GET_RPCB_RMTTIME  	6
203*7c478bd9Sstevel@tonic-gate #define	CLCR_SET_CRED_CACHE_SZ 	7
204*7c478bd9Sstevel@tonic-gate #define	CLCR_GET_CRED_CACHE_SZ 	8
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate #define	RPCSMALLMSGSIZE	400	/* a more reasonable packet size */
207*7c478bd9Sstevel@tonic-gate 
208*7c478bd9Sstevel@tonic-gate #define	KNC_STRSIZE	128	/* maximum length of knetconfig strings */
209*7c478bd9Sstevel@tonic-gate /*
210*7c478bd9Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
211*7c478bd9Sstevel@tonic-gate  * knetconfig
212*7c478bd9Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
213*7c478bd9Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
214*7c478bd9Sstevel@tonic-gate  *
215*7c478bd9Sstevel@tonic-gate  * Note that the knetconfig strings can either be dynamically allocated, or
216*7c478bd9Sstevel@tonic-gate  * they can be string literals.  The code that sets up the knetconfig is
217*7c478bd9Sstevel@tonic-gate  * responsible for keeping track of this and freeing the strings if
218*7c478bd9Sstevel@tonic-gate  * necessary when the knetconfig is destroyed.
219*7c478bd9Sstevel@tonic-gate  */
220*7c478bd9Sstevel@tonic-gate struct knetconfig {
221*7c478bd9Sstevel@tonic-gate 	unsigned int	knc_semantics;	/* token name */
222*7c478bd9Sstevel@tonic-gate 	caddr_t		knc_protofmly;	/* protocol family */
223*7c478bd9Sstevel@tonic-gate 	caddr_t		knc_proto;	/* protocol */
224*7c478bd9Sstevel@tonic-gate 	dev_t		knc_rdev;	/* device id */
225*7c478bd9Sstevel@tonic-gate 	unsigned int	knc_unused[8];
226*7c478bd9Sstevel@tonic-gate };
227*7c478bd9Sstevel@tonic-gate 
228*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32
229*7c478bd9Sstevel@tonic-gate struct knetconfig32 {
230*7c478bd9Sstevel@tonic-gate 	uint32_t	knc_semantics;	/* token name */
231*7c478bd9Sstevel@tonic-gate 	caddr32_t	knc_protofmly;	/* protocol family */
232*7c478bd9Sstevel@tonic-gate 	caddr32_t	knc_proto;	/* protocol */
233*7c478bd9Sstevel@tonic-gate 	dev32_t		knc_rdev;	/* device id */
234*7c478bd9Sstevel@tonic-gate 	uint32_t	knc_unused[8];
235*7c478bd9Sstevel@tonic-gate };
236*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
237*7c478bd9Sstevel@tonic-gate 
238*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
239*7c478bd9Sstevel@tonic-gate 
240*7c478bd9Sstevel@tonic-gate /*
241*7c478bd9Sstevel@tonic-gate  * Bucket defined for the call table.  Padded out to 64 bytes so that
242*7c478bd9Sstevel@tonic-gate  * false sharing won't be induced.
243*7c478bd9Sstevel@tonic-gate  */
244*7c478bd9Sstevel@tonic-gate typedef	union call_table {
245*7c478bd9Sstevel@tonic-gate 	struct {
246*7c478bd9Sstevel@tonic-gate 		struct calllist_s	*uct_call_next;
247*7c478bd9Sstevel@tonic-gate 		struct calllist_s	*uct_call_prev;
248*7c478bd9Sstevel@tonic-gate 		uint_t			uct_len;
249*7c478bd9Sstevel@tonic-gate 		kmutex_t		uct_lock;
250*7c478bd9Sstevel@tonic-gate 	} ct_s;
251*7c478bd9Sstevel@tonic-gate 	char				uct_pad[64];
252*7c478bd9Sstevel@tonic-gate } call_table_t;
253*7c478bd9Sstevel@tonic-gate 
254*7c478bd9Sstevel@tonic-gate /*
255*7c478bd9Sstevel@tonic-gate  * Define some macros for easy access into the call table structure
256*7c478bd9Sstevel@tonic-gate  */
257*7c478bd9Sstevel@tonic-gate #define	ct_call_next ct_s.uct_call_next
258*7c478bd9Sstevel@tonic-gate #define	ct_call_prev ct_s.uct_call_prev
259*7c478bd9Sstevel@tonic-gate #define	ct_len ct_s.uct_len
260*7c478bd9Sstevel@tonic-gate #define	ct_lock ct_s.uct_lock
261*7c478bd9Sstevel@tonic-gate 
262*7c478bd9Sstevel@tonic-gate /*
263*7c478bd9Sstevel@tonic-gate  * List of outstanding calls awaiting replies, for COTS, CLTS
264*7c478bd9Sstevel@tonic-gate  */
265*7c478bd9Sstevel@tonic-gate typedef struct calllist_s {
266*7c478bd9Sstevel@tonic-gate 	struct calllist_s *call_next;	/* hash chain, MUST BE FIRST */
267*7c478bd9Sstevel@tonic-gate 	struct calllist_s *call_prev;
268*7c478bd9Sstevel@tonic-gate 	bool_t		call_notified;
269*7c478bd9Sstevel@tonic-gate 	uint_t		call_xid;	/* the xid on the call */
270*7c478bd9Sstevel@tonic-gate 	uint_t		call_hash;	/* hash value */
271*7c478bd9Sstevel@tonic-gate 	call_table_t	*call_bucket;	/* back pointer to bucket */
272*7c478bd9Sstevel@tonic-gate 	mblk_t		*call_reply;	/* the reply to the call */
273*7c478bd9Sstevel@tonic-gate 	kcondvar_t	call_cv;	/* cv to notify when reply is done */
274*7c478bd9Sstevel@tonic-gate 	kmutex_t	call_lock;	/* lock for cv */
275*7c478bd9Sstevel@tonic-gate 	struct rpc_err	call_err;	/* status on reply */
276*7c478bd9Sstevel@tonic-gate #define	call_status call_err.re_status	/* error on reply (rep is invalid) */
277*7c478bd9Sstevel@tonic-gate #define	call_reason call_err.re_errno	/* reason code on T_DISCON_IND */
278*7c478bd9Sstevel@tonic-gate 	queue_t		*call_wq;	/* the write queue the call is using */
279*7c478bd9Sstevel@tonic-gate } calllist_t;
280*7c478bd9Sstevel@tonic-gate 
281*7c478bd9Sstevel@tonic-gate /*
282*7c478bd9Sstevel@tonic-gate  * Define macros for call table hashing
283*7c478bd9Sstevel@tonic-gate  */
284*7c478bd9Sstevel@tonic-gate /*
285*7c478bd9Sstevel@tonic-gate  * A simple hash function.  Due to the way XID's get allocated, this may be
286*7c478bd9Sstevel@tonic-gate  * sufficient.  This hash function provides round robin bucket selection so
287*7c478bd9Sstevel@tonic-gate  * that the next time a particular bucket gets picked is when there have
288*7c478bd9Sstevel@tonic-gate  * been N-1 calls.  N is the number of buckets.
289*7c478bd9Sstevel@tonic-gate  */
290*7c478bd9Sstevel@tonic-gate #define	call_hash(xid, hashsize) \
291*7c478bd9Sstevel@tonic-gate 		(xid % hashsize);
292*7c478bd9Sstevel@tonic-gate 
293*7c478bd9Sstevel@tonic-gate #define	call_table_enter(e)				\
294*7c478bd9Sstevel@tonic-gate {							\
295*7c478bd9Sstevel@tonic-gate 	call_table_t *ctp = e->call_bucket;		\
296*7c478bd9Sstevel@tonic-gate 	mutex_enter(&ctp->ct_lock);			\
297*7c478bd9Sstevel@tonic-gate 	ctp->ct_len++;					\
298*7c478bd9Sstevel@tonic-gate 	e->call_next = (calllist_t *)ctp->ct_call_next;	\
299*7c478bd9Sstevel@tonic-gate 	e->call_prev = (calllist_t *)ctp;		\
300*7c478bd9Sstevel@tonic-gate 	((call_table_t *)ctp->ct_call_next)->ct_call_prev = e;		\
301*7c478bd9Sstevel@tonic-gate 	ctp->ct_call_next = e;				\
302*7c478bd9Sstevel@tonic-gate 	mutex_exit(&e->call_bucket->ct_lock);		\
303*7c478bd9Sstevel@tonic-gate }
304*7c478bd9Sstevel@tonic-gate 
305*7c478bd9Sstevel@tonic-gate #define	call_table_remove(e)				\
306*7c478bd9Sstevel@tonic-gate {							\
307*7c478bd9Sstevel@tonic-gate 	call_table_t *ctp = e->call_bucket;		\
308*7c478bd9Sstevel@tonic-gate 	mutex_enter(&ctp->ct_lock);			\
309*7c478bd9Sstevel@tonic-gate 	ctp->ct_len--;					\
310*7c478bd9Sstevel@tonic-gate 	((call_table_t *)e->call_prev)->ct_call_next = e->call_next;	\
311*7c478bd9Sstevel@tonic-gate 	((call_table_t *)e->call_next)->ct_call_prev = e->call_prev;	\
312*7c478bd9Sstevel@tonic-gate 	mutex_exit(&ctp->ct_lock);			\
313*7c478bd9Sstevel@tonic-gate }
314*7c478bd9Sstevel@tonic-gate 
315*7c478bd9Sstevel@tonic-gate #define	call_table_find(ctp, xid, ele)			\
316*7c478bd9Sstevel@tonic-gate {							\
317*7c478bd9Sstevel@tonic-gate 	calllist_t *cp;					\
318*7c478bd9Sstevel@tonic-gate 	ele = NULL;					\
319*7c478bd9Sstevel@tonic-gate 	mutex_enter(&(ctp)->ct_lock);			\
320*7c478bd9Sstevel@tonic-gate 	for (cp = (ctp)->ct_call_next;			\
321*7c478bd9Sstevel@tonic-gate 		cp != (calllist_t *)ctp;		\
322*7c478bd9Sstevel@tonic-gate 		cp = cp->call_next) {			\
323*7c478bd9Sstevel@tonic-gate 		if (cp->call_xid == xid)		\
324*7c478bd9Sstevel@tonic-gate 			ele = cp;			\
325*7c478bd9Sstevel@tonic-gate 	}						\
326*7c478bd9Sstevel@tonic-gate }
327*7c478bd9Sstevel@tonic-gate 
328*7c478bd9Sstevel@tonic-gate #define	DEFAULT_MIN_HASH_SIZE	32
329*7c478bd9Sstevel@tonic-gate #define	DEFAULT_HASH_SIZE	1024
330*7c478bd9Sstevel@tonic-gate 
331*7c478bd9Sstevel@tonic-gate #define	RESERVED_PORTSPACE (IPPORT_RESERVED - (IPPORT_RESERVED/2))
332*7c478bd9Sstevel@tonic-gate #define	NONRESERVED_PORTSPACE (0xFFFF - IPPORT_RESERVED)
333*7c478bd9Sstevel@tonic-gate 
334*7c478bd9Sstevel@tonic-gate /*
335*7c478bd9Sstevel@tonic-gate  *	Alloc_xid presents an interface which kernel RPC clients
336*7c478bd9Sstevel@tonic-gate  *	should use to allocate their XIDs.  Its implementation
337*7c478bd9Sstevel@tonic-gate  *	may change over time (for example, to allow sharing of
338*7c478bd9Sstevel@tonic-gate  *	XIDs between the kernel and user-level applications, so
339*7c478bd9Sstevel@tonic-gate  *	all XID allocation should be done by calling alloc_xid().
340*7c478bd9Sstevel@tonic-gate  */
341*7c478bd9Sstevel@tonic-gate extern uint32_t alloc_xid(void);
342*7c478bd9Sstevel@tonic-gate 
343*7c478bd9Sstevel@tonic-gate extern int clnt_tli_kcreate(struct knetconfig *config, struct netbuf *svcaddr,
344*7c478bd9Sstevel@tonic-gate 	rpcprog_t, rpcvers_t, uint_t max_msgsize, int retrys,
345*7c478bd9Sstevel@tonic-gate 	struct cred *cred, CLIENT **ncl);
346*7c478bd9Sstevel@tonic-gate 
347*7c478bd9Sstevel@tonic-gate extern int clnt_tli_kinit(CLIENT *h, struct knetconfig *config,
348*7c478bd9Sstevel@tonic-gate 	struct netbuf *addr, uint_t max_msgsize, int retries,
349*7c478bd9Sstevel@tonic-gate 	struct cred *cred);
350*7c478bd9Sstevel@tonic-gate 
351*7c478bd9Sstevel@tonic-gate extern int rpc_uaddr2port(int af, char *addr);
352*7c478bd9Sstevel@tonic-gate 
353*7c478bd9Sstevel@tonic-gate /*
354*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
355*7c478bd9Sstevel@tonic-gate  */
356*7c478bd9Sstevel@tonic-gate extern int bindresvport(TIUSER *tiptr, struct netbuf *addr,
357*7c478bd9Sstevel@tonic-gate 	struct netbuf *bound_addr, bool_t istcp);
358*7c478bd9Sstevel@tonic-gate 
359*7c478bd9Sstevel@tonic-gate /*
360*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
361*7c478bd9Sstevel@tonic-gate  */
362*7c478bd9Sstevel@tonic-gate extern int clnt_clts_kcreate(struct knetconfig *config, struct netbuf *addr,
363*7c478bd9Sstevel@tonic-gate 	rpcprog_t, rpcvers_t, int retries, struct cred *cred, CLIENT **cl);
364*7c478bd9Sstevel@tonic-gate 
365*7c478bd9Sstevel@tonic-gate /*
366*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
367*7c478bd9Sstevel@tonic-gate  */
368*7c478bd9Sstevel@tonic-gate extern int clnt_cots_kcreate(dev_t dev, struct netbuf *addr, int family,
369*7c478bd9Sstevel@tonic-gate 	rpcprog_t, rpcvers_t, uint_t max_msgsize, struct cred *cred,
370*7c478bd9Sstevel@tonic-gate 	CLIENT **ncl);
371*7c478bd9Sstevel@tonic-gate /*
372*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
373*7c478bd9Sstevel@tonic-gate  */
374*7c478bd9Sstevel@tonic-gate extern int clnt_rdma_kcreate(char *proto, void *handle, struct netbuf *raddr,
375*7c478bd9Sstevel@tonic-gate 	int family, rpcprog_t pgm, rpcvers_t vers, struct cred *cred,
376*7c478bd9Sstevel@tonic-gate 	CLIENT **cl);
377*7c478bd9Sstevel@tonic-gate /*
378*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
379*7c478bd9Sstevel@tonic-gate  */
380*7c478bd9Sstevel@tonic-gate extern int rdma_reachable(int addr_type, struct netbuf *addr,
381*7c478bd9Sstevel@tonic-gate 	struct knetconfig **knconf);
382*7c478bd9Sstevel@tonic-gate 
383*7c478bd9Sstevel@tonic-gate /*
384*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
385*7c478bd9Sstevel@tonic-gate  */
386*7c478bd9Sstevel@tonic-gate extern void clnt_clts_kinit(CLIENT *h, struct netbuf *addr, int retries,
387*7c478bd9Sstevel@tonic-gate 	struct cred *cred);
388*7c478bd9Sstevel@tonic-gate 
389*7c478bd9Sstevel@tonic-gate /*
390*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
391*7c478bd9Sstevel@tonic-gate  */
392*7c478bd9Sstevel@tonic-gate extern void clnt_cots_kinit(CLIENT *h, dev_t dev, int family,
393*7c478bd9Sstevel@tonic-gate 	struct netbuf *addr, int max_msgsize, struct cred *cred);
394*7c478bd9Sstevel@tonic-gate 
395*7c478bd9Sstevel@tonic-gate /*
396*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
397*7c478bd9Sstevel@tonic-gate  */
398*7c478bd9Sstevel@tonic-gate extern void clnt_rdma_kinit(CLIENT *h, char *proto, void *handle,
399*7c478bd9Sstevel@tonic-gate 	struct netbuf *addr, struct cred *cred);
400*7c478bd9Sstevel@tonic-gate 
401*7c478bd9Sstevel@tonic-gate /*
402*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
403*7c478bd9Sstevel@tonic-gate  */
404*7c478bd9Sstevel@tonic-gate extern bool_t clnt_dispatch_notify(mblk_t *, zoneid_t);
405*7c478bd9Sstevel@tonic-gate 
406*7c478bd9Sstevel@tonic-gate /*
407*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
408*7c478bd9Sstevel@tonic-gate  */
409*7c478bd9Sstevel@tonic-gate extern bool_t clnt_dispatch_notifyconn(queue_t *, mblk_t *);
410*7c478bd9Sstevel@tonic-gate 
411*7c478bd9Sstevel@tonic-gate /*
412*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
413*7c478bd9Sstevel@tonic-gate  */
414*7c478bd9Sstevel@tonic-gate extern void clnt_dispatch_notifyall(queue_t *, int32_t, int32_t);
415*7c478bd9Sstevel@tonic-gate 
416*7c478bd9Sstevel@tonic-gate /*
417*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
418*7c478bd9Sstevel@tonic-gate  */
419*7c478bd9Sstevel@tonic-gate extern enum clnt_stat clnt_clts_kcallit_addr(CLIENT *, rpcproc_t, xdrproc_t,
420*7c478bd9Sstevel@tonic-gate 	caddr_t, xdrproc_t, caddr_t, struct timeval, struct netbuf *);
421*7c478bd9Sstevel@tonic-gate 
422*7c478bd9Sstevel@tonic-gate /*
423*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
424*7c478bd9Sstevel@tonic-gate  */
425*7c478bd9Sstevel@tonic-gate extern call_table_t *call_table_init(int);
426*7c478bd9Sstevel@tonic-gate 
427*7c478bd9Sstevel@tonic-gate /*
428*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
429*7c478bd9Sstevel@tonic-gate  */
430*7c478bd9Sstevel@tonic-gate extern void clnt_init(void);
431*7c478bd9Sstevel@tonic-gate 
432*7c478bd9Sstevel@tonic-gate /*
433*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
434*7c478bd9Sstevel@tonic-gate  */
435*7c478bd9Sstevel@tonic-gate extern void clnt_fini(void);
436*7c478bd9Sstevel@tonic-gate 
437*7c478bd9Sstevel@tonic-gate /*
438*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
439*7c478bd9Sstevel@tonic-gate  */
440*7c478bd9Sstevel@tonic-gate extern void clnt_clts_init(void);
441*7c478bd9Sstevel@tonic-gate 
442*7c478bd9Sstevel@tonic-gate /*
443*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
444*7c478bd9Sstevel@tonic-gate  */
445*7c478bd9Sstevel@tonic-gate extern void clnt_clts_fini(void);
446*7c478bd9Sstevel@tonic-gate 
447*7c478bd9Sstevel@tonic-gate /*
448*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
449*7c478bd9Sstevel@tonic-gate  */
450*7c478bd9Sstevel@tonic-gate extern void clnt_cots_init(void);
451*7c478bd9Sstevel@tonic-gate 
452*7c478bd9Sstevel@tonic-gate /*
453*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
454*7c478bd9Sstevel@tonic-gate  */
455*7c478bd9Sstevel@tonic-gate extern void clnt_cots_fini(void);
456*7c478bd9Sstevel@tonic-gate 
457*7c478bd9Sstevel@tonic-gate /*
458*7c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
459*7c478bd9Sstevel@tonic-gate  */
460*7c478bd9Sstevel@tonic-gate extern void clnt_clts_dispatch_notify(mblk_t *, int, zoneid_t);
461*7c478bd9Sstevel@tonic-gate 
462*7c478bd9Sstevel@tonic-gate extern void rpc_poptimod(struct vnode *);
463*7c478bd9Sstevel@tonic-gate extern int kstr_push(struct vnode *, char *);
464*7c478bd9Sstevel@tonic-gate extern void t_kadvise(TIUSER *, uchar_t *, int);
465*7c478bd9Sstevel@tonic-gate 
466*7c478bd9Sstevel@tonic-gate extern boolean_t connmgr_cpr_reset(void *, int);
467*7c478bd9Sstevel@tonic-gate 
468*7c478bd9Sstevel@tonic-gate extern void put_inet_port(struct netbuf *, ushort_t);
469*7c478bd9Sstevel@tonic-gate extern void put_inet6_port(struct netbuf *, ushort_t);
470*7c478bd9Sstevel@tonic-gate extern void put_loopback_port(struct netbuf *, char *);
471*7c478bd9Sstevel@tonic-gate extern enum clnt_stat rpcbind_getaddr(struct knetconfig *, rpcprog_t,
472*7c478bd9Sstevel@tonic-gate     rpcvers_t, struct netbuf *);
473*7c478bd9Sstevel@tonic-gate 
474*7c478bd9Sstevel@tonic-gate /*
475*7c478bd9Sstevel@tonic-gate  * Kstat stuff
476*7c478bd9Sstevel@tonic-gate  */
477*7c478bd9Sstevel@tonic-gate #include <sys/zone.h>
478*7c478bd9Sstevel@tonic-gate 
479*7c478bd9Sstevel@tonic-gate extern zone_key_t rpcstat_zone_key;
480*7c478bd9Sstevel@tonic-gate 
481*7c478bd9Sstevel@tonic-gate struct rpc_clts_client;		/* unix:0:rpc_clts_client */
482*7c478bd9Sstevel@tonic-gate struct rpc_clts_server;		/* unix:0:rpc_clts_server */
483*7c478bd9Sstevel@tonic-gate struct rpc_cots_client;		/* unix:0:rpc_cots_client */
484*7c478bd9Sstevel@tonic-gate struct rpc_cots_server;		/* unix:0:rpc_cots_server */
485*7c478bd9Sstevel@tonic-gate 
486*7c478bd9Sstevel@tonic-gate struct rpcstat {
487*7c478bd9Sstevel@tonic-gate 	struct rpc_clts_client *rpc_clts_client;
488*7c478bd9Sstevel@tonic-gate 	struct rpc_clts_server *rpc_clts_server;
489*7c478bd9Sstevel@tonic-gate 	struct rpc_cots_client *rpc_cots_client;
490*7c478bd9Sstevel@tonic-gate 	struct rpc_cots_server *rpc_cots_server;
491*7c478bd9Sstevel@tonic-gate };
492*7c478bd9Sstevel@tonic-gate 
493*7c478bd9Sstevel@tonic-gate extern kstat_named_t *rpcstat_zone_init_common(zoneid_t, const char *,
494*7c478bd9Sstevel@tonic-gate     const char *, const kstat_named_t *, size_t);
495*7c478bd9Sstevel@tonic-gate extern void rpcstat_zone_fini_common(zoneid_t, const char *, const char *);
496*7c478bd9Sstevel@tonic-gate 
497*7c478bd9Sstevel@tonic-gate extern void clnt_clts_stats_init(zoneid_t, struct rpc_clts_client **);
498*7c478bd9Sstevel@tonic-gate extern void clnt_clts_stats_fini(zoneid_t, struct rpc_clts_client **);
499*7c478bd9Sstevel@tonic-gate 
500*7c478bd9Sstevel@tonic-gate extern void svc_clts_stats_init(zoneid_t, struct rpc_clts_server **);
501*7c478bd9Sstevel@tonic-gate extern void svc_clts_stats_fini(zoneid_t, struct rpc_clts_server **);
502*7c478bd9Sstevel@tonic-gate 
503*7c478bd9Sstevel@tonic-gate extern void clnt_cots_stats_init(zoneid_t, struct rpc_cots_client **);
504*7c478bd9Sstevel@tonic-gate extern void clnt_cots_stats_fini(zoneid_t, struct rpc_cots_client **);
505*7c478bd9Sstevel@tonic-gate 
506*7c478bd9Sstevel@tonic-gate extern void svc_cots_stats_init(zoneid_t, struct rpc_cots_server **);
507*7c478bd9Sstevel@tonic-gate extern void svc_cots_stats_fini(zoneid_t, struct rpc_cots_server **);
508*7c478bd9Sstevel@tonic-gate 
509*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
510*7c478bd9Sstevel@tonic-gate 
511*7c478bd9Sstevel@tonic-gate /*
512*7c478bd9Sstevel@tonic-gate  * client side rpc interface ops
513*7c478bd9Sstevel@tonic-gate  */
514*7c478bd9Sstevel@tonic-gate 
515*7c478bd9Sstevel@tonic-gate /*
516*7c478bd9Sstevel@tonic-gate  * enum clnt_stat
517*7c478bd9Sstevel@tonic-gate  * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
518*7c478bd9Sstevel@tonic-gate  * 	CLIENT *rh;
519*7c478bd9Sstevel@tonic-gate  *	rpcproc_t proc;
520*7c478bd9Sstevel@tonic-gate  *	xdrproc_t xargs;
521*7c478bd9Sstevel@tonic-gate  *	caddr_t argsp;
522*7c478bd9Sstevel@tonic-gate  *	xdrproc_t xres;
523*7c478bd9Sstevel@tonic-gate  *	caddr_t resp;
524*7c478bd9Sstevel@tonic-gate  *	struct timeval timeout;
525*7c478bd9Sstevel@tonic-gate  *
526*7c478bd9Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
527*7c478bd9Sstevel@tonic-gate  * CLNT_CALL
528*7c478bd9Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
529*7c478bd9Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
530*7c478bd9Sstevel@tonic-gate  */
531*7c478bd9Sstevel@tonic-gate #define	CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs)	\
532*7c478bd9Sstevel@tonic-gate 	((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
533*7c478bd9Sstevel@tonic-gate #define	clnt_call(rh, proc, xargs, argsp, xres, resp, secs)	\
534*7c478bd9Sstevel@tonic-gate 	((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
535*7c478bd9Sstevel@tonic-gate 
536*7c478bd9Sstevel@tonic-gate #ifndef _KERNEL
537*7c478bd9Sstevel@tonic-gate /*
538*7c478bd9Sstevel@tonic-gate  * enum clnt_stat
539*7c478bd9Sstevel@tonic-gate  * CLNT_SEND(rh, proc, xargs, argsp)
540*7c478bd9Sstevel@tonic-gate  * 	CLIENT *rh;
541*7c478bd9Sstevel@tonic-gate  *	rpcproc_t proc;
542*7c478bd9Sstevel@tonic-gate  *	xdrproc_t xargs;
543*7c478bd9Sstevel@tonic-gate  *	caddr_t argsp;
544*7c478bd9Sstevel@tonic-gate  *
545*7c478bd9Sstevel@tonic-gate  * PSARC 2000/428  Contract Private Interface
546*7c478bd9Sstevel@tonic-gate  */
547*7c478bd9Sstevel@tonic-gate #define	CLNT_SEND(rh, proc, xargs, argsp)	\
548*7c478bd9Sstevel@tonic-gate 	((*(rh)->cl_ops->cl_send)(rh, proc, xargs, argsp))
549*7c478bd9Sstevel@tonic-gate #define	clnt_send(rh, proc, xargs, argsp)	\
550*7c478bd9Sstevel@tonic-gate 	((*(rh)->cl_ops->cl_send)(rh, proc, xargs, argsp))
551*7c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */
552*7c478bd9Sstevel@tonic-gate 
553*7c478bd9Sstevel@tonic-gate /*
554*7c478bd9Sstevel@tonic-gate  * void
555*7c478bd9Sstevel@tonic-gate  * CLNT_ABORT(rh);
556*7c478bd9Sstevel@tonic-gate  * 	CLIENT *rh;
557*7c478bd9Sstevel@tonic-gate  */
558*7c478bd9Sstevel@tonic-gate #define	CLNT_ABORT(rh)	((*(rh)->cl_ops->cl_abort)(rh))
559*7c478bd9Sstevel@tonic-gate #define	clnt_abort(rh)	((*(rh)->cl_ops->cl_abort)(rh))
560*7c478bd9Sstevel@tonic-gate 
561*7c478bd9Sstevel@tonic-gate /*
562*7c478bd9Sstevel@tonic-gate  * struct rpc_err
563*7c478bd9Sstevel@tonic-gate  * CLNT_GETERR(rh);
564*7c478bd9Sstevel@tonic-gate  * 	CLIENT *rh;
565*7c478bd9Sstevel@tonic-gate  */
566*7c478bd9Sstevel@tonic-gate #define	CLNT_GETERR(rh, errp)	((*(rh)->cl_ops->cl_geterr)(rh, errp))
567*7c478bd9Sstevel@tonic-gate #define	clnt_geterr(rh, errp)	((*(rh)->cl_ops->cl_geterr)(rh, errp))
568*7c478bd9Sstevel@tonic-gate 
569*7c478bd9Sstevel@tonic-gate /*
570*7c478bd9Sstevel@tonic-gate  * bool_t
571*7c478bd9Sstevel@tonic-gate  * CLNT_FREERES(rh, xres, resp);
572*7c478bd9Sstevel@tonic-gate  * 	CLIENT *rh;
573*7c478bd9Sstevel@tonic-gate  *	xdrproc_t xres;
574*7c478bd9Sstevel@tonic-gate  *	caddr_t resp;
575*7c478bd9Sstevel@tonic-gate  */
576*7c478bd9Sstevel@tonic-gate #define	CLNT_FREERES(rh, xres, resp) \
577*7c478bd9Sstevel@tonic-gate 		((*(rh)->cl_ops->cl_freeres)(rh, xres, resp))
578*7c478bd9Sstevel@tonic-gate #define	clnt_freeres(rh, xres, resp) \
579*7c478bd9Sstevel@tonic-gate 		((*(rh)->cl_ops->cl_freeres)(rh, xres, resp))
580*7c478bd9Sstevel@tonic-gate 
581*7c478bd9Sstevel@tonic-gate /*
582*7c478bd9Sstevel@tonic-gate  * bool_t
583*7c478bd9Sstevel@tonic-gate  * CLNT_CONTROL(cl, request, info)
584*7c478bd9Sstevel@tonic-gate  *	CLIENT *cl;
585*7c478bd9Sstevel@tonic-gate  *	uint_t request;
586*7c478bd9Sstevel@tonic-gate  *	char *info;
587*7c478bd9Sstevel@tonic-gate  *
588*7c478bd9Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
589*7c478bd9Sstevel@tonic-gate  * CLNT_CONTROL
590*7c478bd9Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
591*7c478bd9Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
592*7c478bd9Sstevel@tonic-gate  */
593*7c478bd9Sstevel@tonic-gate #define	CLNT_CONTROL(cl, rq, in) ((*(cl)->cl_ops->cl_control)(cl, rq, in))
594*7c478bd9Sstevel@tonic-gate #define	clnt_control(cl, rq, in) ((*(cl)->cl_ops->cl_control)(cl, rq, in))
595*7c478bd9Sstevel@tonic-gate 
596*7c478bd9Sstevel@tonic-gate 
597*7c478bd9Sstevel@tonic-gate /*
598*7c478bd9Sstevel@tonic-gate  * control operations that apply to all transports
599*7c478bd9Sstevel@tonic-gate  */
600*7c478bd9Sstevel@tonic-gate #define	CLSET_TIMEOUT		1	/* set timeout (timeval) */
601*7c478bd9Sstevel@tonic-gate #define	CLGET_TIMEOUT		2	/* get timeout (timeval) */
602*7c478bd9Sstevel@tonic-gate #define	CLGET_SERVER_ADDR	3	/* get server's address (sockaddr) */
603*7c478bd9Sstevel@tonic-gate #define	CLGET_FD		6	/* get connections file descriptor */
604*7c478bd9Sstevel@tonic-gate #define	CLGET_SVC_ADDR		7	/* get server's address (netbuf) */
605*7c478bd9Sstevel@tonic-gate #define	CLSET_FD_CLOSE		8	/* close fd while clnt_destroy */
606*7c478bd9Sstevel@tonic-gate #define	CLSET_FD_NCLOSE		9	/* Do not close fd while clnt_destroy */
607*7c478bd9Sstevel@tonic-gate #define	CLGET_XID 		10	/* Get xid */
608*7c478bd9Sstevel@tonic-gate #define	CLSET_XID		11	/* Set xid */
609*7c478bd9Sstevel@tonic-gate #define	CLGET_VERS		12	/* Get version number */
610*7c478bd9Sstevel@tonic-gate #define	CLSET_VERS		13	/* Set version number */
611*7c478bd9Sstevel@tonic-gate #define	CLGET_PROG		14	/* Get program number */
612*7c478bd9Sstevel@tonic-gate #define	CLSET_PROG		15	/* Set program number */
613*7c478bd9Sstevel@tonic-gate #define	CLSET_SVC_ADDR		16	/* get server's address (netbuf) */
614*7c478bd9Sstevel@tonic-gate #define	CLSET_PUSH_TIMOD	17	/* push timod if not already present */
615*7c478bd9Sstevel@tonic-gate #define	CLSET_POP_TIMOD		18	/* pop timod */
616*7c478bd9Sstevel@tonic-gate #ifndef _KERNEL
617*7c478bd9Sstevel@tonic-gate /* 00-08-17 - NON STANDARD CONTROL PARAMETER */
618*7c478bd9Sstevel@tonic-gate #define	CLSET_IO_MODE		19	/* clnt_send behavior */
619*7c478bd9Sstevel@tonic-gate #define	CLGET_IO_MODE		20	/* clnt_send behavior */
620*7c478bd9Sstevel@tonic-gate #define	CLSET_FLUSH_MODE	21	/* flush behavior */
621*7c478bd9Sstevel@tonic-gate #define	CLGET_FLUSH_MODE	22	/* flush behavior */
622*7c478bd9Sstevel@tonic-gate #define	CLFLUSH			23	/* flush now (user wants it) */
623*7c478bd9Sstevel@tonic-gate #define	CLSET_CONNMAXREC_SIZE	24	/* set pending request buffer size */
624*7c478bd9Sstevel@tonic-gate #define	CLGET_CONNMAXREC_SIZE	25	/* set pending request buffer size */
625*7c478bd9Sstevel@tonic-gate #define	CLGET_CURRENT_REC_SIZE	26	/* get pending request buffer size */
626*7c478bd9Sstevel@tonic-gate 
627*7c478bd9Sstevel@tonic-gate typedef enum {
628*7c478bd9Sstevel@tonic-gate 	RPC_CL_BESTEFFORT_FLUSH = 100,	/* flush as much as possible */
629*7c478bd9Sstevel@tonic-gate 					/* without blocking */
630*7c478bd9Sstevel@tonic-gate 	RPC_CL_BLOCKING_FLUSH,		/* flush the buffer completely */
631*7c478bd9Sstevel@tonic-gate 					/* (possibly blocking) */
632*7c478bd9Sstevel@tonic-gate 	RPC_CL_DEFAULT_FLUSH		/* flush according to the currently */
633*7c478bd9Sstevel@tonic-gate 					/* defined policy. */
634*7c478bd9Sstevel@tonic-gate } rpcflushmode_t;
635*7c478bd9Sstevel@tonic-gate 
636*7c478bd9Sstevel@tonic-gate 
637*7c478bd9Sstevel@tonic-gate typedef enum {
638*7c478bd9Sstevel@tonic-gate 	RPC_CL_BLOCKING = 10,	/* PASSED CLNT_CONTROL SET_IO_MODE */
639*7c478bd9Sstevel@tonic-gate 	RPC_CL_NONBLOCKING
640*7c478bd9Sstevel@tonic-gate } rpciomode_t;
641*7c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */
642*7c478bd9Sstevel@tonic-gate /*
643*7c478bd9Sstevel@tonic-gate  * Connectionless only control operations
644*7c478bd9Sstevel@tonic-gate  */
645*7c478bd9Sstevel@tonic-gate #define	CLSET_RETRY_TIMEOUT 4   /* set retry timeout (timeval) */
646*7c478bd9Sstevel@tonic-gate #define	CLGET_RETRY_TIMEOUT 5   /* get retry timeout (timeval) */
647*7c478bd9Sstevel@tonic-gate 
648*7c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
649*7c478bd9Sstevel@tonic-gate /*
650*7c478bd9Sstevel@tonic-gate  * Connection oriented only control operation.
651*7c478bd9Sstevel@tonic-gate  */
652*7c478bd9Sstevel@tonic-gate #define	CLSET_PROGRESS		10000	/* Report RPC_INPROGRESS if a request */
653*7c478bd9Sstevel@tonic-gate 					/* has been sent but no reply */
654*7c478bd9Sstevel@tonic-gate 					/* received yet. */
655*7c478bd9Sstevel@tonic-gate #define	CLSET_BCAST		10001	/* Set RPC Broadcast hint */
656*7c478bd9Sstevel@tonic-gate #define	CLGET_BCAST		10002	/* Get RPC Broadcast hint */
657*7c478bd9Sstevel@tonic-gate #define	CLSET_NODELAYONERR	10003	/* Set enable/disable of delay on */
658*7c478bd9Sstevel@tonic-gate 					/* connection setup error	  */
659*7c478bd9Sstevel@tonic-gate #define	CLGET_NODELAYONERR	10004	/* Get enable/disable of delay on */
660*7c478bd9Sstevel@tonic-gate 					/* connection setup error	  */
661*7c478bd9Sstevel@tonic-gate #define	CLSET_BINDRESVPORT	10005	/* Set preference for reserve port */
662*7c478bd9Sstevel@tonic-gate #define	CLGET_BINDRESVPORT	10006	/* Get preference for reserve port */
663*7c478bd9Sstevel@tonic-gate #endif
664*7c478bd9Sstevel@tonic-gate 
665*7c478bd9Sstevel@tonic-gate /*
666*7c478bd9Sstevel@tonic-gate  * void
667*7c478bd9Sstevel@tonic-gate  * CLNT_SETTIMERS(rh);
668*7c478bd9Sstevel@tonic-gate  *	CLIENT *rh;
669*7c478bd9Sstevel@tonic-gate  *	struct rpc_timers *t;
670*7c478bd9Sstevel@tonic-gate  *	struct rpc_timers *all;
671*7c478bd9Sstevel@tonic-gate  *	unsigned int min;
672*7c478bd9Sstevel@tonic-gate  *	void    (*fdbck)();
673*7c478bd9Sstevel@tonic-gate  *	caddr_t arg;
674*7c478bd9Sstevel@tonic-gate  *	uint_t  xid;
675*7c478bd9Sstevel@tonic-gate  */
676*7c478bd9Sstevel@tonic-gate #define	CLNT_SETTIMERS(rh, t, all, min, fdbck, arg, xid) \
677*7c478bd9Sstevel@tonic-gate 		((*(rh)->cl_ops->cl_settimers)(rh, t, all, min, \
678*7c478bd9Sstevel@tonic-gate 		fdbck, arg, xid))
679*7c478bd9Sstevel@tonic-gate #define	clnt_settimers(rh, t, all, min, fdbck, arg, xid) \
680*7c478bd9Sstevel@tonic-gate 		((*(rh)->cl_ops->cl_settimers)(rh, t, all, min, \
681*7c478bd9Sstevel@tonic-gate 		fdbck, arg, xid))
682*7c478bd9Sstevel@tonic-gate 
683*7c478bd9Sstevel@tonic-gate 
684*7c478bd9Sstevel@tonic-gate /*
685*7c478bd9Sstevel@tonic-gate  * void
686*7c478bd9Sstevel@tonic-gate  * CLNT_DESTROY(rh);
687*7c478bd9Sstevel@tonic-gate  * 	CLIENT *rh;
688*7c478bd9Sstevel@tonic-gate  *
689*7c478bd9Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
690*7c478bd9Sstevel@tonic-gate  * CLNT_DESTROY
691*7c478bd9Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
692*7c478bd9Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
693*7c478bd9Sstevel@tonic-gate  */
694*7c478bd9Sstevel@tonic-gate #define	CLNT_DESTROY(rh)	((*(rh)->cl_ops->cl_destroy)(rh))
695*7c478bd9Sstevel@tonic-gate #define	clnt_destroy(rh)	((*(rh)->cl_ops->cl_destroy)(rh))
696*7c478bd9Sstevel@tonic-gate 
697*7c478bd9Sstevel@tonic-gate 
698*7c478bd9Sstevel@tonic-gate /*
699*7c478bd9Sstevel@tonic-gate  * RPCTEST is a test program which is accessable on every rpc
700*7c478bd9Sstevel@tonic-gate  * transport/port.  It is used for testing, performance evaluation,
701*7c478bd9Sstevel@tonic-gate  * and network administration.
702*7c478bd9Sstevel@tonic-gate  */
703*7c478bd9Sstevel@tonic-gate 
704*7c478bd9Sstevel@tonic-gate #define	RPCTEST_PROGRAM		((rpcprog_t)1)
705*7c478bd9Sstevel@tonic-gate #define	RPCTEST_VERSION		((rpcvers_t)1)
706*7c478bd9Sstevel@tonic-gate #define	RPCTEST_NULL_PROC	((rpcproc_t)2)
707*7c478bd9Sstevel@tonic-gate #define	RPCTEST_NULL_BATCH_PROC	((rpcproc_t)3)
708*7c478bd9Sstevel@tonic-gate 
709*7c478bd9Sstevel@tonic-gate /*
710*7c478bd9Sstevel@tonic-gate  * By convention, procedure 0 takes null arguments and returns them
711*7c478bd9Sstevel@tonic-gate  */
712*7c478bd9Sstevel@tonic-gate 
713*7c478bd9Sstevel@tonic-gate #define	NULLPROC ((rpcproc_t)0)
714*7c478bd9Sstevel@tonic-gate 
715*7c478bd9Sstevel@tonic-gate /*
716*7c478bd9Sstevel@tonic-gate  * Below are the client handle creation routines for the various
717*7c478bd9Sstevel@tonic-gate  * implementations of client side rpc.  They can return NULL if a
718*7c478bd9Sstevel@tonic-gate  * creation failure occurs.
719*7c478bd9Sstevel@tonic-gate  */
720*7c478bd9Sstevel@tonic-gate 
721*7c478bd9Sstevel@tonic-gate #ifndef _KERNEL
722*7c478bd9Sstevel@tonic-gate 
723*7c478bd9Sstevel@tonic-gate /*
724*7c478bd9Sstevel@tonic-gate  * Generic client creation routine. Supported protocols are which belong
725*7c478bd9Sstevel@tonic-gate  * to the nettype name space
726*7c478bd9Sstevel@tonic-gate  */
727*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
728*7c478bd9Sstevel@tonic-gate extern  CLIENT * clnt_create(const char *, const rpcprog_t, const rpcvers_t,
729*7c478bd9Sstevel@tonic-gate 	const char *);
730*7c478bd9Sstevel@tonic-gate /*
731*7c478bd9Sstevel@tonic-gate  *
732*7c478bd9Sstevel@tonic-gate  * 	const char *hostname;			-- hostname
733*7c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;			-- program number
734*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;			-- version number
735*7c478bd9Sstevel@tonic-gate  *	const char *nettype;			-- network type
736*7c478bd9Sstevel@tonic-gate  */
737*7c478bd9Sstevel@tonic-gate #else
738*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_create();
739*7c478bd9Sstevel@tonic-gate #endif
740*7c478bd9Sstevel@tonic-gate 
741*7c478bd9Sstevel@tonic-gate /*
742*7c478bd9Sstevel@tonic-gate  * Generic client creation routine. Just like clnt_create(), except
743*7c478bd9Sstevel@tonic-gate  * it takes an additional timeout parameter.
744*7c478bd9Sstevel@tonic-gate  */
745*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
746*7c478bd9Sstevel@tonic-gate extern  CLIENT * clnt_create_timed(const char *, const rpcprog_t,
747*7c478bd9Sstevel@tonic-gate 	const rpcvers_t, const char *, const struct timeval *);
748*7c478bd9Sstevel@tonic-gate /*
749*7c478bd9Sstevel@tonic-gate  *
750*7c478bd9Sstevel@tonic-gate  * 	const char *hostname;			-- hostname
751*7c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;			-- program number
752*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;			-- version number
753*7c478bd9Sstevel@tonic-gate  *	const char *nettype;			-- network type
754*7c478bd9Sstevel@tonic-gate  *	const struct timeval *tp;		-- timeout
755*7c478bd9Sstevel@tonic-gate  */
756*7c478bd9Sstevel@tonic-gate #else
757*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_create_timed();
758*7c478bd9Sstevel@tonic-gate #endif
759*7c478bd9Sstevel@tonic-gate 
760*7c478bd9Sstevel@tonic-gate /*
761*7c478bd9Sstevel@tonic-gate  * Generic client creation routine. Supported protocols are which belong
762*7c478bd9Sstevel@tonic-gate  * to the nettype name space.
763*7c478bd9Sstevel@tonic-gate  */
764*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
765*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_create_vers(const char *, const rpcprog_t, rpcvers_t *,
766*7c478bd9Sstevel@tonic-gate 	const rpcvers_t, const rpcvers_t, const char *);
767*7c478bd9Sstevel@tonic-gate /*
768*7c478bd9Sstevel@tonic-gate  *	const char *host;		-- hostname
769*7c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;		-- program number
770*7c478bd9Sstevel@tonic-gate  *	rpcvers_t *vers_out;	-- servers highest available version number
771*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers_low;	-- low version number
772*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers_high;	-- high version number
773*7c478bd9Sstevel@tonic-gate  *	const char *nettype;		-- network type
774*7c478bd9Sstevel@tonic-gate  */
775*7c478bd9Sstevel@tonic-gate #else
776*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_create_vers();
777*7c478bd9Sstevel@tonic-gate #endif
778*7c478bd9Sstevel@tonic-gate 
779*7c478bd9Sstevel@tonic-gate /*
780*7c478bd9Sstevel@tonic-gate  * Generic client creation routine. Supported protocols are which belong
781*7c478bd9Sstevel@tonic-gate  * to the nettype name space.
782*7c478bd9Sstevel@tonic-gate  */
783*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
784*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_create_vers_timed(const char *, const rpcprog_t,
785*7c478bd9Sstevel@tonic-gate 	rpcvers_t *, const rpcvers_t, const rpcvers_t, const char *,
786*7c478bd9Sstevel@tonic-gate 	const struct timeval *);
787*7c478bd9Sstevel@tonic-gate /*
788*7c478bd9Sstevel@tonic-gate  *	const char *host;		-- hostname
789*7c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;		-- program number
790*7c478bd9Sstevel@tonic-gate  *	rpcvers_t *vers_out;	-- servers highest available version number
791*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers_low;	-- low version number
792*7c478bd9Sstevel@tonic-gate  *	const prcvers_t vers_high;	-- high version number
793*7c478bd9Sstevel@tonic-gate  *	const char *nettype;		-- network type
794*7c478bd9Sstevel@tonic-gate  *	const struct timeval *tp	-- timeout
795*7c478bd9Sstevel@tonic-gate  */
796*7c478bd9Sstevel@tonic-gate #else
797*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_create_vers_timed();
798*7c478bd9Sstevel@tonic-gate #endif
799*7c478bd9Sstevel@tonic-gate 
800*7c478bd9Sstevel@tonic-gate 
801*7c478bd9Sstevel@tonic-gate /*
802*7c478bd9Sstevel@tonic-gate  * Generic client creation routine. It takes a netconfig structure
803*7c478bd9Sstevel@tonic-gate  * instead of nettype
804*7c478bd9Sstevel@tonic-gate  */
805*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
806*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_tp_create(const char *, const rpcprog_t, const rpcvers_t,
807*7c478bd9Sstevel@tonic-gate 	const struct netconfig *);
808*7c478bd9Sstevel@tonic-gate /*
809*7c478bd9Sstevel@tonic-gate  *	const char *hostname;			-- hostname
810*7c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;			-- program number
811*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;			-- version number
812*7c478bd9Sstevel@tonic-gate  *	const struct netconfig *netconf; 	-- network config structure
813*7c478bd9Sstevel@tonic-gate  */
814*7c478bd9Sstevel@tonic-gate #else
815*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_tp_create();
816*7c478bd9Sstevel@tonic-gate #endif
817*7c478bd9Sstevel@tonic-gate 
818*7c478bd9Sstevel@tonic-gate /*
819*7c478bd9Sstevel@tonic-gate  * Generic client creation routine. Just like clnt_tp_create(), except
820*7c478bd9Sstevel@tonic-gate  * it takes an additional timeout parameter.
821*7c478bd9Sstevel@tonic-gate  */
822*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
823*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_tp_create_timed(const char *, const rpcprog_t,
824*7c478bd9Sstevel@tonic-gate 	const rpcvers_t, const struct netconfig *, const struct timeval *);
825*7c478bd9Sstevel@tonic-gate /*
826*7c478bd9Sstevel@tonic-gate  *	const char *hostname;			-- hostname
827*7c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;			-- program number
828*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;			-- version number
829*7c478bd9Sstevel@tonic-gate  *	const struct netconfig *netconf; 	-- network config structure
830*7c478bd9Sstevel@tonic-gate  *	const struct timeval *tp;		-- timeout
831*7c478bd9Sstevel@tonic-gate  */
832*7c478bd9Sstevel@tonic-gate #else
833*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_tp_create_timed();
834*7c478bd9Sstevel@tonic-gate #endif
835*7c478bd9Sstevel@tonic-gate 
836*7c478bd9Sstevel@tonic-gate /*
837*7c478bd9Sstevel@tonic-gate  * Generic TLI create routine
838*7c478bd9Sstevel@tonic-gate  */
839*7c478bd9Sstevel@tonic-gate 
840*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
841*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_tli_create(const int, const struct netconfig *,
842*7c478bd9Sstevel@tonic-gate 	struct netbuf *, const rpcprog_t, const rpcvers_t, const uint_t,
843*7c478bd9Sstevel@tonic-gate 	const uint_t);
844*7c478bd9Sstevel@tonic-gate /*
845*7c478bd9Sstevel@tonic-gate  *	const int fd;		-- fd
846*7c478bd9Sstevel@tonic-gate  *	const struct netconfig *nconf;	-- netconfig structure
847*7c478bd9Sstevel@tonic-gate  *	struct netbuf *svcaddr;		-- servers address
848*7c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;		-- program number
849*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;		-- version number
850*7c478bd9Sstevel@tonic-gate  *	const uint_t sendsz;		-- send size
851*7c478bd9Sstevel@tonic-gate  *	const uint_t recvsz;		-- recv size
852*7c478bd9Sstevel@tonic-gate  */
853*7c478bd9Sstevel@tonic-gate 
854*7c478bd9Sstevel@tonic-gate #else
855*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_tli_create();
856*7c478bd9Sstevel@tonic-gate #endif
857*7c478bd9Sstevel@tonic-gate 
858*7c478bd9Sstevel@tonic-gate /*
859*7c478bd9Sstevel@tonic-gate  * Low level clnt create routine for connectionful transports, e.g. tcp.
860*7c478bd9Sstevel@tonic-gate  */
861*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
862*7c478bd9Sstevel@tonic-gate extern  CLIENT * clnt_vc_create(const int, struct netbuf *,
863*7c478bd9Sstevel@tonic-gate 	const rpcprog_t, const rpcvers_t, const uint_t, const uint_t);
864*7c478bd9Sstevel@tonic-gate /*
865*7c478bd9Sstevel@tonic-gate  *	const int fd;				-- open file descriptor
866*7c478bd9Sstevel@tonic-gate  *	const struct netbuf *svcaddr;		-- servers address
867*7c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;			-- program number
868*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;			-- version number
869*7c478bd9Sstevel@tonic-gate  *	const uint_t sendsz;			-- buffer recv size
870*7c478bd9Sstevel@tonic-gate  *	const uint_t recvsz;			-- buffer send size
871*7c478bd9Sstevel@tonic-gate  */
872*7c478bd9Sstevel@tonic-gate #else
873*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_vc_create();
874*7c478bd9Sstevel@tonic-gate #endif
875*7c478bd9Sstevel@tonic-gate 
876*7c478bd9Sstevel@tonic-gate /*
877*7c478bd9Sstevel@tonic-gate  * Low level clnt create routine for connectionless transports, e.g. udp.
878*7c478bd9Sstevel@tonic-gate  */
879*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
880*7c478bd9Sstevel@tonic-gate extern  CLIENT * clnt_dg_create(const int, struct netbuf *,
881*7c478bd9Sstevel@tonic-gate 	const rpcprog_t, const rpcvers_t, const uint_t, const uint_t);
882*7c478bd9Sstevel@tonic-gate /*
883*7c478bd9Sstevel@tonic-gate  *	const int fd;				-- open file descriptor
884*7c478bd9Sstevel@tonic-gate  *	const struct netbuf *svcaddr;		-- servers address
885*7c478bd9Sstevel@tonic-gate  *	const rpcprog_t program;		-- program number
886*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t version;		-- version number
887*7c478bd9Sstevel@tonic-gate  *	const uint_t sendsz;			-- buffer recv size
888*7c478bd9Sstevel@tonic-gate  *	const uint_t recvsz;			-- buffer send size
889*7c478bd9Sstevel@tonic-gate  */
890*7c478bd9Sstevel@tonic-gate #else
891*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_dg_create();
892*7c478bd9Sstevel@tonic-gate #endif
893*7c478bd9Sstevel@tonic-gate 
894*7c478bd9Sstevel@tonic-gate /*
895*7c478bd9Sstevel@tonic-gate  * Memory based rpc (for speed check and testing)
896*7c478bd9Sstevel@tonic-gate  * CLIENT *
897*7c478bd9Sstevel@tonic-gate  * clnt_raw_create(prog, vers)
898*7c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;			-- program number
899*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;			-- version number
900*7c478bd9Sstevel@tonic-gate  */
901*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
902*7c478bd9Sstevel@tonic-gate extern CLIENT *clnt_raw_create(const rpcprog_t, const rpcvers_t);
903*7c478bd9Sstevel@tonic-gate #else
904*7c478bd9Sstevel@tonic-gate extern CLIENT *clnt_raw_create();
905*7c478bd9Sstevel@tonic-gate #endif
906*7c478bd9Sstevel@tonic-gate 
907*7c478bd9Sstevel@tonic-gate /*
908*7c478bd9Sstevel@tonic-gate  * Client creation routine over doors transport.
909*7c478bd9Sstevel@tonic-gate  */
910*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
911*7c478bd9Sstevel@tonic-gate extern  CLIENT * clnt_door_create(const rpcprog_t, const rpcvers_t,
912*7c478bd9Sstevel@tonic-gate 	const uint_t);
913*7c478bd9Sstevel@tonic-gate /*
914*7c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;			-- program number
915*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;			-- version number
916*7c478bd9Sstevel@tonic-gate  *	const uint_t sendsz;			-- max send size
917*7c478bd9Sstevel@tonic-gate  */
918*7c478bd9Sstevel@tonic-gate #else
919*7c478bd9Sstevel@tonic-gate extern CLIENT * clnt_door_create();
920*7c478bd9Sstevel@tonic-gate #endif
921*7c478bd9Sstevel@tonic-gate 
922*7c478bd9Sstevel@tonic-gate /*
923*7c478bd9Sstevel@tonic-gate  * internal function. Not for general use. Subject to rapid change.
924*7c478bd9Sstevel@tonic-gate  */
925*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
926*7c478bd9Sstevel@tonic-gate extern CLIENT *clnt_create_service_timed(const char *,
927*7c478bd9Sstevel@tonic-gate 					const char *,
928*7c478bd9Sstevel@tonic-gate 					const rpcprog_t,
929*7c478bd9Sstevel@tonic-gate 					const rpcvers_t,
930*7c478bd9Sstevel@tonic-gate 					const ushort_t,
931*7c478bd9Sstevel@tonic-gate 					const char *,
932*7c478bd9Sstevel@tonic-gate 					const struct timeval *);
933*7c478bd9Sstevel@tonic-gate #else
934*7c478bd9Sstevel@tonic-gate extern CLIENT *clnt_create_service_timed();
935*7c478bd9Sstevel@tonic-gate #endif
936*7c478bd9Sstevel@tonic-gate 
937*7c478bd9Sstevel@tonic-gate /*
938*7c478bd9Sstevel@tonic-gate  * Print why creation failed
939*7c478bd9Sstevel@tonic-gate  */
940*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
941*7c478bd9Sstevel@tonic-gate void clnt_pcreateerror(const char *);	/* stderr */
942*7c478bd9Sstevel@tonic-gate char *clnt_spcreateerror(const char *);	/* string */
943*7c478bd9Sstevel@tonic-gate #else
944*7c478bd9Sstevel@tonic-gate void clnt_pcreateerror();
945*7c478bd9Sstevel@tonic-gate char *clnt_spcreateerror();
946*7c478bd9Sstevel@tonic-gate #endif
947*7c478bd9Sstevel@tonic-gate 
948*7c478bd9Sstevel@tonic-gate /*
949*7c478bd9Sstevel@tonic-gate  * Like clnt_perror(), but is more verbose in its output
950*7c478bd9Sstevel@tonic-gate  */
951*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
952*7c478bd9Sstevel@tonic-gate void clnt_perrno(const enum clnt_stat);	/* stderr */
953*7c478bd9Sstevel@tonic-gate #else
954*7c478bd9Sstevel@tonic-gate void clnt_perrno();
955*7c478bd9Sstevel@tonic-gate #endif
956*7c478bd9Sstevel@tonic-gate 
957*7c478bd9Sstevel@tonic-gate /*
958*7c478bd9Sstevel@tonic-gate  * Print an error message, given the client error code
959*7c478bd9Sstevel@tonic-gate  */
960*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
961*7c478bd9Sstevel@tonic-gate void clnt_perror(const CLIENT *, const char *);
962*7c478bd9Sstevel@tonic-gate #else
963*7c478bd9Sstevel@tonic-gate void clnt_perror();
964*7c478bd9Sstevel@tonic-gate #endif
965*7c478bd9Sstevel@tonic-gate 
966*7c478bd9Sstevel@tonic-gate /*
967*7c478bd9Sstevel@tonic-gate  * If a creation fails, the following allows the user to figure out why.
968*7c478bd9Sstevel@tonic-gate  */
969*7c478bd9Sstevel@tonic-gate struct rpc_createerr {
970*7c478bd9Sstevel@tonic-gate 	enum clnt_stat cf_stat;
971*7c478bd9Sstevel@tonic-gate 	struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */
972*7c478bd9Sstevel@tonic-gate };
973*7c478bd9Sstevel@tonic-gate 
974*7c478bd9Sstevel@tonic-gate #ifdef	_REENTRANT
975*7c478bd9Sstevel@tonic-gate extern struct rpc_createerr	*__rpc_createerr();
976*7c478bd9Sstevel@tonic-gate #define	rpc_createerr	(*(__rpc_createerr()))
977*7c478bd9Sstevel@tonic-gate #else
978*7c478bd9Sstevel@tonic-gate extern struct rpc_createerr rpc_createerr;
979*7c478bd9Sstevel@tonic-gate #endif	/* _REENTRANT */
980*7c478bd9Sstevel@tonic-gate 
981*7c478bd9Sstevel@tonic-gate /*
982*7c478bd9Sstevel@tonic-gate  * The simplified interface:
983*7c478bd9Sstevel@tonic-gate  * enum clnt_stat
984*7c478bd9Sstevel@tonic-gate  * rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype)
985*7c478bd9Sstevel@tonic-gate  *	const char *host;
986*7c478bd9Sstevel@tonic-gate  *	const rpcprog_t prognum;
987*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t versnum;
988*7c478bd9Sstevel@tonic-gate  *	const rpcproc_t procnum;
989*7c478bd9Sstevel@tonic-gate  *	const xdrproc_t inproc, outproc;
990*7c478bd9Sstevel@tonic-gate  *	const char *in;
991*7c478bd9Sstevel@tonic-gate  *	char *out;
992*7c478bd9Sstevel@tonic-gate  *	const char *nettype;
993*7c478bd9Sstevel@tonic-gate  */
994*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
995*7c478bd9Sstevel@tonic-gate extern enum clnt_stat rpc_call(const char *, const rpcprog_t, const rpcvers_t,
996*7c478bd9Sstevel@tonic-gate 	const rpcproc_t, const xdrproc_t, const char *, const xdrproc_t,
997*7c478bd9Sstevel@tonic-gate 	char *, const char *);
998*7c478bd9Sstevel@tonic-gate #else
999*7c478bd9Sstevel@tonic-gate extern enum clnt_stat rpc_call();
1000*7c478bd9Sstevel@tonic-gate #endif
1001*7c478bd9Sstevel@tonic-gate 
1002*7c478bd9Sstevel@tonic-gate #ifdef	_REENTRANT
1003*7c478bd9Sstevel@tonic-gate extern struct rpc_err	*__rpc_callerr();
1004*7c478bd9Sstevel@tonic-gate #define	rpc_callerr	(*(__rpc_callerr()))
1005*7c478bd9Sstevel@tonic-gate #else
1006*7c478bd9Sstevel@tonic-gate extern struct rpc_err rpc_callerr;
1007*7c478bd9Sstevel@tonic-gate #endif	/* _REENTRANT */
1008*7c478bd9Sstevel@tonic-gate 
1009*7c478bd9Sstevel@tonic-gate /*
1010*7c478bd9Sstevel@tonic-gate  * RPC broadcast interface
1011*7c478bd9Sstevel@tonic-gate  * The call is broadcasted to all locally connected nets.
1012*7c478bd9Sstevel@tonic-gate  *
1013*7c478bd9Sstevel@tonic-gate  * extern enum clnt_stat
1014*7c478bd9Sstevel@tonic-gate  * rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp,
1015*7c478bd9Sstevel@tonic-gate  *			eachresult, nettype)
1016*7c478bd9Sstevel@tonic-gate  *	const rpcprog_t		prog;		-- program number
1017*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t		vers;		-- version number
1018*7c478bd9Sstevel@tonic-gate  *	const rpcproc_t		proc;		-- procedure number
1019*7c478bd9Sstevel@tonic-gate  *	const xdrproc_t	xargs;		-- xdr routine for args
1020*7c478bd9Sstevel@tonic-gate  *	caddr_t		argsp;		-- pointer to args
1021*7c478bd9Sstevel@tonic-gate  *	const xdrproc_t	xresults;	-- xdr routine for results
1022*7c478bd9Sstevel@tonic-gate  *	caddr_t		resultsp;	-- pointer to results
1023*7c478bd9Sstevel@tonic-gate  *	const resultproc_t	eachresult;	-- call with each result
1024*7c478bd9Sstevel@tonic-gate  *	const char		*nettype;	-- Transport type
1025*7c478bd9Sstevel@tonic-gate  *
1026*7c478bd9Sstevel@tonic-gate  * For each valid response received, the procedure eachresult is called.
1027*7c478bd9Sstevel@tonic-gate  * Its form is:
1028*7c478bd9Sstevel@tonic-gate  *		done = eachresult(resp, raddr, nconf)
1029*7c478bd9Sstevel@tonic-gate  *			bool_t done;
1030*7c478bd9Sstevel@tonic-gate  *			caddr_t resp;
1031*7c478bd9Sstevel@tonic-gate  *			struct netbuf *raddr;
1032*7c478bd9Sstevel@tonic-gate  *			struct netconfig *nconf;
1033*7c478bd9Sstevel@tonic-gate  * where resp points to the results of the call and raddr is the
1034*7c478bd9Sstevel@tonic-gate  * address if the responder to the broadcast.  nconf is the transport
1035*7c478bd9Sstevel@tonic-gate  * on which the response was received.
1036*7c478bd9Sstevel@tonic-gate  *
1037*7c478bd9Sstevel@tonic-gate  * extern enum clnt_stat
1038*7c478bd9Sstevel@tonic-gate  * rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
1039*7c478bd9Sstevel@tonic-gate  *			eachresult, inittime, waittime, nettype)
1040*7c478bd9Sstevel@tonic-gate  *	const rpcprog_t		prog;		-- program number
1041*7c478bd9Sstevel@tonic-gate  *	const rpcvers_t		vers;		-- version number
1042*7c478bd9Sstevel@tonic-gate  *	const rpcproc_t		proc;		-- procedure number
1043*7c478bd9Sstevel@tonic-gate  *	const xdrproc_t	xargs;		-- xdr routine for args
1044*7c478bd9Sstevel@tonic-gate  *	caddr_t		argsp;		-- pointer to args
1045*7c478bd9Sstevel@tonic-gate  *	const xdrproc_t	xresults;	-- xdr routine for results
1046*7c478bd9Sstevel@tonic-gate  *	caddr_t		resultsp;	-- pointer to results
1047*7c478bd9Sstevel@tonic-gate  *	const resultproc_t	eachresult;	-- call with each result
1048*7c478bd9Sstevel@tonic-gate  *	const int 		inittime;	-- how long to wait initially
1049*7c478bd9Sstevel@tonic-gate  *	const int 		waittime;	-- maximum time to wait
1050*7c478bd9Sstevel@tonic-gate  *	const char		*nettype;	-- Transport type
1051*7c478bd9Sstevel@tonic-gate  */
1052*7c478bd9Sstevel@tonic-gate 
1053*7c478bd9Sstevel@tonic-gate typedef bool_t(*resultproc_t)(
1054*7c478bd9Sstevel@tonic-gate #ifdef	__STDC__
1055*7c478bd9Sstevel@tonic-gate 	caddr_t,
1056*7c478bd9Sstevel@tonic-gate 	... /* for backward compatibility */
1057*7c478bd9Sstevel@tonic-gate #endif				/* __STDC__ */
1058*7c478bd9Sstevel@tonic-gate );
1059*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
1060*7c478bd9Sstevel@tonic-gate extern enum clnt_stat rpc_broadcast(const rpcprog_t, const rpcvers_t,
1061*7c478bd9Sstevel@tonic-gate 	const rpcproc_t, const xdrproc_t, caddr_t, const xdrproc_t,
1062*7c478bd9Sstevel@tonic-gate 	caddr_t, const resultproc_t, const char *);
1063*7c478bd9Sstevel@tonic-gate extern enum clnt_stat rpc_broadcast_exp(const rpcprog_t, const rpcvers_t,
1064*7c478bd9Sstevel@tonic-gate 	const rpcproc_t, const xdrproc_t, caddr_t, const xdrproc_t, caddr_t,
1065*7c478bd9Sstevel@tonic-gate 	const resultproc_t, const int, const int, const char *);
1066*7c478bd9Sstevel@tonic-gate #else
1067*7c478bd9Sstevel@tonic-gate extern enum clnt_stat rpc_broadcast();
1068*7c478bd9Sstevel@tonic-gate extern enum clnt_stat rpc_broadcast_exp();
1069*7c478bd9Sstevel@tonic-gate #endif
1070*7c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */
1071*7c478bd9Sstevel@tonic-gate 
1072*7c478bd9Sstevel@tonic-gate /*
1073*7c478bd9Sstevel@tonic-gate  * Copy error message to buffer.
1074*7c478bd9Sstevel@tonic-gate  */
1075*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
1076*7c478bd9Sstevel@tonic-gate const char *clnt_sperrno(const enum clnt_stat);
1077*7c478bd9Sstevel@tonic-gate #else
1078*7c478bd9Sstevel@tonic-gate char *clnt_sperrno();	/* string */
1079*7c478bd9Sstevel@tonic-gate #endif
1080*7c478bd9Sstevel@tonic-gate 
1081*7c478bd9Sstevel@tonic-gate /*
1082*7c478bd9Sstevel@tonic-gate  * Print an error message, given the client error code
1083*7c478bd9Sstevel@tonic-gate  */
1084*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
1085*7c478bd9Sstevel@tonic-gate char *clnt_sperror(const CLIENT *, const char *);
1086*7c478bd9Sstevel@tonic-gate #else
1087*7c478bd9Sstevel@tonic-gate char *clnt_sperror();
1088*7c478bd9Sstevel@tonic-gate #endif
1089*7c478bd9Sstevel@tonic-gate 
1090*7c478bd9Sstevel@tonic-gate /*
1091*7c478bd9Sstevel@tonic-gate  * Client side rpc control routine for rpcbind.
1092*7c478bd9Sstevel@tonic-gate  */
1093*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
1094*7c478bd9Sstevel@tonic-gate bool_t __rpc_control(int, void *);
1095*7c478bd9Sstevel@tonic-gate #else
1096*7c478bd9Sstevel@tonic-gate bool_t __rpc_control();
1097*7c478bd9Sstevel@tonic-gate #endif
1098*7c478bd9Sstevel@tonic-gate 
1099*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1100*7c478bd9Sstevel@tonic-gate }
1101*7c478bd9Sstevel@tonic-gate #endif
1102*7c478bd9Sstevel@tonic-gate 
1103*7c478bd9Sstevel@tonic-gate #ifdef PORTMAP
1104*7c478bd9Sstevel@tonic-gate /* For backward compatibility */
1105*7c478bd9Sstevel@tonic-gate #include <rpc/clnt_soc.h>
1106*7c478bd9Sstevel@tonic-gate #endif
1107*7c478bd9Sstevel@tonic-gate 
1108*7c478bd9Sstevel@tonic-gate #endif	/* !_RPC_CLNT_H */
1109