xref: /onnv-gate/usr/src/uts/common/rpc/svc.h (revision 7208:568549b138d8)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51676Sjpk  * Common Development and Distribution License (the "License").
61676Sjpk  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
226786Srmesta  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
260Sstevel@tonic-gate /* All Rights Reserved */
270Sstevel@tonic-gate /*
280Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley
290Sstevel@tonic-gate  * 4.3 BSD under license from the Regents of the University of
300Sstevel@tonic-gate  * California.
310Sstevel@tonic-gate  */
320Sstevel@tonic-gate 
330Sstevel@tonic-gate /*
340Sstevel@tonic-gate  * svc.h, Server-side remote procedure call interface.
350Sstevel@tonic-gate  */
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #ifndef	_RPC_SVC_H
380Sstevel@tonic-gate #define	_RPC_SVC_H
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #include <rpc/rpc_com.h>
430Sstevel@tonic-gate #include <rpc/rpc_msg.h>
440Sstevel@tonic-gate #include <sys/tihdr.h>
450Sstevel@tonic-gate #include <sys/poll.h>
461676Sjpk #include <sys/tsol/label.h>
470Sstevel@tonic-gate 
480Sstevel@tonic-gate #ifdef	_KERNEL
490Sstevel@tonic-gate #include <rpc/svc_auth.h>
500Sstevel@tonic-gate #include <sys/callb.h>
510Sstevel@tonic-gate #endif	/* _KERNEL */
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /*
540Sstevel@tonic-gate  * This interface must manage two items concerning remote procedure calling:
550Sstevel@tonic-gate  *
560Sstevel@tonic-gate  * 1) An arbitrary number of transport connections upon which rpc requests
570Sstevel@tonic-gate  * are received. They are created and registered by routines in svc_generic.c,
580Sstevel@tonic-gate  * svc_vc.c and svc_dg.c; they in turn call xprt_register and
590Sstevel@tonic-gate  * xprt_unregister.
600Sstevel@tonic-gate  *
610Sstevel@tonic-gate  * 2) An arbitrary number of locally registered services.  Services are
620Sstevel@tonic-gate  * described by the following four data: program number, version number,
630Sstevel@tonic-gate  * "service dispatch" function, a transport handle, and a boolean that
640Sstevel@tonic-gate  * indicates whether or not the exported program should be registered with a
650Sstevel@tonic-gate  * local binder service;  if true the program's number and version and the
660Sstevel@tonic-gate  * address from the transport handle are registered with the binder.
670Sstevel@tonic-gate  * These data are registered with rpcbind via svc_reg().
680Sstevel@tonic-gate  *
690Sstevel@tonic-gate  * A service's dispatch function is called whenever an rpc request comes in
700Sstevel@tonic-gate  * on a transport.  The request's program and version numbers must match
710Sstevel@tonic-gate  * those of the registered service.  The dispatch function is passed two
720Sstevel@tonic-gate  * parameters, struct svc_req * and SVCXPRT *, defined below.
730Sstevel@tonic-gate  */
740Sstevel@tonic-gate 
750Sstevel@tonic-gate #ifdef __cplusplus
760Sstevel@tonic-gate extern "C" {
770Sstevel@tonic-gate #endif
780Sstevel@tonic-gate 
790Sstevel@tonic-gate /*
800Sstevel@tonic-gate  * Server-side transport handles.
810Sstevel@tonic-gate  * The actual type definitions are below.
820Sstevel@tonic-gate  */
830Sstevel@tonic-gate #ifdef	_KERNEL
840Sstevel@tonic-gate typedef struct __svcmasterxprt	SVCMASTERXPRT;	/* Master transport handle */
850Sstevel@tonic-gate typedef struct __svcxprt	SVCXPRT;	/* Per-thread clone handle */
860Sstevel@tonic-gate typedef	struct __svcpool	SVCPOOL;	/* Kernel thread pool	   */
870Sstevel@tonic-gate #else	/* _KERNEL */
880Sstevel@tonic-gate typedef struct __svcxprt	SVCXPRT;	/* Server transport handle */
890Sstevel@tonic-gate #endif	/* _KERNEL */
900Sstevel@tonic-gate 
910Sstevel@tonic-gate /*
920Sstevel@tonic-gate  *  Prototype of error handler callback
930Sstevel@tonic-gate  */
940Sstevel@tonic-gate #ifndef _KERNEL
950Sstevel@tonic-gate typedef void (*svc_errorhandler_t)(const SVCXPRT* svc, const bool_t isAConn);
960Sstevel@tonic-gate #endif
970Sstevel@tonic-gate 
980Sstevel@tonic-gate /*
990Sstevel@tonic-gate  * Service request.
1000Sstevel@tonic-gate  *
1010Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
1020Sstevel@tonic-gate  * svc_req
1030Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
1040Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
1050Sstevel@tonic-gate  */
1060Sstevel@tonic-gate struct svc_req {
1070Sstevel@tonic-gate 	rpcprog_t	rq_prog;	/* service program number */
1080Sstevel@tonic-gate 	rpcvers_t	rq_vers;	/* service protocol version */
1090Sstevel@tonic-gate 	rpcproc_t	rq_proc;	/* the desired procedure */
1100Sstevel@tonic-gate 	struct opaque_auth rq_cred;	/* raw creds from the wire */
1110Sstevel@tonic-gate 	caddr_t		rq_clntcred;	/* read only cooked cred */
1120Sstevel@tonic-gate 	SVCXPRT		*rq_xprt;	/* associated transport */
1131676Sjpk 	bslabel_t	*rq_label;	/* TSOL label of the request */
1140Sstevel@tonic-gate };
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate #ifdef _KERNEL
1170Sstevel@tonic-gate struct dupreq {
1180Sstevel@tonic-gate 	uint32_t	dr_xid;
1190Sstevel@tonic-gate 	rpcproc_t	dr_proc;
1200Sstevel@tonic-gate 	rpcvers_t	dr_vers;
1210Sstevel@tonic-gate 	rpcprog_t	dr_prog;
1220Sstevel@tonic-gate 	struct netbuf	dr_addr;
1230Sstevel@tonic-gate 	struct netbuf	dr_resp;
1240Sstevel@tonic-gate 	void		(*dr_resfree)();
1250Sstevel@tonic-gate 	int		dr_status;
1260Sstevel@tonic-gate 	struct dupreq	*dr_next;
1270Sstevel@tonic-gate 	struct dupreq	*dr_chain;
1280Sstevel@tonic-gate };
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate /*
1310Sstevel@tonic-gate  * States of requests for duplicate request caching.
1320Sstevel@tonic-gate  */
1330Sstevel@tonic-gate #define	DUP_NEW			0x00	/* new entry */
1340Sstevel@tonic-gate #define	DUP_INPROGRESS		0x01	/* request already going */
1350Sstevel@tonic-gate #define	DUP_DONE		0x02	/* request done */
1360Sstevel@tonic-gate #define	DUP_DROP		0x03	/* request dropped */
1370Sstevel@tonic-gate #define	DUP_ERROR		0x04	/* error in dup req cache */
1380Sstevel@tonic-gate 
1390Sstevel@tonic-gate /*
1400Sstevel@tonic-gate  * Prototype for a service dispatch routine.
1410Sstevel@tonic-gate  */
1420Sstevel@tonic-gate typedef void (SVC_DISPATCH)(struct svc_req *, SVCXPRT *);
1430Sstevel@tonic-gate 
1440Sstevel@tonic-gate /*
1450Sstevel@tonic-gate  * The service provider callout.
1460Sstevel@tonic-gate  * Each entry identifies a dispatch routine to be called
1470Sstevel@tonic-gate  * for a given RPC program number and a version fitting
1480Sstevel@tonic-gate  * into the registered range.
1490Sstevel@tonic-gate  */
1500Sstevel@tonic-gate typedef struct {
1510Sstevel@tonic-gate 	rpcprog_t	sc_prog;	/* RPC Program number */
1520Sstevel@tonic-gate 	rpcvers_t	sc_versmin;	/* Min version number */
1530Sstevel@tonic-gate 	rpcvers_t	sc_versmax;	/* Max version number */
1540Sstevel@tonic-gate 	SVC_DISPATCH	*sc_dispatch;	/* Dispatch routine   */
1550Sstevel@tonic-gate } SVC_CALLOUT;
1560Sstevel@tonic-gate 
1570Sstevel@tonic-gate /*
1580Sstevel@tonic-gate  * Table of service provider `callouts' for an RPC
1590Sstevel@tonic-gate  * transport handle. If sct_free is TRUE then transport
1600Sstevel@tonic-gate  * destructor is supposed to deallocate this table.
1610Sstevel@tonic-gate  */
1620Sstevel@tonic-gate typedef struct {
1630Sstevel@tonic-gate 	size_t		sct_size;	/* Number of entries  */
1640Sstevel@tonic-gate 	bool_t		sct_free;	/* Deallocate if true */
1650Sstevel@tonic-gate 	SVC_CALLOUT	*sct_sc;	/* Callout entries    */
1660Sstevel@tonic-gate } SVC_CALLOUT_TABLE;
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate struct svc_ops {
1690Sstevel@tonic-gate 	bool_t	(*xp_recv)(SVCXPRT *, mblk_t *, struct rpc_msg *);
1700Sstevel@tonic-gate 		/* receive incoming requests */
1710Sstevel@tonic-gate 	bool_t	(*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t);
1720Sstevel@tonic-gate 		/* get arguments */
1730Sstevel@tonic-gate 	bool_t	(*xp_reply)(SVCXPRT *, struct rpc_msg *);
1740Sstevel@tonic-gate 		/* send reply */
1750Sstevel@tonic-gate 	bool_t	(*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t);
1760Sstevel@tonic-gate 		/* free mem allocated for args */
1770Sstevel@tonic-gate 	void	(*xp_destroy)(SVCMASTERXPRT *);
1780Sstevel@tonic-gate 		/* destroy this struct */
1790Sstevel@tonic-gate 	int	(*xp_dup)(struct svc_req *, caddr_t, int,
1800Sstevel@tonic-gate 				struct dupreq **, bool_t *);
1810Sstevel@tonic-gate 		/* check for dup */
1820Sstevel@tonic-gate 	void	(*xp_dupdone)(struct dupreq *, caddr_t, void (*)(), int, int);
1830Sstevel@tonic-gate 		/* mark dup entry as completed */
1840Sstevel@tonic-gate 	int32_t *(*xp_getres)(SVCXPRT *, int);
1850Sstevel@tonic-gate 		/* get pointer to response buffer */
1860Sstevel@tonic-gate 	void	(*xp_freeres)(SVCXPRT *);
1870Sstevel@tonic-gate 		/* destroy pre-serialized response */
1880Sstevel@tonic-gate 	void	(*xp_clone_destroy)(SVCXPRT *);
1890Sstevel@tonic-gate 		/* destroy a clone xprt */
1900Sstevel@tonic-gate 	void	(*xp_start)(SVCMASTERXPRT *);
1910Sstevel@tonic-gate 		/* `ready-to-receive' */
1920Sstevel@tonic-gate };
1930Sstevel@tonic-gate #else	/* _KERNEL */
1940Sstevel@tonic-gate /*
1950Sstevel@tonic-gate  *	Service control requests
1960Sstevel@tonic-gate  */
1970Sstevel@tonic-gate #define	SVCGET_VERSQUIET	1
1980Sstevel@tonic-gate #define	SVCSET_VERSQUIET	2
1990Sstevel@tonic-gate #define	SVCGET_XID		4
2000Sstevel@tonic-gate #define	SVCSET_KEEPALIVE	5
2010Sstevel@tonic-gate #define	SVCSET_CONNMAXREC	6
2020Sstevel@tonic-gate #define	SVCGET_CONNMAXREC	7
2030Sstevel@tonic-gate #define	SVCGET_RECVERRHANDLER	8
2040Sstevel@tonic-gate #define	SVCSET_RECVERRHANDLER	9
2050Sstevel@tonic-gate 
2060Sstevel@tonic-gate enum xprt_stat {
2070Sstevel@tonic-gate 	XPRT_DIED,
2080Sstevel@tonic-gate 	XPRT_MOREREQS,
2090Sstevel@tonic-gate 	XPRT_IDLE
2100Sstevel@tonic-gate };
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate struct xp_ops {
2130Sstevel@tonic-gate #ifdef	__STDC__
2140Sstevel@tonic-gate 	bool_t	(*xp_recv)(SVCXPRT *, struct rpc_msg *);
2150Sstevel@tonic-gate 		/* receive incoming requests */
2160Sstevel@tonic-gate 	enum xprt_stat (*xp_stat)(SVCXPRT *);
2170Sstevel@tonic-gate 		/* get transport status */
2180Sstevel@tonic-gate 	bool_t	(*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t);
2190Sstevel@tonic-gate 		/* get arguments */
2200Sstevel@tonic-gate 	bool_t	(*xp_reply)(SVCXPRT *,	struct rpc_msg *);
2210Sstevel@tonic-gate 		/* send reply */
2220Sstevel@tonic-gate 	bool_t	(*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t);
2230Sstevel@tonic-gate 		/* free mem allocated for args */
2240Sstevel@tonic-gate 	void	(*xp_destroy)(SVCXPRT *);
2250Sstevel@tonic-gate 		/* destroy this struct */
2260Sstevel@tonic-gate 	bool_t	(*xp_control)(SVCXPRT *, const uint_t,	void *);
2270Sstevel@tonic-gate 		/* catch-all control function */
2280Sstevel@tonic-gate #else	/* __STDC__ */
2290Sstevel@tonic-gate 	bool_t	(*xp_recv)(); /* receive incoming requests */
2300Sstevel@tonic-gate 	enum xprt_stat (*xp_stat)(); /* get transport status */
2310Sstevel@tonic-gate 	bool_t	(*xp_getargs)(); /* get arguments */
2320Sstevel@tonic-gate 	bool_t	(*xp_reply)(); /* send reply */
2330Sstevel@tonic-gate 	bool_t	(*xp_freeargs)(); /* free mem allocated for args */
2340Sstevel@tonic-gate 	void	(*xp_destroy)(); /* destroy this struct */
2350Sstevel@tonic-gate 	bool_t	(*xp_control)(); /* catch-all control function */
2360Sstevel@tonic-gate #endif	/* __STDC__ */
2370Sstevel@tonic-gate };
2380Sstevel@tonic-gate #endif	/* _KERNEL */
2390Sstevel@tonic-gate 
2400Sstevel@tonic-gate #ifdef	_KERNEL
2410Sstevel@tonic-gate /*
2420Sstevel@tonic-gate  * SVCPOOL
2430Sstevel@tonic-gate  * Kernel RPC server-side thread pool structure.
2440Sstevel@tonic-gate  */
2450Sstevel@tonic-gate typedef struct __svcxprt_qnode __SVCXPRT_QNODE;	/* Defined in svc.c */
2460Sstevel@tonic-gate 
2470Sstevel@tonic-gate struct __svcpool {
2480Sstevel@tonic-gate 	/*
2490Sstevel@tonic-gate 	 * Thread pool variables.
2500Sstevel@tonic-gate 	 *
2510Sstevel@tonic-gate 	 * The pool's thread lock p_thread_lock protects:
2520Sstevel@tonic-gate 	 * - p_threads, p_detached_threads, p_reserved_threads and p_closing
2530Sstevel@tonic-gate 	 * The pool's request lock protects:
2540Sstevel@tonic-gate 	 * - p_asleep, p_drowsy, p_reqs, p_walkers, p_req_cv.
2550Sstevel@tonic-gate 	 * The following fields are `initialized constants':
2560Sstevel@tonic-gate 	 * - p_id, p_stksize, p_timeout.
2570Sstevel@tonic-gate 	 * Access to p_next and p_prev is protected by the pool
2580Sstevel@tonic-gate 	 * list lock.
2590Sstevel@tonic-gate 	 */
2600Sstevel@tonic-gate 	SVCPOOL		*p_next;		/* Next pool in the list  */
2610Sstevel@tonic-gate 	SVCPOOL		*p_prev;		/* Prev pool in the list  */
2620Sstevel@tonic-gate 	int		p_id;			/* Pool id		  */
2630Sstevel@tonic-gate 	int		p_threads;		/* Non-detached threads	  */
2640Sstevel@tonic-gate 	int		p_detached_threads;	/* Detached threads	  */
2650Sstevel@tonic-gate 	int		p_maxthreads;		/* Max threads in the pool */
2660Sstevel@tonic-gate 	int		p_redline;		/* `Redline' for the pool */
2670Sstevel@tonic-gate 	int		p_reserved_threads;	/* Reserved threads	  */
2680Sstevel@tonic-gate 	kmutex_t	p_thread_lock;		/* Thread lock		  */
2690Sstevel@tonic-gate 	int		p_asleep;		/* Asleep threads	  */
2700Sstevel@tonic-gate 	int		p_drowsy;		/* Drowsy flag		  */
2710Sstevel@tonic-gate 	kcondvar_t 	p_req_cv;		/* svc_poll() sleep var.  */
2720Sstevel@tonic-gate 	clock_t		p_timeout;		/* svc_poll() timeout	  */
2730Sstevel@tonic-gate 	kmutex_t	p_req_lock;		/* Request lock		  */
2740Sstevel@tonic-gate 	int		p_reqs;			/* Pending requests	  */
2750Sstevel@tonic-gate 	int		p_walkers;		/* Walking threads	  */
2760Sstevel@tonic-gate 	int		p_max_same_xprt;	/* Max reqs from the xprt */
2770Sstevel@tonic-gate 	int		p_stksize;		/* Stack size for svc_run */
2780Sstevel@tonic-gate 	bool_t		p_closing : 1;		/* Pool is closing	  */
2790Sstevel@tonic-gate 
2800Sstevel@tonic-gate 	/*
2810Sstevel@tonic-gate 	 * Thread creator variables.
2820Sstevel@tonic-gate 	 * The `creator signaled' flag is turned on when a signal is send
2830Sstevel@tonic-gate 	 * to the creator thread (to create a new service thread). The
2840Sstevel@tonic-gate 	 * creator clears when the thread is created. The protocol is not
2850Sstevel@tonic-gate 	 * to signal the creator thread when the flag is on. However,
2860Sstevel@tonic-gate 	 * a new thread should signal the creator if there are more
2870Sstevel@tonic-gate 	 * requests in the queue.
2880Sstevel@tonic-gate 	 *
2890Sstevel@tonic-gate 	 * When the pool is closing (ie it has been already unregistered from
2900Sstevel@tonic-gate 	 * the pool list) the last thread on the last transport should turn
2910Sstevel@tonic-gate 	 * the p_creator_exit flag on. This tells the creator thread to
2920Sstevel@tonic-gate 	 * free the pool structure and exit.
2930Sstevel@tonic-gate 	 */
2940Sstevel@tonic-gate 	bool_t		p_creator_signaled : 1;	/* Create requested flag  */
2950Sstevel@tonic-gate 	bool_t		p_creator_exit : 1;	/* If true creator exits  */
2960Sstevel@tonic-gate 	kcondvar_t	p_creator_cv;		/* Creator cond. variable */
2970Sstevel@tonic-gate 	kmutex_t	p_creator_lock;		/* Creator lock		  */
2980Sstevel@tonic-gate 
2990Sstevel@tonic-gate 	/*
3000Sstevel@tonic-gate 	 * Doubly linked list containing `registered' master transport handles.
3010Sstevel@tonic-gate 	 * There is no special structure for a list node. Instead the
3020Sstevel@tonic-gate 	 * SVCMASTERXPRT structure has the xp_next and xp_prev fields.
3030Sstevel@tonic-gate 	 *
3040Sstevel@tonic-gate 	 * The p_lrwlock protects access to xprt->xp_next and xprt->xp_prev.
3050Sstevel@tonic-gate 	 * A service thread should also acquire a reader lock before accessing
3060Sstevel@tonic-gate 	 * any transports it is no longer linked to (to prevent them from
3070Sstevel@tonic-gate 	 * being destroyed).
3080Sstevel@tonic-gate 	 *
3090Sstevel@tonic-gate 	 * The list lock governs also the `pool is closing' flag.
3100Sstevel@tonic-gate 	 */
3110Sstevel@tonic-gate 	size_t		p_lcount;		/* Current count	  */
3120Sstevel@tonic-gate 	SVCMASTERXPRT	*p_lhead;		/* List head		  */
3130Sstevel@tonic-gate 	krwlock_t	p_lrwlock;		/* R/W lock		  */
3140Sstevel@tonic-gate 
3150Sstevel@tonic-gate 	/*
3160Sstevel@tonic-gate 	 * Circular linked list for the `xprt-ready' queue (FIFO).
3170Sstevel@tonic-gate 	 * Must be initialized with svc_xprt_qinit() before it is used.
3180Sstevel@tonic-gate 	 *
3190Sstevel@tonic-gate 	 * The writer's end is protected by the pool's request lock
3200Sstevel@tonic-gate 	 * (pool->p_req_lock). The reader's end is protected by q_end_lock.
3210Sstevel@tonic-gate 	 *
3220Sstevel@tonic-gate 	 * When the queue is full the p_qoverflow flag is raised. It stays
3230Sstevel@tonic-gate 	 * on until all the pending request are drained.
3240Sstevel@tonic-gate 	 */
3250Sstevel@tonic-gate 	size_t		p_qsize;		/* Number of queue nodes  */
3260Sstevel@tonic-gate 	int		p_qoverflow : 1;	/* Overflow flag	  */
3270Sstevel@tonic-gate 	__SVCXPRT_QNODE *p_qbody;		/* Queue body (array)	  */
3280Sstevel@tonic-gate 	__SVCXPRT_QNODE *p_qtop;		/* Writer's end of FIFO   */
3290Sstevel@tonic-gate 	__SVCXPRT_QNODE *p_qend;		/* Reader's end of FIFO	  */
3300Sstevel@tonic-gate 	kmutex_t	p_qend_lock;		/* Reader's end lock	  */
3310Sstevel@tonic-gate 
3320Sstevel@tonic-gate 	/*
3330Sstevel@tonic-gate 	 * Userspace thread creator variables.
3340Sstevel@tonic-gate 	 * Thread creation is actually done in userland, via a thread
3350Sstevel@tonic-gate 	 * that is parked in the kernel. When that thread is signaled,
3360Sstevel@tonic-gate 	 * it returns back down to the daemon from whence it came and
3370Sstevel@tonic-gate 	 * does the lwp create.
3380Sstevel@tonic-gate 	 *
3390Sstevel@tonic-gate 	 * A parallel "creator" thread runs in the kernel. That is the
3400Sstevel@tonic-gate 	 * thread that will signal for the user thread to return to
3410Sstevel@tonic-gate 	 * userland and do its work.
3420Sstevel@tonic-gate 	 *
3430Sstevel@tonic-gate 	 * Since the thread doesn't always exist (there could be a race
3440Sstevel@tonic-gate 	 * if two threads are created in rapid succession), we set
3450Sstevel@tonic-gate 	 * p_signal_create_thread to FALSE when we're ready to accept work.
3460Sstevel@tonic-gate 	 *
3470Sstevel@tonic-gate 	 * p_user_exit is set to true when the service pool is about
3480Sstevel@tonic-gate 	 * to close. This is done so that the user creation thread
3490Sstevel@tonic-gate 	 * can be informed and cleanup any userland state.
3500Sstevel@tonic-gate 	 */
3510Sstevel@tonic-gate 
3520Sstevel@tonic-gate 	bool_t		p_signal_create_thread : 1; /* Create requested flag  */
3530Sstevel@tonic-gate 	bool_t		p_user_exit : 1;	/* If true creator exits  */
3540Sstevel@tonic-gate 	bool_t		p_user_waiting : 1;	/* Thread waiting for work */
3550Sstevel@tonic-gate 	kcondvar_t	p_user_cv;		/* Creator cond. variable */
3560Sstevel@tonic-gate 	kmutex_t	p_user_lock;		/* Creator lock		  */
3570Sstevel@tonic-gate 	void		(*p_offline)();		/* callout for unregister */
3580Sstevel@tonic-gate 	void		(*p_shutdown)();	/* callout for shutdown */
3590Sstevel@tonic-gate };
3600Sstevel@tonic-gate 
3610Sstevel@tonic-gate /*
3620Sstevel@tonic-gate  * Server side transport handle (SVCMASTERXPRT).
3630Sstevel@tonic-gate  * xprt->xp_req_lock governs the following fields in xprt:
3640Sstevel@tonic-gate  *		xp_req_head, xp_req_tail.
3650Sstevel@tonic-gate  * xprt->xp_thread_lock governs the following fields in xprt:
3660Sstevel@tonic-gate  *		xp_threads, xp_detached_threads.
3670Sstevel@tonic-gate  *
3680Sstevel@tonic-gate  * xp_req_tail is only valid if xp_req_head is non-NULL
3690Sstevel@tonic-gate  *
3700Sstevel@tonic-gate  * The xp_threads count is the number of attached threads.  These threads
3710Sstevel@tonic-gate  * are able to handle new requests, and it is expected that they will not
3720Sstevel@tonic-gate  * block for a very long time handling a given request. The
3730Sstevel@tonic-gate  * xp_detached_threads count is the number of threads that have detached
3740Sstevel@tonic-gate  * themselves from the transport. These threads can block indefinitely
3750Sstevel@tonic-gate  * while handling a request.  Once they complete the request, they exit.
3760Sstevel@tonic-gate  *
3770Sstevel@tonic-gate  * A kernel service provider may register a callback function "closeproc"
3780Sstevel@tonic-gate  * for a transport.  When the transport is closing the last exiting attached
3790Sstevel@tonic-gate  * thread - xp_threads goes to zero - it calls the callback function, passing
3800Sstevel@tonic-gate  * it a reference to the transport.  This call is made with xp_thread_lock
3810Sstevel@tonic-gate  * held, so any cleanup bookkeeping it does should be done quickly.
3820Sstevel@tonic-gate  *
3830Sstevel@tonic-gate  * When the transport is closing the last exiting thread is supposed
3840Sstevel@tonic-gate  * to destroy/free the data structure.
3850Sstevel@tonic-gate  */
3860Sstevel@tonic-gate typedef struct __svcxprt_common {
3870Sstevel@tonic-gate 	struct file	*xpc_fp;
3880Sstevel@tonic-gate 	struct svc_ops	*xpc_ops;
3890Sstevel@tonic-gate 	queue_t		*xpc_wq;	/* queue to write onto		*/
3900Sstevel@tonic-gate 	cred_t		*xpc_cred;	/* cached cred for server to use */
3910Sstevel@tonic-gate 	int32_t		xpc_type;	/* transport type		*/
3920Sstevel@tonic-gate 	int		xpc_msg_size;	/* TSDU or TIDU size		*/
3930Sstevel@tonic-gate 	struct netbuf	xpc_rtaddr;	/* remote transport address	*/
394*7208Svv149972 	struct netbuf	xpc_lcladdr;	/* local transport address	*/
3950Sstevel@tonic-gate 	SVC_CALLOUT_TABLE *xpc_sct;
3960Sstevel@tonic-gate } __SVCXPRT_COMMON;
3970Sstevel@tonic-gate 
3980Sstevel@tonic-gate #define	xp_fp		xp_xpc.xpc_fp
3990Sstevel@tonic-gate #define	xp_ops		xp_xpc.xpc_ops
4000Sstevel@tonic-gate #define	xp_wq		xp_xpc.xpc_wq
4010Sstevel@tonic-gate #define	xp_cred		xp_xpc.xpc_cred
4020Sstevel@tonic-gate #define	xp_type		xp_xpc.xpc_type
4030Sstevel@tonic-gate #define	xp_msg_size	xp_xpc.xpc_msg_size
4040Sstevel@tonic-gate #define	xp_rtaddr	xp_xpc.xpc_rtaddr
405*7208Svv149972 #define	xp_lcladdr	xp_xpc.xpc_lcladdr
4060Sstevel@tonic-gate #define	xp_sct		xp_xpc.xpc_sct
4070Sstevel@tonic-gate 
4080Sstevel@tonic-gate struct __svcmasterxprt {
4090Sstevel@tonic-gate 	SVCMASTERXPRT 	*xp_next;	/* Next transport in the list	*/
4100Sstevel@tonic-gate 	SVCMASTERXPRT 	*xp_prev;	/* Prev transport in the list	*/
4110Sstevel@tonic-gate 	__SVCXPRT_COMMON xp_xpc;	/* Fields common with the clone	*/
4120Sstevel@tonic-gate 	SVCPOOL		*xp_pool;	/* Pointer to the pool		*/
4130Sstevel@tonic-gate 	mblk_t		*xp_req_head;	/* Request queue head		*/
4140Sstevel@tonic-gate 	mblk_t		*xp_req_tail;	/* Request queue tail		*/
4150Sstevel@tonic-gate 	kmutex_t	xp_req_lock;	/* Request lock			*/
4160Sstevel@tonic-gate 	int		xp_threads;	/* Current num. of attached threads */
4170Sstevel@tonic-gate 	int		xp_detached_threads; /* num. of detached threads */
4180Sstevel@tonic-gate 	kmutex_t	xp_thread_lock;	/* Thread count lock		*/
4190Sstevel@tonic-gate 	void		(*xp_closeproc)(const SVCMASTERXPRT *);
4200Sstevel@tonic-gate 					/* optional; see comments above	*/
4210Sstevel@tonic-gate 	char		*xp_netid;	/* network token		*/
4220Sstevel@tonic-gate 	struct netbuf	xp_addrmask;	/* address mask			*/
4230Sstevel@tonic-gate 
4240Sstevel@tonic-gate 	caddr_t		xp_p2;		/* private: for use by svc ops  */
4250Sstevel@tonic-gate };
4260Sstevel@tonic-gate 
4270Sstevel@tonic-gate /*
4280Sstevel@tonic-gate  * Service thread `clone' transport handle (SVCXPRT)
4290Sstevel@tonic-gate  *
4300Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
4310Sstevel@tonic-gate  * SVCXPRT
4320Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
4330Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
4340Sstevel@tonic-gate  *
4350Sstevel@tonic-gate  * The xp_p2buf buffer is used as the storage for a transport type
4360Sstevel@tonic-gate  * specific structure. It is private for the svc ops for a given
4370Sstevel@tonic-gate  * transport type.
4380Sstevel@tonic-gate  */
4390Sstevel@tonic-gate 
4400Sstevel@tonic-gate #define	SVC_P2LEN   64
4410Sstevel@tonic-gate 
4420Sstevel@tonic-gate struct __svcxprt {
4430Sstevel@tonic-gate 	__SVCXPRT_COMMON xp_xpc;
4440Sstevel@tonic-gate 	SVCMASTERXPRT	*xp_master;	/* back ptr to master		*/
4450Sstevel@tonic-gate 
4460Sstevel@tonic-gate 	/* The following fileds are on a per-thread basis */
4470Sstevel@tonic-gate 	callb_cpr_t	*xp_cprp;	/* unused padding for Contract	*/
4480Sstevel@tonic-gate 	bool_t		xp_reserved : 1; /* is thread reserved?		*/
4490Sstevel@tonic-gate 	bool_t		xp_detached : 1; /* is thread detached?		*/
4500Sstevel@tonic-gate 	int		xp_same_xprt;	/* Reqs from the same xprt	*/
4510Sstevel@tonic-gate 
4520Sstevel@tonic-gate 	/* The following fields are used on a per-request basis */
4530Sstevel@tonic-gate 	struct opaque_auth xp_verf;	/* raw response verifier	*/
4540Sstevel@tonic-gate 	SVCAUTH		xp_auth;	/* auth flavor of current req	*/
4550Sstevel@tonic-gate 	void		*xp_cookie;	/* a cookie			*/
4560Sstevel@tonic-gate 	uint32_t	xp_xid;		/* id				*/
4570Sstevel@tonic-gate 	XDR		xp_xdrin;	/* input xdr stream		*/
4580Sstevel@tonic-gate 	XDR		xp_xdrout;	/* output xdr stream		*/
4590Sstevel@tonic-gate 
4600Sstevel@tonic-gate 	/* Private for svc ops */
4610Sstevel@tonic-gate 	char		xp_p2buf[SVC_P2LEN]; /* udp_data or cots_data_t */
4620Sstevel@tonic-gate 						/* or clone_rdma_data_t */
4630Sstevel@tonic-gate };
4640Sstevel@tonic-gate #else	/* _KERNEL */
4650Sstevel@tonic-gate struct __svcxprt {
4660Sstevel@tonic-gate 	int		xp_fd;
4670Sstevel@tonic-gate #define	xp_sock		xp_fd
4680Sstevel@tonic-gate 	ushort_t	xp_port;
4690Sstevel@tonic-gate 	/*
4700Sstevel@tonic-gate 	 * associated port number.
4710Sstevel@tonic-gate 	 * Obsolete, but still used to
4720Sstevel@tonic-gate 	 * specify whether rendezvouser
4730Sstevel@tonic-gate 	 * or normal connection
4740Sstevel@tonic-gate 	 */
4750Sstevel@tonic-gate 	struct	xp_ops	*xp_ops;
4760Sstevel@tonic-gate 	int		xp_addrlen;	/* length of remote addr. Obsoleted */
4770Sstevel@tonic-gate 	char		*xp_tp;		/* transport provider device name */
4780Sstevel@tonic-gate 	char		*xp_netid;	/* network token */
4790Sstevel@tonic-gate 	struct netbuf	xp_ltaddr;	/* local transport address */
4800Sstevel@tonic-gate 	struct netbuf	xp_rtaddr;	/* remote transport address */
4810Sstevel@tonic-gate 	char		xp_raddr[16];	/* remote address. Now obsoleted */
4820Sstevel@tonic-gate 	struct opaque_auth xp_verf;	/* raw response verifier */
4830Sstevel@tonic-gate 	caddr_t		xp_p1;		/* private: for use by svc ops */
4840Sstevel@tonic-gate 	caddr_t		xp_p2;		/* private: for use by svc ops */
4850Sstevel@tonic-gate 	caddr_t		xp_p3;		/* private: for use by svc lib */
4860Sstevel@tonic-gate 	int		xp_type;	/* transport type */
4870Sstevel@tonic-gate 	/*
4880Sstevel@tonic-gate 	 * callback on client death
4890Sstevel@tonic-gate 	 * First parameter is the current structure,
4900Sstevel@tonic-gate 	 * Second parameter :
4910Sstevel@tonic-gate 	 *	- FALSE for the service listener
4920Sstevel@tonic-gate 	 *	- TRUE for a real connected socket
4930Sstevel@tonic-gate 	 */
4940Sstevel@tonic-gate 	svc_errorhandler_t xp_closeclnt;
4950Sstevel@tonic-gate };
4960Sstevel@tonic-gate #endif	/* _KERNEL */
4970Sstevel@tonic-gate 
4980Sstevel@tonic-gate /*
4990Sstevel@tonic-gate  *  Approved way of getting address of caller,
5000Sstevel@tonic-gate  *  address mask, and netid of transport.
5010Sstevel@tonic-gate  */
5020Sstevel@tonic-gate #define	svc_getrpccaller(x) (&(x)->xp_rtaddr)
5030Sstevel@tonic-gate #ifdef _KERNEL
5040Sstevel@tonic-gate #define	svc_getcaller(x) (&(x)->xp_rtaddr.buf)
5050Sstevel@tonic-gate #define	svc_getaddrmask(x) (&(x)->xp_master->xp_addrmask)
5060Sstevel@tonic-gate #define	svc_getnetid(x) ((x)->xp_master->xp_netid)
5070Sstevel@tonic-gate #endif	/* _KERNEL */
5080Sstevel@tonic-gate 
5090Sstevel@tonic-gate /*
5100Sstevel@tonic-gate  * Operations defined on an SVCXPRT handle
5110Sstevel@tonic-gate  */
5120Sstevel@tonic-gate 
5130Sstevel@tonic-gate #ifdef	_KERNEL
5140Sstevel@tonic-gate #define	SVC_RECV(clone_xprt, mp, msg) \
5150Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_recv)((clone_xprt), (mp), (msg))
5160Sstevel@tonic-gate 
5170Sstevel@tonic-gate /*
5180Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
5190Sstevel@tonic-gate  * SVC_GETARGS
5200Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
5210Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
5220Sstevel@tonic-gate  */
5230Sstevel@tonic-gate #define	SVC_GETARGS(clone_xprt, xargs, argsp) \
5240Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_getargs)((clone_xprt), (xargs), (argsp))
5250Sstevel@tonic-gate 
5260Sstevel@tonic-gate #define	SVC_REPLY(clone_xprt, msg) \
5270Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_reply) ((clone_xprt), (msg))
5280Sstevel@tonic-gate 
5290Sstevel@tonic-gate #define	SVC_FREEARGS(clone_xprt, xargs, argsp) \
5300Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_freeargs)((clone_xprt), (xargs), (argsp))
5310Sstevel@tonic-gate 
5320Sstevel@tonic-gate #define	SVC_GETRES(clone_xprt, size) \
5330Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_getres)((clone_xprt), (size))
5340Sstevel@tonic-gate 
5350Sstevel@tonic-gate #define	SVC_FREERES(clone_xprt)	\
5360Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_freeres)(clone_xprt)
5370Sstevel@tonic-gate 
5380Sstevel@tonic-gate #define	SVC_DESTROY(xprt) \
5390Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_destroy)(xprt)
5400Sstevel@tonic-gate 
5410Sstevel@tonic-gate /*
5420Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interfaces
5430Sstevel@tonic-gate  * SVC_DUP, SVC_DUPDONE, SVC_DUP_EXT, SVC_DUPDONE_EXT
5440Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
5450Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
5460Sstevel@tonic-gate  *
5470Sstevel@tonic-gate  * SVC_DUP and SVC_DUPDONE are defined here for backward compatibility.
5480Sstevel@tonic-gate  */
5490Sstevel@tonic-gate #define	SVC_DUP_EXT(clone_xprt, req, res, size, drpp, dupcachedp) \
5500Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, dupcachedp)
5510Sstevel@tonic-gate 
5520Sstevel@tonic-gate #define	SVC_DUPDONE_EXT(clone_xprt, dr, res, resfree, size, status) \
5530Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, resfree, size, status)
5540Sstevel@tonic-gate 
5550Sstevel@tonic-gate #define	SVC_DUP(clone_xprt, req, res, size, drpp) \
5560Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, NULL)
5570Sstevel@tonic-gate 
5580Sstevel@tonic-gate #define	SVC_DUPDONE(clone_xprt, dr, res, size, status) \
5590Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, NULL, size, status)
5600Sstevel@tonic-gate 
5610Sstevel@tonic-gate #define	SVC_CLONE_DESTROY(clone_xprt) \
5620Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_clone_destroy)(clone_xprt)
5630Sstevel@tonic-gate 
5640Sstevel@tonic-gate 
5650Sstevel@tonic-gate #define	SVC_START(xprt) \
5660Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_start)(xprt)
5670Sstevel@tonic-gate 
5680Sstevel@tonic-gate #else	/* _KERNEL */
5690Sstevel@tonic-gate 
5700Sstevel@tonic-gate #define	SVC_RECV(xprt, msg) \
5710Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
5720Sstevel@tonic-gate #define	svc_recv(xprt, msg) \
5730Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
5740Sstevel@tonic-gate 
5750Sstevel@tonic-gate #define	SVC_STAT(xprt) \
5760Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_stat)(xprt)
5770Sstevel@tonic-gate #define	svc_stat(xprt) \
5780Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_stat)(xprt)
5790Sstevel@tonic-gate 
5800Sstevel@tonic-gate #define	SVC_GETARGS(xprt, xargs, argsp) \
5810Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
5820Sstevel@tonic-gate #define	svc_getargs(xprt, xargs, argsp)	\
5830Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
5840Sstevel@tonic-gate 
5850Sstevel@tonic-gate #define	SVC_REPLY(xprt, msg) \
5860Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
5870Sstevel@tonic-gate #define	svc_reply(xprt, msg) \
5880Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
5890Sstevel@tonic-gate 
5900Sstevel@tonic-gate #define	SVC_FREEARGS(xprt, xargs, argsp) \
5910Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
5920Sstevel@tonic-gate #define	svc_freeargs(xprt, xargs, argsp) \
5930Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
5940Sstevel@tonic-gate 
5950Sstevel@tonic-gate #define	SVC_GETRES(xprt, size) \
5960Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_getres)((xprt), (size))
5970Sstevel@tonic-gate #define	svc_getres(xprt, size) \
5980Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_getres)((xprt), (size))
5990Sstevel@tonic-gate 
6000Sstevel@tonic-gate #define	SVC_FREERES(xprt) \
6010Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_freeres)(xprt)
6020Sstevel@tonic-gate #define	svc_freeres(xprt) \
6030Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_freeres)(xprt)
6040Sstevel@tonic-gate 
6050Sstevel@tonic-gate #define	SVC_DESTROY(xprt) \
6060Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_destroy)(xprt)
6070Sstevel@tonic-gate #define	svc_destroy(xprt) \
6080Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_destroy)(xprt)
6090Sstevel@tonic-gate 
6100Sstevel@tonic-gate /*
6110Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
6120Sstevel@tonic-gate  * SVC_CONTROL
6130Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
6140Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
6150Sstevel@tonic-gate  */
6160Sstevel@tonic-gate #define	SVC_CONTROL(xprt, rq, in) \
6170Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_control)((xprt), (rq), (in))
6180Sstevel@tonic-gate #endif	/* _KERNEL */
6190Sstevel@tonic-gate 
6200Sstevel@tonic-gate /*
6210Sstevel@tonic-gate  * Pool id's reserved for NFS, NLM, and the NFSv4 callback program.
6220Sstevel@tonic-gate  */
6230Sstevel@tonic-gate #define	NFS_SVCPOOL_ID		0x01
6240Sstevel@tonic-gate #define	NLM_SVCPOOL_ID		0x02
6250Sstevel@tonic-gate #define	NFS_CB_SVCPOOL_ID	0x03
6260Sstevel@tonic-gate #define	RDC_SVCPOOL_ID		0x05	/* SNDR, PSARC 2001/699 */
6270Sstevel@tonic-gate 
6280Sstevel@tonic-gate struct svcpool_args {
6290Sstevel@tonic-gate 	uint32_t	id;		/* Pool id */
6300Sstevel@tonic-gate 	uint32_t	maxthreads;	/* Max threads in the pool */
6310Sstevel@tonic-gate 	uint32_t	redline;	/* `Redline' for the pool */
6320Sstevel@tonic-gate 	uint32_t	qsize;		/* `xprt-ready' queue size */
6330Sstevel@tonic-gate 	uint32_t	timeout;	/* svc_poll() timeout */
6340Sstevel@tonic-gate 	uint32_t	stksize;	/* svc_run() stack size */
6350Sstevel@tonic-gate 	uint32_t	max_same_xprt;	/* Max reqs from the same xprt */
6360Sstevel@tonic-gate };
6370Sstevel@tonic-gate 
6380Sstevel@tonic-gate 
6390Sstevel@tonic-gate #ifdef	_KERNEL
6400Sstevel@tonic-gate /*
6410Sstevel@tonic-gate  * Transport registration and thread pool creation.
6420Sstevel@tonic-gate  */
6430Sstevel@tonic-gate extern int	svc_xprt_register(SVCMASTERXPRT *, int);
6440Sstevel@tonic-gate extern void	svc_xprt_unregister(SVCMASTERXPRT *);
6450Sstevel@tonic-gate extern int	svc_pool_create(struct svcpool_args *);
6460Sstevel@tonic-gate extern int	svc_wait(int);
6470Sstevel@tonic-gate extern int	svc_do_run(int);
6480Sstevel@tonic-gate #define	SVCPSET_SHUTDOWN_PROC	1
6490Sstevel@tonic-gate #define	SVCPSET_UNREGISTER_PROC	2
6500Sstevel@tonic-gate extern int	svc_pool_control(int, int, void *);
6510Sstevel@tonic-gate #else	/* _KERNEL */
6520Sstevel@tonic-gate #ifdef	__STDC__
6530Sstevel@tonic-gate extern bool_t	rpc_reg(const rpcprog_t, const rpcvers_t, const rpcproc_t,
6540Sstevel@tonic-gate 			char *(*)(char *), const xdrproc_t, const xdrproc_t,
6550Sstevel@tonic-gate 			const char *);
6560Sstevel@tonic-gate 
6570Sstevel@tonic-gate /*
6580Sstevel@tonic-gate  * Service registration
6590Sstevel@tonic-gate  *
6600Sstevel@tonic-gate  * svc_reg(xprt, prog, vers, dispatch, nconf)
6610Sstevel@tonic-gate  *	const SVCXPRT *xprt;
6620Sstevel@tonic-gate  *	const rpcprog_t prog;
6630Sstevel@tonic-gate  *	const rpcvers_t vers;
6640Sstevel@tonic-gate  *	const void (*dispatch)();
6650Sstevel@tonic-gate  *	const struct netconfig *nconf;
6660Sstevel@tonic-gate  */
6670Sstevel@tonic-gate extern bool_t	svc_reg(const SVCXPRT *, const rpcprog_t, const rpcvers_t,
6680Sstevel@tonic-gate 			void (*)(struct svc_req *, SVCXPRT *),
6690Sstevel@tonic-gate 			const struct netconfig *);
6700Sstevel@tonic-gate 
6710Sstevel@tonic-gate /*
6720Sstevel@tonic-gate  * Service authentication registration
6730Sstevel@tonic-gate  *
6740Sstevel@tonic-gate  * svc_auth_reg(cred_flavor, handler)
6750Sstevel@tonic-gate  *    int cred_flavor;
6760Sstevel@tonic-gate  *    enum auth_stat (*handler)();
6770Sstevel@tonic-gate  */
6780Sstevel@tonic-gate extern int	svc_auth_reg(int, enum auth_stat (*)());
6790Sstevel@tonic-gate 
6800Sstevel@tonic-gate /*
6810Sstevel@tonic-gate  * Service un-registration
6820Sstevel@tonic-gate  *
6830Sstevel@tonic-gate  * svc_unreg(prog, vers)
6840Sstevel@tonic-gate  *	const rpcprog_t prog;
6850Sstevel@tonic-gate  *	const rpcvers_t vers;
6860Sstevel@tonic-gate  */
6870Sstevel@tonic-gate extern void	svc_unreg(const rpcprog_t, const rpcvers_t);
6880Sstevel@tonic-gate 
6890Sstevel@tonic-gate /*
6900Sstevel@tonic-gate  * Transport registration/unregistration.
6910Sstevel@tonic-gate  *
6920Sstevel@tonic-gate  * xprt_register(xprt)
6930Sstevel@tonic-gate  *	const SVCXPRT *xprt;
6940Sstevel@tonic-gate  *
6950Sstevel@tonic-gate  * xprt_unregister(xprt)
6960Sstevel@tonic-gate  *	const SVCXPRT *xprt;
6970Sstevel@tonic-gate  */
6980Sstevel@tonic-gate extern void	xprt_register(const SVCXPRT *);
6990Sstevel@tonic-gate extern void	xprt_unregister(const SVCXPRT *);
7000Sstevel@tonic-gate #else	/* __STDC__ */
7010Sstevel@tonic-gate extern bool_t	rpc_reg();
7020Sstevel@tonic-gate extern bool_t	svc_reg();
7030Sstevel@tonic-gate extern bool_t	svc_auth_reg();
7040Sstevel@tonic-gate extern void	svc_unreg();
7050Sstevel@tonic-gate extern void	xprt_register();
7060Sstevel@tonic-gate extern void	xprt_unregister();
7070Sstevel@tonic-gate #endif /* __STDC__ */
7080Sstevel@tonic-gate #endif	/* _KERNEL */
7090Sstevel@tonic-gate 
7100Sstevel@tonic-gate 
7110Sstevel@tonic-gate /*
7120Sstevel@tonic-gate  * When the service routine is called, it must first check to see if it
7130Sstevel@tonic-gate  * knows about the procedure;  if not, it should call svcerr_noproc
7140Sstevel@tonic-gate  * and return.  If so, it should deserialize its arguments via
7150Sstevel@tonic-gate  * SVC_GETARGS (defined above).  If the deserialization does not work,
7160Sstevel@tonic-gate  * svcerr_decode should be called followed by a return.  Successful
7170Sstevel@tonic-gate  * decoding of the arguments should be followed the execution of the
7180Sstevel@tonic-gate  * procedure's code and a call to svc_sendreply.
7190Sstevel@tonic-gate  *
7200Sstevel@tonic-gate  * Also, if the service refuses to execute the procedure due to too-
7210Sstevel@tonic-gate  * weak authentication parameters, svcerr_weakauth should be called.
7220Sstevel@tonic-gate  * Note: do not confuse access-control failure with weak authentication!
7230Sstevel@tonic-gate  *
7240Sstevel@tonic-gate  * NB: In pure implementations of rpc, the caller always waits for a reply
7250Sstevel@tonic-gate  * msg.  This message is sent when svc_sendreply is called.
7260Sstevel@tonic-gate  * Therefore pure service implementations should always call
7270Sstevel@tonic-gate  * svc_sendreply even if the function logically returns void;  use
7280Sstevel@tonic-gate  * xdr.h - xdr_void for the xdr routine.  HOWEVER, connectionful rpc allows
7290Sstevel@tonic-gate  * for the abuse of pure rpc via batched calling or pipelining.  In the
7300Sstevel@tonic-gate  * case of a batched call, svc_sendreply should NOT be called since
7310Sstevel@tonic-gate  * this would send a return message, which is what batching tries to avoid.
7320Sstevel@tonic-gate  * It is the service/protocol writer's responsibility to know which calls are
7330Sstevel@tonic-gate  * batched and which are not.  Warning: responding to batch calls may
7340Sstevel@tonic-gate  * deadlock the caller and server processes!
7350Sstevel@tonic-gate  */
7360Sstevel@tonic-gate #ifdef	__STDC__
7370Sstevel@tonic-gate extern bool_t	svc_sendreply(const SVCXPRT *, const xdrproc_t,	const caddr_t);
7380Sstevel@tonic-gate extern void	svcerr_decode(const SVCXPRT *);
7390Sstevel@tonic-gate extern void	svcerr_weakauth(const SVCXPRT *);
7400Sstevel@tonic-gate extern void	svcerr_noproc(const SVCXPRT *);
7410Sstevel@tonic-gate extern void	svcerr_progvers(const SVCXPRT *, const rpcvers_t,
7420Sstevel@tonic-gate     const rpcvers_t);
7430Sstevel@tonic-gate extern void	svcerr_auth(const SVCXPRT *, const enum auth_stat);
7440Sstevel@tonic-gate extern void	svcerr_noprog(const SVCXPRT *);
7450Sstevel@tonic-gate extern void	svcerr_systemerr(const SVCXPRT *);
7466786Srmesta extern void	svcerr_badcred(const SVCXPRT *);
7470Sstevel@tonic-gate #else	/* __STDC__ */
7480Sstevel@tonic-gate extern bool_t	svc_sendreply();
7490Sstevel@tonic-gate extern void	svcerr_decode();
7500Sstevel@tonic-gate extern void	svcerr_weakauth();
7510Sstevel@tonic-gate extern void	svcerr_noproc();
7520Sstevel@tonic-gate extern void	svcerr_progvers();
7530Sstevel@tonic-gate extern void	svcerr_auth();
7540Sstevel@tonic-gate extern void	svcerr_noprog();
7550Sstevel@tonic-gate extern void	svcerr_systemerr();
7566786Srmesta extern void	svcerr_badcred();
7570Sstevel@tonic-gate #endif	/* __STDC__ */
7580Sstevel@tonic-gate 
7590Sstevel@tonic-gate #ifdef	_KERNEL
7600Sstevel@tonic-gate /*
7610Sstevel@tonic-gate  * Kernel RPC functions.
7620Sstevel@tonic-gate  */
7630Sstevel@tonic-gate extern void	svc_init(void);
7640Sstevel@tonic-gate extern void	svc_cots_init(void);
7650Sstevel@tonic-gate extern void	svc_clts_init(void);
7660Sstevel@tonic-gate extern void	mt_kstat_init(void);
7670Sstevel@tonic-gate extern void	mt_kstat_fini(void);
7680Sstevel@tonic-gate extern int	svc_tli_kcreate(struct file *, uint_t, char *,
7690Sstevel@tonic-gate 				struct netbuf *, SVCMASTERXPRT **,
7700Sstevel@tonic-gate 				SVC_CALLOUT_TABLE *,
7710Sstevel@tonic-gate 				void (*closeproc)(const SVCMASTERXPRT *),
7720Sstevel@tonic-gate 				int, bool_t);
7730Sstevel@tonic-gate extern int	svc_clts_kcreate(struct file *, uint_t, struct T_info_ack *,
7740Sstevel@tonic-gate 				SVCMASTERXPRT **);
7750Sstevel@tonic-gate extern int	svc_cots_kcreate(struct file *, uint_t, struct T_info_ack *,
7760Sstevel@tonic-gate 				SVCMASTERXPRT **);
7770Sstevel@tonic-gate extern void	svc_queuereq(queue_t *, mblk_t *);
7780Sstevel@tonic-gate extern void	svc_queueclean(queue_t *);
7790Sstevel@tonic-gate extern void	svc_queueclose(queue_t *);
7800Sstevel@tonic-gate extern int	svc_reserve_thread(SVCXPRT *);
7810Sstevel@tonic-gate extern void	svc_unreserve_thread(SVCXPRT *);
7820Sstevel@tonic-gate extern callb_cpr_t *svc_detach_thread(SVCXPRT *);
7830Sstevel@tonic-gate 
7840Sstevel@tonic-gate /*
7850Sstevel@tonic-gate  * For RDMA based kRPC.
7860Sstevel@tonic-gate  * "rdma_xprt_record" is a reference to master transport handles
7870Sstevel@tonic-gate  * in kRPC thread pools. This is an easy way of tracking and shuting
7880Sstevel@tonic-gate  * down rdma based kRPC transports on demand.
7890Sstevel@tonic-gate  * "rdma_xprt_group" is a list of RDMA based mster transport handles
7900Sstevel@tonic-gate  * or records in a kRPC thread pool.
7910Sstevel@tonic-gate  */
7920Sstevel@tonic-gate typedef struct rdma_xprt_record		rdma_xprt_record_t;
7930Sstevel@tonic-gate struct rdma_xprt_record {
7940Sstevel@tonic-gate 	int			rtr_type;	/* Type of rdma; IB/VI/RDDP */
7950Sstevel@tonic-gate 	SVCMASTERXPRT		*rtr_xprt_ptr;	/* Ptr to master xprt handle */
7960Sstevel@tonic-gate 	rdma_xprt_record_t	*rtr_next;	/* Ptr to next record */
7970Sstevel@tonic-gate };
7980Sstevel@tonic-gate 
7990Sstevel@tonic-gate typedef struct {
8000Sstevel@tonic-gate 	int			rtg_count;	/* Number transport records */
8010Sstevel@tonic-gate 	int			rtg_poolid;	/* Pool Id for this group */
8020Sstevel@tonic-gate 	rdma_xprt_record_t	*rtg_listhead;	/* Head of the records list */
8030Sstevel@tonic-gate } rdma_xprt_group_t;
8040Sstevel@tonic-gate 
8050Sstevel@tonic-gate extern int	svc_rdma_kcreate(char *, SVC_CALLOUT_TABLE *, int,
8060Sstevel@tonic-gate 			rdma_xprt_group_t *);
8070Sstevel@tonic-gate extern void	svc_rdma_kstop(SVCMASTERXPRT *);
8080Sstevel@tonic-gate extern void	svc_rdma_kdestroy(SVCMASTERXPRT *);
8090Sstevel@tonic-gate extern void	rdma_stop(rdma_xprt_group_t);
8100Sstevel@tonic-gate 
8110Sstevel@tonic-gate /*
8120Sstevel@tonic-gate  * GSS cleanup method.
8130Sstevel@tonic-gate  */
8140Sstevel@tonic-gate extern void	rpc_gss_cleanup(SVCXPRT *);
8150Sstevel@tonic-gate #else	/* _KERNEL */
8160Sstevel@tonic-gate /*
8170Sstevel@tonic-gate  * Lowest level dispatching -OR- who owns this process anyway.
8180Sstevel@tonic-gate  * Somebody has to wait for incoming requests and then call the correct
8190Sstevel@tonic-gate  * service routine.  The routine svc_run does infinite waiting; i.e.,
8200Sstevel@tonic-gate  * svc_run never returns.
8210Sstevel@tonic-gate  * Since another (co-existant) package may wish to selectively wait for
8220Sstevel@tonic-gate  * incoming calls or other events outside of the rpc architecture, the
8230Sstevel@tonic-gate  * routine svc_getreq_poll is provided.  It must be passed pollfds, the
8240Sstevel@tonic-gate  * "in-place" results of a poll call (see poll, section 2).
8250Sstevel@tonic-gate  */
8260Sstevel@tonic-gate 
8270Sstevel@tonic-gate /*
8280Sstevel@tonic-gate  * Global keeper of rpc service descriptors in use
8290Sstevel@tonic-gate  * dynamic; must be inspected before each call to select or poll
8300Sstevel@tonic-gate  */
8310Sstevel@tonic-gate extern pollfd_t	*svc_pollfd;
8320Sstevel@tonic-gate extern int	svc_max_pollfd;
8330Sstevel@tonic-gate extern fd_set	svc_fdset;
8340Sstevel@tonic-gate #if !defined(_LP64) && FD_SETSIZE > 1024
8350Sstevel@tonic-gate extern fd_set	_new_svc_fdset;
8360Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME
8370Sstevel@tonic-gate #pragma redefine_extname	svc_fdset	_new_svc_fdset
8380Sstevel@tonic-gate #else   /* __PRAGMA_REDEFINE_EXTNAME */
8390Sstevel@tonic-gate #define	svc_fdset	_new_svc_fdset
8400Sstevel@tonic-gate #endif  /* __PRAGMA_REDEFINE_EXTNAME */
8410Sstevel@tonic-gate #endif	/* LP64 && FD_SETSIZE > 1024 */
8420Sstevel@tonic-gate #define	svc_fds svc_fdset.fds_bits[0]	/* compatibility */
8430Sstevel@tonic-gate 
8440Sstevel@tonic-gate /*
8450Sstevel@tonic-gate  * A small program implemented by the svc_rpc implementation itself.
8460Sstevel@tonic-gate  * Also see clnt.h for protocol numbers.
8470Sstevel@tonic-gate  */
8480Sstevel@tonic-gate #ifdef __STDC__
8490Sstevel@tonic-gate extern void	svc_getreq(int);
8500Sstevel@tonic-gate extern void	svc_getreq_common(const int);
8510Sstevel@tonic-gate extern void	svc_getreqset(fd_set *); /* takes fdset instead of int */
8520Sstevel@tonic-gate extern void	svc_getreq_poll(struct pollfd *, const int);
8530Sstevel@tonic-gate extern void	svc_run(void);
8540Sstevel@tonic-gate extern void	svc_exit(void);
8550Sstevel@tonic-gate #else	/* __STDC__ */
8560Sstevel@tonic-gate extern void	rpctest_service();
8570Sstevel@tonic-gate extern void	svc_getreqset();
8580Sstevel@tonic-gate extern void	svc_getreq();
8590Sstevel@tonic-gate extern void	svc_getreq_common();
8600Sstevel@tonic-gate extern void	svc_getreqset();	 /* takes fdset instead of int */
8610Sstevel@tonic-gate extern void	svc_getreq_poll();
8620Sstevel@tonic-gate extern void	svc_run();
8630Sstevel@tonic-gate extern void	svc_exit();
8640Sstevel@tonic-gate #endif	/* __STDC__ */
8650Sstevel@tonic-gate 
8660Sstevel@tonic-gate /*
8670Sstevel@tonic-gate  *  Functions used to manage user file descriptors
8680Sstevel@tonic-gate  */
8690Sstevel@tonic-gate typedef int svc_input_id_t;
8700Sstevel@tonic-gate typedef void (*svc_callback_t)(svc_input_id_t id, int fd,
8710Sstevel@tonic-gate 				unsigned int events, void* cookie);
8720Sstevel@tonic-gate 
8730Sstevel@tonic-gate #ifdef __STDC__
8740Sstevel@tonic-gate extern svc_input_id_t svc_add_input(int fd, unsigned int events,
8750Sstevel@tonic-gate 				svc_callback_t user_callback,
8760Sstevel@tonic-gate 				void* cookie);
8770Sstevel@tonic-gate extern int svc_remove_input(svc_input_id_t id);
8780Sstevel@tonic-gate #else	/* __STDC__ */
8790Sstevel@tonic-gate extern svc_input_id_t svc_add_input();
8800Sstevel@tonic-gate extern int	svc_remove_input();
8810Sstevel@tonic-gate #endif
8820Sstevel@tonic-gate 
8830Sstevel@tonic-gate /*
8840Sstevel@tonic-gate  * These are the existing service side transport implementations.
8850Sstevel@tonic-gate  *
8860Sstevel@tonic-gate  * Transport independent svc_create routine.
8870Sstevel@tonic-gate  */
8880Sstevel@tonic-gate #ifdef __STDC__
8890Sstevel@tonic-gate extern int	svc_create(void (*)(struct svc_req *, SVCXPRT *),
8900Sstevel@tonic-gate 				const rpcprog_t, const rpcvers_t,
8910Sstevel@tonic-gate 				const char *);
8920Sstevel@tonic-gate 	/*
8930Sstevel@tonic-gate 	 * 	void (*dispatch)();		-- dispatch routine
8940Sstevel@tonic-gate 	 *	const rpcprog_t prognum;	-- program number
8950Sstevel@tonic-gate 	 *	const rpcvers_t versnum;	-- version number
8960Sstevel@tonic-gate 	 *	const char *nettype;		-- network type
8970Sstevel@tonic-gate 	 */
8980Sstevel@tonic-gate 
8990Sstevel@tonic-gate /*
9000Sstevel@tonic-gate  * Generic server creation routine. It takes a netconfig structure
9010Sstevel@tonic-gate  * instead of a nettype.
9020Sstevel@tonic-gate  */
9030Sstevel@tonic-gate extern SVCXPRT	*svc_tp_create(void (*)(struct svc_req *, SVCXPRT *),
9040Sstevel@tonic-gate 				const rpcprog_t, const rpcvers_t,
9050Sstevel@tonic-gate 				const struct netconfig *);
9060Sstevel@tonic-gate 	/*
9070Sstevel@tonic-gate 	 * void (*dispatch)();			-- dispatch routine
9080Sstevel@tonic-gate 	 * const rpcprog_t prognum;		-- program number
9090Sstevel@tonic-gate 	 * const rpcvers_t versnum;		-- version number
9100Sstevel@tonic-gate 	 * const struct netconfig *nconf;	-- netconfig structure
9110Sstevel@tonic-gate 	 */
9120Sstevel@tonic-gate 
9130Sstevel@tonic-gate /*
9140Sstevel@tonic-gate  * Generic TLI create routine
9150Sstevel@tonic-gate  */
9160Sstevel@tonic-gate extern  SVCXPRT	*svc_tli_create(const int, const struct netconfig *,
9170Sstevel@tonic-gate 				const struct t_bind *, const uint_t,
9180Sstevel@tonic-gate 				const uint_t);
9190Sstevel@tonic-gate 	/*
9200Sstevel@tonic-gate 	 *	const int fd;			-- connection end point
9210Sstevel@tonic-gate 	 *	const struct netconfig *nconf;	-- netconfig structure
9220Sstevel@tonic-gate 	 *	const struct t_bind *bindaddr;	-- local bind address
9230Sstevel@tonic-gate 	 *	const uint_t sendsz;		-- max sendsize
9240Sstevel@tonic-gate 	 *	const uint_t recvsz;		-- max recvsize
9250Sstevel@tonic-gate 	 */
9260Sstevel@tonic-gate 
9270Sstevel@tonic-gate /*
9280Sstevel@tonic-gate  * Connectionless and connectionful create routines.
9290Sstevel@tonic-gate  */
9300Sstevel@tonic-gate extern SVCXPRT	*svc_vc_create(const int, const uint_t, const uint_t);
9310Sstevel@tonic-gate 	/*
9320Sstevel@tonic-gate 	 *	const int fd;			-- open connection end point
9330Sstevel@tonic-gate 	 *	const uint_t sendsize;		-- max send size
9340Sstevel@tonic-gate 	 *	const uint_t recvsize;		-- max recv size
9350Sstevel@tonic-gate 	 */
9360Sstevel@tonic-gate 
9370Sstevel@tonic-gate extern SVCXPRT	*svc_dg_create(const int, const uint_t, const uint_t);
9380Sstevel@tonic-gate 	/*
9390Sstevel@tonic-gate 	 * const int fd;			-- open connection
9400Sstevel@tonic-gate 	 * const uint_t sendsize;		-- max send size
9410Sstevel@tonic-gate 	 * const uint_t recvsize;		-- max recv size
9420Sstevel@tonic-gate 	 */
9430Sstevel@tonic-gate 
9440Sstevel@tonic-gate /*
9450Sstevel@tonic-gate  * the routine takes any *open* TLI file
9460Sstevel@tonic-gate  * descriptor as its first input and is used for open connections.
9470Sstevel@tonic-gate  */
9480Sstevel@tonic-gate extern  SVCXPRT	*svc_fd_create(const int, const uint_t, const uint_t);
9490Sstevel@tonic-gate 	/*
9500Sstevel@tonic-gate 	 * 	const int fd;			-- open connection end point
9510Sstevel@tonic-gate 	 * 	const uint_t sendsize;		-- max send size
9520Sstevel@tonic-gate 	 * 	const uint_t recvsize;		-- max recv size
9530Sstevel@tonic-gate 	 */
9540Sstevel@tonic-gate 
9550Sstevel@tonic-gate /*
9560Sstevel@tonic-gate  * Memory based rpc (for speed check and testing)
9570Sstevel@tonic-gate  */
9580Sstevel@tonic-gate extern SVCXPRT	*svc_raw_create(void);
9590Sstevel@tonic-gate 
9600Sstevel@tonic-gate /*
9610Sstevel@tonic-gate  * Creation of service over doors transport.
9620Sstevel@tonic-gate  */
9630Sstevel@tonic-gate extern SVCXPRT	*svc_door_create(void (*)(struct svc_req *, SVCXPRT *),
9640Sstevel@tonic-gate 				const rpcprog_t, const rpcvers_t,
9650Sstevel@tonic-gate 				const uint_t);
9660Sstevel@tonic-gate 	/*
9670Sstevel@tonic-gate 	 * 	void (*dispatch)();		-- dispatch routine
9680Sstevel@tonic-gate 	 *	const rpcprog_t prognum;	-- program number
9690Sstevel@tonic-gate 	 *	const rpcvers_t versnum;	-- version number
9700Sstevel@tonic-gate 	 *	const uint_t sendsize;		-- send buffer size
9710Sstevel@tonic-gate 	 */
9720Sstevel@tonic-gate 
9730Sstevel@tonic-gate /*
9740Sstevel@tonic-gate  * Service control interface
9750Sstevel@tonic-gate  */
9760Sstevel@tonic-gate extern	bool_t	svc_control(SVCXPRT *, const uint_t, void *);
9770Sstevel@tonic-gate 	/*
9780Sstevel@tonic-gate 	 *	SVCXPRT *svc;			-- service to manipulate
9790Sstevel@tonic-gate 	 *	const uint_t req;		-- request
9800Sstevel@tonic-gate 	 *	void *info;			-- argument to request
9810Sstevel@tonic-gate 	 */
9820Sstevel@tonic-gate 
9830Sstevel@tonic-gate /*
9840Sstevel@tonic-gate  * svc_dg_enable_cache() enables the cache on dg transports.
9850Sstevel@tonic-gate  */
9860Sstevel@tonic-gate extern int svc_dg_enablecache(SVCXPRT *, const uint_t);
9870Sstevel@tonic-gate #else	/* __STDC__ */
9880Sstevel@tonic-gate extern int	svc_create();
9890Sstevel@tonic-gate extern SVCXPRT	*svc_tp_create();
9900Sstevel@tonic-gate extern SVCXPRT	*svc_tli_create();
9910Sstevel@tonic-gate extern SVCXPRT	*svc_vc_create();
9920Sstevel@tonic-gate extern SVCXPRT	*svc_dg_create();
9930Sstevel@tonic-gate extern SVCXPRT	*svc_fd_create();
9940Sstevel@tonic-gate extern SVCXPRT	*svc_raw_create();
9950Sstevel@tonic-gate extern SVCXPRT	*svc_door_create();
9960Sstevel@tonic-gate extern int svc_dg_enablecache();
9970Sstevel@tonic-gate #endif	/* __STDC__ */
9980Sstevel@tonic-gate 
9991676Sjpk extern boolean_t is_multilevel(rpcprog_t);
10001676Sjpk 
10010Sstevel@tonic-gate #ifdef	PORTMAP
10020Sstevel@tonic-gate /* For backward compatibility */
10030Sstevel@tonic-gate #include <rpc/svc_soc.h>
10040Sstevel@tonic-gate #endif	/* PORTMAP */
10050Sstevel@tonic-gate 
10060Sstevel@tonic-gate /*
10070Sstevel@tonic-gate  * For user level MT hot server functions
10080Sstevel@tonic-gate  */
10090Sstevel@tonic-gate 
10100Sstevel@tonic-gate /*
10110Sstevel@tonic-gate  * Different MT modes
10120Sstevel@tonic-gate  */
10130Sstevel@tonic-gate #define	RPC_SVC_MT_NONE		0	/* default, single-threaded */
10140Sstevel@tonic-gate #define	RPC_SVC_MT_AUTO		1	/* automatic MT mode */
10150Sstevel@tonic-gate #define	RPC_SVC_MT_USER		2	/* user MT mode */
10160Sstevel@tonic-gate 
10170Sstevel@tonic-gate #ifdef	__STDC__
10180Sstevel@tonic-gate extern void	svc_done(SVCXPRT *);
10190Sstevel@tonic-gate #else
10200Sstevel@tonic-gate extern void	svc_done();
10210Sstevel@tonic-gate #endif	/* __STDC__ */
10220Sstevel@tonic-gate 
10230Sstevel@tonic-gate /*
10240Sstevel@tonic-gate  * Obtaining local credentials.
10250Sstevel@tonic-gate  */
10260Sstevel@tonic-gate typedef struct __svc_local_cred_t {
10270Sstevel@tonic-gate 	uid_t	euid;	/* effective uid */
10280Sstevel@tonic-gate 	gid_t	egid;	/* effective gid */
10290Sstevel@tonic-gate 	uid_t	ruid;	/* real uid */
10300Sstevel@tonic-gate 	gid_t	rgid;	/* real gid */
10310Sstevel@tonic-gate 	pid_t	pid;	/* caller's pid, or -1 if not available */
10320Sstevel@tonic-gate } svc_local_cred_t;
10330Sstevel@tonic-gate 
10340Sstevel@tonic-gate #ifdef __STDC__
10350Sstevel@tonic-gate struct ucred_s;
10360Sstevel@tonic-gate extern void	svc_fd_negotiate_ucred(int);
10370Sstevel@tonic-gate extern int	svc_getcallerucred(const SVCXPRT *, struct ucred_s **);
10380Sstevel@tonic-gate extern bool_t	svc_get_local_cred(SVCXPRT *, svc_local_cred_t *);
10390Sstevel@tonic-gate #else
10400Sstevel@tonic-gate extern void	svc_fd_negotiate_ucred();
10410Sstevel@tonic-gate extern int	svc_getcallerucred();
10420Sstevel@tonic-gate extern bool_t	svc_get_local_cred();
10430Sstevel@tonic-gate #endif	/* __STDC__ */
10440Sstevel@tonic-gate 
10450Sstevel@tonic-gate /*
10460Sstevel@tonic-gate  * Private interfaces and structures for user level duplicate request caching.
10470Sstevel@tonic-gate  * The interfaces and data structures are not committed and subject to
10480Sstevel@tonic-gate  * change in future releases. Currently only intended for use by automountd.
10490Sstevel@tonic-gate  */
10500Sstevel@tonic-gate struct dupreq {
10510Sstevel@tonic-gate 	uint32_t	dr_xid;
10520Sstevel@tonic-gate 	rpcproc_t	dr_proc;
10530Sstevel@tonic-gate 	rpcvers_t	dr_vers;
10540Sstevel@tonic-gate 	rpcprog_t	dr_prog;
10550Sstevel@tonic-gate 	struct netbuf	dr_addr;
10560Sstevel@tonic-gate 	struct netbuf	dr_resp;
10570Sstevel@tonic-gate 	int		dr_status;
10580Sstevel@tonic-gate 	time_t		dr_time;
10590Sstevel@tonic-gate 	uint_t		dr_hash;
10600Sstevel@tonic-gate 	struct dupreq	*dr_next;
10610Sstevel@tonic-gate 	struct dupreq	*dr_prev;
10620Sstevel@tonic-gate 	struct dupreq	*dr_chain;
10630Sstevel@tonic-gate 	struct dupreq	*dr_prevchain;
10640Sstevel@tonic-gate };
10650Sstevel@tonic-gate 
10660Sstevel@tonic-gate /*
10670Sstevel@tonic-gate  * The fixedtime state is defined if we want to expand the routines to
10680Sstevel@tonic-gate  * handle and encompass fixed size caches.
10690Sstevel@tonic-gate  */
10700Sstevel@tonic-gate #define	DUPCACHE_FIXEDTIME	0
10710Sstevel@tonic-gate 
10720Sstevel@tonic-gate /*
10730Sstevel@tonic-gate  * States of requests for duplicate request caching.
10740Sstevel@tonic-gate  * These are the same as defined for the kernel.
10750Sstevel@tonic-gate  */
10760Sstevel@tonic-gate #define	DUP_NEW			0x00	/* new entry */
10770Sstevel@tonic-gate #define	DUP_INPROGRESS		0x01	/* request already going */
10780Sstevel@tonic-gate #define	DUP_DONE		0x02	/* request done */
10790Sstevel@tonic-gate #define	DUP_DROP		0x03	/* request dropped */
10800Sstevel@tonic-gate #define	DUP_ERROR		0x04	/* error in dup req cache */
10810Sstevel@tonic-gate 
10820Sstevel@tonic-gate #ifdef __STDC__
10830Sstevel@tonic-gate extern bool_t	__svc_dupcache_init(void *, int, char **);
10840Sstevel@tonic-gate extern int	__svc_dup(struct svc_req *, caddr_t *, uint_t *, char *);
10850Sstevel@tonic-gate extern int	__svc_dupdone(struct svc_req *, caddr_t, uint_t, int, char *);
10860Sstevel@tonic-gate extern bool_t	__svc_vc_dupcache_init(SVCXPRT *, void *, int);
10870Sstevel@tonic-gate extern int	__svc_vc_dup(struct svc_req *, caddr_t *, uint_t *);
10880Sstevel@tonic-gate extern int	__svc_vc_dupdone(struct svc_req *, caddr_t, uint_t, int);
10890Sstevel@tonic-gate #else
10900Sstevel@tonic-gate extern bool_t	__svc_dupcache_init();
10910Sstevel@tonic-gate extern int	__svc_dup();
10920Sstevel@tonic-gate extern int	__svc_dupdone();
10930Sstevel@tonic-gate extern bool_t	__svc_vc_dupcache_init();
10940Sstevel@tonic-gate extern int	__svc_vc_dup();
10950Sstevel@tonic-gate extern int	__svc_vc_dupdone();
10960Sstevel@tonic-gate #endif	/* __STDC__ */
10970Sstevel@tonic-gate #endif	/* _KERNEL */
10980Sstevel@tonic-gate 
10990Sstevel@tonic-gate #ifdef	__cplusplus
11000Sstevel@tonic-gate }
11010Sstevel@tonic-gate #endif
11020Sstevel@tonic-gate 
11030Sstevel@tonic-gate #endif	/* !_RPC_SVC_H */
1104