xref: /illumos-gate/usr/src/uts/common/rpc/svc.h (revision 214d537cc1e7896ae3489ebec3ae766e01f32b2a)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
23  * Copyright 2012 Marcel Telka <marcel@telka.sk>
24  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
25  * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
26  */
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
29 /*
30  * Portions of this source code were derived from Berkeley
31  * 4.3 BSD under license from the Regents of the University of
32  * California.
33  */
34 
35 /*
36  * svc.h, Server-side remote procedure call interface.
37  */
38 
39 #ifndef	_RPC_SVC_H
40 #define	_RPC_SVC_H
41 
42 #include <rpc/rpc_com.h>
43 #include <rpc/rpc_msg.h>
44 #include <sys/tihdr.h>
45 #include <sys/poll.h>
46 #include <sys/tsol/label.h>
47 
48 #ifdef	_KERNEL
49 #include <rpc/svc_auth.h>
50 #include <sys/callb.h>
51 #endif	/* _KERNEL */
52 
53 /*
54  * This interface must manage two items concerning remote procedure calling:
55  *
56  * 1) An arbitrary number of transport connections upon which rpc requests
57  * are received. They are created and registered by routines in svc_generic.c,
58  * svc_vc.c and svc_dg.c; they in turn call xprt_register and
59  * xprt_unregister.
60  *
61  * 2) An arbitrary number of locally registered services.  Services are
62  * described by the following four data: program number, version number,
63  * "service dispatch" function, a transport handle, and a boolean that
64  * indicates whether or not the exported program should be registered with a
65  * local binder service;  if true the program's number and version and the
66  * address from the transport handle are registered with the binder.
67  * These data are registered with rpcbind via svc_reg().
68  *
69  * A service's dispatch function is called whenever an rpc request comes in
70  * on a transport.  The request's program and version numbers must match
71  * those of the registered service.  The dispatch function is passed two
72  * parameters, struct svc_req * and SVCXPRT *, defined below.
73  */
74 
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78 
79 /*
80  * Server-side transport handles.
81  * The actual type definitions are below.
82  */
83 #ifdef	_KERNEL
84 typedef struct __svcmasterxprt	SVCMASTERXPRT;	/* Master transport handle */
85 typedef struct __svcxprt	SVCXPRT;	/* Per-thread clone handle */
86 typedef	struct __svcpool	SVCPOOL;	/* Kernel thread pool	   */
87 #else	/* _KERNEL */
88 typedef struct __svcxprt	SVCXPRT;	/* Server transport handle */
89 #endif	/* _KERNEL */
90 
91 /*
92  *  Prototype of error handler callback
93  */
94 #ifndef _KERNEL
95 typedef void (*svc_errorhandler_t)(const SVCXPRT* svc, const bool_t isAConn);
96 #endif
97 
98 /*
99  * Service request.
100  *
101  * PSARC 2003/523 Contract Private Interface
102  * svc_req
103  * Changes must be reviewed by Solaris File Sharing
104  * Changes must be communicated to contract-2003-523@sun.com
105  */
106 struct svc_req {
107 	rpcprog_t	rq_prog;	/* service program number */
108 	rpcvers_t	rq_vers;	/* service protocol version */
109 	rpcproc_t	rq_proc;	/* the desired procedure */
110 	struct opaque_auth rq_cred;	/* raw creds from the wire */
111 	caddr_t		rq_clntcred;	/* read only cooked cred */
112 	SVCXPRT		*rq_xprt;	/* associated transport */
113 	bslabel_t	*rq_label;	/* TSOL label of the request */
114 };
115 
116 #ifdef _KERNEL
117 struct dupreq {
118 	uint32_t	dr_xid;
119 	rpcproc_t	dr_proc;
120 	rpcvers_t	dr_vers;
121 	rpcprog_t	dr_prog;
122 	struct netbuf	dr_addr;
123 	struct netbuf	dr_resp;
124 	void		(*dr_resfree)();
125 	int		dr_status;
126 	struct dupreq	*dr_next;
127 	struct dupreq	*dr_chain;
128 };
129 
130 /*
131  * States of requests for duplicate request caching.
132  */
133 #define	DUP_NEW			0x00	/* new entry */
134 #define	DUP_INPROGRESS		0x01	/* request already going */
135 #define	DUP_DONE		0x02	/* request done */
136 #define	DUP_DROP		0x03	/* request dropped */
137 #define	DUP_ERROR		0x04	/* error in dup req cache */
138 
139 /*
140  * Prototype for a service dispatch routine.
141  */
142 typedef void (SVC_DISPATCH)(struct svc_req *, SVCXPRT *);
143 
144 /*
145  * The service provider callout.
146  * Each entry identifies a dispatch routine to be called
147  * for a given RPC program number and a version fitting
148  * into the registered range.
149  */
150 typedef struct {
151 	rpcprog_t	sc_prog;	/* RPC Program number */
152 	rpcvers_t	sc_versmin;	/* Min version number */
153 	rpcvers_t	sc_versmax;	/* Max version number */
154 	SVC_DISPATCH	*sc_dispatch;	/* Dispatch routine   */
155 } SVC_CALLOUT;
156 
157 /*
158  * Table of service provider `callouts' for an RPC
159  * transport handle. If sct_free is TRUE then transport
160  * destructor is supposed to deallocate this table.
161  */
162 typedef struct {
163 	size_t		sct_size;	/* Number of entries  */
164 	bool_t		sct_free;	/* Deallocate if true */
165 	SVC_CALLOUT	*sct_sc;	/* Callout entries    */
166 } SVC_CALLOUT_TABLE;
167 
168 struct svc_ops {
169 	bool_t	(*xp_recv)(SVCXPRT *, mblk_t *, struct rpc_msg *);
170 		/* receive incoming requests */
171 	bool_t	(*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t);
172 		/* get arguments */
173 	bool_t	(*xp_reply)(SVCXPRT *, struct rpc_msg *);
174 		/* send reply */
175 	bool_t	(*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t);
176 		/* free mem allocated for args */
177 	void	(*xp_destroy)(SVCMASTERXPRT *);
178 		/* destroy this struct */
179 	int	(*xp_dup)(struct svc_req *, caddr_t, int,
180 				struct dupreq **, bool_t *);
181 		/* check for dup */
182 	void	(*xp_dupdone)(struct dupreq *, caddr_t, void (*)(), int, int);
183 		/* mark dup entry as completed */
184 	int32_t *(*xp_getres)(SVCXPRT *, int);
185 		/* get pointer to response buffer */
186 	void	(*xp_freeres)(SVCXPRT *);
187 		/* destroy pre-serialized response */
188 	void	(*xp_clone_destroy)(SVCXPRT *);
189 		/* destroy a clone xprt */
190 	void	(*xp_start)(SVCMASTERXPRT *);
191 		/* `ready-to-receive' */
192 	void	(*xp_clone_xprt)(SVCXPRT *, SVCXPRT *);
193 		/* transport specific clone function */
194 	void	(*xp_tattrs)(SVCXPRT *, int, void **);
195 		/* transport specific hold function */
196 	void	(*xp_hold)(queue_t *);
197 		/* transport specific release function */
198 	void	(*xp_release)(queue_t *, mblk_t *, bool_t);
199 };
200 
201 #define	SVC_TATTR_ADDRMASK	1
202 
203 #else	/* _KERNEL */
204 /*
205  *	Service control requests
206  */
207 #define	SVCGET_VERSQUIET	1
208 #define	SVCSET_VERSQUIET	2
209 #define	SVCGET_XID		4
210 #define	SVCSET_KEEPALIVE	5
211 #define	SVCSET_CONNMAXREC	6
212 #define	SVCGET_CONNMAXREC	7
213 #define	SVCGET_RECVERRHANDLER	8
214 #define	SVCSET_RECVERRHANDLER	9
215 
216 enum xprt_stat {
217 	XPRT_DIED,
218 	XPRT_MOREREQS,
219 	XPRT_IDLE
220 };
221 
222 struct xp_ops {
223 #ifdef	__STDC__
224 	bool_t	(*xp_recv)(SVCXPRT *, struct rpc_msg *);
225 		/* receive incoming requests */
226 	enum xprt_stat (*xp_stat)(SVCXPRT *);
227 		/* get transport status */
228 	bool_t	(*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t);
229 		/* get arguments */
230 	bool_t	(*xp_reply)(SVCXPRT *,	struct rpc_msg *);
231 		/* send reply */
232 	bool_t	(*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t);
233 		/* free mem allocated for args */
234 	void	(*xp_destroy)(SVCXPRT *);
235 		/* destroy this struct */
236 	bool_t	(*xp_control)(SVCXPRT *, const uint_t,	void *);
237 		/* catch-all control function */
238 #else	/* __STDC__ */
239 	bool_t	(*xp_recv)(); /* receive incoming requests */
240 	enum xprt_stat (*xp_stat)(); /* get transport status */
241 	bool_t	(*xp_getargs)(); /* get arguments */
242 	bool_t	(*xp_reply)(); /* send reply */
243 	bool_t	(*xp_freeargs)(); /* free mem allocated for args */
244 	void	(*xp_destroy)(); /* destroy this struct */
245 	bool_t	(*xp_control)(); /* catch-all control function */
246 #endif	/* __STDC__ */
247 };
248 #endif	/* _KERNEL */
249 
250 #ifdef	_KERNEL
251 /*
252  * SVCPOOL
253  * Kernel RPC server-side thread pool structure.
254  */
255 typedef struct __svcxprt_qnode __SVCXPRT_QNODE;	/* Defined in svc.c */
256 
257 struct __svcpool {
258 	/*
259 	 * Thread pool variables.
260 	 *
261 	 * The pool's thread lock p_thread_lock protects:
262 	 * - p_threads, p_detached_threads, p_reserved_threads and p_closing
263 	 * The pool's request lock protects:
264 	 * - p_asleep, p_drowsy, p_reqs, p_size, p_walkers, p_req_cv.
265 	 * The following fields are `initialized constants':
266 	 * - p_id, p_stksize, p_timeout.
267 	 * Access to p_next and p_prev is protected by the pool
268 	 * list lock.
269 	 */
270 	SVCPOOL		*p_next;		/* Next pool in the list  */
271 	SVCPOOL		*p_prev;		/* Prev pool in the list  */
272 	int		p_id;			/* Pool id		  */
273 	int		p_threads;		/* Non-detached threads	  */
274 	int		p_detached_threads;	/* Detached threads	  */
275 	int		p_maxthreads;		/* Max threads in the pool */
276 	int		p_redline;		/* `Redline' for the pool */
277 	int		p_reserved_threads;	/* Reserved threads	  */
278 	kmutex_t	p_thread_lock;		/* Thread lock		  */
279 	int		p_asleep;		/* Asleep threads	  */
280 	int		p_drowsy;		/* Drowsy flag		  */
281 	kcondvar_t	p_req_cv;		/* svc_poll() sleep var.  */
282 	clock_t		p_timeout;		/* svc_poll() timeout	  */
283 	kmutex_t	p_req_lock;		/* Request lock		  */
284 	int		p_reqs;			/* Pending requests	  */
285 	int		p_walkers;		/* Walking threads	  */
286 	int		p_max_same_xprt;	/* Max reqs from the xprt */
287 	int		p_stksize;		/* Stack size for svc_run */
288 	bool_t		p_closing : 1;		/* Pool is closing	  */
289 
290 	/*
291 	 * Thread creator variables.
292 	 * The `creator signaled' flag is turned on when a signal is send
293 	 * to the creator thread (to create a new service thread). The
294 	 * creator clears when the thread is created. The protocol is not
295 	 * to signal the creator thread when the flag is on. However,
296 	 * a new thread should signal the creator if there are more
297 	 * requests in the queue.
298 	 *
299 	 * When the pool is closing (ie it has been already unregistered from
300 	 * the pool list) the last thread on the last transport should turn
301 	 * the p_creator_exit flag on. This tells the creator thread to
302 	 * free the pool structure and exit.
303 	 */
304 	bool_t		p_creator_signaled : 1;	/* Create requested flag  */
305 	bool_t		p_creator_exit : 1;	/* If true creator exits  */
306 	kcondvar_t	p_creator_cv;		/* Creator cond. variable */
307 	kmutex_t	p_creator_lock;		/* Creator lock		  */
308 
309 	/*
310 	 * Doubly linked list containing `registered' master transport handles.
311 	 * There is no special structure for a list node. Instead the
312 	 * SVCMASTERXPRT structure has the xp_next and xp_prev fields.
313 	 *
314 	 * The p_lrwlock protects access to xprt->xp_next and xprt->xp_prev.
315 	 * A service thread should also acquire a reader lock before accessing
316 	 * any transports it is no longer linked to (to prevent them from
317 	 * being destroyed).
318 	 *
319 	 * The list lock governs also the `pool is closing' flag.
320 	 */
321 	size_t		p_lcount;		/* Current count	  */
322 	SVCMASTERXPRT	*p_lhead;		/* List head		  */
323 	krwlock_t	p_lrwlock;		/* R/W lock		  */
324 
325 	/*
326 	 * Circular linked list for the `xprt-ready' queue (FIFO).
327 	 * Must be initialized with svc_xprt_qinit() before it is used.
328 	 *
329 	 * The writer's end is protected by the pool's request lock
330 	 * (pool->p_req_lock). The reader's end is protected by q_end_lock.
331 	 *
332 	 * When the queue is full the p_qoverflow flag is raised. It stays
333 	 * on until all the pending request are drained.
334 	 */
335 	size_t		p_qsize;		/* Number of queue nodes  */
336 	int		p_qoverflow : 1;	/* Overflow flag	  */
337 	__SVCXPRT_QNODE *p_qbody;		/* Queue body (array)	  */
338 	__SVCXPRT_QNODE *p_qtop;		/* Writer's end of FIFO   */
339 	__SVCXPRT_QNODE *p_qend;		/* Reader's end of FIFO	  */
340 	kmutex_t	p_qend_lock;		/* Reader's end lock	  */
341 
342 	/*
343 	 * Userspace thread creator variables.
344 	 * Thread creation is actually done in userland, via a thread
345 	 * that is parked in the kernel. When that thread is signaled,
346 	 * it returns back down to the daemon from whence it came and
347 	 * does the lwp create.
348 	 *
349 	 * A parallel "creator" thread runs in the kernel. That is the
350 	 * thread that will signal for the user thread to return to
351 	 * userland and do its work.
352 	 *
353 	 * Since the thread doesn't always exist (there could be a race
354 	 * if two threads are created in rapid succession), we set
355 	 * p_signal_create_thread to FALSE when we're ready to accept work.
356 	 *
357 	 * p_user_exit is set to true when the service pool is about
358 	 * to close. This is done so that the user creation thread
359 	 * can be informed and cleanup any userland state.
360 	 */
361 
362 	bool_t		p_signal_create_thread : 1; /* Create requested flag  */
363 	bool_t		p_user_exit : 1;	/* If true creator exits  */
364 	bool_t		p_user_waiting : 1;	/* Thread waiting for work */
365 	kcondvar_t	p_user_cv;		/* Creator cond. variable */
366 	kmutex_t	p_user_lock;		/* Creator lock		  */
367 	void		(*p_offline)();		/* callout for unregister */
368 	void		(*p_shutdown)();	/* callout for shutdown */
369 
370 	size_t		p_size;			/* Total size of queued msgs */
371 };
372 
373 /*
374  * Server side transport handle (SVCMASTERXPRT).
375  * xprt->xp_req_lock governs the following fields in xprt:
376  *		xp_req_head, xp_req_tail.
377  * xprt->xp_thread_lock governs the following fields in xprt:
378  *		xp_threads, xp_detached_threads.
379  *
380  * xp_req_tail is only valid if xp_req_head is non-NULL
381  *
382  * The xp_threads count is the number of attached threads.  These threads
383  * are able to handle new requests, and it is expected that they will not
384  * block for a very long time handling a given request. The
385  * xp_detached_threads count is the number of threads that have detached
386  * themselves from the transport. These threads can block indefinitely
387  * while handling a request.  Once they complete the request, they exit.
388  *
389  * A kernel service provider may register a callback function "closeproc"
390  * for a transport.  When the transport is closing the last exiting attached
391  * thread - xp_threads goes to zero - it calls the callback function, passing
392  * it a reference to the transport.  This call is made with xp_thread_lock
393  * held, so any cleanup bookkeeping it does should be done quickly.
394  *
395  * When the transport is closing the last exiting thread is supposed
396  * to destroy/free the data structure.
397  */
398 typedef struct __svcxprt_common {
399 	struct file	*xpc_fp;
400 	struct svc_ops	*xpc_ops;
401 	queue_t		*xpc_wq;	/* queue to write onto		*/
402 	cred_t		*xpc_cred;	/* cached cred for server to use */
403 	int32_t		xpc_type;	/* transport type		*/
404 	int		xpc_msg_size;	/* TSDU or TIDU size		*/
405 	struct netbuf	xpc_rtaddr;	/* remote transport address	*/
406 	struct netbuf	xpc_lcladdr;	/* local transport address	*/
407 	char		*xpc_netid;	/* network token		*/
408 	SVC_CALLOUT_TABLE *xpc_sct;
409 } __SVCXPRT_COMMON;
410 
411 #define	xp_fp		xp_xpc.xpc_fp
412 #define	xp_ops		xp_xpc.xpc_ops
413 #define	xp_wq		xp_xpc.xpc_wq
414 #define	xp_cred		xp_xpc.xpc_cred
415 #define	xp_type		xp_xpc.xpc_type
416 #define	xp_msg_size	xp_xpc.xpc_msg_size
417 #define	xp_rtaddr	xp_xpc.xpc_rtaddr
418 #define	xp_lcladdr	xp_xpc.xpc_lcladdr
419 #define	xp_sct		xp_xpc.xpc_sct
420 #define	xp_netid	xp_xpc.xpc_netid
421 
422 struct __svcmasterxprt {
423 	SVCMASTERXPRT	*xp_next;	/* Next transport in the list	*/
424 	SVCMASTERXPRT	*xp_prev;	/* Prev transport in the list	*/
425 	__SVCXPRT_COMMON xp_xpc;	/* Fields common with the clone	*/
426 	SVCPOOL		*xp_pool;	/* Pointer to the pool		*/
427 	mblk_t		*xp_req_head;	/* Request queue head		*/
428 	mblk_t		*xp_req_tail;	/* Request queue tail		*/
429 	kmutex_t	xp_req_lock;	/* Request lock			*/
430 	int		xp_threads;	/* Current num. of attached threads */
431 	int		xp_detached_threads; /* num. of detached threads */
432 	kmutex_t	xp_thread_lock;	/* Thread count lock		*/
433 	void		(*xp_closeproc)(const SVCMASTERXPRT *);
434 					/* optional; see comments above	*/
435 	struct netbuf	xp_addrmask;	/* address mask			*/
436 
437 	caddr_t		xp_p2;		/* private: for use by svc ops  */
438 
439 	int		xp_full : 1;	/* xprt is full			*/
440 	int		xp_enable : 1;	/* xprt needs to be enabled	*/
441 	int		xp_reqs;	/* number of requests queued	*/
442 	size_t		xp_size;	/* total size of queued msgs	*/
443 };
444 
445 /*
446  * Service thread `clone' transport handle (SVCXPRT)
447  *
448  * PSARC 2003/523 Contract Private Interface
449  * SVCXPRT
450  * Changes must be reviewed by Solaris File Sharing
451  * Changes must be communicated to contract-2003-523@sun.com
452  *
453  * The xp_p2buf buffer is used as the storage for a transport type
454  * specific structure. It is private for the svc ops for a given
455  * transport type.
456  */
457 
458 #define	SVC_P2LEN   128
459 
460 struct __svcxprt {
461 	__SVCXPRT_COMMON xp_xpc;
462 	SVCMASTERXPRT	*xp_master;	/* back ptr to master		*/
463 
464 	/* The following fileds are on a per-thread basis */
465 	callb_cpr_t	*xp_cprp;	/* unused padding for Contract	*/
466 	bool_t		xp_reserved : 1; /* is thread reserved?		*/
467 	bool_t		xp_detached : 1; /* is thread detached?		*/
468 	int		xp_same_xprt;	/* Reqs from the same xprt	*/
469 
470 	/* The following fields are used on a per-request basis */
471 	struct opaque_auth xp_verf;	/* raw response verifier	*/
472 	SVCAUTH		xp_auth;	/* auth flavor of current req	*/
473 	void		*xp_cookie;	/* a cookie			*/
474 	uint32_t	xp_xid;		/* id				*/
475 	XDR		xp_xdrin;	/* input xdr stream		*/
476 	XDR		xp_xdrout;	/* output xdr stream		*/
477 
478 	/* Private for svc ops */
479 	char		xp_p2buf[SVC_P2LEN]; /* udp_data or cots_data_t */
480 						/* or clone_rdma_data_t */
481 };
482 #else	/* _KERNEL */
483 struct __svcxprt {
484 	int		xp_fd;
485 #define	xp_sock		xp_fd
486 	ushort_t	xp_port;
487 	/*
488 	 * associated port number.
489 	 * Obsolete, but still used to
490 	 * specify whether rendezvouser
491 	 * or normal connection
492 	 */
493 	struct	xp_ops	*xp_ops;
494 	int		xp_addrlen;	/* length of remote addr. Obsoleted */
495 	char		*xp_tp;		/* transport provider device name */
496 	char		*xp_netid;	/* network token */
497 	struct netbuf	xp_ltaddr;	/* local transport address */
498 	struct netbuf	xp_rtaddr;	/* remote transport address */
499 	char		xp_raddr[16];	/* remote address. Now obsoleted */
500 	struct opaque_auth xp_verf;	/* raw response verifier */
501 	caddr_t		xp_p1;		/* private: for use by svc ops */
502 	caddr_t		xp_p2;		/* private: for use by svc ops */
503 	caddr_t		xp_p3;		/* private: for use by svc lib */
504 	int		xp_type;	/* transport type */
505 	/*
506 	 * callback on client death
507 	 * First parameter is the current structure,
508 	 * Second parameter :
509 	 *	- FALSE for the service listener
510 	 *	- TRUE for a real connected socket
511 	 */
512 	svc_errorhandler_t xp_closeclnt;
513 };
514 #endif	/* _KERNEL */
515 
516 /*
517  *  Approved way of getting address of caller,
518  *  address mask, and netid of transport.
519  */
520 #define	svc_getrpccaller(x) (&(x)->xp_rtaddr)
521 #ifdef _KERNEL
522 #define	svc_getcaller(x) (&(x)->xp_rtaddr.buf)
523 #define	svc_getaddrmask(x) (&(x)->xp_master->xp_addrmask)
524 #define	svc_getnetid(x) ((x)->xp_netid)
525 #endif	/* _KERNEL */
526 
527 /*
528  * Operations defined on an SVCXPRT handle
529  */
530 
531 #ifdef	_KERNEL
532 
533 #define	SVC_GETADDRMASK(clone_xprt, attrflag, tattr) \
534 (*(clone_xprt)->xp_ops->xp_tattrs)((clone_xprt), (attrflag), (tattr))
535 
536 #define	SVC_CLONE_XPRT(src_xprt, dst_xprt) \
537 	if ((src_xprt)->xp_ops->xp_clone_xprt) \
538 		(*(src_xprt)->xp_ops->xp_clone_xprt) \
539 		    (src_xprt, dst_xprt)
540 
541 #define	SVC_HOLD(xprt) \
542 	if ((xprt)->xp_ops->xp_hold) \
543 		(*(xprt)->xp_ops->xp_hold)((xprt)->xp_wq)
544 
545 #define	SVC_RELE(xprt, mp, enable) \
546 	if ((xprt)->xp_ops->xp_release) \
547 		(*(xprt)->xp_ops->xp_release)((xprt)->xp_wq, (mp), (enable))
548 
549 #define	SVC_RECV(clone_xprt, mp, msg) \
550 	(*(clone_xprt)->xp_ops->xp_recv)((clone_xprt), (mp), (msg))
551 
552 /*
553  * PSARC 2003/523 Contract Private Interface
554  * SVC_GETARGS
555  * Changes must be reviewed by Solaris File Sharing
556  * Changes must be communicated to contract-2003-523@sun.com
557  */
558 #define	SVC_GETARGS(clone_xprt, xargs, argsp) \
559 	(*(clone_xprt)->xp_ops->xp_getargs)((clone_xprt), (xargs), (argsp))
560 
561 #define	SVC_REPLY(clone_xprt, msg) \
562 	(*(clone_xprt)->xp_ops->xp_reply) ((clone_xprt), (msg))
563 
564 #define	SVC_FREEARGS(clone_xprt, xargs, argsp) \
565 	(*(clone_xprt)->xp_ops->xp_freeargs)((clone_xprt), (xargs), (argsp))
566 
567 #define	SVC_GETRES(clone_xprt, size) \
568 	(*(clone_xprt)->xp_ops->xp_getres)((clone_xprt), (size))
569 
570 #define	SVC_FREERES(clone_xprt)	\
571 	(*(clone_xprt)->xp_ops->xp_freeres)(clone_xprt)
572 
573 #define	SVC_DESTROY(xprt) \
574 	(*(xprt)->xp_ops->xp_destroy)(xprt)
575 
576 /*
577  * PSARC 2003/523 Contract Private Interfaces
578  * SVC_DUP, SVC_DUPDONE, SVC_DUP_EXT, SVC_DUPDONE_EXT
579  * Changes must be reviewed by Solaris File Sharing
580  * Changes must be communicated to contract-2003-523@sun.com
581  *
582  * SVC_DUP and SVC_DUPDONE are defined here for backward compatibility.
583  */
584 #define	SVC_DUP_EXT(clone_xprt, req, res, size, drpp, dupcachedp) \
585 	(*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, dupcachedp)
586 
587 #define	SVC_DUPDONE_EXT(clone_xprt, dr, res, resfree, size, status) \
588 	(*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, resfree, size, status)
589 
590 #define	SVC_DUP(clone_xprt, req, res, size, drpp) \
591 	(*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, NULL)
592 
593 #define	SVC_DUPDONE(clone_xprt, dr, res, size, status) \
594 	(*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, NULL, size, status)
595 
596 #define	SVC_CLONE_DESTROY(clone_xprt) \
597 	(*(clone_xprt)->xp_ops->xp_clone_destroy)(clone_xprt)
598 
599 
600 #define	SVC_START(xprt) \
601 	(*(xprt)->xp_ops->xp_start)(xprt)
602 
603 #else	/* _KERNEL */
604 
605 #define	SVC_RECV(xprt, msg) \
606 	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
607 #define	svc_recv(xprt, msg) \
608 	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
609 
610 #define	SVC_STAT(xprt) \
611 	(*(xprt)->xp_ops->xp_stat)(xprt)
612 #define	svc_stat(xprt) \
613 	(*(xprt)->xp_ops->xp_stat)(xprt)
614 
615 #define	SVC_GETARGS(xprt, xargs, argsp) \
616 	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
617 #define	svc_getargs(xprt, xargs, argsp)	\
618 	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
619 
620 #define	SVC_REPLY(xprt, msg) \
621 	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
622 #define	svc_reply(xprt, msg) \
623 	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
624 
625 #define	SVC_FREEARGS(xprt, xargs, argsp) \
626 	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
627 #define	svc_freeargs(xprt, xargs, argsp) \
628 	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
629 
630 #define	SVC_GETRES(xprt, size) \
631 	(*(xprt)->xp_ops->xp_getres)((xprt), (size))
632 #define	svc_getres(xprt, size) \
633 	(*(xprt)->xp_ops->xp_getres)((xprt), (size))
634 
635 #define	SVC_FREERES(xprt) \
636 	(*(xprt)->xp_ops->xp_freeres)(xprt)
637 #define	svc_freeres(xprt) \
638 	(*(xprt)->xp_ops->xp_freeres)(xprt)
639 
640 #define	SVC_DESTROY(xprt) \
641 	(*(xprt)->xp_ops->xp_destroy)(xprt)
642 #define	svc_destroy(xprt) \
643 	(*(xprt)->xp_ops->xp_destroy)(xprt)
644 
645 /*
646  * PSARC 2003/523 Contract Private Interface
647  * SVC_CONTROL
648  * Changes must be reviewed by Solaris File Sharing
649  * Changes must be communicated to contract-2003-523@sun.com
650  */
651 #define	SVC_CONTROL(xprt, rq, in) \
652 	(*(xprt)->xp_ops->xp_control)((xprt), (rq), (in))
653 #endif	/* _KERNEL */
654 
655 /*
656  * Pool id's reserved for NFS, NLM, and the NFSv4 callback program.
657  */
658 #define	NFS_SVCPOOL_ID		0x01
659 #define	NLM_SVCPOOL_ID		0x02
660 #define	NFS_CB_SVCPOOL_ID	0x03
661 #define	RDC_SVCPOOL_ID		0x05	/* SNDR, PSARC 2001/699 */
662 
663 struct svcpool_args {
664 	uint32_t	id;		/* Pool id */
665 	uint32_t	maxthreads;	/* Max threads in the pool */
666 	uint32_t	redline;	/* `Redline' for the pool */
667 	uint32_t	qsize;		/* `xprt-ready' queue size */
668 	uint32_t	timeout;	/* svc_poll() timeout */
669 	uint32_t	stksize;	/* svc_run() stack size */
670 	uint32_t	max_same_xprt;	/* Max reqs from the same xprt */
671 };
672 
673 
674 #ifdef	_KERNEL
675 /*
676  * Transport registration and thread pool creation.
677  */
678 extern int	svc_xprt_register(SVCMASTERXPRT *, int);
679 extern void	svc_xprt_unregister(SVCMASTERXPRT *);
680 extern int	svc_pool_create(struct svcpool_args *);
681 extern int	svc_wait(int);
682 extern int	svc_do_run(int);
683 #define	SVCPSET_SHUTDOWN_PROC	1
684 #define	SVCPSET_UNREGISTER_PROC	2
685 extern int	svc_pool_control(int, int, void *);
686 #else	/* _KERNEL */
687 #ifdef	__STDC__
688 extern bool_t	rpc_reg(const rpcprog_t, const rpcvers_t, const rpcproc_t,
689 			char *(*)(char *), const xdrproc_t, const xdrproc_t,
690 			const char *);
691 
692 /*
693  * Service registration
694  *
695  * svc_reg(xprt, prog, vers, dispatch, nconf)
696  *	const SVCXPRT *xprt;
697  *	const rpcprog_t prog;
698  *	const rpcvers_t vers;
699  *	const void (*dispatch)();
700  *	const struct netconfig *nconf;
701  */
702 extern bool_t	svc_reg(const SVCXPRT *, const rpcprog_t, const rpcvers_t,
703 			void (*)(struct svc_req *, SVCXPRT *),
704 			const struct netconfig *);
705 
706 /*
707  * Service authentication registration
708  *
709  * svc_auth_reg(cred_flavor, handler)
710  *    int cred_flavor;
711  *    enum auth_stat (*handler)();
712  */
713 extern int	svc_auth_reg(int, enum auth_stat (*)());
714 
715 /*
716  * Service un-registration
717  *
718  * svc_unreg(prog, vers)
719  *	const rpcprog_t prog;
720  *	const rpcvers_t vers;
721  */
722 extern void	svc_unreg(const rpcprog_t, const rpcvers_t);
723 
724 /*
725  * Transport registration/unregistration.
726  *
727  * xprt_register(xprt)
728  *	const SVCXPRT *xprt;
729  *
730  * xprt_unregister(xprt)
731  *	const SVCXPRT *xprt;
732  */
733 extern void	xprt_register(const SVCXPRT *);
734 extern void	xprt_unregister(const SVCXPRT *);
735 #else	/* __STDC__ */
736 extern bool_t	rpc_reg();
737 extern bool_t	svc_reg();
738 extern bool_t	svc_auth_reg();
739 extern void	svc_unreg();
740 extern void	xprt_register();
741 extern void	xprt_unregister();
742 #endif /* __STDC__ */
743 #endif	/* _KERNEL */
744 
745 #ifdef _KERNEL
746 /*
747  * Transport hold and release.
748  */
749 extern void rpcmod_hold(queue_t *);
750 extern void rpcmod_release(queue_t *, mblk_t *, bool_t);
751 extern void mir_svc_hold(queue_t *);
752 extern void mir_svc_release(queue_t *, mblk_t *, bool_t);
753 #endif /* _KERNEL */
754 
755 /*
756  * When the service routine is called, it must first check to see if it
757  * knows about the procedure;  if not, it should call svcerr_noproc
758  * and return.  If so, it should deserialize its arguments via
759  * SVC_GETARGS (defined above).  If the deserialization does not work,
760  * svcerr_decode should be called followed by a return.  Successful
761  * decoding of the arguments should be followed the execution of the
762  * procedure's code and a call to svc_sendreply.
763  *
764  * Also, if the service refuses to execute the procedure due to too-
765  * weak authentication parameters, svcerr_weakauth should be called.
766  * Note: do not confuse access-control failure with weak authentication!
767  *
768  * NB: In pure implementations of rpc, the caller always waits for a reply
769  * msg.  This message is sent when svc_sendreply is called.
770  * Therefore pure service implementations should always call
771  * svc_sendreply even if the function logically returns void;  use
772  * xdr.h - xdr_void for the xdr routine.  HOWEVER, connectionful rpc allows
773  * for the abuse of pure rpc via batched calling or pipelining.  In the
774  * case of a batched call, svc_sendreply should NOT be called since
775  * this would send a return message, which is what batching tries to avoid.
776  * It is the service/protocol writer's responsibility to know which calls are
777  * batched and which are not.  Warning: responding to batch calls may
778  * deadlock the caller and server processes!
779  */
780 #ifdef	__STDC__
781 extern bool_t	svc_sendreply(const SVCXPRT *, const xdrproc_t,	const caddr_t);
782 extern void	svcerr_decode(const SVCXPRT *);
783 extern void	svcerr_weakauth(const SVCXPRT *);
784 extern void	svcerr_noproc(const SVCXPRT *);
785 extern void	svcerr_progvers(const SVCXPRT *, const rpcvers_t,
786     const rpcvers_t);
787 extern void	svcerr_auth(const SVCXPRT *, const enum auth_stat);
788 extern void	svcerr_noprog(const SVCXPRT *);
789 extern void	svcerr_systemerr(const SVCXPRT *);
790 extern void	svcerr_badcred(const SVCXPRT *);
791 #else	/* __STDC__ */
792 extern bool_t	svc_sendreply();
793 extern void	svcerr_decode();
794 extern void	svcerr_weakauth();
795 extern void	svcerr_noproc();
796 extern void	svcerr_progvers();
797 extern void	svcerr_auth();
798 extern void	svcerr_noprog();
799 extern void	svcerr_systemerr();
800 extern void	svcerr_badcred();
801 #endif	/* __STDC__ */
802 
803 #ifdef	_KERNEL
804 /*
805  * Kernel RPC functions.
806  */
807 extern void	svc_init(void);
808 extern void	svc_cots_init(void);
809 extern void	svc_clts_init(void);
810 extern void	mt_kstat_init(void);
811 extern void	mt_kstat_fini(void);
812 extern int	svc_tli_kcreate(struct file *, uint_t, char *,
813 				struct netbuf *, SVCMASTERXPRT **,
814 				SVC_CALLOUT_TABLE *,
815 				void (*closeproc)(const SVCMASTERXPRT *),
816 				int, bool_t);
817 extern int	svc_clts_kcreate(struct file *, uint_t, struct T_info_ack *,
818 				SVCMASTERXPRT **);
819 extern int	svc_cots_kcreate(struct file *, uint_t, struct T_info_ack *,
820 				SVCMASTERXPRT **);
821 extern bool_t	svc_queuereq(queue_t *, mblk_t *, bool_t);
822 extern void	svc_queueclean(queue_t *);
823 extern void	svc_queueclose(queue_t *);
824 extern int	svc_reserve_thread(SVCXPRT *);
825 extern void	svc_unreserve_thread(SVCXPRT *);
826 extern callb_cpr_t *svc_detach_thread(SVCXPRT *);
827 
828 /*
829  * For RDMA based kRPC.
830  * "rdma_xprt_record" is a reference to master transport handles
831  * in kRPC thread pools. This is an easy way of tracking and shuting
832  * down rdma based kRPC transports on demand.
833  * "rdma_xprt_group" is a list of RDMA based mster transport handles
834  * or records in a kRPC thread pool.
835  */
836 typedef struct rdma_xprt_record		rdma_xprt_record_t;
837 struct rdma_xprt_record {
838 	int			rtr_type;	/* Type of rdma; IB/VI/RDDP */
839 	SVCMASTERXPRT		*rtr_xprt_ptr;	/* Ptr to master xprt handle */
840 	rdma_xprt_record_t	*rtr_next;	/* Ptr to next record */
841 };
842 
843 typedef struct {
844 	int			rtg_count;	/* Number transport records */
845 	int			rtg_poolid;	/* Pool Id for this group */
846 	rdma_xprt_record_t	*rtg_listhead;	/* Head of the records list */
847 } rdma_xprt_group_t;
848 
849 extern int	svc_rdma_kcreate(char *, SVC_CALLOUT_TABLE *, int,
850 			rdma_xprt_group_t *);
851 extern void	svc_rdma_kstop(SVCMASTERXPRT *);
852 extern void	svc_rdma_kdestroy(SVCMASTERXPRT *);
853 extern void	rdma_stop(rdma_xprt_group_t *);
854 
855 /*
856  * GSS cleanup method.
857  */
858 extern void	rpc_gss_cleanup(SVCXPRT *);
859 #else	/* _KERNEL */
860 /*
861  * Lowest level dispatching -OR- who owns this process anyway.
862  * Somebody has to wait for incoming requests and then call the correct
863  * service routine.  The routine svc_run does infinite waiting; i.e.,
864  * svc_run never returns.
865  * Since another (co-existant) package may wish to selectively wait for
866  * incoming calls or other events outside of the rpc architecture, the
867  * routine svc_getreq_poll is provided.  It must be passed pollfds, the
868  * "in-place" results of a poll call (see poll, section 2).
869  */
870 
871 /*
872  * Global keeper of rpc service descriptors in use
873  * dynamic; must be inspected before each call to select or poll
874  */
875 extern pollfd_t	*svc_pollfd;
876 extern int	svc_max_pollfd;
877 extern fd_set	svc_fdset;
878 #define	svc_fds svc_fdset.fds_bits[0]	/* compatibility */
879 
880 /*
881  * A small program implemented by the svc_rpc implementation itself.
882  * Also see clnt.h for protocol numbers.
883  */
884 #ifdef __STDC__
885 extern void	svc_getreq(int);
886 extern void	svc_getreq_common(const int);
887 extern void	svc_getreqset(fd_set *); /* takes fdset instead of int */
888 extern void	svc_getreq_poll(struct pollfd *, const int);
889 extern void	svc_run(void);
890 extern void	svc_exit(void);
891 #else	/* __STDC__ */
892 extern void	rpctest_service();
893 extern void	svc_getreqset();
894 extern void	svc_getreq();
895 extern void	svc_getreq_common();
896 extern void	svc_getreqset();	 /* takes fdset instead of int */
897 extern void	svc_getreq_poll();
898 extern void	svc_run();
899 extern void	svc_exit();
900 #endif	/* __STDC__ */
901 
902 /*
903  *  Functions used to manage user file descriptors
904  */
905 typedef int svc_input_id_t;
906 typedef void (*svc_callback_t)(svc_input_id_t id, int fd,
907 				unsigned int events, void* cookie);
908 
909 #ifdef __STDC__
910 extern svc_input_id_t svc_add_input(int fd, unsigned int events,
911 				svc_callback_t user_callback,
912 				void* cookie);
913 extern int svc_remove_input(svc_input_id_t id);
914 #else	/* __STDC__ */
915 extern svc_input_id_t svc_add_input();
916 extern int	svc_remove_input();
917 #endif
918 
919 /*
920  * These are the existing service side transport implementations.
921  *
922  * Transport independent svc_create routine.
923  */
924 #ifdef __STDC__
925 extern int	svc_create(void (*)(struct svc_req *, SVCXPRT *),
926 				const rpcprog_t, const rpcvers_t,
927 				const char *);
928 	/*
929 	 *	void (*dispatch)();		-- dispatch routine
930 	 *	const rpcprog_t prognum;	-- program number
931 	 *	const rpcvers_t versnum;	-- version number
932 	 *	const char *nettype;		-- network type
933 	 */
934 
935 /*
936  * Generic server creation routine. It takes a netconfig structure
937  * instead of a nettype.
938  */
939 extern SVCXPRT	*svc_tp_create(void (*)(struct svc_req *, SVCXPRT *),
940 				const rpcprog_t, const rpcvers_t,
941 				const struct netconfig *);
942 	/*
943 	 * void (*dispatch)();			-- dispatch routine
944 	 * const rpcprog_t prognum;		-- program number
945 	 * const rpcvers_t versnum;		-- version number
946 	 * const struct netconfig *nconf;	-- netconfig structure
947 	 */
948 
949 /*
950  * Variant of svc_tp_create that accepts a binding address.
951  * If addr == NULL, this is the same as svc_tp_create().
952  */
953 extern SVCXPRT	*svc_tp_create_addr(void (*)(struct svc_req *, SVCXPRT *),
954 				const rpcprog_t, const rpcvers_t,
955 				const struct netconfig *,
956 				const struct netbuf *);
957 	/*
958 	 * void (*dispatch)();			-- dispatch routine
959 	 * const rpcprog_t prognum;		-- program number
960 	 * const rpcvers_t versnum;		-- version number
961 	 * const struct netconfig *nconf;	-- netconfig structure
962 	 * const struct netbuf *addr;		-- address to bind
963 	 */
964 
965 /*
966  * Generic TLI create routine
967  */
968 extern  SVCXPRT	*svc_tli_create(const int, const struct netconfig *,
969 				const struct t_bind *, const uint_t,
970 				const uint_t);
971 	/*
972 	 *	const int fd;			-- connection end point
973 	 *	const struct netconfig *nconf;	-- netconfig structure
974 	 *	const struct t_bind *bindaddr;	-- local bind address
975 	 *	const uint_t sendsz;		-- max sendsize
976 	 *	const uint_t recvsz;		-- max recvsize
977 	 */
978 
979 /*
980  * Connectionless and connectionful create routines.
981  */
982 extern SVCXPRT	*svc_vc_create(const int, const uint_t, const uint_t);
983 	/*
984 	 *	const int fd;			-- open connection end point
985 	 *	const uint_t sendsize;		-- max send size
986 	 *	const uint_t recvsize;		-- max recv size
987 	 */
988 
989 extern SVCXPRT	*svc_dg_create(const int, const uint_t, const uint_t);
990 	/*
991 	 * const int fd;			-- open connection
992 	 * const uint_t sendsize;		-- max send size
993 	 * const uint_t recvsize;		-- max recv size
994 	 */
995 
996 /*
997  * the routine takes any *open* TLI file
998  * descriptor as its first input and is used for open connections.
999  */
1000 extern  SVCXPRT	*svc_fd_create(const int, const uint_t, const uint_t);
1001 	/*
1002 	 *	const int fd;			-- open connection end point
1003 	 *	const uint_t sendsize;		-- max send size
1004 	 *	const uint_t recvsize;		-- max recv size
1005 	 */
1006 
1007 /*
1008  * Memory based rpc (for speed check and testing)
1009  */
1010 extern SVCXPRT	*svc_raw_create(void);
1011 
1012 /*
1013  * Creation of service over doors transport.
1014  */
1015 extern SVCXPRT	*svc_door_create(void (*)(struct svc_req *, SVCXPRT *),
1016 				const rpcprog_t, const rpcvers_t,
1017 				const uint_t);
1018 	/*
1019 	 *	void (*dispatch)();		-- dispatch routine
1020 	 *	const rpcprog_t prognum;	-- program number
1021 	 *	const rpcvers_t versnum;	-- version number
1022 	 *	const uint_t sendsize;		-- send buffer size
1023 	 */
1024 
1025 /*
1026  * Service control interface
1027  */
1028 extern	bool_t	svc_control(SVCXPRT *, const uint_t, void *);
1029 	/*
1030 	 *	SVCXPRT *svc;			-- service to manipulate
1031 	 *	const uint_t req;		-- request
1032 	 *	void *info;			-- argument to request
1033 	 */
1034 
1035 /*
1036  * svc_dg_enable_cache() enables the cache on dg transports.
1037  */
1038 extern int svc_dg_enablecache(SVCXPRT *, const uint_t);
1039 #else	/* __STDC__ */
1040 extern int	svc_create();
1041 extern SVCXPRT	*svc_tp_create();
1042 extern SVCXPRT	*svc_tli_create();
1043 extern SVCXPRT	*svc_vc_create();
1044 extern SVCXPRT	*svc_dg_create();
1045 extern SVCXPRT	*svc_fd_create();
1046 extern SVCXPRT	*svc_raw_create();
1047 extern SVCXPRT	*svc_door_create();
1048 extern int svc_dg_enablecache();
1049 #endif	/* __STDC__ */
1050 
1051 extern boolean_t is_multilevel(rpcprog_t);
1052 
1053 #ifdef	PORTMAP
1054 /* For backward compatibility */
1055 #include <rpc/svc_soc.h>
1056 #endif	/* PORTMAP */
1057 
1058 /*
1059  * For user level MT hot server functions
1060  */
1061 
1062 /*
1063  * Different MT modes
1064  */
1065 #define	RPC_SVC_MT_NONE		0	/* default, single-threaded */
1066 #define	RPC_SVC_MT_AUTO		1	/* automatic MT mode */
1067 #define	RPC_SVC_MT_USER		2	/* user MT mode */
1068 
1069 #ifdef	__STDC__
1070 extern void	svc_done(SVCXPRT *);
1071 #else
1072 extern void	svc_done();
1073 #endif	/* __STDC__ */
1074 
1075 /*
1076  * Obtaining local credentials.
1077  */
1078 typedef struct __svc_local_cred_t {
1079 	uid_t	euid;	/* effective uid */
1080 	gid_t	egid;	/* effective gid */
1081 	uid_t	ruid;	/* real uid */
1082 	gid_t	rgid;	/* real gid */
1083 	pid_t	pid;	/* caller's pid, or -1 if not available */
1084 } svc_local_cred_t;
1085 
1086 #ifdef __STDC__
1087 struct ucred_s;
1088 extern void	svc_fd_negotiate_ucred(int);
1089 extern int	svc_getcallerucred(const SVCXPRT *, struct ucred_s **);
1090 extern bool_t	svc_get_local_cred(SVCXPRT *, svc_local_cred_t *);
1091 #else
1092 extern void	svc_fd_negotiate_ucred();
1093 extern int	svc_getcallerucred();
1094 extern bool_t	svc_get_local_cred();
1095 #endif	/* __STDC__ */
1096 
1097 /*
1098  * Private interfaces and structures for user level duplicate request caching.
1099  * The interfaces and data structures are not committed and subject to
1100  * change in future releases. Currently only intended for use by automountd.
1101  */
1102 struct dupreq {
1103 	uint32_t	dr_xid;
1104 	rpcproc_t	dr_proc;
1105 	rpcvers_t	dr_vers;
1106 	rpcprog_t	dr_prog;
1107 	struct netbuf	dr_addr;
1108 	struct netbuf	dr_resp;
1109 	int		dr_status;
1110 	time_t		dr_time;
1111 	uint_t		dr_hash;
1112 	struct dupreq	*dr_next;
1113 	struct dupreq	*dr_prev;
1114 	struct dupreq	*dr_chain;
1115 	struct dupreq	*dr_prevchain;
1116 };
1117 
1118 /*
1119  * The fixedtime state is defined if we want to expand the routines to
1120  * handle and encompass fixed size caches.
1121  */
1122 #define	DUPCACHE_FIXEDTIME	0
1123 
1124 /*
1125  * States of requests for duplicate request caching.
1126  * These are the same as defined for the kernel.
1127  */
1128 #define	DUP_NEW			0x00	/* new entry */
1129 #define	DUP_INPROGRESS		0x01	/* request already going */
1130 #define	DUP_DONE		0x02	/* request done */
1131 #define	DUP_DROP		0x03	/* request dropped */
1132 #define	DUP_ERROR		0x04	/* error in dup req cache */
1133 
1134 #ifdef __STDC__
1135 extern bool_t	__svc_dupcache_init(void *, int, char **);
1136 extern int	__svc_dup(struct svc_req *, caddr_t *, uint_t *, char *);
1137 extern int	__svc_dupdone(struct svc_req *, caddr_t, uint_t, int, char *);
1138 extern bool_t	__svc_vc_dupcache_init(SVCXPRT *, void *, int);
1139 extern int	__svc_vc_dup(struct svc_req *, caddr_t *, uint_t *);
1140 extern int	__svc_vc_dupdone(struct svc_req *, caddr_t, uint_t, int);
1141 #else
1142 extern bool_t	__svc_dupcache_init();
1143 extern int	__svc_dup();
1144 extern int	__svc_dupdone();
1145 extern bool_t	__svc_vc_dupcache_init();
1146 extern int	__svc_vc_dup();
1147 extern int	__svc_vc_dupdone();
1148 #endif	/* __STDC__ */
1149 #endif	/* _KERNEL */
1150 
1151 #ifdef	_KERNEL
1152 /*
1153  * Private interfaces and structures for SVCXPRT cloning.
1154  * The interfaces and data structures are not committed and subject to
1155  * change in future releases.
1156  */
1157 extern SVCXPRT *svc_clone_init(void);
1158 extern void svc_clone_free(SVCXPRT *);
1159 extern void svc_clone_link(SVCMASTERXPRT *, SVCXPRT *, SVCXPRT *);
1160 extern void svc_clone_unlink(SVCXPRT *);
1161 
1162 /* Get cached preallocated cred */
1163 extern cred_t *svc_xprt_cred(SVCXPRT *);
1164 #endif	/* _KERNEL */
1165 
1166 #ifdef	__cplusplus
1167 }
1168 #endif
1169 
1170 #endif	/* !_RPC_SVC_H */
1171