xref: /illumos-gate/usr/src/uts/common/rpc/clnt.h (revision 28a15eaa)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
58ffff9fdSgt  * Common Development and Distribution License (the "License").
68ffff9fdSgt  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*28a15eaaSMarcel Telka  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
267c478bd9Sstevel@tonic-gate /* All Rights Reserved */
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley
297c478bd9Sstevel@tonic-gate  * 4.3 BSD under license from the Regents of the University of
307c478bd9Sstevel@tonic-gate  * California.
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*
347c478bd9Sstevel@tonic-gate  * clnt.h - Client side remote procedure call interface.
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifndef	_RPC_CLNT_H
387c478bd9Sstevel@tonic-gate #define	_RPC_CLNT_H
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #include <sys/types.h>
417c478bd9Sstevel@tonic-gate #include <rpc/rpc_com.h>
427c478bd9Sstevel@tonic-gate #include <rpc/clnt_stat.h>
437c478bd9Sstevel@tonic-gate #include <rpc/auth.h>
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * rpc calls return an enum clnt_stat.  This should be looked at more,
477c478bd9Sstevel@tonic-gate  * since each implementation is required to live with this (implementation
487c478bd9Sstevel@tonic-gate  * independent) list of errors.
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate #include <sys/netconfig.h>
517c478bd9Sstevel@tonic-gate #ifdef _KERNEL
527c478bd9Sstevel@tonic-gate #include <sys/t_kuser.h>
537c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate #ifdef __cplusplus
567c478bd9Sstevel@tonic-gate extern "C" {
577c478bd9Sstevel@tonic-gate #endif
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate /*
607c478bd9Sstevel@tonic-gate  * Following defines the multicast group address used by IPV6 enabled
617c478bd9Sstevel@tonic-gate  * client to do the broadcast. IPv6 doesn't have any broadcast support
627c478bd9Sstevel@tonic-gate  * as IPv4 provides, thus it used this reserved address which is joined
637c478bd9Sstevel@tonic-gate  * by all rpc clients.
647c478bd9Sstevel@tonic-gate  */
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate #define	RPCB_MULTICAST_ADDR "FF02::202"
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate /*
697c478bd9Sstevel@tonic-gate  * the following errors are in general unrecoverable.  The caller
707c478bd9Sstevel@tonic-gate  * should give up rather than retry.
717c478bd9Sstevel@tonic-gate  */
727c478bd9Sstevel@tonic-gate #define	IS_UNRECOVERABLE_RPC(s)	(((s) == RPC_AUTHERROR) || \
737c478bd9Sstevel@tonic-gate 	((s) == RPC_CANTENCODEARGS) || \
747c478bd9Sstevel@tonic-gate 	((s) == RPC_CANTDECODERES) || \
757c478bd9Sstevel@tonic-gate 	((s) == RPC_VERSMISMATCH) || \
767c478bd9Sstevel@tonic-gate 	((s) == RPC_PROCUNAVAIL) || \
777c478bd9Sstevel@tonic-gate 	((s) == RPC_PROGUNAVAIL) || \
787c478bd9Sstevel@tonic-gate 	((s) == RPC_PROGVERSMISMATCH) || \
790a701b1eSRobert Gordon 	((s) == RPC_SYSTEMERROR) || \
807c478bd9Sstevel@tonic-gate 	((s) == RPC_CANTDECODEARGS))
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /* Maximum rpc backoff time */
837c478bd9Sstevel@tonic-gate #define	RPC_MAX_BACKOFF	30
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /*
867c478bd9Sstevel@tonic-gate  * Error info.
877c478bd9Sstevel@tonic-gate  */
887c478bd9Sstevel@tonic-gate struct rpc_err {
897c478bd9Sstevel@tonic-gate 	enum clnt_stat re_status;
907c478bd9Sstevel@tonic-gate 	union {
917c478bd9Sstevel@tonic-gate 		struct {
927c478bd9Sstevel@tonic-gate 			int RE_errno;	/* related system error */
937c478bd9Sstevel@tonic-gate 			int RE_t_errno;	/* related tli error number */
947c478bd9Sstevel@tonic-gate 		} RE_err;
957c478bd9Sstevel@tonic-gate 		enum auth_stat RE_why;	/* why the auth error occurred */
967c478bd9Sstevel@tonic-gate 		struct {
977c478bd9Sstevel@tonic-gate 			rpcvers_t low;	/* lowest verion supported */
987c478bd9Sstevel@tonic-gate 			rpcvers_t high;	/* highest verion supported */
997c478bd9Sstevel@tonic-gate 		} RE_vers;
1007c478bd9Sstevel@tonic-gate 		struct {		/* maybe meaningful if RPC_FAILED */
1017c478bd9Sstevel@tonic-gate 			int32_t s1;
1027c478bd9Sstevel@tonic-gate 			int32_t s2;
1037c478bd9Sstevel@tonic-gate 		} RE_lb;		/* life boot & debugging only */
1047c478bd9Sstevel@tonic-gate 	} ru;
1057c478bd9Sstevel@tonic-gate #define	re_errno	ru.RE_err.RE_errno
1067c478bd9Sstevel@tonic-gate #define	re_terrno	ru.RE_err.RE_t_errno
1077c478bd9Sstevel@tonic-gate #define	re_why		ru.RE_why
1087c478bd9Sstevel@tonic-gate #define	re_vers		ru.RE_vers
1097c478bd9Sstevel@tonic-gate #define	re_lb		ru.RE_lb
1107c478bd9Sstevel@tonic-gate };
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate /*
1147c478bd9Sstevel@tonic-gate  * Timers used for the pseudo-transport protocol when using datagrams
1157c478bd9Sstevel@tonic-gate  */
1167c478bd9Sstevel@tonic-gate struct rpc_timers {
1177c478bd9Sstevel@tonic-gate 	clock_t		rt_srtt;	/* smoothed round-trip time */
1187c478bd9Sstevel@tonic-gate 	clock_t		rt_deviate;	/* estimated deviation */
1197c478bd9Sstevel@tonic-gate 	clock_t		rt_rtxcur;	/* current (backed-off) rto */
1207c478bd9Sstevel@tonic-gate };
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate /*
1237c478bd9Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
1247c478bd9Sstevel@tonic-gate  * CLIENT
1257c478bd9Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
1267c478bd9Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
1277c478bd9Sstevel@tonic-gate  *
1287c478bd9Sstevel@tonic-gate  * Client rpc handle.
1297c478bd9Sstevel@tonic-gate  * Created by individual implementations
1307c478bd9Sstevel@tonic-gate  * Client is responsible for initializing auth, see e.g. auth_none.c.
1317c478bd9Sstevel@tonic-gate  */
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate typedef struct __client {
1347c478bd9Sstevel@tonic-gate 	AUTH	*cl_auth;			/* authenticator */
1357c478bd9Sstevel@tonic-gate 	struct clnt_ops {
1367c478bd9Sstevel@tonic-gate #ifdef __STDC__
1377c478bd9Sstevel@tonic-gate 		/* call remote procedure */
1387c478bd9Sstevel@tonic-gate 		enum clnt_stat	(*cl_call)(struct __client *, rpcproc_t,
1397c478bd9Sstevel@tonic-gate 				    xdrproc_t, caddr_t, xdrproc_t,
1407c478bd9Sstevel@tonic-gate 				    caddr_t, struct timeval);
1417c478bd9Sstevel@tonic-gate 		/* abort a call */
1427c478bd9Sstevel@tonic-gate 		void		(*cl_abort)(/* various */);
1437c478bd9Sstevel@tonic-gate 		/* get specific error code */
1447c478bd9Sstevel@tonic-gate 		void		(*cl_geterr)(struct __client *,
1457c478bd9Sstevel@tonic-gate 				    struct rpc_err *);
1467c478bd9Sstevel@tonic-gate 		/* frees results */
1477c478bd9Sstevel@tonic-gate 		bool_t		(*cl_freeres)(struct __client *, xdrproc_t,
1487c478bd9Sstevel@tonic-gate 				    caddr_t);
1497c478bd9Sstevel@tonic-gate 		/* destroy this structure */
1507c478bd9Sstevel@tonic-gate 		void		(*cl_destroy)(struct __client *);
1517c478bd9Sstevel@tonic-gate 		/* the ioctl() of rpc */
1527c478bd9Sstevel@tonic-gate 		bool_t		(*cl_control)(struct __client *, int, char *);
1537c478bd9Sstevel@tonic-gate 		/* set rpc level timers */
1547c478bd9Sstevel@tonic-gate 		int		(*cl_settimers)(struct __client *,
1557c478bd9Sstevel@tonic-gate 				    struct rpc_timers *, struct rpc_timers *,
1567c478bd9Sstevel@tonic-gate 				    int, void (*)(), caddr_t, uint32_t);
1577c478bd9Sstevel@tonic-gate #ifndef _KERNEL
1587c478bd9Sstevel@tonic-gate 		/* send a one-way asynchronous call to remote procedure */
1597c478bd9Sstevel@tonic-gate 		enum clnt_stat	(*cl_send)(struct __client *, rpcproc_t,
1607c478bd9Sstevel@tonic-gate 				    xdrproc_t, caddr_t);
1617c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */
1627c478bd9Sstevel@tonic-gate #else
1637c478bd9Sstevel@tonic-gate 		enum clnt_stat	(*cl_call)();	/* call remote procedure */
1647c478bd9Sstevel@tonic-gate 		void		(*cl_abort)();	/* abort a call */
1657c478bd9Sstevel@tonic-gate 		void		(*cl_geterr)();	/* get specific error code */
1667c478bd9Sstevel@tonic-gate 		bool_t		(*cl_freeres)(); /* frees results */
1677c478bd9Sstevel@tonic-gate 		void		(*cl_destroy)(); /* destroy this structure */
1687c478bd9Sstevel@tonic-gate 		bool_t		(*cl_control)(); /* the ioctl() of rpc */
1697c478bd9Sstevel@tonic-gate 		int		(*cl_settimers)(); /* set rpc level timers */
1707c478bd9Sstevel@tonic-gate #ifndef _KERNEL
1717c478bd9Sstevel@tonic-gate 		enum clnt_stat  (*cl_send)();   /* send one-way request */
1727c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */
1737c478bd9Sstevel@tonic-gate #endif
1747c478bd9Sstevel@tonic-gate 	} *cl_ops;
1757c478bd9Sstevel@tonic-gate 	caddr_t			cl_private;	/* private stuff */
1767c478bd9Sstevel@tonic-gate #ifndef _KERNEL
1777c478bd9Sstevel@tonic-gate 	char			*cl_netid;	/* network token */
1787c478bd9Sstevel@tonic-gate 	char			*cl_tp;		/* device name */
1797c478bd9Sstevel@tonic-gate #else
1807c478bd9Sstevel@tonic-gate 	bool_t			cl_nosignal;  /* to handle NOINTR */
1817c478bd9Sstevel@tonic-gate #endif
1827c478bd9Sstevel@tonic-gate } CLIENT;
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate /*
1857c478bd9Sstevel@tonic-gate  * Feedback values used for possible congestion and rate control
1867c478bd9Sstevel@tonic-gate  */
1877c478bd9Sstevel@tonic-gate #define	FEEDBACK_REXMIT1	1	/* first retransmit */
1887c478bd9Sstevel@tonic-gate #define	FEEDBACK_OK		2	/* no retransmits */
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate /*
1917c478bd9Sstevel@tonic-gate  * The following defines the control routines
1927c478bd9Sstevel@tonic-gate  * for rpcbind.
1937c478bd9Sstevel@tonic-gate  */
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate #define	CLCR_GET_RPCB_TIMEOUT	1
1967c478bd9Sstevel@tonic-gate #define	CLCR_SET_RPCB_TIMEOUT	2
1977c478bd9Sstevel@tonic-gate #define	CLCR_SET_LOWVERS	3
1987c478bd9Sstevel@tonic-gate #define	CLCR_GET_LOWVERS	4
1997c478bd9Sstevel@tonic-gate #define	CLCR_SET_RPCB_RMTTIME	5
2007c478bd9Sstevel@tonic-gate #define	CLCR_GET_RPCB_RMTTIME  	6
2017c478bd9Sstevel@tonic-gate #define	CLCR_SET_CRED_CACHE_SZ 	7
2027c478bd9Sstevel@tonic-gate #define	CLCR_GET_CRED_CACHE_SZ 	8
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate #define	RPCSMALLMSGSIZE	400	/* a more reasonable packet size */
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate #define	KNC_STRSIZE	128	/* maximum length of knetconfig strings */
2077c478bd9Sstevel@tonic-gate /*
2087c478bd9Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
2097c478bd9Sstevel@tonic-gate  * knetconfig
2107c478bd9Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
2117c478bd9Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
2127c478bd9Sstevel@tonic-gate  *
2137c478bd9Sstevel@tonic-gate  * Note that the knetconfig strings can either be dynamically allocated, or
2147c478bd9Sstevel@tonic-gate  * they can be string literals.  The code that sets up the knetconfig is
2157c478bd9Sstevel@tonic-gate  * responsible for keeping track of this and freeing the strings if
2167c478bd9Sstevel@tonic-gate  * necessary when the knetconfig is destroyed.
2177c478bd9Sstevel@tonic-gate  */
2187c478bd9Sstevel@tonic-gate struct knetconfig {
2197c478bd9Sstevel@tonic-gate 	unsigned int	knc_semantics;	/* token name */
2207c478bd9Sstevel@tonic-gate 	caddr_t		knc_protofmly;	/* protocol family */
2217c478bd9Sstevel@tonic-gate 	caddr_t		knc_proto;	/* protocol */
2227c478bd9Sstevel@tonic-gate 	dev_t		knc_rdev;	/* device id */
2237c478bd9Sstevel@tonic-gate 	unsigned int	knc_unused[8];
2247c478bd9Sstevel@tonic-gate };
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32
2277c478bd9Sstevel@tonic-gate struct knetconfig32 {
2287c478bd9Sstevel@tonic-gate 	uint32_t	knc_semantics;	/* token name */
2297c478bd9Sstevel@tonic-gate 	caddr32_t	knc_protofmly;	/* protocol family */
2307c478bd9Sstevel@tonic-gate 	caddr32_t	knc_proto;	/* protocol */
2317c478bd9Sstevel@tonic-gate 	dev32_t		knc_rdev;	/* device id */
2327c478bd9Sstevel@tonic-gate 	uint32_t	knc_unused[8];
2337c478bd9Sstevel@tonic-gate };
2347c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate #ifdef _KERNEL
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate /*
2397c478bd9Sstevel@tonic-gate  * Bucket defined for the call table.  Padded out to 64 bytes so that
2407c478bd9Sstevel@tonic-gate  * false sharing won't be induced.
2417c478bd9Sstevel@tonic-gate  */
2427c478bd9Sstevel@tonic-gate typedef	union call_table {
2437c478bd9Sstevel@tonic-gate 	struct {
2447c478bd9Sstevel@tonic-gate 		struct calllist_s	*uct_call_next;
2457c478bd9Sstevel@tonic-gate 		struct calllist_s	*uct_call_prev;
2467c478bd9Sstevel@tonic-gate 		uint_t			uct_len;
2477c478bd9Sstevel@tonic-gate 		kmutex_t		uct_lock;
2487c478bd9Sstevel@tonic-gate 	} ct_s;
2497c478bd9Sstevel@tonic-gate 	char				uct_pad[64];
2507c478bd9Sstevel@tonic-gate } call_table_t;
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate /*
2537c478bd9Sstevel@tonic-gate  * Define some macros for easy access into the call table structure
2547c478bd9Sstevel@tonic-gate  */
2557c478bd9Sstevel@tonic-gate #define	ct_call_next ct_s.uct_call_next
2567c478bd9Sstevel@tonic-gate #define	ct_call_prev ct_s.uct_call_prev
2577c478bd9Sstevel@tonic-gate #define	ct_len ct_s.uct_len
2587c478bd9Sstevel@tonic-gate #define	ct_lock ct_s.uct_lock
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate /*
2617c478bd9Sstevel@tonic-gate  * List of outstanding calls awaiting replies, for COTS, CLTS
2627c478bd9Sstevel@tonic-gate  */
2637c478bd9Sstevel@tonic-gate typedef struct calllist_s {
2647c478bd9Sstevel@tonic-gate 	struct calllist_s *call_next;	/* hash chain, MUST BE FIRST */
2657c478bd9Sstevel@tonic-gate 	struct calllist_s *call_prev;
2667c478bd9Sstevel@tonic-gate 	bool_t		call_notified;
2677c478bd9Sstevel@tonic-gate 	uint_t		call_xid;	/* the xid on the call */
2687c478bd9Sstevel@tonic-gate 	uint_t		call_hash;	/* hash value */
2697c478bd9Sstevel@tonic-gate 	call_table_t	*call_bucket;	/* back pointer to bucket */
2707c478bd9Sstevel@tonic-gate 	mblk_t		*call_reply;	/* the reply to the call */
2717c478bd9Sstevel@tonic-gate 	kcondvar_t	call_cv;	/* cv to notify when reply is done */
2727c478bd9Sstevel@tonic-gate 	kmutex_t	call_lock;	/* lock for cv */
2737c478bd9Sstevel@tonic-gate 	struct rpc_err	call_err;	/* status on reply */
2747c478bd9Sstevel@tonic-gate #define	call_status call_err.re_status	/* error on reply (rep is invalid) */
2757c478bd9Sstevel@tonic-gate #define	call_reason call_err.re_errno	/* reason code on T_DISCON_IND */
2767c478bd9Sstevel@tonic-gate 	queue_t		*call_wq;	/* the write queue the call is using */
2778ffff9fdSgt 	zoneid_t	call_zoneid;	/* zoneid the call was made from */
2787c478bd9Sstevel@tonic-gate } calllist_t;
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate /*
2817c478bd9Sstevel@tonic-gate  * Define macros for call table hashing
2827c478bd9Sstevel@tonic-gate  */
2837c478bd9Sstevel@tonic-gate /*
2847c478bd9Sstevel@tonic-gate  * A simple hash function.  Due to the way XID's get allocated, this may be
2857c478bd9Sstevel@tonic-gate  * sufficient.  This hash function provides round robin bucket selection so
2867c478bd9Sstevel@tonic-gate  * that the next time a particular bucket gets picked is when there have
2877c478bd9Sstevel@tonic-gate  * been N-1 calls.  N is the number of buckets.
2887c478bd9Sstevel@tonic-gate  */
2897c478bd9Sstevel@tonic-gate #define	call_hash(xid, hashsize) \
2907c478bd9Sstevel@tonic-gate 		(xid % hashsize);
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate #define	call_table_enter(e)				\
2937c478bd9Sstevel@tonic-gate {							\
294*28a15eaaSMarcel Telka 	call_table_t *ctp = (e)->call_bucket;		\
2957c478bd9Sstevel@tonic-gate 	mutex_enter(&ctp->ct_lock);			\
2967c478bd9Sstevel@tonic-gate 	ctp->ct_len++;					\
297*28a15eaaSMarcel Telka 	(e)->call_next = ctp->ct_call_next;		\
298*28a15eaaSMarcel Telka 	(e)->call_prev = (calllist_t *)ctp;		\
299*28a15eaaSMarcel Telka 	ctp->ct_call_next->call_prev = (e);		\
300*28a15eaaSMarcel Telka 	ctp->ct_call_next = (e);			\
301*28a15eaaSMarcel Telka 	mutex_exit(&ctp->ct_lock);			\
3027c478bd9Sstevel@tonic-gate }
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate #define	call_table_remove(e)				\
3057c478bd9Sstevel@tonic-gate {							\
306*28a15eaaSMarcel Telka 	call_table_t *ctp = (e)->call_bucket;		\
3077c478bd9Sstevel@tonic-gate 	mutex_enter(&ctp->ct_lock);			\
3087c478bd9Sstevel@tonic-gate 	ctp->ct_len--;					\
309*28a15eaaSMarcel Telka 	(e)->call_prev->call_next = (e)->call_next;	\
310*28a15eaaSMarcel Telka 	(e)->call_next->call_prev = (e)->call_prev;	\
3117c478bd9Sstevel@tonic-gate 	mutex_exit(&ctp->ct_lock);			\
3127c478bd9Sstevel@tonic-gate }
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate #define	call_table_find(ctp, xid, ele)			\
3157c478bd9Sstevel@tonic-gate {							\
3167c478bd9Sstevel@tonic-gate 	calllist_t *cp;					\
317*28a15eaaSMarcel Telka 	(ele) = NULL;					\
3187c478bd9Sstevel@tonic-gate 	mutex_enter(&(ctp)->ct_lock);			\
3197c478bd9Sstevel@tonic-gate 	for (cp = (ctp)->ct_call_next;			\
320*28a15eaaSMarcel Telka 		cp != (calllist_t *)(ctp);		\
3217c478bd9Sstevel@tonic-gate 		cp = cp->call_next) {			\
322*28a15eaaSMarcel Telka 		if (cp->call_xid == (xid))		\
323*28a15eaaSMarcel Telka 			(ele) = cp;			\
3247c478bd9Sstevel@tonic-gate 	}						\
3257c478bd9Sstevel@tonic-gate }
3267c478bd9Sstevel@tonic-gate 
3277c478bd9Sstevel@tonic-gate #define	DEFAULT_MIN_HASH_SIZE	32
3287c478bd9Sstevel@tonic-gate #define	DEFAULT_HASH_SIZE	1024
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate #define	RESERVED_PORTSPACE (IPPORT_RESERVED - (IPPORT_RESERVED/2))
3317c478bd9Sstevel@tonic-gate #define	NONRESERVED_PORTSPACE (0xFFFF - IPPORT_RESERVED)
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate /*
3347c478bd9Sstevel@tonic-gate  *	Alloc_xid presents an interface which kernel RPC clients
3357c478bd9Sstevel@tonic-gate  *	should use to allocate their XIDs.  Its implementation
3367c478bd9Sstevel@tonic-gate  *	may change over time (for example, to allow sharing of
3377c478bd9Sstevel@tonic-gate  *	XIDs between the kernel and user-level applications, so
3387c478bd9Sstevel@tonic-gate  *	all XID allocation should be done by calling alloc_xid().
3397c478bd9Sstevel@tonic-gate  */
3407c478bd9Sstevel@tonic-gate extern uint32_t alloc_xid(void);
3417c478bd9Sstevel@tonic-gate 
342108322fbScarlsonj extern struct zone *rpc_zone(void);
343108322fbScarlsonj extern zoneid_t rpc_zoneid(void);
344108322fbScarlsonj 
3457c478bd9Sstevel@tonic-gate extern int clnt_tli_kcreate(struct knetconfig *config, struct netbuf *svcaddr,
3467c478bd9Sstevel@tonic-gate 	rpcprog_t, rpcvers_t, uint_t max_msgsize, int retrys,
3477c478bd9Sstevel@tonic-gate 	struct cred *cred, CLIENT **ncl);
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate extern int clnt_tli_kinit(CLIENT *h, struct knetconfig *config,
3507c478bd9Sstevel@tonic-gate 	struct netbuf *addr, uint_t max_msgsize, int retries,
3517c478bd9Sstevel@tonic-gate 	struct cred *cred);
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate extern int rpc_uaddr2port(int af, char *addr);
3547c478bd9Sstevel@tonic-gate 
3557c478bd9Sstevel@tonic-gate /*
3567c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
3577c478bd9Sstevel@tonic-gate  */
3587c478bd9Sstevel@tonic-gate extern int bindresvport(TIUSER *tiptr, struct netbuf *addr,
3597c478bd9Sstevel@tonic-gate 	struct netbuf *bound_addr, bool_t istcp);
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate /*
3627c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
3637c478bd9Sstevel@tonic-gate  */
3647c478bd9Sstevel@tonic-gate extern int clnt_clts_kcreate(struct knetconfig *config, struct netbuf *addr,
3657c478bd9Sstevel@tonic-gate 	rpcprog_t, rpcvers_t, int retries, struct cred *cred, CLIENT **cl);
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate /*
3687c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
3697c478bd9Sstevel@tonic-gate  */
3707c478bd9Sstevel@tonic-gate extern int clnt_cots_kcreate(dev_t dev, struct netbuf *addr, int family,
3717c478bd9Sstevel@tonic-gate 	rpcprog_t, rpcvers_t, uint_t max_msgsize, struct cred *cred,
3727c478bd9Sstevel@tonic-gate 	CLIENT **ncl);
3737c478bd9Sstevel@tonic-gate /*
3747c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
3757c478bd9Sstevel@tonic-gate  */
3767c478bd9Sstevel@tonic-gate extern int clnt_rdma_kcreate(char *proto, void *handle, struct netbuf *raddr,
3777c478bd9Sstevel@tonic-gate 	int family, rpcprog_t pgm, rpcvers_t vers, struct cred *cred,
3787c478bd9Sstevel@tonic-gate 	CLIENT **cl);
3797c478bd9Sstevel@tonic-gate /*
3807c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
3817c478bd9Sstevel@tonic-gate  */
3827c478bd9Sstevel@tonic-gate extern int rdma_reachable(int addr_type, struct netbuf *addr,
3837c478bd9Sstevel@tonic-gate 	struct knetconfig **knconf);
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate /*
3867c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
3877c478bd9Sstevel@tonic-gate  */
3887c478bd9Sstevel@tonic-gate extern void clnt_clts_kinit(CLIENT *h, struct netbuf *addr, int retries,
3897c478bd9Sstevel@tonic-gate 	struct cred *cred);
3907c478bd9Sstevel@tonic-gate 
3917c478bd9Sstevel@tonic-gate /*
3927c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
3937c478bd9Sstevel@tonic-gate  */
3947c478bd9Sstevel@tonic-gate extern void clnt_cots_kinit(CLIENT *h, dev_t dev, int family,
3957c478bd9Sstevel@tonic-gate 	struct netbuf *addr, int max_msgsize, struct cred *cred);
3967c478bd9Sstevel@tonic-gate 
3977c478bd9Sstevel@tonic-gate /*
3987c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
3997c478bd9Sstevel@tonic-gate  */
4007c478bd9Sstevel@tonic-gate extern void clnt_rdma_kinit(CLIENT *h, char *proto, void *handle,
4017c478bd9Sstevel@tonic-gate 	struct netbuf *addr, struct cred *cred);
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate /*
4047c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
4057c478bd9Sstevel@tonic-gate  */
4067c478bd9Sstevel@tonic-gate extern bool_t clnt_dispatch_notify(mblk_t *, zoneid_t);
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate /*
4097c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
4107c478bd9Sstevel@tonic-gate  */
4117c478bd9Sstevel@tonic-gate extern bool_t clnt_dispatch_notifyconn(queue_t *, mblk_t *);
4127c478bd9Sstevel@tonic-gate 
4137c478bd9Sstevel@tonic-gate /*
4147c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
4157c478bd9Sstevel@tonic-gate  */
4167c478bd9Sstevel@tonic-gate extern void clnt_dispatch_notifyall(queue_t *, int32_t, int32_t);
4177c478bd9Sstevel@tonic-gate 
4187c478bd9Sstevel@tonic-gate /*
4197c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
4207c478bd9Sstevel@tonic-gate  */
4217c478bd9Sstevel@tonic-gate extern enum clnt_stat clnt_clts_kcallit_addr(CLIENT *, rpcproc_t, xdrproc_t,
4227c478bd9Sstevel@tonic-gate 	caddr_t, xdrproc_t, caddr_t, struct timeval, struct netbuf *);
4237c478bd9Sstevel@tonic-gate 
4247c478bd9Sstevel@tonic-gate /*
4257c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
4267c478bd9Sstevel@tonic-gate  */
4277c478bd9Sstevel@tonic-gate extern call_table_t *call_table_init(int);
4287c478bd9Sstevel@tonic-gate 
4297c478bd9Sstevel@tonic-gate /*
4307c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
4317c478bd9Sstevel@tonic-gate  */
4327c478bd9Sstevel@tonic-gate extern void clnt_init(void);
4337c478bd9Sstevel@tonic-gate 
4347c478bd9Sstevel@tonic-gate /*
4357c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
4367c478bd9Sstevel@tonic-gate  */
4377c478bd9Sstevel@tonic-gate extern void clnt_fini(void);
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate /*
4407c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
4417c478bd9Sstevel@tonic-gate  */
4427c478bd9Sstevel@tonic-gate extern void clnt_clts_init(void);
4437c478bd9Sstevel@tonic-gate 
4447c478bd9Sstevel@tonic-gate /*
4457c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
4467c478bd9Sstevel@tonic-gate  */
4477c478bd9Sstevel@tonic-gate extern void clnt_clts_fini(void);
4487c478bd9Sstevel@tonic-gate 
4497c478bd9Sstevel@tonic-gate /*
4507c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
4517c478bd9Sstevel@tonic-gate  */
4527c478bd9Sstevel@tonic-gate extern void clnt_cots_init(void);
4537c478bd9Sstevel@tonic-gate 
4547c478bd9Sstevel@tonic-gate /*
4557c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
4567c478bd9Sstevel@tonic-gate  */
4577c478bd9Sstevel@tonic-gate extern void clnt_cots_fini(void);
4587c478bd9Sstevel@tonic-gate 
4597c478bd9Sstevel@tonic-gate /*
4607c478bd9Sstevel@tonic-gate  * kRPC internal function. Not for general use. Subject to rapid change.
4617c478bd9Sstevel@tonic-gate  */
4627c478bd9Sstevel@tonic-gate extern void clnt_clts_dispatch_notify(mblk_t *, int, zoneid_t);
4637c478bd9Sstevel@tonic-gate 
4647c478bd9Sstevel@tonic-gate extern void rpc_poptimod(struct vnode *);
4657c478bd9Sstevel@tonic-gate extern int kstr_push(struct vnode *, char *);
4667c478bd9Sstevel@tonic-gate extern void t_kadvise(TIUSER *, uchar_t *, int);
4677c478bd9Sstevel@tonic-gate 
4687c478bd9Sstevel@tonic-gate extern boolean_t connmgr_cpr_reset(void *, int);
4697c478bd9Sstevel@tonic-gate 
4707c478bd9Sstevel@tonic-gate extern void put_inet_port(struct netbuf *, ushort_t);
4717c478bd9Sstevel@tonic-gate extern void put_inet6_port(struct netbuf *, ushort_t);
4727c478bd9Sstevel@tonic-gate extern void put_loopback_port(struct netbuf *, char *);
4737c478bd9Sstevel@tonic-gate extern enum clnt_stat rpcbind_getaddr(struct knetconfig *, rpcprog_t,
4747c478bd9Sstevel@tonic-gate     rpcvers_t, struct netbuf *);
4757c478bd9Sstevel@tonic-gate 
4767c478bd9Sstevel@tonic-gate /*
4777c478bd9Sstevel@tonic-gate  * Kstat stuff
4787c478bd9Sstevel@tonic-gate  */
4797c478bd9Sstevel@tonic-gate #include <sys/zone.h>
4807c478bd9Sstevel@tonic-gate 
4817c478bd9Sstevel@tonic-gate extern zone_key_t rpcstat_zone_key;
4827c478bd9Sstevel@tonic-gate 
4837c478bd9Sstevel@tonic-gate struct rpc_clts_client;		/* unix:0:rpc_clts_client */
4847c478bd9Sstevel@tonic-gate struct rpc_clts_server;		/* unix:0:rpc_clts_server */
4857c478bd9Sstevel@tonic-gate struct rpc_cots_client;		/* unix:0:rpc_cots_client */
4867c478bd9Sstevel@tonic-gate struct rpc_cots_server;		/* unix:0:rpc_cots_server */
4877c478bd9Sstevel@tonic-gate 
4887c478bd9Sstevel@tonic-gate struct rpcstat {
4897c478bd9Sstevel@tonic-gate 	struct rpc_clts_client *rpc_clts_client;
4907c478bd9Sstevel@tonic-gate 	struct rpc_clts_server *rpc_clts_server;
4917c478bd9Sstevel@tonic-gate 	struct rpc_cots_client *rpc_cots_client;
4927c478bd9Sstevel@tonic-gate 	struct rpc_cots_server *rpc_cots_server;
4937c478bd9Sstevel@tonic-gate };
4947c478bd9Sstevel@tonic-gate 
4957c478bd9Sstevel@tonic-gate extern kstat_named_t *rpcstat_zone_init_common(zoneid_t, const char *,
4967c478bd9Sstevel@tonic-gate     const char *, const kstat_named_t *, size_t);
4977c478bd9Sstevel@tonic-gate extern void rpcstat_zone_fini_common(zoneid_t, const char *, const char *);
4987c478bd9Sstevel@tonic-gate 
4997c478bd9Sstevel@tonic-gate extern void clnt_clts_stats_init(zoneid_t, struct rpc_clts_client **);
5007c478bd9Sstevel@tonic-gate extern void clnt_clts_stats_fini(zoneid_t, struct rpc_clts_client **);
5017c478bd9Sstevel@tonic-gate 
5027c478bd9Sstevel@tonic-gate extern void svc_clts_stats_init(zoneid_t, struct rpc_clts_server **);
5037c478bd9Sstevel@tonic-gate extern void svc_clts_stats_fini(zoneid_t, struct rpc_clts_server **);
5047c478bd9Sstevel@tonic-gate 
5057c478bd9Sstevel@tonic-gate extern void clnt_cots_stats_init(zoneid_t, struct rpc_cots_client **);
5067c478bd9Sstevel@tonic-gate extern void clnt_cots_stats_fini(zoneid_t, struct rpc_cots_client **);
5077c478bd9Sstevel@tonic-gate 
5087c478bd9Sstevel@tonic-gate extern void svc_cots_stats_init(zoneid_t, struct rpc_cots_server **);
5097c478bd9Sstevel@tonic-gate extern void svc_cots_stats_fini(zoneid_t, struct rpc_cots_server **);
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
5127c478bd9Sstevel@tonic-gate 
5137c478bd9Sstevel@tonic-gate /*
5147c478bd9Sstevel@tonic-gate  * client side rpc interface ops
5157c478bd9Sstevel@tonic-gate  */
5167c478bd9Sstevel@tonic-gate 
5177c478bd9Sstevel@tonic-gate /*
5187c478bd9Sstevel@tonic-gate  * enum clnt_stat
5197c478bd9Sstevel@tonic-gate  * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
5207c478bd9Sstevel@tonic-gate  * 	CLIENT *rh;
5217c478bd9Sstevel@tonic-gate  *	rpcproc_t proc;
5227c478bd9Sstevel@tonic-gate  *	xdrproc_t xargs;
5237c478bd9Sstevel@tonic-gate  *	caddr_t argsp;
5247c478bd9Sstevel@tonic-gate  *	xdrproc_t xres;
5257c478bd9Sstevel@tonic-gate  *	caddr_t resp;
5267c478bd9Sstevel@tonic-gate  *	struct timeval timeout;
5277c478bd9Sstevel@tonic-gate  *
5287c478bd9Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
5297c478bd9Sstevel@tonic-gate  * CLNT_CALL
5307c478bd9Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
5317c478bd9Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
5327c478bd9Sstevel@tonic-gate  */
5337c478bd9Sstevel@tonic-gate #define	CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs)	\
5347c478bd9Sstevel@tonic-gate 	((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
5357c478bd9Sstevel@tonic-gate #define	clnt_call(rh, proc, xargs, argsp, xres, resp, secs)	\
5367c478bd9Sstevel@tonic-gate 	((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
5377c478bd9Sstevel@tonic-gate 
5387c478bd9Sstevel@tonic-gate #ifndef _KERNEL
5397c478bd9Sstevel@tonic-gate /*
5407c478bd9Sstevel@tonic-gate  * enum clnt_stat
5417c478bd9Sstevel@tonic-gate  * CLNT_SEND(rh, proc, xargs, argsp)
5427c478bd9Sstevel@tonic-gate  * 	CLIENT *rh;
5437c478bd9Sstevel@tonic-gate  *	rpcproc_t proc;
5447c478bd9Sstevel@tonic-gate  *	xdrproc_t xargs;
5457c478bd9Sstevel@tonic-gate  *	caddr_t argsp;
5467c478bd9Sstevel@tonic-gate  *
5477c478bd9Sstevel@tonic-gate  * PSARC 2000/428  Contract Private Interface
5487c478bd9Sstevel@tonic-gate  */
5497c478bd9Sstevel@tonic-gate #define	CLNT_SEND(rh, proc, xargs, argsp)	\
5507c478bd9Sstevel@tonic-gate 	((*(rh)->cl_ops->cl_send)(rh, proc, xargs, argsp))
5517c478bd9Sstevel@tonic-gate #define	clnt_send(rh, proc, xargs, argsp)	\
5527c478bd9Sstevel@tonic-gate 	((*(rh)->cl_ops->cl_send)(rh, proc, xargs, argsp))
5537c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */
5547c478bd9Sstevel@tonic-gate 
5557c478bd9Sstevel@tonic-gate /*
5567c478bd9Sstevel@tonic-gate  * void
5577c478bd9Sstevel@tonic-gate  * CLNT_ABORT(rh);
5587c478bd9Sstevel@tonic-gate  * 	CLIENT *rh;
5597c478bd9Sstevel@tonic-gate  */
5607c478bd9Sstevel@tonic-gate #define	CLNT_ABORT(rh)	((*(rh)->cl_ops->cl_abort)(rh))
5617c478bd9Sstevel@tonic-gate #define	clnt_abort(rh)	((*(rh)->cl_ops->cl_abort)(rh))
5627c478bd9Sstevel@tonic-gate 
5637c478bd9Sstevel@tonic-gate /*
5647c478bd9Sstevel@tonic-gate  * struct rpc_err
5657c478bd9Sstevel@tonic-gate  * CLNT_GETERR(rh);
5667c478bd9Sstevel@tonic-gate  * 	CLIENT *rh;
5677c478bd9Sstevel@tonic-gate  */
5687c478bd9Sstevel@tonic-gate #define	CLNT_GETERR(rh, errp)	((*(rh)->cl_ops->cl_geterr)(rh, errp))
5697c478bd9Sstevel@tonic-gate #define	clnt_geterr(rh, errp)	((*(rh)->cl_ops->cl_geterr)(rh, errp))
5707c478bd9Sstevel@tonic-gate 
5717c478bd9Sstevel@tonic-gate /*
5727c478bd9Sstevel@tonic-gate  * bool_t
5737c478bd9Sstevel@tonic-gate  * CLNT_FREERES(rh, xres, resp);
5747c478bd9Sstevel@tonic-gate  * 	CLIENT *rh;
5757c478bd9Sstevel@tonic-gate  *	xdrproc_t xres;
5767c478bd9Sstevel@tonic-gate  *	caddr_t resp;
5777c478bd9Sstevel@tonic-gate  */
5787c478bd9Sstevel@tonic-gate #define	CLNT_FREERES(rh, xres, resp) \
5797c478bd9Sstevel@tonic-gate 		((*(rh)->cl_ops->cl_freeres)(rh, xres, resp))
5807c478bd9Sstevel@tonic-gate #define	clnt_freeres(rh, xres, resp) \
5817c478bd9Sstevel@tonic-gate 		((*(rh)->cl_ops->cl_freeres)(rh, xres, resp))
5827c478bd9Sstevel@tonic-gate 
5837c478bd9Sstevel@tonic-gate /*
5847c478bd9Sstevel@tonic-gate  * bool_t
5857c478bd9Sstevel@tonic-gate  * CLNT_CONTROL(cl, request, info)
5867c478bd9Sstevel@tonic-gate  *	CLIENT *cl;
5877c478bd9Sstevel@tonic-gate  *	uint_t request;
5887c478bd9Sstevel@tonic-gate  *	char *info;
5897c478bd9Sstevel@tonic-gate  *
5907c478bd9Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
5917c478bd9Sstevel@tonic-gate  * CLNT_CONTROL
5927c478bd9Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
5937c478bd9Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
5947c478bd9Sstevel@tonic-gate  */
5957c478bd9Sstevel@tonic-gate #define	CLNT_CONTROL(cl, rq, in) ((*(cl)->cl_ops->cl_control)(cl, rq, in))
5967c478bd9Sstevel@tonic-gate #define	clnt_control(cl, rq, in) ((*(cl)->cl_ops->cl_control)(cl, rq, in))
5977c478bd9Sstevel@tonic-gate 
5987c478bd9Sstevel@tonic-gate 
5997c478bd9Sstevel@tonic-gate /*
6007c478bd9Sstevel@tonic-gate  * control operations that apply to all transports
6017c478bd9Sstevel@tonic-gate  */
6027c478bd9Sstevel@tonic-gate #define	CLSET_TIMEOUT		1	/* set timeout (timeval) */
6037c478bd9Sstevel@tonic-gate #define	CLGET_TIMEOUT		2	/* get timeout (timeval) */
6047c478bd9Sstevel@tonic-gate #define	CLGET_SERVER_ADDR	3	/* get server's address (sockaddr) */
6057c478bd9Sstevel@tonic-gate #define	CLGET_FD		6	/* get connections file descriptor */
6067c478bd9Sstevel@tonic-gate #define	CLGET_SVC_ADDR		7	/* get server's address (netbuf) */
6077c478bd9Sstevel@tonic-gate #define	CLSET_FD_CLOSE		8	/* close fd while clnt_destroy */
6087c478bd9Sstevel@tonic-gate #define	CLSET_FD_NCLOSE		9	/* Do not close fd while clnt_destroy */
6097c478bd9Sstevel@tonic-gate #define	CLGET_XID 		10	/* Get xid */
6107c478bd9Sstevel@tonic-gate #define	CLSET_XID		11	/* Set xid */
6117c478bd9Sstevel@tonic-gate #define	CLGET_VERS		12	/* Get version number */
6127c478bd9Sstevel@tonic-gate #define	CLSET_VERS		13	/* Set version number */
6137c478bd9Sstevel@tonic-gate #define	CLGET_PROG		14	/* Get program number */
6147c478bd9Sstevel@tonic-gate #define	CLSET_PROG		15	/* Set program number */
6157c478bd9Sstevel@tonic-gate #define	CLSET_SVC_ADDR		16	/* get server's address (netbuf) */
6167c478bd9Sstevel@tonic-gate #define	CLSET_PUSH_TIMOD	17	/* push timod if not already present */
6177c478bd9Sstevel@tonic-gate #define	CLSET_POP_TIMOD		18	/* pop timod */
6187c478bd9Sstevel@tonic-gate #ifndef _KERNEL
6197c478bd9Sstevel@tonic-gate /* 00-08-17 - NON STANDARD CONTROL PARAMETER */
6207c478bd9Sstevel@tonic-gate #define	CLSET_IO_MODE		19	/* clnt_send behavior */
6217c478bd9Sstevel@tonic-gate #define	CLGET_IO_MODE		20	/* clnt_send behavior */
6227c478bd9Sstevel@tonic-gate #define	CLSET_FLUSH_MODE	21	/* flush behavior */
6237c478bd9Sstevel@tonic-gate #define	CLGET_FLUSH_MODE	22	/* flush behavior */
6247c478bd9Sstevel@tonic-gate #define	CLFLUSH			23	/* flush now (user wants it) */
6257c478bd9Sstevel@tonic-gate #define	CLSET_CONNMAXREC_SIZE	24	/* set pending request buffer size */
6267c478bd9Sstevel@tonic-gate #define	CLGET_CONNMAXREC_SIZE	25	/* set pending request buffer size */
6277c478bd9Sstevel@tonic-gate #define	CLGET_CURRENT_REC_SIZE	26	/* get pending request buffer size */
6287c478bd9Sstevel@tonic-gate 
6297c478bd9Sstevel@tonic-gate typedef enum {
6307c478bd9Sstevel@tonic-gate 	RPC_CL_BESTEFFORT_FLUSH = 100,	/* flush as much as possible */
6317c478bd9Sstevel@tonic-gate 					/* without blocking */
6327c478bd9Sstevel@tonic-gate 	RPC_CL_BLOCKING_FLUSH,		/* flush the buffer completely */
6337c478bd9Sstevel@tonic-gate 					/* (possibly blocking) */
6347c478bd9Sstevel@tonic-gate 	RPC_CL_DEFAULT_FLUSH		/* flush according to the currently */
6357c478bd9Sstevel@tonic-gate 					/* defined policy. */
6367c478bd9Sstevel@tonic-gate } rpcflushmode_t;
6377c478bd9Sstevel@tonic-gate 
6387c478bd9Sstevel@tonic-gate 
6397c478bd9Sstevel@tonic-gate typedef enum {
6407c478bd9Sstevel@tonic-gate 	RPC_CL_BLOCKING = 10,	/* PASSED CLNT_CONTROL SET_IO_MODE */
6417c478bd9Sstevel@tonic-gate 	RPC_CL_NONBLOCKING
6427c478bd9Sstevel@tonic-gate } rpciomode_t;
6437c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */
6447c478bd9Sstevel@tonic-gate /*
6457c478bd9Sstevel@tonic-gate  * Connectionless only control operations
6467c478bd9Sstevel@tonic-gate  */
6477c478bd9Sstevel@tonic-gate #define	CLSET_RETRY_TIMEOUT 4   /* set retry timeout (timeval) */
6487c478bd9Sstevel@tonic-gate #define	CLGET_RETRY_TIMEOUT 5   /* get retry timeout (timeval) */
6497c478bd9Sstevel@tonic-gate 
6507c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
6517c478bd9Sstevel@tonic-gate /*
6527c478bd9Sstevel@tonic-gate  * Connection oriented only control operation.
6537c478bd9Sstevel@tonic-gate  */
6547c478bd9Sstevel@tonic-gate #define	CLSET_PROGRESS		10000	/* Report RPC_INPROGRESS if a request */
6557c478bd9Sstevel@tonic-gate 					/* has been sent but no reply */
6567c478bd9Sstevel@tonic-gate 					/* received yet. */
6577c478bd9Sstevel@tonic-gate #define	CLSET_BCAST		10001	/* Set RPC Broadcast hint */
6587c478bd9Sstevel@tonic-gate #define	CLGET_BCAST		10002	/* Get RPC Broadcast hint */
6597c478bd9Sstevel@tonic-gate #define	CLSET_NODELAYONERR	10003	/* Set enable/disable of delay on */
6607c478bd9Sstevel@tonic-gate 					/* connection setup error	  */
6617c478bd9Sstevel@tonic-gate #define	CLGET_NODELAYONERR	10004	/* Get enable/disable of delay on */
6627c478bd9Sstevel@tonic-gate 					/* connection setup error	  */
6637c478bd9Sstevel@tonic-gate #define	CLSET_BINDRESVPORT	10005	/* Set preference for reserve port */
6647c478bd9Sstevel@tonic-gate #define	CLGET_BINDRESVPORT	10006	/* Get preference for reserve port */
6657c478bd9Sstevel@tonic-gate #endif
6667c478bd9Sstevel@tonic-gate 
6677c478bd9Sstevel@tonic-gate /*
6687c478bd9Sstevel@tonic-gate  * void
6697c478bd9Sstevel@tonic-gate  * CLNT_SETTIMERS(rh);
6707c478bd9Sstevel@tonic-gate  *	CLIENT *rh;
6717c478bd9Sstevel@tonic-gate  *	struct rpc_timers *t;
6727c478bd9Sstevel@tonic-gate  *	struct rpc_timers *all;
6737c478bd9Sstevel@tonic-gate  *	unsigned int min;
6747c478bd9Sstevel@tonic-gate  *	void    (*fdbck)();
6757c478bd9Sstevel@tonic-gate  *	caddr_t arg;
6767c478bd9Sstevel@tonic-gate  *	uint_t  xid;
6777c478bd9Sstevel@tonic-gate  */
6787c478bd9Sstevel@tonic-gate #define	CLNT_SETTIMERS(rh, t, all, min, fdbck, arg, xid) \
6797c478bd9Sstevel@tonic-gate 		((*(rh)->cl_ops->cl_settimers)(rh, t, all, min, \
6807c478bd9Sstevel@tonic-gate 		fdbck, arg, xid))
6817c478bd9Sstevel@tonic-gate #define	clnt_settimers(rh, t, all, min, fdbck, arg, xid) \
6827c478bd9Sstevel@tonic-gate 		((*(rh)->cl_ops->cl_settimers)(rh, t, all, min, \
6837c478bd9Sstevel@tonic-gate 		fdbck, arg, xid))
6847c478bd9Sstevel@tonic-gate 
6857c478bd9Sstevel@tonic-gate 
6867c478bd9Sstevel@tonic-gate /*
6877c478bd9Sstevel@tonic-gate  * void
6887c478bd9Sstevel@tonic-gate  * CLNT_DESTROY(rh);
6897c478bd9Sstevel@tonic-gate  * 	CLIENT *rh;
6907c478bd9Sstevel@tonic-gate  *
6917c478bd9Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
6927c478bd9Sstevel@tonic-gate  * CLNT_DESTROY
6937c478bd9Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
6947c478bd9Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
6957c478bd9Sstevel@tonic-gate  */
6967c478bd9Sstevel@tonic-gate #define	CLNT_DESTROY(rh)	((*(rh)->cl_ops->cl_destroy)(rh))
6977c478bd9Sstevel@tonic-gate #define	clnt_destroy(rh)	((*(rh)->cl_ops->cl_destroy)(rh))
6987c478bd9Sstevel@tonic-gate 
6997c478bd9Sstevel@tonic-gate 
7007c478bd9Sstevel@tonic-gate /*
7017c478bd9Sstevel@tonic-gate  * RPCTEST is a test program which is accessable on every rpc
7027c478bd9Sstevel@tonic-gate  * transport/port.  It is used for testing, performance evaluation,
7037c478bd9Sstevel@tonic-gate  * and network administration.
7047c478bd9Sstevel@tonic-gate  */
7057c478bd9Sstevel@tonic-gate 
7067c478bd9Sstevel@tonic-gate #define	RPCTEST_PROGRAM		((rpcprog_t)1)
7077c478bd9Sstevel@tonic-gate #define	RPCTEST_VERSION		((rpcvers_t)1)
7087c478bd9Sstevel@tonic-gate #define	RPCTEST_NULL_PROC	((rpcproc_t)2)
7097c478bd9Sstevel@tonic-gate #define	RPCTEST_NULL_BATCH_PROC	((rpcproc_t)3)
7107c478bd9Sstevel@tonic-gate 
7117c478bd9Sstevel@tonic-gate /*
7127c478bd9Sstevel@tonic-gate  * By convention, procedure 0 takes null arguments and returns them
7137c478bd9Sstevel@tonic-gate  */
7147c478bd9Sstevel@tonic-gate 
7157c478bd9Sstevel@tonic-gate #define	NULLPROC ((rpcproc_t)0)
7167c478bd9Sstevel@tonic-gate 
7177c478bd9Sstevel@tonic-gate /*
7187c478bd9Sstevel@tonic-gate  * Below are the client handle creation routines for the various
7197c478bd9Sstevel@tonic-gate  * implementations of client side rpc.  They can return NULL if a
7207c478bd9Sstevel@tonic-gate  * creation failure occurs.
7217c478bd9Sstevel@tonic-gate  */
7227c478bd9Sstevel@tonic-gate 
7237c478bd9Sstevel@tonic-gate #ifndef _KERNEL
7247c478bd9Sstevel@tonic-gate 
7257c478bd9Sstevel@tonic-gate /*
7267c478bd9Sstevel@tonic-gate  * Generic client creation routine. Supported protocols are which belong
7277c478bd9Sstevel@tonic-gate  * to the nettype name space
7287c478bd9Sstevel@tonic-gate  */
7297c478bd9Sstevel@tonic-gate #ifdef __STDC__
7307c478bd9Sstevel@tonic-gate extern  CLIENT * clnt_create(const char *, const rpcprog_t, const rpcvers_t,
7317c478bd9Sstevel@tonic-gate 	const char *);
7327c478bd9Sstevel@tonic-gate /*
7337c478bd9Sstevel@tonic-gate  *
7347c478bd9Sstevel@tonic-gate  * 	const char *hostname;			-- hostname
7357c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;			-- program number
7367c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;			-- version number
7377c478bd9Sstevel@tonic-gate  *	const char *nettype;			-- network type
7387c478bd9Sstevel@tonic-gate  */
7397c478bd9Sstevel@tonic-gate #else
7407c478bd9Sstevel@tonic-gate extern CLIENT * clnt_create();
7417c478bd9Sstevel@tonic-gate #endif
7427c478bd9Sstevel@tonic-gate 
7437c478bd9Sstevel@tonic-gate /*
7447c478bd9Sstevel@tonic-gate  * Generic client creation routine. Just like clnt_create(), except
7457c478bd9Sstevel@tonic-gate  * it takes an additional timeout parameter.
7467c478bd9Sstevel@tonic-gate  */
7477c478bd9Sstevel@tonic-gate #ifdef __STDC__
7487c478bd9Sstevel@tonic-gate extern  CLIENT * clnt_create_timed(const char *, const rpcprog_t,
7497c478bd9Sstevel@tonic-gate 	const rpcvers_t, const char *, const struct timeval *);
7507c478bd9Sstevel@tonic-gate /*
7517c478bd9Sstevel@tonic-gate  *
7527c478bd9Sstevel@tonic-gate  * 	const char *hostname;			-- hostname
7537c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;			-- program number
7547c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;			-- version number
7557c478bd9Sstevel@tonic-gate  *	const char *nettype;			-- network type
7567c478bd9Sstevel@tonic-gate  *	const struct timeval *tp;		-- timeout
7577c478bd9Sstevel@tonic-gate  */
7587c478bd9Sstevel@tonic-gate #else
7597c478bd9Sstevel@tonic-gate extern CLIENT * clnt_create_timed();
7607c478bd9Sstevel@tonic-gate #endif
7617c478bd9Sstevel@tonic-gate 
7627c478bd9Sstevel@tonic-gate /*
7637c478bd9Sstevel@tonic-gate  * Generic client creation routine. Supported protocols are which belong
7647c478bd9Sstevel@tonic-gate  * to the nettype name space.
7657c478bd9Sstevel@tonic-gate  */
7667c478bd9Sstevel@tonic-gate #ifdef __STDC__
7677c478bd9Sstevel@tonic-gate extern CLIENT * clnt_create_vers(const char *, const rpcprog_t, rpcvers_t *,
7687c478bd9Sstevel@tonic-gate 	const rpcvers_t, const rpcvers_t, const char *);
7697c478bd9Sstevel@tonic-gate /*
7707c478bd9Sstevel@tonic-gate  *	const char *host;		-- hostname
7717c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;		-- program number
7727c478bd9Sstevel@tonic-gate  *	rpcvers_t *vers_out;	-- servers highest available version number
7737c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers_low;	-- low version number
7747c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers_high;	-- high version number
7757c478bd9Sstevel@tonic-gate  *	const char *nettype;		-- network type
7767c478bd9Sstevel@tonic-gate  */
7777c478bd9Sstevel@tonic-gate #else
7787c478bd9Sstevel@tonic-gate extern CLIENT * clnt_create_vers();
7797c478bd9Sstevel@tonic-gate #endif
7807c478bd9Sstevel@tonic-gate 
7817c478bd9Sstevel@tonic-gate /*
7827c478bd9Sstevel@tonic-gate  * Generic client creation routine. Supported protocols are which belong
7837c478bd9Sstevel@tonic-gate  * to the nettype name space.
7847c478bd9Sstevel@tonic-gate  */
7857c478bd9Sstevel@tonic-gate #ifdef __STDC__
7867c478bd9Sstevel@tonic-gate extern CLIENT * clnt_create_vers_timed(const char *, const rpcprog_t,
7877c478bd9Sstevel@tonic-gate 	rpcvers_t *, const rpcvers_t, const rpcvers_t, const char *,
7887c478bd9Sstevel@tonic-gate 	const struct timeval *);
7897c478bd9Sstevel@tonic-gate /*
7907c478bd9Sstevel@tonic-gate  *	const char *host;		-- hostname
7917c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;		-- program number
7927c478bd9Sstevel@tonic-gate  *	rpcvers_t *vers_out;	-- servers highest available version number
7937c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers_low;	-- low version number
7947c478bd9Sstevel@tonic-gate  *	const prcvers_t vers_high;	-- high version number
7957c478bd9Sstevel@tonic-gate  *	const char *nettype;		-- network type
7967c478bd9Sstevel@tonic-gate  *	const struct timeval *tp	-- timeout
7977c478bd9Sstevel@tonic-gate  */
7987c478bd9Sstevel@tonic-gate #else
7997c478bd9Sstevel@tonic-gate extern CLIENT * clnt_create_vers_timed();
8007c478bd9Sstevel@tonic-gate #endif
8017c478bd9Sstevel@tonic-gate 
8027c478bd9Sstevel@tonic-gate 
8037c478bd9Sstevel@tonic-gate /*
8047c478bd9Sstevel@tonic-gate  * Generic client creation routine. It takes a netconfig structure
8057c478bd9Sstevel@tonic-gate  * instead of nettype
8067c478bd9Sstevel@tonic-gate  */
8077c478bd9Sstevel@tonic-gate #ifdef __STDC__
8087c478bd9Sstevel@tonic-gate extern CLIENT * clnt_tp_create(const char *, const rpcprog_t, const rpcvers_t,
8097c478bd9Sstevel@tonic-gate 	const struct netconfig *);
8107c478bd9Sstevel@tonic-gate /*
8117c478bd9Sstevel@tonic-gate  *	const char *hostname;			-- hostname
8127c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;			-- program number
8137c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;			-- version number
8147c478bd9Sstevel@tonic-gate  *	const struct netconfig *netconf; 	-- network config structure
8157c478bd9Sstevel@tonic-gate  */
8167c478bd9Sstevel@tonic-gate #else
8177c478bd9Sstevel@tonic-gate extern CLIENT * clnt_tp_create();
8187c478bd9Sstevel@tonic-gate #endif
8197c478bd9Sstevel@tonic-gate 
8207c478bd9Sstevel@tonic-gate /*
8217c478bd9Sstevel@tonic-gate  * Generic client creation routine. Just like clnt_tp_create(), except
8227c478bd9Sstevel@tonic-gate  * it takes an additional timeout parameter.
8237c478bd9Sstevel@tonic-gate  */
8247c478bd9Sstevel@tonic-gate #ifdef __STDC__
8257c478bd9Sstevel@tonic-gate extern CLIENT * clnt_tp_create_timed(const char *, const rpcprog_t,
8267c478bd9Sstevel@tonic-gate 	const rpcvers_t, const struct netconfig *, const struct timeval *);
8277c478bd9Sstevel@tonic-gate /*
8287c478bd9Sstevel@tonic-gate  *	const char *hostname;			-- hostname
8297c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;			-- program number
8307c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;			-- version number
8317c478bd9Sstevel@tonic-gate  *	const struct netconfig *netconf; 	-- network config structure
8327c478bd9Sstevel@tonic-gate  *	const struct timeval *tp;		-- timeout
8337c478bd9Sstevel@tonic-gate  */
8347c478bd9Sstevel@tonic-gate #else
8357c478bd9Sstevel@tonic-gate extern CLIENT * clnt_tp_create_timed();
8367c478bd9Sstevel@tonic-gate #endif
8377c478bd9Sstevel@tonic-gate 
8387c478bd9Sstevel@tonic-gate /*
8397c478bd9Sstevel@tonic-gate  * Generic TLI create routine
8407c478bd9Sstevel@tonic-gate  */
8417c478bd9Sstevel@tonic-gate 
8427c478bd9Sstevel@tonic-gate #ifdef __STDC__
8437c478bd9Sstevel@tonic-gate extern CLIENT * clnt_tli_create(const int, const struct netconfig *,
8447c478bd9Sstevel@tonic-gate 	struct netbuf *, const rpcprog_t, const rpcvers_t, const uint_t,
8457c478bd9Sstevel@tonic-gate 	const uint_t);
8467c478bd9Sstevel@tonic-gate /*
8477c478bd9Sstevel@tonic-gate  *	const int fd;		-- fd
8487c478bd9Sstevel@tonic-gate  *	const struct netconfig *nconf;	-- netconfig structure
8497c478bd9Sstevel@tonic-gate  *	struct netbuf *svcaddr;		-- servers address
8507c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;		-- program number
8517c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;		-- version number
8527c478bd9Sstevel@tonic-gate  *	const uint_t sendsz;		-- send size
8537c478bd9Sstevel@tonic-gate  *	const uint_t recvsz;		-- recv size
8547c478bd9Sstevel@tonic-gate  */
8557c478bd9Sstevel@tonic-gate 
8567c478bd9Sstevel@tonic-gate #else
8577c478bd9Sstevel@tonic-gate extern CLIENT * clnt_tli_create();
8587c478bd9Sstevel@tonic-gate #endif
8597c478bd9Sstevel@tonic-gate 
8607c478bd9Sstevel@tonic-gate /*
8617c478bd9Sstevel@tonic-gate  * Low level clnt create routine for connectionful transports, e.g. tcp.
8627c478bd9Sstevel@tonic-gate  */
8637c478bd9Sstevel@tonic-gate #ifdef __STDC__
8647c478bd9Sstevel@tonic-gate extern  CLIENT * clnt_vc_create(const int, struct netbuf *,
8657c478bd9Sstevel@tonic-gate 	const rpcprog_t, const rpcvers_t, const uint_t, const uint_t);
8667c478bd9Sstevel@tonic-gate /*
8677c478bd9Sstevel@tonic-gate  *	const int fd;				-- open file descriptor
8687c478bd9Sstevel@tonic-gate  *	const struct netbuf *svcaddr;		-- servers address
8697c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;			-- program number
8707c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;			-- version number
8717c478bd9Sstevel@tonic-gate  *	const uint_t sendsz;			-- buffer recv size
8727c478bd9Sstevel@tonic-gate  *	const uint_t recvsz;			-- buffer send size
8737c478bd9Sstevel@tonic-gate  */
8747c478bd9Sstevel@tonic-gate #else
8757c478bd9Sstevel@tonic-gate extern CLIENT * clnt_vc_create();
8767c478bd9Sstevel@tonic-gate #endif
8777c478bd9Sstevel@tonic-gate 
8787c478bd9Sstevel@tonic-gate /*
8797c478bd9Sstevel@tonic-gate  * Low level clnt create routine for connectionless transports, e.g. udp.
8807c478bd9Sstevel@tonic-gate  */
8817c478bd9Sstevel@tonic-gate #ifdef __STDC__
8827c478bd9Sstevel@tonic-gate extern  CLIENT * clnt_dg_create(const int, struct netbuf *,
8837c478bd9Sstevel@tonic-gate 	const rpcprog_t, const rpcvers_t, const uint_t, const uint_t);
8847c478bd9Sstevel@tonic-gate /*
8857c478bd9Sstevel@tonic-gate  *	const int fd;				-- open file descriptor
8867c478bd9Sstevel@tonic-gate  *	const struct netbuf *svcaddr;		-- servers address
8877c478bd9Sstevel@tonic-gate  *	const rpcprog_t program;		-- program number
8887c478bd9Sstevel@tonic-gate  *	const rpcvers_t version;		-- version number
8897c478bd9Sstevel@tonic-gate  *	const uint_t sendsz;			-- buffer recv size
8907c478bd9Sstevel@tonic-gate  *	const uint_t recvsz;			-- buffer send size
8917c478bd9Sstevel@tonic-gate  */
8927c478bd9Sstevel@tonic-gate #else
8937c478bd9Sstevel@tonic-gate extern CLIENT * clnt_dg_create();
8947c478bd9Sstevel@tonic-gate #endif
8957c478bd9Sstevel@tonic-gate 
8967c478bd9Sstevel@tonic-gate /*
8977c478bd9Sstevel@tonic-gate  * Memory based rpc (for speed check and testing)
8987c478bd9Sstevel@tonic-gate  * CLIENT *
8997c478bd9Sstevel@tonic-gate  * clnt_raw_create(prog, vers)
9007c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;			-- program number
9017c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;			-- version number
9027c478bd9Sstevel@tonic-gate  */
9037c478bd9Sstevel@tonic-gate #ifdef __STDC__
9047c478bd9Sstevel@tonic-gate extern CLIENT *clnt_raw_create(const rpcprog_t, const rpcvers_t);
9057c478bd9Sstevel@tonic-gate #else
9067c478bd9Sstevel@tonic-gate extern CLIENT *clnt_raw_create();
9077c478bd9Sstevel@tonic-gate #endif
9087c478bd9Sstevel@tonic-gate 
9097c478bd9Sstevel@tonic-gate /*
9107c478bd9Sstevel@tonic-gate  * Client creation routine over doors transport.
9117c478bd9Sstevel@tonic-gate  */
9127c478bd9Sstevel@tonic-gate #ifdef __STDC__
9137c478bd9Sstevel@tonic-gate extern  CLIENT * clnt_door_create(const rpcprog_t, const rpcvers_t,
9147c478bd9Sstevel@tonic-gate 	const uint_t);
9157c478bd9Sstevel@tonic-gate /*
9167c478bd9Sstevel@tonic-gate  *	const rpcprog_t prog;			-- program number
9177c478bd9Sstevel@tonic-gate  *	const rpcvers_t vers;			-- version number
9187c478bd9Sstevel@tonic-gate  *	const uint_t sendsz;			-- max send size
9197c478bd9Sstevel@tonic-gate  */
9207c478bd9Sstevel@tonic-gate #else
9217c478bd9Sstevel@tonic-gate extern CLIENT * clnt_door_create();
9227c478bd9Sstevel@tonic-gate #endif
9237c478bd9Sstevel@tonic-gate 
9247c478bd9Sstevel@tonic-gate /*
9257c478bd9Sstevel@tonic-gate  * internal function. Not for general use. Subject to rapid change.
9267c478bd9Sstevel@tonic-gate  */
9277c478bd9Sstevel@tonic-gate #ifdef __STDC__
9287c478bd9Sstevel@tonic-gate extern CLIENT *clnt_create_service_timed(const char *,
9297c478bd9Sstevel@tonic-gate 					const char *,
9307c478bd9Sstevel@tonic-gate 					const rpcprog_t,
9317c478bd9Sstevel@tonic-gate 					const rpcvers_t,
9327c478bd9Sstevel@tonic-gate 					const ushort_t,
9337c478bd9Sstevel@tonic-gate 					const char *,
9347c478bd9Sstevel@tonic-gate 					const struct timeval *);
9357c478bd9Sstevel@tonic-gate #else
9367c478bd9Sstevel@tonic-gate extern CLIENT *clnt_create_service_timed();
9377c478bd9Sstevel@tonic-gate #endif
9387c478bd9Sstevel@tonic-gate 
9397c478bd9Sstevel@tonic-gate /*
9407c478bd9Sstevel@tonic-gate  * Print why creation failed
9417c478bd9Sstevel@tonic-gate  */
9427c478bd9Sstevel@tonic-gate #ifdef __STDC__
9437c478bd9Sstevel@tonic-gate void clnt_pcreateerror(const char *);	/* stderr */
9447c478bd9Sstevel@tonic-gate char *clnt_spcreateerror(const char *);	/* string */
9457c478bd9Sstevel@tonic-gate #else
9467c478bd9Sstevel@tonic-gate void clnt_pcreateerror();
9477c478bd9Sstevel@tonic-gate char *clnt_spcreateerror();
9487c478bd9Sstevel@tonic-gate #endif
9497c478bd9Sstevel@tonic-gate 
9507c478bd9Sstevel@tonic-gate /*
9517c478bd9Sstevel@tonic-gate  * Like clnt_perror(), but is more verbose in its output
9527c478bd9Sstevel@tonic-gate  */
9537c478bd9Sstevel@tonic-gate #ifdef __STDC__
9547c478bd9Sstevel@tonic-gate void clnt_perrno(const enum clnt_stat);	/* stderr */
9557c478bd9Sstevel@tonic-gate #else
9567c478bd9Sstevel@tonic-gate void clnt_perrno();
9577c478bd9Sstevel@tonic-gate #endif
9587c478bd9Sstevel@tonic-gate 
9597c478bd9Sstevel@tonic-gate /*
9607c478bd9Sstevel@tonic-gate  * Print an error message, given the client error code
9617c478bd9Sstevel@tonic-gate  */
9627c478bd9Sstevel@tonic-gate #ifdef __STDC__
9637c478bd9Sstevel@tonic-gate void clnt_perror(const CLIENT *, const char *);
9647c478bd9Sstevel@tonic-gate #else
9657c478bd9Sstevel@tonic-gate void clnt_perror();
9667c478bd9Sstevel@tonic-gate #endif
9677c478bd9Sstevel@tonic-gate 
9687c478bd9Sstevel@tonic-gate /*
9697c478bd9Sstevel@tonic-gate  * If a creation fails, the following allows the user to figure out why.
9707c478bd9Sstevel@tonic-gate  */
9717c478bd9Sstevel@tonic-gate struct rpc_createerr {
9727c478bd9Sstevel@tonic-gate 	enum clnt_stat cf_stat;
9737c478bd9Sstevel@tonic-gate 	struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */
9747c478bd9Sstevel@tonic-gate };
9757c478bd9Sstevel@tonic-gate 
9767c478bd9Sstevel@tonic-gate #ifdef	_REENTRANT
9777c478bd9Sstevel@tonic-gate extern struct rpc_createerr	*__rpc_createerr();
9787c478bd9Sstevel@tonic-gate #define	rpc_createerr	(*(__rpc_createerr()))
9797c478bd9Sstevel@tonic-gate #else
9807c478bd9Sstevel@tonic-gate extern struct rpc_createerr rpc_createerr;
9817c478bd9Sstevel@tonic-gate #endif	/* _REENTRANT */
9827c478bd9Sstevel@tonic-gate 
9837c478bd9Sstevel@tonic-gate /*
9847c478bd9Sstevel@tonic-gate  * The simplified interface:
9857c478bd9Sstevel@tonic-gate  * enum clnt_stat
9867c478bd9Sstevel@tonic-gate  * rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype)
9877c478bd9Sstevel@tonic-gate  *	const char *host;
9887c478bd9Sstevel@tonic-gate  *	const rpcprog_t prognum;
9897c478bd9Sstevel@tonic-gate  *	const rpcvers_t versnum;
9907c478bd9Sstevel@tonic-gate  *	const rpcproc_t procnum;
9917c478bd9Sstevel@tonic-gate  *	const xdrproc_t inproc, outproc;
9927c478bd9Sstevel@tonic-gate  *	const char *in;
9937c478bd9Sstevel@tonic-gate  *	char *out;
9947c478bd9Sstevel@tonic-gate  *	const char *nettype;
9957c478bd9Sstevel@tonic-gate  */
9967c478bd9Sstevel@tonic-gate #ifdef __STDC__
9977c478bd9Sstevel@tonic-gate extern enum clnt_stat rpc_call(const char *, const rpcprog_t, const rpcvers_t,
9987c478bd9Sstevel@tonic-gate 	const rpcproc_t, const xdrproc_t, const char *, const xdrproc_t,
9997c478bd9Sstevel@tonic-gate 	char *, const char *);
10007c478bd9Sstevel@tonic-gate #else
10017c478bd9Sstevel@tonic-gate extern enum clnt_stat rpc_call();
10027c478bd9Sstevel@tonic-gate #endif
10037c478bd9Sstevel@tonic-gate 
10047c478bd9Sstevel@tonic-gate #ifdef	_REENTRANT
10057c478bd9Sstevel@tonic-gate extern struct rpc_err	*__rpc_callerr();
10067c478bd9Sstevel@tonic-gate #define	rpc_callerr	(*(__rpc_callerr()))
10077c478bd9Sstevel@tonic-gate #else
10087c478bd9Sstevel@tonic-gate extern struct rpc_err rpc_callerr;
10097c478bd9Sstevel@tonic-gate #endif	/* _REENTRANT */
10107c478bd9Sstevel@tonic-gate 
10117c478bd9Sstevel@tonic-gate /*
10127c478bd9Sstevel@tonic-gate  * RPC broadcast interface
10137c478bd9Sstevel@tonic-gate  * The call is broadcasted to all locally connected nets.
10147c478bd9Sstevel@tonic-gate  *
10157c478bd9Sstevel@tonic-gate  * extern enum clnt_stat
10167c478bd9Sstevel@tonic-gate  * rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp,
10177c478bd9Sstevel@tonic-gate  *			eachresult, nettype)
10187c478bd9Sstevel@tonic-gate  *	const rpcprog_t		prog;		-- program number
10197c478bd9Sstevel@tonic-gate  *	const rpcvers_t		vers;		-- version number
10207c478bd9Sstevel@tonic-gate  *	const rpcproc_t		proc;		-- procedure number
10217c478bd9Sstevel@tonic-gate  *	const xdrproc_t	xargs;		-- xdr routine for args
10227c478bd9Sstevel@tonic-gate  *	caddr_t		argsp;		-- pointer to args
10237c478bd9Sstevel@tonic-gate  *	const xdrproc_t	xresults;	-- xdr routine for results
10247c478bd9Sstevel@tonic-gate  *	caddr_t		resultsp;	-- pointer to results
10257c478bd9Sstevel@tonic-gate  *	const resultproc_t	eachresult;	-- call with each result
10267c478bd9Sstevel@tonic-gate  *	const char		*nettype;	-- Transport type
10277c478bd9Sstevel@tonic-gate  *
10287c478bd9Sstevel@tonic-gate  * For each valid response received, the procedure eachresult is called.
10297c478bd9Sstevel@tonic-gate  * Its form is:
10307c478bd9Sstevel@tonic-gate  *		done = eachresult(resp, raddr, nconf)
10317c478bd9Sstevel@tonic-gate  *			bool_t done;
10327c478bd9Sstevel@tonic-gate  *			caddr_t resp;
10337c478bd9Sstevel@tonic-gate  *			struct netbuf *raddr;
10347c478bd9Sstevel@tonic-gate  *			struct netconfig *nconf;
10357c478bd9Sstevel@tonic-gate  * where resp points to the results of the call and raddr is the
10367c478bd9Sstevel@tonic-gate  * address if the responder to the broadcast.  nconf is the transport
10377c478bd9Sstevel@tonic-gate  * on which the response was received.
10387c478bd9Sstevel@tonic-gate  *
10397c478bd9Sstevel@tonic-gate  * extern enum clnt_stat
10407c478bd9Sstevel@tonic-gate  * rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
10417c478bd9Sstevel@tonic-gate  *			eachresult, inittime, waittime, nettype)
10427c478bd9Sstevel@tonic-gate  *	const rpcprog_t		prog;		-- program number
10437c478bd9Sstevel@tonic-gate  *	const rpcvers_t		vers;		-- version number
10447c478bd9Sstevel@tonic-gate  *	const rpcproc_t		proc;		-- procedure number
10457c478bd9Sstevel@tonic-gate  *	const xdrproc_t	xargs;		-- xdr routine for args
10467c478bd9Sstevel@tonic-gate  *	caddr_t		argsp;		-- pointer to args
10477c478bd9Sstevel@tonic-gate  *	const xdrproc_t	xresults;	-- xdr routine for results
10487c478bd9Sstevel@tonic-gate  *	caddr_t		resultsp;	-- pointer to results
10497c478bd9Sstevel@tonic-gate  *	const resultproc_t	eachresult;	-- call with each result
10507c478bd9Sstevel@tonic-gate  *	const int 		inittime;	-- how long to wait initially
10517c478bd9Sstevel@tonic-gate  *	const int 		waittime;	-- maximum time to wait
10527c478bd9Sstevel@tonic-gate  *	const char		*nettype;	-- Transport type
10537c478bd9Sstevel@tonic-gate  */
10547c478bd9Sstevel@tonic-gate 
10557c478bd9Sstevel@tonic-gate typedef bool_t(*resultproc_t)(
10567c478bd9Sstevel@tonic-gate #ifdef	__STDC__
10577c478bd9Sstevel@tonic-gate 	caddr_t,
10587c478bd9Sstevel@tonic-gate 	... /* for backward compatibility */
10597c478bd9Sstevel@tonic-gate #endif				/* __STDC__ */
10607c478bd9Sstevel@tonic-gate );
10617c478bd9Sstevel@tonic-gate #ifdef __STDC__
10627c478bd9Sstevel@tonic-gate extern enum clnt_stat rpc_broadcast(const rpcprog_t, const rpcvers_t,
10637c478bd9Sstevel@tonic-gate 	const rpcproc_t, const xdrproc_t, caddr_t, const xdrproc_t,
10647c478bd9Sstevel@tonic-gate 	caddr_t, const resultproc_t, const char *);
10657c478bd9Sstevel@tonic-gate extern enum clnt_stat rpc_broadcast_exp(const rpcprog_t, const rpcvers_t,
10667c478bd9Sstevel@tonic-gate 	const rpcproc_t, const xdrproc_t, caddr_t, const xdrproc_t, caddr_t,
10677c478bd9Sstevel@tonic-gate 	const resultproc_t, const int, const int, const char *);
10687c478bd9Sstevel@tonic-gate #else
10697c478bd9Sstevel@tonic-gate extern enum clnt_stat rpc_broadcast();
10707c478bd9Sstevel@tonic-gate extern enum clnt_stat rpc_broadcast_exp();
10717c478bd9Sstevel@tonic-gate #endif
10727c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */
10737c478bd9Sstevel@tonic-gate 
10747c478bd9Sstevel@tonic-gate /*
10757c478bd9Sstevel@tonic-gate  * Copy error message to buffer.
10767c478bd9Sstevel@tonic-gate  */
10777c478bd9Sstevel@tonic-gate #ifdef __STDC__
10787c478bd9Sstevel@tonic-gate const char *clnt_sperrno(const enum clnt_stat);
10797c478bd9Sstevel@tonic-gate #else
10807c478bd9Sstevel@tonic-gate char *clnt_sperrno();	/* string */
10817c478bd9Sstevel@tonic-gate #endif
10827c478bd9Sstevel@tonic-gate 
10837c478bd9Sstevel@tonic-gate /*
10847c478bd9Sstevel@tonic-gate  * Print an error message, given the client error code
10857c478bd9Sstevel@tonic-gate  */
10867c478bd9Sstevel@tonic-gate #ifdef __STDC__
10877c478bd9Sstevel@tonic-gate char *clnt_sperror(const CLIENT *, const char *);
10887c478bd9Sstevel@tonic-gate #else
10897c478bd9Sstevel@tonic-gate char *clnt_sperror();
10907c478bd9Sstevel@tonic-gate #endif
10917c478bd9Sstevel@tonic-gate 
10927c478bd9Sstevel@tonic-gate /*
10937c478bd9Sstevel@tonic-gate  * Client side rpc control routine for rpcbind.
10947c478bd9Sstevel@tonic-gate  */
10957c478bd9Sstevel@tonic-gate #ifdef __STDC__
10967c478bd9Sstevel@tonic-gate bool_t __rpc_control(int, void *);
10977c478bd9Sstevel@tonic-gate #else
10987c478bd9Sstevel@tonic-gate bool_t __rpc_control();
10997c478bd9Sstevel@tonic-gate #endif
11007c478bd9Sstevel@tonic-gate 
11017c478bd9Sstevel@tonic-gate #ifdef __cplusplus
11027c478bd9Sstevel@tonic-gate }
11037c478bd9Sstevel@tonic-gate #endif
11047c478bd9Sstevel@tonic-gate 
11057c478bd9Sstevel@tonic-gate #ifdef PORTMAP
11067c478bd9Sstevel@tonic-gate /* For backward compatibility */
11077c478bd9Sstevel@tonic-gate #include <rpc/clnt_soc.h>
11087c478bd9Sstevel@tonic-gate #endif
11097c478bd9Sstevel@tonic-gate 
11107c478bd9Sstevel@tonic-gate #endif	/* !_RPC_CLNT_H */
1111