xref: /onnv-gate/usr/src/uts/common/rpc/svc.h (revision 11967:f91b268929d9)
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 /*
22*11967SKaren.Rochford@Sun.COM  * Copyright 2010 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 #include <rpc/rpc_com.h>
410Sstevel@tonic-gate #include <rpc/rpc_msg.h>
420Sstevel@tonic-gate #include <sys/tihdr.h>
430Sstevel@tonic-gate #include <sys/poll.h>
441676Sjpk #include <sys/tsol/label.h>
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #ifdef	_KERNEL
470Sstevel@tonic-gate #include <rpc/svc_auth.h>
480Sstevel@tonic-gate #include <sys/callb.h>
490Sstevel@tonic-gate #endif	/* _KERNEL */
500Sstevel@tonic-gate 
510Sstevel@tonic-gate /*
520Sstevel@tonic-gate  * This interface must manage two items concerning remote procedure calling:
530Sstevel@tonic-gate  *
540Sstevel@tonic-gate  * 1) An arbitrary number of transport connections upon which rpc requests
550Sstevel@tonic-gate  * are received. They are created and registered by routines in svc_generic.c,
560Sstevel@tonic-gate  * svc_vc.c and svc_dg.c; they in turn call xprt_register and
570Sstevel@tonic-gate  * xprt_unregister.
580Sstevel@tonic-gate  *
590Sstevel@tonic-gate  * 2) An arbitrary number of locally registered services.  Services are
600Sstevel@tonic-gate  * described by the following four data: program number, version number,
610Sstevel@tonic-gate  * "service dispatch" function, a transport handle, and a boolean that
620Sstevel@tonic-gate  * indicates whether or not the exported program should be registered with a
630Sstevel@tonic-gate  * local binder service;  if true the program's number and version and the
640Sstevel@tonic-gate  * address from the transport handle are registered with the binder.
650Sstevel@tonic-gate  * These data are registered with rpcbind via svc_reg().
660Sstevel@tonic-gate  *
670Sstevel@tonic-gate  * A service's dispatch function is called whenever an rpc request comes in
680Sstevel@tonic-gate  * on a transport.  The request's program and version numbers must match
690Sstevel@tonic-gate  * those of the registered service.  The dispatch function is passed two
700Sstevel@tonic-gate  * parameters, struct svc_req * and SVCXPRT *, defined below.
710Sstevel@tonic-gate  */
720Sstevel@tonic-gate 
730Sstevel@tonic-gate #ifdef __cplusplus
740Sstevel@tonic-gate extern "C" {
750Sstevel@tonic-gate #endif
760Sstevel@tonic-gate 
770Sstevel@tonic-gate /*
780Sstevel@tonic-gate  * Server-side transport handles.
790Sstevel@tonic-gate  * The actual type definitions are below.
800Sstevel@tonic-gate  */
810Sstevel@tonic-gate #ifdef	_KERNEL
820Sstevel@tonic-gate typedef struct __svcmasterxprt	SVCMASTERXPRT;	/* Master transport handle */
830Sstevel@tonic-gate typedef struct __svcxprt	SVCXPRT;	/* Per-thread clone handle */
840Sstevel@tonic-gate typedef	struct __svcpool	SVCPOOL;	/* Kernel thread pool	   */
850Sstevel@tonic-gate #else	/* _KERNEL */
860Sstevel@tonic-gate typedef struct __svcxprt	SVCXPRT;	/* Server transport handle */
870Sstevel@tonic-gate #endif	/* _KERNEL */
880Sstevel@tonic-gate 
890Sstevel@tonic-gate /*
900Sstevel@tonic-gate  *  Prototype of error handler callback
910Sstevel@tonic-gate  */
920Sstevel@tonic-gate #ifndef _KERNEL
930Sstevel@tonic-gate typedef void (*svc_errorhandler_t)(const SVCXPRT* svc, const bool_t isAConn);
940Sstevel@tonic-gate #endif
950Sstevel@tonic-gate 
960Sstevel@tonic-gate /*
970Sstevel@tonic-gate  * Service request.
980Sstevel@tonic-gate  *
990Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
1000Sstevel@tonic-gate  * svc_req
1010Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
1020Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
1030Sstevel@tonic-gate  */
1040Sstevel@tonic-gate struct svc_req {
1050Sstevel@tonic-gate 	rpcprog_t	rq_prog;	/* service program number */
1060Sstevel@tonic-gate 	rpcvers_t	rq_vers;	/* service protocol version */
1070Sstevel@tonic-gate 	rpcproc_t	rq_proc;	/* the desired procedure */
1080Sstevel@tonic-gate 	struct opaque_auth rq_cred;	/* raw creds from the wire */
1090Sstevel@tonic-gate 	caddr_t		rq_clntcred;	/* read only cooked cred */
1100Sstevel@tonic-gate 	SVCXPRT		*rq_xprt;	/* associated transport */
1111676Sjpk 	bslabel_t	*rq_label;	/* TSOL label of the request */
1120Sstevel@tonic-gate };
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate #ifdef _KERNEL
1150Sstevel@tonic-gate struct dupreq {
1160Sstevel@tonic-gate 	uint32_t	dr_xid;
1170Sstevel@tonic-gate 	rpcproc_t	dr_proc;
1180Sstevel@tonic-gate 	rpcvers_t	dr_vers;
1190Sstevel@tonic-gate 	rpcprog_t	dr_prog;
1200Sstevel@tonic-gate 	struct netbuf	dr_addr;
1210Sstevel@tonic-gate 	struct netbuf	dr_resp;
1220Sstevel@tonic-gate 	void		(*dr_resfree)();
1230Sstevel@tonic-gate 	int		dr_status;
1240Sstevel@tonic-gate 	struct dupreq	*dr_next;
1250Sstevel@tonic-gate 	struct dupreq	*dr_chain;
1260Sstevel@tonic-gate };
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate /*
1290Sstevel@tonic-gate  * States of requests for duplicate request caching.
1300Sstevel@tonic-gate  */
1310Sstevel@tonic-gate #define	DUP_NEW			0x00	/* new entry */
1320Sstevel@tonic-gate #define	DUP_INPROGRESS		0x01	/* request already going */
1330Sstevel@tonic-gate #define	DUP_DONE		0x02	/* request done */
1340Sstevel@tonic-gate #define	DUP_DROP		0x03	/* request dropped */
1350Sstevel@tonic-gate #define	DUP_ERROR		0x04	/* error in dup req cache */
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate /*
1380Sstevel@tonic-gate  * Prototype for a service dispatch routine.
1390Sstevel@tonic-gate  */
1400Sstevel@tonic-gate typedef void (SVC_DISPATCH)(struct svc_req *, SVCXPRT *);
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate /*
1430Sstevel@tonic-gate  * The service provider callout.
1440Sstevel@tonic-gate  * Each entry identifies a dispatch routine to be called
1450Sstevel@tonic-gate  * for a given RPC program number and a version fitting
1460Sstevel@tonic-gate  * into the registered range.
1470Sstevel@tonic-gate  */
1480Sstevel@tonic-gate typedef struct {
1490Sstevel@tonic-gate 	rpcprog_t	sc_prog;	/* RPC Program number */
1500Sstevel@tonic-gate 	rpcvers_t	sc_versmin;	/* Min version number */
1510Sstevel@tonic-gate 	rpcvers_t	sc_versmax;	/* Max version number */
1520Sstevel@tonic-gate 	SVC_DISPATCH	*sc_dispatch;	/* Dispatch routine   */
1530Sstevel@tonic-gate } SVC_CALLOUT;
1540Sstevel@tonic-gate 
1550Sstevel@tonic-gate /*
1560Sstevel@tonic-gate  * Table of service provider `callouts' for an RPC
1570Sstevel@tonic-gate  * transport handle. If sct_free is TRUE then transport
1580Sstevel@tonic-gate  * destructor is supposed to deallocate this table.
1590Sstevel@tonic-gate  */
1600Sstevel@tonic-gate typedef struct {
1610Sstevel@tonic-gate 	size_t		sct_size;	/* Number of entries  */
1620Sstevel@tonic-gate 	bool_t		sct_free;	/* Deallocate if true */
1630Sstevel@tonic-gate 	SVC_CALLOUT	*sct_sc;	/* Callout entries    */
1640Sstevel@tonic-gate } SVC_CALLOUT_TABLE;
1650Sstevel@tonic-gate 
1660Sstevel@tonic-gate struct svc_ops {
1670Sstevel@tonic-gate 	bool_t	(*xp_recv)(SVCXPRT *, mblk_t *, struct rpc_msg *);
1680Sstevel@tonic-gate 		/* receive incoming requests */
1690Sstevel@tonic-gate 	bool_t	(*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t);
1700Sstevel@tonic-gate 		/* get arguments */
1710Sstevel@tonic-gate 	bool_t	(*xp_reply)(SVCXPRT *, struct rpc_msg *);
1720Sstevel@tonic-gate 		/* send reply */
1730Sstevel@tonic-gate 	bool_t	(*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t);
1740Sstevel@tonic-gate 		/* free mem allocated for args */
1750Sstevel@tonic-gate 	void	(*xp_destroy)(SVCMASTERXPRT *);
1760Sstevel@tonic-gate 		/* destroy this struct */
1770Sstevel@tonic-gate 	int	(*xp_dup)(struct svc_req *, caddr_t, int,
1780Sstevel@tonic-gate 				struct dupreq **, bool_t *);
1790Sstevel@tonic-gate 		/* check for dup */
1800Sstevel@tonic-gate 	void	(*xp_dupdone)(struct dupreq *, caddr_t, void (*)(), int, int);
1810Sstevel@tonic-gate 		/* mark dup entry as completed */
1820Sstevel@tonic-gate 	int32_t *(*xp_getres)(SVCXPRT *, int);
1830Sstevel@tonic-gate 		/* get pointer to response buffer */
1840Sstevel@tonic-gate 	void	(*xp_freeres)(SVCXPRT *);
1850Sstevel@tonic-gate 		/* destroy pre-serialized response */
1860Sstevel@tonic-gate 	void	(*xp_clone_destroy)(SVCXPRT *);
1870Sstevel@tonic-gate 		/* destroy a clone xprt */
1880Sstevel@tonic-gate 	void	(*xp_start)(SVCMASTERXPRT *);
1890Sstevel@tonic-gate 		/* `ready-to-receive' */
190*11967SKaren.Rochford@Sun.COM 	void	(*xp_clone_xprt)(SVCXPRT *, SVCXPRT *);
191*11967SKaren.Rochford@Sun.COM 		/* transport specific clone function */
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	*/
3947208Svv149972 	struct netbuf	xpc_lcladdr;	/* local transport address	*/
39510326SSiddheshwar.Mahesh@Sun.COM 	char		*xpc_netid;	/* network token		*/
3960Sstevel@tonic-gate 	SVC_CALLOUT_TABLE *xpc_sct;
3970Sstevel@tonic-gate } __SVCXPRT_COMMON;
3980Sstevel@tonic-gate 
3990Sstevel@tonic-gate #define	xp_fp		xp_xpc.xpc_fp
4000Sstevel@tonic-gate #define	xp_ops		xp_xpc.xpc_ops
4010Sstevel@tonic-gate #define	xp_wq		xp_xpc.xpc_wq
4020Sstevel@tonic-gate #define	xp_cred		xp_xpc.xpc_cred
4030Sstevel@tonic-gate #define	xp_type		xp_xpc.xpc_type
4040Sstevel@tonic-gate #define	xp_msg_size	xp_xpc.xpc_msg_size
4050Sstevel@tonic-gate #define	xp_rtaddr	xp_xpc.xpc_rtaddr
4067208Svv149972 #define	xp_lcladdr	xp_xpc.xpc_lcladdr
4070Sstevel@tonic-gate #define	xp_sct		xp_xpc.xpc_sct
40810326SSiddheshwar.Mahesh@Sun.COM #define	xp_netid	xp_xpc.xpc_netid
4090Sstevel@tonic-gate 
4100Sstevel@tonic-gate struct __svcmasterxprt {
4110Sstevel@tonic-gate 	SVCMASTERXPRT 	*xp_next;	/* Next transport in the list	*/
4120Sstevel@tonic-gate 	SVCMASTERXPRT 	*xp_prev;	/* Prev transport in the list	*/
4130Sstevel@tonic-gate 	__SVCXPRT_COMMON xp_xpc;	/* Fields common with the clone	*/
4140Sstevel@tonic-gate 	SVCPOOL		*xp_pool;	/* Pointer to the pool		*/
4150Sstevel@tonic-gate 	mblk_t		*xp_req_head;	/* Request queue head		*/
4160Sstevel@tonic-gate 	mblk_t		*xp_req_tail;	/* Request queue tail		*/
4170Sstevel@tonic-gate 	kmutex_t	xp_req_lock;	/* Request lock			*/
4180Sstevel@tonic-gate 	int		xp_threads;	/* Current num. of attached threads */
4190Sstevel@tonic-gate 	int		xp_detached_threads; /* num. of detached threads */
4200Sstevel@tonic-gate 	kmutex_t	xp_thread_lock;	/* Thread count lock		*/
4210Sstevel@tonic-gate 	void		(*xp_closeproc)(const SVCMASTERXPRT *);
4220Sstevel@tonic-gate 					/* optional; see comments above	*/
4230Sstevel@tonic-gate 	struct netbuf	xp_addrmask;	/* address mask			*/
4240Sstevel@tonic-gate 
4250Sstevel@tonic-gate 	caddr_t		xp_p2;		/* private: for use by svc ops  */
4260Sstevel@tonic-gate };
4270Sstevel@tonic-gate 
4280Sstevel@tonic-gate /*
4290Sstevel@tonic-gate  * Service thread `clone' transport handle (SVCXPRT)
4300Sstevel@tonic-gate  *
4310Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
4320Sstevel@tonic-gate  * SVCXPRT
4330Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
4340Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
4350Sstevel@tonic-gate  *
4360Sstevel@tonic-gate  * The xp_p2buf buffer is used as the storage for a transport type
4370Sstevel@tonic-gate  * specific structure. It is private for the svc ops for a given
4380Sstevel@tonic-gate  * transport type.
4390Sstevel@tonic-gate  */
4400Sstevel@tonic-gate 
4417387SRobert.Gordon@Sun.COM #define	SVC_P2LEN   128
4420Sstevel@tonic-gate 
4430Sstevel@tonic-gate struct __svcxprt {
4440Sstevel@tonic-gate 	__SVCXPRT_COMMON xp_xpc;
4450Sstevel@tonic-gate 	SVCMASTERXPRT	*xp_master;	/* back ptr to master		*/
4460Sstevel@tonic-gate 
4470Sstevel@tonic-gate 	/* The following fileds are on a per-thread basis */
4480Sstevel@tonic-gate 	callb_cpr_t	*xp_cprp;	/* unused padding for Contract	*/
4490Sstevel@tonic-gate 	bool_t		xp_reserved : 1; /* is thread reserved?		*/
4500Sstevel@tonic-gate 	bool_t		xp_detached : 1; /* is thread detached?		*/
4510Sstevel@tonic-gate 	int		xp_same_xprt;	/* Reqs from the same xprt	*/
4520Sstevel@tonic-gate 
4530Sstevel@tonic-gate 	/* The following fields are used on a per-request basis */
4540Sstevel@tonic-gate 	struct opaque_auth xp_verf;	/* raw response verifier	*/
4550Sstevel@tonic-gate 	SVCAUTH		xp_auth;	/* auth flavor of current req	*/
4560Sstevel@tonic-gate 	void		*xp_cookie;	/* a cookie			*/
4570Sstevel@tonic-gate 	uint32_t	xp_xid;		/* id				*/
4580Sstevel@tonic-gate 	XDR		xp_xdrin;	/* input xdr stream		*/
4590Sstevel@tonic-gate 	XDR		xp_xdrout;	/* output xdr stream		*/
4600Sstevel@tonic-gate 
4610Sstevel@tonic-gate 	/* Private for svc ops */
4620Sstevel@tonic-gate 	char		xp_p2buf[SVC_P2LEN]; /* udp_data or cots_data_t */
4630Sstevel@tonic-gate 						/* or clone_rdma_data_t */
4640Sstevel@tonic-gate };
4650Sstevel@tonic-gate #else	/* _KERNEL */
4660Sstevel@tonic-gate struct __svcxprt {
4670Sstevel@tonic-gate 	int		xp_fd;
4680Sstevel@tonic-gate #define	xp_sock		xp_fd
4690Sstevel@tonic-gate 	ushort_t	xp_port;
4700Sstevel@tonic-gate 	/*
4710Sstevel@tonic-gate 	 * associated port number.
4720Sstevel@tonic-gate 	 * Obsolete, but still used to
4730Sstevel@tonic-gate 	 * specify whether rendezvouser
4740Sstevel@tonic-gate 	 * or normal connection
4750Sstevel@tonic-gate 	 */
4760Sstevel@tonic-gate 	struct	xp_ops	*xp_ops;
4770Sstevel@tonic-gate 	int		xp_addrlen;	/* length of remote addr. Obsoleted */
4780Sstevel@tonic-gate 	char		*xp_tp;		/* transport provider device name */
4790Sstevel@tonic-gate 	char		*xp_netid;	/* network token */
4800Sstevel@tonic-gate 	struct netbuf	xp_ltaddr;	/* local transport address */
4810Sstevel@tonic-gate 	struct netbuf	xp_rtaddr;	/* remote transport address */
4820Sstevel@tonic-gate 	char		xp_raddr[16];	/* remote address. Now obsoleted */
4830Sstevel@tonic-gate 	struct opaque_auth xp_verf;	/* raw response verifier */
4840Sstevel@tonic-gate 	caddr_t		xp_p1;		/* private: for use by svc ops */
4850Sstevel@tonic-gate 	caddr_t		xp_p2;		/* private: for use by svc ops */
4860Sstevel@tonic-gate 	caddr_t		xp_p3;		/* private: for use by svc lib */
4870Sstevel@tonic-gate 	int		xp_type;	/* transport type */
4880Sstevel@tonic-gate 	/*
4890Sstevel@tonic-gate 	 * callback on client death
4900Sstevel@tonic-gate 	 * First parameter is the current structure,
4910Sstevel@tonic-gate 	 * Second parameter :
4920Sstevel@tonic-gate 	 *	- FALSE for the service listener
4930Sstevel@tonic-gate 	 *	- TRUE for a real connected socket
4940Sstevel@tonic-gate 	 */
4950Sstevel@tonic-gate 	svc_errorhandler_t xp_closeclnt;
4960Sstevel@tonic-gate };
4970Sstevel@tonic-gate #endif	/* _KERNEL */
4980Sstevel@tonic-gate 
4990Sstevel@tonic-gate /*
5000Sstevel@tonic-gate  *  Approved way of getting address of caller,
5010Sstevel@tonic-gate  *  address mask, and netid of transport.
5020Sstevel@tonic-gate  */
5030Sstevel@tonic-gate #define	svc_getrpccaller(x) (&(x)->xp_rtaddr)
5040Sstevel@tonic-gate #ifdef _KERNEL
5050Sstevel@tonic-gate #define	svc_getcaller(x) (&(x)->xp_rtaddr.buf)
5060Sstevel@tonic-gate #define	svc_getaddrmask(x) (&(x)->xp_master->xp_addrmask)
50710326SSiddheshwar.Mahesh@Sun.COM #define	svc_getnetid(x) ((x)->xp_netid)
5080Sstevel@tonic-gate #endif	/* _KERNEL */
5090Sstevel@tonic-gate 
5100Sstevel@tonic-gate /*
5110Sstevel@tonic-gate  * Operations defined on an SVCXPRT handle
5120Sstevel@tonic-gate  */
5130Sstevel@tonic-gate 
5140Sstevel@tonic-gate #ifdef	_KERNEL
515*11967SKaren.Rochford@Sun.COM 
516*11967SKaren.Rochford@Sun.COM #define	SVC_CLONE_XPRT(src_xprt, dst_xprt) \
517*11967SKaren.Rochford@Sun.COM 	if ((src_xprt)->xp_ops->xp_clone_xprt) \
518*11967SKaren.Rochford@Sun.COM 		(*(src_xprt)->xp_ops->xp_clone_xprt) \
519*11967SKaren.Rochford@Sun.COM 		    (src_xprt, dst_xprt)
520*11967SKaren.Rochford@Sun.COM 
5210Sstevel@tonic-gate #define	SVC_RECV(clone_xprt, mp, msg) \
5220Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_recv)((clone_xprt), (mp), (msg))
5230Sstevel@tonic-gate 
5240Sstevel@tonic-gate /*
5250Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
5260Sstevel@tonic-gate  * SVC_GETARGS
5270Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
5280Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
5290Sstevel@tonic-gate  */
5300Sstevel@tonic-gate #define	SVC_GETARGS(clone_xprt, xargs, argsp) \
5310Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_getargs)((clone_xprt), (xargs), (argsp))
5320Sstevel@tonic-gate 
5330Sstevel@tonic-gate #define	SVC_REPLY(clone_xprt, msg) \
5340Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_reply) ((clone_xprt), (msg))
5350Sstevel@tonic-gate 
5360Sstevel@tonic-gate #define	SVC_FREEARGS(clone_xprt, xargs, argsp) \
5370Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_freeargs)((clone_xprt), (xargs), (argsp))
5380Sstevel@tonic-gate 
5390Sstevel@tonic-gate #define	SVC_GETRES(clone_xprt, size) \
5400Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_getres)((clone_xprt), (size))
5410Sstevel@tonic-gate 
5420Sstevel@tonic-gate #define	SVC_FREERES(clone_xprt)	\
5430Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_freeres)(clone_xprt)
5440Sstevel@tonic-gate 
5450Sstevel@tonic-gate #define	SVC_DESTROY(xprt) \
5460Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_destroy)(xprt)
5470Sstevel@tonic-gate 
5480Sstevel@tonic-gate /*
5490Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interfaces
5500Sstevel@tonic-gate  * SVC_DUP, SVC_DUPDONE, SVC_DUP_EXT, SVC_DUPDONE_EXT
5510Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
5520Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
5530Sstevel@tonic-gate  *
5540Sstevel@tonic-gate  * SVC_DUP and SVC_DUPDONE are defined here for backward compatibility.
5550Sstevel@tonic-gate  */
5560Sstevel@tonic-gate #define	SVC_DUP_EXT(clone_xprt, req, res, size, drpp, dupcachedp) \
5570Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, dupcachedp)
5580Sstevel@tonic-gate 
5590Sstevel@tonic-gate #define	SVC_DUPDONE_EXT(clone_xprt, dr, res, resfree, size, status) \
5600Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, resfree, size, status)
5610Sstevel@tonic-gate 
5620Sstevel@tonic-gate #define	SVC_DUP(clone_xprt, req, res, size, drpp) \
5630Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, NULL)
5640Sstevel@tonic-gate 
5650Sstevel@tonic-gate #define	SVC_DUPDONE(clone_xprt, dr, res, size, status) \
5660Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, NULL, size, status)
5670Sstevel@tonic-gate 
5680Sstevel@tonic-gate #define	SVC_CLONE_DESTROY(clone_xprt) \
5690Sstevel@tonic-gate 	(*(clone_xprt)->xp_ops->xp_clone_destroy)(clone_xprt)
5700Sstevel@tonic-gate 
5710Sstevel@tonic-gate 
5720Sstevel@tonic-gate #define	SVC_START(xprt) \
5730Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_start)(xprt)
5740Sstevel@tonic-gate 
5750Sstevel@tonic-gate #else	/* _KERNEL */
5760Sstevel@tonic-gate 
5770Sstevel@tonic-gate #define	SVC_RECV(xprt, msg) \
5780Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
5790Sstevel@tonic-gate #define	svc_recv(xprt, msg) \
5800Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
5810Sstevel@tonic-gate 
5820Sstevel@tonic-gate #define	SVC_STAT(xprt) \
5830Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_stat)(xprt)
5840Sstevel@tonic-gate #define	svc_stat(xprt) \
5850Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_stat)(xprt)
5860Sstevel@tonic-gate 
5870Sstevel@tonic-gate #define	SVC_GETARGS(xprt, xargs, argsp) \
5880Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
5890Sstevel@tonic-gate #define	svc_getargs(xprt, xargs, argsp)	\
5900Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
5910Sstevel@tonic-gate 
5920Sstevel@tonic-gate #define	SVC_REPLY(xprt, msg) \
5930Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
5940Sstevel@tonic-gate #define	svc_reply(xprt, msg) \
5950Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
5960Sstevel@tonic-gate 
5970Sstevel@tonic-gate #define	SVC_FREEARGS(xprt, xargs, argsp) \
5980Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
5990Sstevel@tonic-gate #define	svc_freeargs(xprt, xargs, argsp) \
6000Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
6010Sstevel@tonic-gate 
6020Sstevel@tonic-gate #define	SVC_GETRES(xprt, size) \
6030Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_getres)((xprt), (size))
6040Sstevel@tonic-gate #define	svc_getres(xprt, size) \
6050Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_getres)((xprt), (size))
6060Sstevel@tonic-gate 
6070Sstevel@tonic-gate #define	SVC_FREERES(xprt) \
6080Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_freeres)(xprt)
6090Sstevel@tonic-gate #define	svc_freeres(xprt) \
6100Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_freeres)(xprt)
6110Sstevel@tonic-gate 
6120Sstevel@tonic-gate #define	SVC_DESTROY(xprt) \
6130Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_destroy)(xprt)
6140Sstevel@tonic-gate #define	svc_destroy(xprt) \
6150Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_destroy)(xprt)
6160Sstevel@tonic-gate 
6170Sstevel@tonic-gate /*
6180Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
6190Sstevel@tonic-gate  * SVC_CONTROL
6200Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
6210Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
6220Sstevel@tonic-gate  */
6230Sstevel@tonic-gate #define	SVC_CONTROL(xprt, rq, in) \
6240Sstevel@tonic-gate 	(*(xprt)->xp_ops->xp_control)((xprt), (rq), (in))
6250Sstevel@tonic-gate #endif	/* _KERNEL */
6260Sstevel@tonic-gate 
6270Sstevel@tonic-gate /*
6280Sstevel@tonic-gate  * Pool id's reserved for NFS, NLM, and the NFSv4 callback program.
6290Sstevel@tonic-gate  */
6300Sstevel@tonic-gate #define	NFS_SVCPOOL_ID		0x01
6310Sstevel@tonic-gate #define	NLM_SVCPOOL_ID		0x02
6320Sstevel@tonic-gate #define	NFS_CB_SVCPOOL_ID	0x03
6330Sstevel@tonic-gate #define	RDC_SVCPOOL_ID		0x05	/* SNDR, PSARC 2001/699 */
6340Sstevel@tonic-gate 
6350Sstevel@tonic-gate struct svcpool_args {
6360Sstevel@tonic-gate 	uint32_t	id;		/* Pool id */
6370Sstevel@tonic-gate 	uint32_t	maxthreads;	/* Max threads in the pool */
6380Sstevel@tonic-gate 	uint32_t	redline;	/* `Redline' for the pool */
6390Sstevel@tonic-gate 	uint32_t	qsize;		/* `xprt-ready' queue size */
6400Sstevel@tonic-gate 	uint32_t	timeout;	/* svc_poll() timeout */
6410Sstevel@tonic-gate 	uint32_t	stksize;	/* svc_run() stack size */
6420Sstevel@tonic-gate 	uint32_t	max_same_xprt;	/* Max reqs from the same xprt */
6430Sstevel@tonic-gate };
6440Sstevel@tonic-gate 
6450Sstevel@tonic-gate 
6460Sstevel@tonic-gate #ifdef	_KERNEL
6470Sstevel@tonic-gate /*
6480Sstevel@tonic-gate  * Transport registration and thread pool creation.
6490Sstevel@tonic-gate  */
6500Sstevel@tonic-gate extern int	svc_xprt_register(SVCMASTERXPRT *, int);
6510Sstevel@tonic-gate extern void	svc_xprt_unregister(SVCMASTERXPRT *);
6520Sstevel@tonic-gate extern int	svc_pool_create(struct svcpool_args *);
6530Sstevel@tonic-gate extern int	svc_wait(int);
6540Sstevel@tonic-gate extern int	svc_do_run(int);
6550Sstevel@tonic-gate #define	SVCPSET_SHUTDOWN_PROC	1
6560Sstevel@tonic-gate #define	SVCPSET_UNREGISTER_PROC	2
6570Sstevel@tonic-gate extern int	svc_pool_control(int, int, void *);
6580Sstevel@tonic-gate #else	/* _KERNEL */
6590Sstevel@tonic-gate #ifdef	__STDC__
6600Sstevel@tonic-gate extern bool_t	rpc_reg(const rpcprog_t, const rpcvers_t, const rpcproc_t,
6610Sstevel@tonic-gate 			char *(*)(char *), const xdrproc_t, const xdrproc_t,
6620Sstevel@tonic-gate 			const char *);
6630Sstevel@tonic-gate 
6640Sstevel@tonic-gate /*
6650Sstevel@tonic-gate  * Service registration
6660Sstevel@tonic-gate  *
6670Sstevel@tonic-gate  * svc_reg(xprt, prog, vers, dispatch, nconf)
6680Sstevel@tonic-gate  *	const SVCXPRT *xprt;
6690Sstevel@tonic-gate  *	const rpcprog_t prog;
6700Sstevel@tonic-gate  *	const rpcvers_t vers;
6710Sstevel@tonic-gate  *	const void (*dispatch)();
6720Sstevel@tonic-gate  *	const struct netconfig *nconf;
6730Sstevel@tonic-gate  */
6740Sstevel@tonic-gate extern bool_t	svc_reg(const SVCXPRT *, const rpcprog_t, const rpcvers_t,
6750Sstevel@tonic-gate 			void (*)(struct svc_req *, SVCXPRT *),
6760Sstevel@tonic-gate 			const struct netconfig *);
6770Sstevel@tonic-gate 
6780Sstevel@tonic-gate /*
6790Sstevel@tonic-gate  * Service authentication registration
6800Sstevel@tonic-gate  *
6810Sstevel@tonic-gate  * svc_auth_reg(cred_flavor, handler)
6820Sstevel@tonic-gate  *    int cred_flavor;
6830Sstevel@tonic-gate  *    enum auth_stat (*handler)();
6840Sstevel@tonic-gate  */
6850Sstevel@tonic-gate extern int	svc_auth_reg(int, enum auth_stat (*)());
6860Sstevel@tonic-gate 
6870Sstevel@tonic-gate /*
6880Sstevel@tonic-gate  * Service un-registration
6890Sstevel@tonic-gate  *
6900Sstevel@tonic-gate  * svc_unreg(prog, vers)
6910Sstevel@tonic-gate  *	const rpcprog_t prog;
6920Sstevel@tonic-gate  *	const rpcvers_t vers;
6930Sstevel@tonic-gate  */
6940Sstevel@tonic-gate extern void	svc_unreg(const rpcprog_t, const rpcvers_t);
6950Sstevel@tonic-gate 
6960Sstevel@tonic-gate /*
6970Sstevel@tonic-gate  * Transport registration/unregistration.
6980Sstevel@tonic-gate  *
6990Sstevel@tonic-gate  * xprt_register(xprt)
7000Sstevel@tonic-gate  *	const SVCXPRT *xprt;
7010Sstevel@tonic-gate  *
7020Sstevel@tonic-gate  * xprt_unregister(xprt)
7030Sstevel@tonic-gate  *	const SVCXPRT *xprt;
7040Sstevel@tonic-gate  */
7050Sstevel@tonic-gate extern void	xprt_register(const SVCXPRT *);
7060Sstevel@tonic-gate extern void	xprt_unregister(const SVCXPRT *);
7070Sstevel@tonic-gate #else	/* __STDC__ */
7080Sstevel@tonic-gate extern bool_t	rpc_reg();
7090Sstevel@tonic-gate extern bool_t	svc_reg();
7100Sstevel@tonic-gate extern bool_t	svc_auth_reg();
7110Sstevel@tonic-gate extern void	svc_unreg();
7120Sstevel@tonic-gate extern void	xprt_register();
7130Sstevel@tonic-gate extern void	xprt_unregister();
7140Sstevel@tonic-gate #endif /* __STDC__ */
7150Sstevel@tonic-gate #endif	/* _KERNEL */
7160Sstevel@tonic-gate 
7170Sstevel@tonic-gate 
7180Sstevel@tonic-gate /*
7190Sstevel@tonic-gate  * When the service routine is called, it must first check to see if it
7200Sstevel@tonic-gate  * knows about the procedure;  if not, it should call svcerr_noproc
7210Sstevel@tonic-gate  * and return.  If so, it should deserialize its arguments via
7220Sstevel@tonic-gate  * SVC_GETARGS (defined above).  If the deserialization does not work,
7230Sstevel@tonic-gate  * svcerr_decode should be called followed by a return.  Successful
7240Sstevel@tonic-gate  * decoding of the arguments should be followed the execution of the
7250Sstevel@tonic-gate  * procedure's code and a call to svc_sendreply.
7260Sstevel@tonic-gate  *
7270Sstevel@tonic-gate  * Also, if the service refuses to execute the procedure due to too-
7280Sstevel@tonic-gate  * weak authentication parameters, svcerr_weakauth should be called.
7290Sstevel@tonic-gate  * Note: do not confuse access-control failure with weak authentication!
7300Sstevel@tonic-gate  *
7310Sstevel@tonic-gate  * NB: In pure implementations of rpc, the caller always waits for a reply
7320Sstevel@tonic-gate  * msg.  This message is sent when svc_sendreply is called.
7330Sstevel@tonic-gate  * Therefore pure service implementations should always call
7340Sstevel@tonic-gate  * svc_sendreply even if the function logically returns void;  use
7350Sstevel@tonic-gate  * xdr.h - xdr_void for the xdr routine.  HOWEVER, connectionful rpc allows
7360Sstevel@tonic-gate  * for the abuse of pure rpc via batched calling or pipelining.  In the
7370Sstevel@tonic-gate  * case of a batched call, svc_sendreply should NOT be called since
7380Sstevel@tonic-gate  * this would send a return message, which is what batching tries to avoid.
7390Sstevel@tonic-gate  * It is the service/protocol writer's responsibility to know which calls are
7400Sstevel@tonic-gate  * batched and which are not.  Warning: responding to batch calls may
7410Sstevel@tonic-gate  * deadlock the caller and server processes!
7420Sstevel@tonic-gate  */
7430Sstevel@tonic-gate #ifdef	__STDC__
7440Sstevel@tonic-gate extern bool_t	svc_sendreply(const SVCXPRT *, const xdrproc_t,	const caddr_t);
7450Sstevel@tonic-gate extern void	svcerr_decode(const SVCXPRT *);
7460Sstevel@tonic-gate extern void	svcerr_weakauth(const SVCXPRT *);
7470Sstevel@tonic-gate extern void	svcerr_noproc(const SVCXPRT *);
7480Sstevel@tonic-gate extern void	svcerr_progvers(const SVCXPRT *, const rpcvers_t,
7490Sstevel@tonic-gate     const rpcvers_t);
7500Sstevel@tonic-gate extern void	svcerr_auth(const SVCXPRT *, const enum auth_stat);
7510Sstevel@tonic-gate extern void	svcerr_noprog(const SVCXPRT *);
7520Sstevel@tonic-gate extern void	svcerr_systemerr(const SVCXPRT *);
7536786Srmesta extern void	svcerr_badcred(const SVCXPRT *);
7540Sstevel@tonic-gate #else	/* __STDC__ */
7550Sstevel@tonic-gate extern bool_t	svc_sendreply();
7560Sstevel@tonic-gate extern void	svcerr_decode();
7570Sstevel@tonic-gate extern void	svcerr_weakauth();
7580Sstevel@tonic-gate extern void	svcerr_noproc();
7590Sstevel@tonic-gate extern void	svcerr_progvers();
7600Sstevel@tonic-gate extern void	svcerr_auth();
7610Sstevel@tonic-gate extern void	svcerr_noprog();
7620Sstevel@tonic-gate extern void	svcerr_systemerr();
7636786Srmesta extern void	svcerr_badcred();
7640Sstevel@tonic-gate #endif	/* __STDC__ */
7650Sstevel@tonic-gate 
7660Sstevel@tonic-gate #ifdef	_KERNEL
7670Sstevel@tonic-gate /*
7680Sstevel@tonic-gate  * Kernel RPC functions.
7690Sstevel@tonic-gate  */
7700Sstevel@tonic-gate extern void	svc_init(void);
7710Sstevel@tonic-gate extern void	svc_cots_init(void);
7720Sstevel@tonic-gate extern void	svc_clts_init(void);
7730Sstevel@tonic-gate extern void	mt_kstat_init(void);
7740Sstevel@tonic-gate extern void	mt_kstat_fini(void);
7750Sstevel@tonic-gate extern int	svc_tli_kcreate(struct file *, uint_t, char *,
7760Sstevel@tonic-gate 				struct netbuf *, SVCMASTERXPRT **,
7770Sstevel@tonic-gate 				SVC_CALLOUT_TABLE *,
7780Sstevel@tonic-gate 				void (*closeproc)(const SVCMASTERXPRT *),
7790Sstevel@tonic-gate 				int, bool_t);
7800Sstevel@tonic-gate extern int	svc_clts_kcreate(struct file *, uint_t, struct T_info_ack *,
7810Sstevel@tonic-gate 				SVCMASTERXPRT **);
7820Sstevel@tonic-gate extern int	svc_cots_kcreate(struct file *, uint_t, struct T_info_ack *,
7830Sstevel@tonic-gate 				SVCMASTERXPRT **);
7840Sstevel@tonic-gate extern void	svc_queuereq(queue_t *, mblk_t *);
7850Sstevel@tonic-gate extern void	svc_queueclean(queue_t *);
7860Sstevel@tonic-gate extern void	svc_queueclose(queue_t *);
7870Sstevel@tonic-gate extern int	svc_reserve_thread(SVCXPRT *);
7880Sstevel@tonic-gate extern void	svc_unreserve_thread(SVCXPRT *);
7890Sstevel@tonic-gate extern callb_cpr_t *svc_detach_thread(SVCXPRT *);
7900Sstevel@tonic-gate 
7910Sstevel@tonic-gate /*
7920Sstevel@tonic-gate  * For RDMA based kRPC.
7930Sstevel@tonic-gate  * "rdma_xprt_record" is a reference to master transport handles
7940Sstevel@tonic-gate  * in kRPC thread pools. This is an easy way of tracking and shuting
7950Sstevel@tonic-gate  * down rdma based kRPC transports on demand.
7960Sstevel@tonic-gate  * "rdma_xprt_group" is a list of RDMA based mster transport handles
7970Sstevel@tonic-gate  * or records in a kRPC thread pool.
7980Sstevel@tonic-gate  */
7990Sstevel@tonic-gate typedef struct rdma_xprt_record		rdma_xprt_record_t;
8000Sstevel@tonic-gate struct rdma_xprt_record {
8010Sstevel@tonic-gate 	int			rtr_type;	/* Type of rdma; IB/VI/RDDP */
8020Sstevel@tonic-gate 	SVCMASTERXPRT		*rtr_xprt_ptr;	/* Ptr to master xprt handle */
8030Sstevel@tonic-gate 	rdma_xprt_record_t	*rtr_next;	/* Ptr to next record */
8040Sstevel@tonic-gate };
8050Sstevel@tonic-gate 
8060Sstevel@tonic-gate typedef struct {
8070Sstevel@tonic-gate 	int			rtg_count;	/* Number transport records */
8080Sstevel@tonic-gate 	int			rtg_poolid;	/* Pool Id for this group */
8090Sstevel@tonic-gate 	rdma_xprt_record_t	*rtg_listhead;	/* Head of the records list */
8100Sstevel@tonic-gate } rdma_xprt_group_t;
8110Sstevel@tonic-gate 
8120Sstevel@tonic-gate extern int	svc_rdma_kcreate(char *, SVC_CALLOUT_TABLE *, int,
8130Sstevel@tonic-gate 			rdma_xprt_group_t *);
8140Sstevel@tonic-gate extern void	svc_rdma_kstop(SVCMASTERXPRT *);
8150Sstevel@tonic-gate extern void	svc_rdma_kdestroy(SVCMASTERXPRT *);
8168695SRajkumar.Sivaprakasam@Sun.COM extern void	rdma_stop(rdma_xprt_group_t *);
8170Sstevel@tonic-gate 
8180Sstevel@tonic-gate /*
8190Sstevel@tonic-gate  * GSS cleanup method.
8200Sstevel@tonic-gate  */
8210Sstevel@tonic-gate extern void	rpc_gss_cleanup(SVCXPRT *);
8220Sstevel@tonic-gate #else	/* _KERNEL */
8230Sstevel@tonic-gate /*
8240Sstevel@tonic-gate  * Lowest level dispatching -OR- who owns this process anyway.
8250Sstevel@tonic-gate  * Somebody has to wait for incoming requests and then call the correct
8260Sstevel@tonic-gate  * service routine.  The routine svc_run does infinite waiting; i.e.,
8270Sstevel@tonic-gate  * svc_run never returns.
8280Sstevel@tonic-gate  * Since another (co-existant) package may wish to selectively wait for
8290Sstevel@tonic-gate  * incoming calls or other events outside of the rpc architecture, the
8300Sstevel@tonic-gate  * routine svc_getreq_poll is provided.  It must be passed pollfds, the
8310Sstevel@tonic-gate  * "in-place" results of a poll call (see poll, section 2).
8320Sstevel@tonic-gate  */
8330Sstevel@tonic-gate 
8340Sstevel@tonic-gate /*
8350Sstevel@tonic-gate  * Global keeper of rpc service descriptors in use
8360Sstevel@tonic-gate  * dynamic; must be inspected before each call to select or poll
8370Sstevel@tonic-gate  */
8380Sstevel@tonic-gate extern pollfd_t	*svc_pollfd;
8390Sstevel@tonic-gate extern int	svc_max_pollfd;
8400Sstevel@tonic-gate extern fd_set	svc_fdset;
8410Sstevel@tonic-gate #if !defined(_LP64) && FD_SETSIZE > 1024
8420Sstevel@tonic-gate extern fd_set	_new_svc_fdset;
8430Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME
8440Sstevel@tonic-gate #pragma redefine_extname	svc_fdset	_new_svc_fdset
8450Sstevel@tonic-gate #else   /* __PRAGMA_REDEFINE_EXTNAME */
8460Sstevel@tonic-gate #define	svc_fdset	_new_svc_fdset
8470Sstevel@tonic-gate #endif  /* __PRAGMA_REDEFINE_EXTNAME */
8480Sstevel@tonic-gate #endif	/* LP64 && FD_SETSIZE > 1024 */
8490Sstevel@tonic-gate #define	svc_fds svc_fdset.fds_bits[0]	/* compatibility */
8500Sstevel@tonic-gate 
8510Sstevel@tonic-gate /*
8520Sstevel@tonic-gate  * A small program implemented by the svc_rpc implementation itself.
8530Sstevel@tonic-gate  * Also see clnt.h for protocol numbers.
8540Sstevel@tonic-gate  */
8550Sstevel@tonic-gate #ifdef __STDC__
8560Sstevel@tonic-gate extern void	svc_getreq(int);
8570Sstevel@tonic-gate extern void	svc_getreq_common(const int);
8580Sstevel@tonic-gate extern void	svc_getreqset(fd_set *); /* takes fdset instead of int */
8590Sstevel@tonic-gate extern void	svc_getreq_poll(struct pollfd *, const int);
8600Sstevel@tonic-gate extern void	svc_run(void);
8610Sstevel@tonic-gate extern void	svc_exit(void);
8620Sstevel@tonic-gate #else	/* __STDC__ */
8630Sstevel@tonic-gate extern void	rpctest_service();
8640Sstevel@tonic-gate extern void	svc_getreqset();
8650Sstevel@tonic-gate extern void	svc_getreq();
8660Sstevel@tonic-gate extern void	svc_getreq_common();
8670Sstevel@tonic-gate extern void	svc_getreqset();	 /* takes fdset instead of int */
8680Sstevel@tonic-gate extern void	svc_getreq_poll();
8690Sstevel@tonic-gate extern void	svc_run();
8700Sstevel@tonic-gate extern void	svc_exit();
8710Sstevel@tonic-gate #endif	/* __STDC__ */
8720Sstevel@tonic-gate 
8730Sstevel@tonic-gate /*
8740Sstevel@tonic-gate  *  Functions used to manage user file descriptors
8750Sstevel@tonic-gate  */
8760Sstevel@tonic-gate typedef int svc_input_id_t;
8770Sstevel@tonic-gate typedef void (*svc_callback_t)(svc_input_id_t id, int fd,
8780Sstevel@tonic-gate 				unsigned int events, void* cookie);
8790Sstevel@tonic-gate 
8800Sstevel@tonic-gate #ifdef __STDC__
8810Sstevel@tonic-gate extern svc_input_id_t svc_add_input(int fd, unsigned int events,
8820Sstevel@tonic-gate 				svc_callback_t user_callback,
8830Sstevel@tonic-gate 				void* cookie);
8840Sstevel@tonic-gate extern int svc_remove_input(svc_input_id_t id);
8850Sstevel@tonic-gate #else	/* __STDC__ */
8860Sstevel@tonic-gate extern svc_input_id_t svc_add_input();
8870Sstevel@tonic-gate extern int	svc_remove_input();
8880Sstevel@tonic-gate #endif
8890Sstevel@tonic-gate 
8900Sstevel@tonic-gate /*
8910Sstevel@tonic-gate  * These are the existing service side transport implementations.
8920Sstevel@tonic-gate  *
8930Sstevel@tonic-gate  * Transport independent svc_create routine.
8940Sstevel@tonic-gate  */
8950Sstevel@tonic-gate #ifdef __STDC__
8960Sstevel@tonic-gate extern int	svc_create(void (*)(struct svc_req *, SVCXPRT *),
8970Sstevel@tonic-gate 				const rpcprog_t, const rpcvers_t,
8980Sstevel@tonic-gate 				const char *);
8990Sstevel@tonic-gate 	/*
9000Sstevel@tonic-gate 	 * 	void (*dispatch)();		-- dispatch routine
9010Sstevel@tonic-gate 	 *	const rpcprog_t prognum;	-- program number
9020Sstevel@tonic-gate 	 *	const rpcvers_t versnum;	-- version number
9030Sstevel@tonic-gate 	 *	const char *nettype;		-- network type
9040Sstevel@tonic-gate 	 */
9050Sstevel@tonic-gate 
9060Sstevel@tonic-gate /*
9070Sstevel@tonic-gate  * Generic server creation routine. It takes a netconfig structure
9080Sstevel@tonic-gate  * instead of a nettype.
9090Sstevel@tonic-gate  */
9100Sstevel@tonic-gate extern SVCXPRT	*svc_tp_create(void (*)(struct svc_req *, SVCXPRT *),
9110Sstevel@tonic-gate 				const rpcprog_t, const rpcvers_t,
9120Sstevel@tonic-gate 				const struct netconfig *);
9130Sstevel@tonic-gate 	/*
9140Sstevel@tonic-gate 	 * void (*dispatch)();			-- dispatch routine
9150Sstevel@tonic-gate 	 * const rpcprog_t prognum;		-- program number
9160Sstevel@tonic-gate 	 * const rpcvers_t versnum;		-- version number
9170Sstevel@tonic-gate 	 * const struct netconfig *nconf;	-- netconfig structure
9180Sstevel@tonic-gate 	 */
9190Sstevel@tonic-gate 
9200Sstevel@tonic-gate /*
9210Sstevel@tonic-gate  * Generic TLI create routine
9220Sstevel@tonic-gate  */
9230Sstevel@tonic-gate extern  SVCXPRT	*svc_tli_create(const int, const struct netconfig *,
9240Sstevel@tonic-gate 				const struct t_bind *, const uint_t,
9250Sstevel@tonic-gate 				const uint_t);
9260Sstevel@tonic-gate 	/*
9270Sstevel@tonic-gate 	 *	const int fd;			-- connection end point
9280Sstevel@tonic-gate 	 *	const struct netconfig *nconf;	-- netconfig structure
9290Sstevel@tonic-gate 	 *	const struct t_bind *bindaddr;	-- local bind address
9300Sstevel@tonic-gate 	 *	const uint_t sendsz;		-- max sendsize
9310Sstevel@tonic-gate 	 *	const uint_t recvsz;		-- max recvsize
9320Sstevel@tonic-gate 	 */
9330Sstevel@tonic-gate 
9340Sstevel@tonic-gate /*
9350Sstevel@tonic-gate  * Connectionless and connectionful create routines.
9360Sstevel@tonic-gate  */
9370Sstevel@tonic-gate extern SVCXPRT	*svc_vc_create(const int, const uint_t, const uint_t);
9380Sstevel@tonic-gate 	/*
9390Sstevel@tonic-gate 	 *	const int fd;			-- open connection end point
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 extern SVCXPRT	*svc_dg_create(const int, const uint_t, const uint_t);
9450Sstevel@tonic-gate 	/*
9460Sstevel@tonic-gate 	 * const int fd;			-- open connection
9470Sstevel@tonic-gate 	 * const uint_t sendsize;		-- max send size
9480Sstevel@tonic-gate 	 * const uint_t recvsize;		-- max recv size
9490Sstevel@tonic-gate 	 */
9500Sstevel@tonic-gate 
9510Sstevel@tonic-gate /*
9520Sstevel@tonic-gate  * the routine takes any *open* TLI file
9530Sstevel@tonic-gate  * descriptor as its first input and is used for open connections.
9540Sstevel@tonic-gate  */
9550Sstevel@tonic-gate extern  SVCXPRT	*svc_fd_create(const int, const uint_t, const uint_t);
9560Sstevel@tonic-gate 	/*
9570Sstevel@tonic-gate 	 * 	const int fd;			-- open connection end point
9580Sstevel@tonic-gate 	 * 	const uint_t sendsize;		-- max send size
9590Sstevel@tonic-gate 	 * 	const uint_t recvsize;		-- max recv size
9600Sstevel@tonic-gate 	 */
9610Sstevel@tonic-gate 
9620Sstevel@tonic-gate /*
9630Sstevel@tonic-gate  * Memory based rpc (for speed check and testing)
9640Sstevel@tonic-gate  */
9650Sstevel@tonic-gate extern SVCXPRT	*svc_raw_create(void);
9660Sstevel@tonic-gate 
9670Sstevel@tonic-gate /*
9680Sstevel@tonic-gate  * Creation of service over doors transport.
9690Sstevel@tonic-gate  */
9700Sstevel@tonic-gate extern SVCXPRT	*svc_door_create(void (*)(struct svc_req *, SVCXPRT *),
9710Sstevel@tonic-gate 				const rpcprog_t, const rpcvers_t,
9720Sstevel@tonic-gate 				const uint_t);
9730Sstevel@tonic-gate 	/*
9740Sstevel@tonic-gate 	 * 	void (*dispatch)();		-- dispatch routine
9750Sstevel@tonic-gate 	 *	const rpcprog_t prognum;	-- program number
9760Sstevel@tonic-gate 	 *	const rpcvers_t versnum;	-- version number
9770Sstevel@tonic-gate 	 *	const uint_t sendsize;		-- send buffer size
9780Sstevel@tonic-gate 	 */
9790Sstevel@tonic-gate 
9800Sstevel@tonic-gate /*
9810Sstevel@tonic-gate  * Service control interface
9820Sstevel@tonic-gate  */
9830Sstevel@tonic-gate extern	bool_t	svc_control(SVCXPRT *, const uint_t, void *);
9840Sstevel@tonic-gate 	/*
9850Sstevel@tonic-gate 	 *	SVCXPRT *svc;			-- service to manipulate
9860Sstevel@tonic-gate 	 *	const uint_t req;		-- request
9870Sstevel@tonic-gate 	 *	void *info;			-- argument to request
9880Sstevel@tonic-gate 	 */
9890Sstevel@tonic-gate 
9900Sstevel@tonic-gate /*
9910Sstevel@tonic-gate  * svc_dg_enable_cache() enables the cache on dg transports.
9920Sstevel@tonic-gate  */
9930Sstevel@tonic-gate extern int svc_dg_enablecache(SVCXPRT *, const uint_t);
9940Sstevel@tonic-gate #else	/* __STDC__ */
9950Sstevel@tonic-gate extern int	svc_create();
9960Sstevel@tonic-gate extern SVCXPRT	*svc_tp_create();
9970Sstevel@tonic-gate extern SVCXPRT	*svc_tli_create();
9980Sstevel@tonic-gate extern SVCXPRT	*svc_vc_create();
9990Sstevel@tonic-gate extern SVCXPRT	*svc_dg_create();
10000Sstevel@tonic-gate extern SVCXPRT	*svc_fd_create();
10010Sstevel@tonic-gate extern SVCXPRT	*svc_raw_create();
10020Sstevel@tonic-gate extern SVCXPRT	*svc_door_create();
10030Sstevel@tonic-gate extern int svc_dg_enablecache();
10040Sstevel@tonic-gate #endif	/* __STDC__ */
10050Sstevel@tonic-gate 
10061676Sjpk extern boolean_t is_multilevel(rpcprog_t);
10071676Sjpk 
10080Sstevel@tonic-gate #ifdef	PORTMAP
10090Sstevel@tonic-gate /* For backward compatibility */
10100Sstevel@tonic-gate #include <rpc/svc_soc.h>
10110Sstevel@tonic-gate #endif	/* PORTMAP */
10120Sstevel@tonic-gate 
10130Sstevel@tonic-gate /*
10140Sstevel@tonic-gate  * For user level MT hot server functions
10150Sstevel@tonic-gate  */
10160Sstevel@tonic-gate 
10170Sstevel@tonic-gate /*
10180Sstevel@tonic-gate  * Different MT modes
10190Sstevel@tonic-gate  */
10200Sstevel@tonic-gate #define	RPC_SVC_MT_NONE		0	/* default, single-threaded */
10210Sstevel@tonic-gate #define	RPC_SVC_MT_AUTO		1	/* automatic MT mode */
10220Sstevel@tonic-gate #define	RPC_SVC_MT_USER		2	/* user MT mode */
10230Sstevel@tonic-gate 
10240Sstevel@tonic-gate #ifdef	__STDC__
10250Sstevel@tonic-gate extern void	svc_done(SVCXPRT *);
10260Sstevel@tonic-gate #else
10270Sstevel@tonic-gate extern void	svc_done();
10280Sstevel@tonic-gate #endif	/* __STDC__ */
10290Sstevel@tonic-gate 
10300Sstevel@tonic-gate /*
10310Sstevel@tonic-gate  * Obtaining local credentials.
10320Sstevel@tonic-gate  */
10330Sstevel@tonic-gate typedef struct __svc_local_cred_t {
10340Sstevel@tonic-gate 	uid_t	euid;	/* effective uid */
10350Sstevel@tonic-gate 	gid_t	egid;	/* effective gid */
10360Sstevel@tonic-gate 	uid_t	ruid;	/* real uid */
10370Sstevel@tonic-gate 	gid_t	rgid;	/* real gid */
10380Sstevel@tonic-gate 	pid_t	pid;	/* caller's pid, or -1 if not available */
10390Sstevel@tonic-gate } svc_local_cred_t;
10400Sstevel@tonic-gate 
10410Sstevel@tonic-gate #ifdef __STDC__
10420Sstevel@tonic-gate struct ucred_s;
10430Sstevel@tonic-gate extern void	svc_fd_negotiate_ucred(int);
10440Sstevel@tonic-gate extern int	svc_getcallerucred(const SVCXPRT *, struct ucred_s **);
10450Sstevel@tonic-gate extern bool_t	svc_get_local_cred(SVCXPRT *, svc_local_cred_t *);
10460Sstevel@tonic-gate #else
10470Sstevel@tonic-gate extern void	svc_fd_negotiate_ucred();
10480Sstevel@tonic-gate extern int	svc_getcallerucred();
10490Sstevel@tonic-gate extern bool_t	svc_get_local_cred();
10500Sstevel@tonic-gate #endif	/* __STDC__ */
10510Sstevel@tonic-gate 
10520Sstevel@tonic-gate /*
10530Sstevel@tonic-gate  * Private interfaces and structures for user level duplicate request caching.
10540Sstevel@tonic-gate  * The interfaces and data structures are not committed and subject to
10550Sstevel@tonic-gate  * change in future releases. Currently only intended for use by automountd.
10560Sstevel@tonic-gate  */
10570Sstevel@tonic-gate struct dupreq {
10580Sstevel@tonic-gate 	uint32_t	dr_xid;
10590Sstevel@tonic-gate 	rpcproc_t	dr_proc;
10600Sstevel@tonic-gate 	rpcvers_t	dr_vers;
10610Sstevel@tonic-gate 	rpcprog_t	dr_prog;
10620Sstevel@tonic-gate 	struct netbuf	dr_addr;
10630Sstevel@tonic-gate 	struct netbuf	dr_resp;
10640Sstevel@tonic-gate 	int		dr_status;
10650Sstevel@tonic-gate 	time_t		dr_time;
10660Sstevel@tonic-gate 	uint_t		dr_hash;
10670Sstevel@tonic-gate 	struct dupreq	*dr_next;
10680Sstevel@tonic-gate 	struct dupreq	*dr_prev;
10690Sstevel@tonic-gate 	struct dupreq	*dr_chain;
10700Sstevel@tonic-gate 	struct dupreq	*dr_prevchain;
10710Sstevel@tonic-gate };
10720Sstevel@tonic-gate 
10730Sstevel@tonic-gate /*
10740Sstevel@tonic-gate  * The fixedtime state is defined if we want to expand the routines to
10750Sstevel@tonic-gate  * handle and encompass fixed size caches.
10760Sstevel@tonic-gate  */
10770Sstevel@tonic-gate #define	DUPCACHE_FIXEDTIME	0
10780Sstevel@tonic-gate 
10790Sstevel@tonic-gate /*
10800Sstevel@tonic-gate  * States of requests for duplicate request caching.
10810Sstevel@tonic-gate  * These are the same as defined for the kernel.
10820Sstevel@tonic-gate  */
10830Sstevel@tonic-gate #define	DUP_NEW			0x00	/* new entry */
10840Sstevel@tonic-gate #define	DUP_INPROGRESS		0x01	/* request already going */
10850Sstevel@tonic-gate #define	DUP_DONE		0x02	/* request done */
10860Sstevel@tonic-gate #define	DUP_DROP		0x03	/* request dropped */
10870Sstevel@tonic-gate #define	DUP_ERROR		0x04	/* error in dup req cache */
10880Sstevel@tonic-gate 
10890Sstevel@tonic-gate #ifdef __STDC__
10900Sstevel@tonic-gate extern bool_t	__svc_dupcache_init(void *, int, char **);
10910Sstevel@tonic-gate extern int	__svc_dup(struct svc_req *, caddr_t *, uint_t *, char *);
10920Sstevel@tonic-gate extern int	__svc_dupdone(struct svc_req *, caddr_t, uint_t, int, char *);
10930Sstevel@tonic-gate extern bool_t	__svc_vc_dupcache_init(SVCXPRT *, void *, int);
10940Sstevel@tonic-gate extern int	__svc_vc_dup(struct svc_req *, caddr_t *, uint_t *);
10950Sstevel@tonic-gate extern int	__svc_vc_dupdone(struct svc_req *, caddr_t, uint_t, int);
10960Sstevel@tonic-gate #else
10970Sstevel@tonic-gate extern bool_t	__svc_dupcache_init();
10980Sstevel@tonic-gate extern int	__svc_dup();
10990Sstevel@tonic-gate extern int	__svc_dupdone();
11000Sstevel@tonic-gate extern bool_t	__svc_vc_dupcache_init();
11010Sstevel@tonic-gate extern int	__svc_vc_dup();
11020Sstevel@tonic-gate extern int	__svc_vc_dupdone();
11030Sstevel@tonic-gate #endif	/* __STDC__ */
11040Sstevel@tonic-gate #endif	/* _KERNEL */
11050Sstevel@tonic-gate 
110610721SGlenn.Barry@Sun.COM #ifdef	_KERNEL
110710721SGlenn.Barry@Sun.COM /*
110810721SGlenn.Barry@Sun.COM  * Private interfaces and structures for SVCXPRT cloning.
110910721SGlenn.Barry@Sun.COM  * The interfaces and data structures are not committed and subject to
111010721SGlenn.Barry@Sun.COM  * change in future releases.
111110721SGlenn.Barry@Sun.COM  */
111210721SGlenn.Barry@Sun.COM extern SVCXPRT *svc_clone_init(void);
111310721SGlenn.Barry@Sun.COM extern void svc_clone_free(SVCXPRT *);
1114*11967SKaren.Rochford@Sun.COM extern void svc_clone_link(SVCMASTERXPRT *, SVCXPRT *, SVCXPRT *);
111510721SGlenn.Barry@Sun.COM extern void svc_clone_unlink(SVCXPRT *);
111610721SGlenn.Barry@Sun.COM #endif	/* _KERNEL */
111710721SGlenn.Barry@Sun.COM 
11180Sstevel@tonic-gate #ifdef	__cplusplus
11190Sstevel@tonic-gate }
11200Sstevel@tonic-gate #endif
11210Sstevel@tonic-gate 
11220Sstevel@tonic-gate #endif	/* !_RPC_SVC_H */
1123