1177633Sdfr/*	$NetBSD: svc.h,v 1.17 2000/06/02 22:57:56 fvdl Exp $	*/
2177633Sdfr
3261046Smav/*-
4261046Smav * Copyright (c) 2009, Sun Microsystems, Inc.
5261046Smav * All rights reserved.
6177633Sdfr *
7261046Smav * Redistribution and use in source and binary forms, with or without
8261046Smav * modification, are permitted provided that the following conditions are met:
9261046Smav * - Redistributions of source code must retain the above copyright notice,
10261046Smav *   this list of conditions and the following disclaimer.
11261046Smav * - Redistributions in binary form must reproduce the above copyright notice,
12261046Smav *   this list of conditions and the following disclaimer in the documentation
13261046Smav *   and/or other materials provided with the distribution.
14261046Smav * - Neither the name of Sun Microsystems, Inc. nor the names of its
15261046Smav *   contributors may be used to endorse or promote products derived
16261046Smav *   from this software without specific prior written permission.
17261046Smav *
18261046Smav * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19261046Smav * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20261046Smav * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21261046Smav * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22261046Smav * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23261046Smav * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24261046Smav * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25261046Smav * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26261046Smav * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27261046Smav * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28261046Smav * POSSIBILITY OF SUCH DAMAGE.
29177633Sdfr *
30177633Sdfr *	from: @(#)svc.h 1.35 88/12/17 SMI
31177633Sdfr *	from: @(#)svc.h      1.27    94/04/25 SMI
32177633Sdfr * $FreeBSD: releng/10.3/sys/rpc/svc.h 290203 2015-10-30 19:26:55Z wollman $
33177633Sdfr */
34177633Sdfr
35177633Sdfr/*
36177633Sdfr * svc.h, Server-side remote procedure call interface.
37177633Sdfr *
38177633Sdfr * Copyright (C) 1986-1993 by Sun Microsystems, Inc.
39177633Sdfr */
40177633Sdfr
41177633Sdfr#ifndef _RPC_SVC_H
42177633Sdfr#define _RPC_SVC_H
43177633Sdfr#include <sys/cdefs.h>
44177633Sdfr
45177633Sdfr#ifdef _KERNEL
46177633Sdfr#include <sys/queue.h>
47177633Sdfr#include <sys/_lock.h>
48177633Sdfr#include <sys/_mutex.h>
49184588Sdfr#include <sys/_sx.h>
50184588Sdfr#include <sys/condvar.h>
51184588Sdfr#include <sys/sysctl.h>
52177633Sdfr#endif
53177633Sdfr
54177633Sdfr/*
55177633Sdfr * This interface must manage two items concerning remote procedure calling:
56177633Sdfr *
57177633Sdfr * 1) An arbitrary number of transport connections upon which rpc requests
58177633Sdfr * are received.  The two most notable transports are TCP and UDP;  they are
59177633Sdfr * created and registered by routines in svc_tcp.c and svc_udp.c, respectively;
60177633Sdfr * they in turn call xprt_register and xprt_unregister.
61177633Sdfr *
62177633Sdfr * 2) An arbitrary number of locally registered services.  Services are
63177633Sdfr * described by the following four data: program number, version number,
64177633Sdfr * "service dispatch" function, a transport handle, and a boolean that
65177633Sdfr * indicates whether or not the exported program should be registered with a
66177633Sdfr * local binder service;  if true the program's number and version and the
67177633Sdfr * port number from the transport handle are registered with the binder.
68177633Sdfr * These data are registered with the rpc svc system via svc_register.
69177633Sdfr *
70177633Sdfr * A service's dispatch function is called whenever an rpc request comes in
71177633Sdfr * on a transport.  The request's program and version numbers must match
72177633Sdfr * those of the registered service.  The dispatch function is passed two
73177633Sdfr * parameters, struct svc_req * and SVCXPRT *, defined below.
74177633Sdfr */
75177633Sdfr
76177633Sdfr/*
77177633Sdfr *      Service control requests
78177633Sdfr */
79177633Sdfr#define SVCGET_VERSQUIET	1
80177633Sdfr#define SVCSET_VERSQUIET	2
81177633Sdfr#define SVCGET_CONNMAXREC	3
82177633Sdfr#define SVCSET_CONNMAXREC	4
83177633Sdfr
84177633Sdfr/*
85177633Sdfr * Operations for rpc_control().
86177633Sdfr */
87177633Sdfr#define RPC_SVC_CONNMAXREC_SET  0	/* set max rec size, enable nonblock */
88177633Sdfr#define RPC_SVC_CONNMAXREC_GET  1
89177633Sdfr
90177633Sdfrenum xprt_stat {
91177633Sdfr	XPRT_DIED,
92177633Sdfr	XPRT_MOREREQS,
93177633Sdfr	XPRT_IDLE
94177633Sdfr};
95177633Sdfr
96177633Sdfrstruct __rpc_svcxprt;
97184588Sdfrstruct mbuf;
98177633Sdfr
99177633Sdfrstruct xp_ops {
100184588Sdfr#ifdef _KERNEL
101177633Sdfr	/* receive incoming requests */
102184588Sdfr	bool_t	(*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *,
103184588Sdfr	    struct sockaddr **, struct mbuf **);
104184588Sdfr	/* get transport status */
105184588Sdfr	enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *);
106261055Smav	/* get transport acknowledge sequence */
107261055Smav	bool_t (*xp_ack)(struct __rpc_svcxprt *, uint32_t *);
108184588Sdfr	/* send reply */
109184588Sdfr	bool_t	(*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *,
110261055Smav	    struct sockaddr *, struct mbuf *, uint32_t *);
111184588Sdfr	/* destroy this struct */
112184588Sdfr	void	(*xp_destroy)(struct __rpc_svcxprt *);
113184588Sdfr	/* catch-all function */
114184588Sdfr	bool_t  (*xp_control)(struct __rpc_svcxprt *, const u_int, void *);
115184588Sdfr#else
116184588Sdfr	/* receive incoming requests */
117177633Sdfr	bool_t	(*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *);
118177633Sdfr	/* get transport status */
119177633Sdfr	enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *);
120177633Sdfr	/* get arguments */
121177633Sdfr	bool_t	(*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t, void *);
122177633Sdfr	/* send reply */
123177633Sdfr	bool_t	(*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *);
124177633Sdfr	/* free mem allocated for args */
125177633Sdfr	bool_t	(*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t, void *);
126177633Sdfr	/* destroy this struct */
127177633Sdfr	void	(*xp_destroy)(struct __rpc_svcxprt *);
128177633Sdfr#endif
129177633Sdfr};
130177633Sdfr
131177633Sdfr#ifndef _KERNEL
132177633Sdfrstruct xp_ops2 {
133177633Sdfr	/* catch-all function */
134177633Sdfr	bool_t  (*xp_control)(struct __rpc_svcxprt *, const u_int, void *);
135177633Sdfr};
136177633Sdfr#endif
137177633Sdfr
138177633Sdfr#ifdef _KERNEL
139177633Sdfrstruct __rpc_svcpool;
140267742Smavstruct __rpc_svcgroup;
141184588Sdfrstruct __rpc_svcthread;
142177633Sdfr#endif
143177633Sdfr
144177633Sdfr/*
145184588Sdfr * Server side transport handle. In the kernel, transports have a
146184588Sdfr * reference count which tracks the number of currently assigned
147184588Sdfr * worker threads plus one for the service pool's reference.
148269398Srmacklem * For NFSv4.1 sessions, a reference is also held for a backchannel.
149177633Sdfr */
150177633Sdfrtypedef struct __rpc_svcxprt {
151177633Sdfr#ifdef _KERNEL
152184588Sdfr	volatile u_int	xp_refs;
153184588Sdfr	struct sx	xp_lock;
154177633Sdfr	struct __rpc_svcpool *xp_pool;  /* owning pool (see below) */
155267742Smav	struct __rpc_svcgroup *xp_group; /* owning group (see below) */
156177633Sdfr	TAILQ_ENTRY(__rpc_svcxprt) xp_link;
157177633Sdfr	TAILQ_ENTRY(__rpc_svcxprt) xp_alink;
158177633Sdfr	bool_t		xp_registered;	/* xprt_register has been called */
159177633Sdfr	bool_t		xp_active;	/* xprt_active has been called */
160184588Sdfr	struct __rpc_svcthread *xp_thread; /* assigned service thread */
161177633Sdfr	struct socket*	xp_socket;
162177633Sdfr	const struct xp_ops *xp_ops;
163177633Sdfr	char		*xp_netid;	/* network token */
164184588Sdfr	struct sockaddr_storage xp_ltaddr; /* local transport address */
165184588Sdfr	struct sockaddr_storage	xp_rtaddr; /* remote transport address */
166177633Sdfr	void		*xp_p1;		/* private: for use by svc ops */
167177633Sdfr	void		*xp_p2;		/* private: for use by svc ops */
168177633Sdfr	void		*xp_p3;		/* private: for use by svc lib */
169177633Sdfr	int		xp_type;	/* transport type */
170184588Sdfr	int		xp_idletimeout; /* idle time before closing */
171184588Sdfr	time_t		xp_lastactive;	/* time of last RPC */
172191145Srmacklem	u_int64_t	xp_sockref;	/* set by nfsv4 to identify socket */
173193436Srmacklem	int		xp_upcallset;	/* socket upcall is set up */
174261055Smav	uint32_t	xp_snd_cnt;	/* # of bytes to send to socket */
175261055Smav	uint32_t	xp_snt_cnt;	/* # of bytes sent to socket */
176177633Sdfr#else
177177633Sdfr	int		xp_fd;
178177633Sdfr	u_short		xp_port;	 /* associated port number */
179177633Sdfr	const struct xp_ops *xp_ops;
180177633Sdfr	int		xp_addrlen;	 /* length of remote address */
181177633Sdfr	struct sockaddr_in xp_raddr;	 /* remote addr. (backward ABI compat) */
182177633Sdfr	/* XXX - fvdl stick this here for ABI backward compat reasons */
183177633Sdfr	const struct xp_ops2 *xp_ops2;
184177633Sdfr	char		*xp_tp;		 /* transport provider device name */
185177633Sdfr	char		*xp_netid;	 /* network token */
186177633Sdfr	struct netbuf	xp_ltaddr;	 /* local transport address */
187177633Sdfr	struct netbuf	xp_rtaddr;	 /* remote transport address */
188177633Sdfr	struct opaque_auth xp_verf;	 /* raw response verifier */
189177633Sdfr	void		*xp_p1;		 /* private: for use by svc ops */
190177633Sdfr	void		*xp_p2;		 /* private: for use by svc ops */
191177633Sdfr	void		*xp_p3;		 /* private: for use by svc lib */
192177633Sdfr	int		xp_type;	 /* transport type */
193177633Sdfr#endif
194177633Sdfr} SVCXPRT;
195177633Sdfr
196184588Sdfr/*
197184588Sdfr * Interface to server-side authentication flavors.
198184588Sdfr */
199184588Sdfrtypedef struct __rpc_svcauth {
200184588Sdfr	struct svc_auth_ops {
201177633Sdfr#ifdef _KERNEL
202184588Sdfr		int   (*svc_ah_wrap)(struct __rpc_svcauth *,  struct mbuf **);
203184588Sdfr		int   (*svc_ah_unwrap)(struct __rpc_svcauth *, struct mbuf **);
204184588Sdfr		void  (*svc_ah_release)(struct __rpc_svcauth *);
205184588Sdfr#else
206184588Sdfr		int   (*svc_ah_wrap)(struct __rpc_svcauth *, XDR *,
207184588Sdfr		    xdrproc_t, caddr_t);
208184588Sdfr		int   (*svc_ah_unwrap)(struct __rpc_svcauth *, XDR *,
209184588Sdfr		    xdrproc_t, caddr_t);
210184588Sdfr#endif
211184588Sdfr	} *svc_ah_ops;
212184588Sdfr	void *svc_ah_private;
213184588Sdfr} SVCAUTH;
214177633Sdfr
215177633Sdfr/*
216184588Sdfr * Server transport extensions (accessed via xp_p3).
217184588Sdfr */
218184588Sdfrtypedef struct __rpc_svcxprt_ext {
219184588Sdfr	int		xp_flags;	/* versquiet */
220184588Sdfr	SVCAUTH		xp_auth;	/* interface to auth methods */
221184588Sdfr} SVCXPRT_EXT;
222184588Sdfr
223184588Sdfr#ifdef _KERNEL
224184588Sdfr
225184588Sdfr/*
226177633Sdfr * The services list
227177633Sdfr * Each entry represents a set of procedures (an rpc program).
228177633Sdfr * The dispatch routine takes request structs and runs the
229177633Sdfr * apropriate procedure.
230177633Sdfr */
231177633Sdfrstruct svc_callout {
232177633Sdfr	TAILQ_ENTRY(svc_callout) sc_link;
233177633Sdfr	rpcprog_t	    sc_prog;
234177633Sdfr	rpcvers_t	    sc_vers;
235177633Sdfr	char		   *sc_netid;
236177633Sdfr	void		    (*sc_dispatch)(struct svc_req *, SVCXPRT *);
237177633Sdfr};
238177633SdfrTAILQ_HEAD(svc_callout_list, svc_callout);
239177633Sdfr
240261055Smav/*
241261055Smav * The services connection loss list
242261055Smav * The dispatch routine takes request structs and runs the
243261055Smav * apropriate procedure.
244261055Smav */
245261055Smavstruct svc_loss_callout {
246261055Smav	TAILQ_ENTRY(svc_loss_callout) slc_link;
247261055Smav	void		    (*slc_dispatch)(SVCXPRT *);
248261055Smav};
249261055SmavTAILQ_HEAD(svc_loss_callout_list, svc_loss_callout);
250261055Smav
251177633Sdfr/*
252184588Sdfr * Service request
253184588Sdfr */
254184588Sdfrstruct svc_req {
255184588Sdfr	STAILQ_ENTRY(svc_req) rq_link;	/* list of requests for a thread */
256184588Sdfr	struct __rpc_svcthread *rq_thread; /* thread which is to execute this */
257184588Sdfr	uint32_t	rq_xid;		/* RPC transaction ID */
258184588Sdfr	uint32_t	rq_prog;	/* service program number */
259184588Sdfr	uint32_t	rq_vers;	/* service protocol version */
260184588Sdfr	uint32_t	rq_proc;	/* the desired procedure */
261184588Sdfr	size_t		rq_size;	/* space used by request */
262184588Sdfr	struct mbuf	*rq_args;	/* XDR-encoded procedure arguments */
263184588Sdfr	struct opaque_auth rq_cred;	/* raw creds from the wire */
264184588Sdfr	struct opaque_auth rq_verf;	/* verifier for the reply */
265184588Sdfr	void		*rq_clntcred;	/* read only cooked cred */
266184588Sdfr	SVCAUTH		rq_auth;	/* interface to auth methods */
267184588Sdfr	SVCXPRT		*rq_xprt;	/* associated transport */
268184588Sdfr	struct sockaddr	*rq_addr;	/* reply address or NULL if connected */
269184588Sdfr	void		*rq_p1;		/* application workspace */
270184588Sdfr	int		rq_p2;		/* application workspace */
271184588Sdfr	uint64_t	rq_p3;		/* application workspace */
272261055Smav	uint32_t	rq_reply_seq;	/* reply socket sequence # */
273184588Sdfr	char		rq_credarea[3*MAX_AUTH_BYTES];
274184588Sdfr};
275184588SdfrSTAILQ_HEAD(svc_reqlist, svc_req);
276184588Sdfr
277184588Sdfr#define svc_getrpccaller(rq)					\
278184588Sdfr	((rq)->rq_addr ? (rq)->rq_addr :			\
279184588Sdfr	    (struct sockaddr *) &(rq)->rq_xprt->xp_rtaddr)
280184588Sdfr
281184588Sdfr/*
282184588Sdfr * This structure is used to manage a thread which is executing
283184588Sdfr * requests from a service pool. A service thread is in one of three
284184588Sdfr * states:
285184588Sdfr *
286184588Sdfr *	SVCTHREAD_SLEEPING	waiting for a request to process
287184588Sdfr *	SVCTHREAD_ACTIVE	processing a request
288184588Sdfr *	SVCTHREAD_EXITING	exiting after finishing current request
289184588Sdfr *
290184588Sdfr * Threads which have no work to process sleep on the pool's sp_active
291184588Sdfr * list. When a transport becomes active, it is assigned a service
292184588Sdfr * thread to read and execute pending RPCs.
293184588Sdfr */
294184588Sdfrtypedef struct __rpc_svcthread {
295267740Smav	struct mtx_padalign	st_lock; /* protects st_reqs field */
296261054Smav	struct __rpc_svcpool	*st_pool;
297184588Sdfr	SVCXPRT			*st_xprt; /* transport we are processing */
298184588Sdfr	struct svc_reqlist	st_reqs;  /* RPC requests to execute */
299184588Sdfr	struct cv		st_cond; /* sleeping for work */
300184588Sdfr	LIST_ENTRY(__rpc_svcthread) st_ilink; /* idle threads list */
301184588Sdfr	LIST_ENTRY(__rpc_svcthread) st_alink; /* application thread list */
302261054Smav	int		st_p2;		/* application workspace */
303261054Smav	uint64_t	st_p3;		/* application workspace */
304184588Sdfr} SVCTHREAD;
305184588SdfrLIST_HEAD(svcthread_list, __rpc_svcthread);
306184588Sdfr
307184588Sdfr/*
308267742Smav * A thread group contain all information needed to assign subset of
309267742Smav * transports to subset of threads.  On systems with many CPUs and many
310267742Smav * threads that allows to reduce lock congestion and improve performance.
311267742Smav * Hundreds of threads on dozens of CPUs sharing the single pool lock do
312267742Smav * not scale well otherwise.
313267742Smav */
314267742SmavTAILQ_HEAD(svcxprt_list, __rpc_svcxprt);
315267742Smavenum svcpool_state {
316267742Smav	SVCPOOL_INIT,		/* svc_run not called yet */
317267742Smav	SVCPOOL_ACTIVE,		/* normal running state */
318267742Smav	SVCPOOL_THREADWANTED,	/* new service thread requested */
319267742Smav	SVCPOOL_THREADSTARTING,	/* new service thread started */
320267742Smav	SVCPOOL_CLOSING		/* svc_exit called */
321267742Smav};
322267742Smavtypedef struct __rpc_svcgroup {
323267742Smav	struct mtx_padalign sg_lock;	/* protect the thread/req lists */
324267742Smav	struct __rpc_svcpool	*sg_pool;
325267742Smav	enum svcpool_state sg_state;	/* current pool state */
326267742Smav	struct svcxprt_list sg_xlist;	/* all transports in the group */
327267742Smav	struct svcxprt_list sg_active;	/* transports needing service */
328267742Smav	struct svcthread_list sg_idlethreads; /* idle service threads */
329267742Smav
330267742Smav	int		sg_minthreads;	/* minimum service thread count */
331267742Smav	int		sg_maxthreads;	/* maximum service thread count */
332267742Smav	int		sg_threadcount; /* current service thread count */
333267742Smav	time_t		sg_lastcreatetime; /* when we last started a thread */
334267742Smav	time_t		sg_lastidlecheck;  /* when we last checked idle transports */
335267742Smav} SVCGROUP;
336267742Smav
337267742Smav/*
338177633Sdfr * In the kernel, we can't use global variables to store lists of
339177633Sdfr * transports etc. since otherwise we could not have two unrelated RPC
340177633Sdfr * services running, each on its own thread. We solve this by
341177633Sdfr * importing a tiny part of a Solaris kernel concept, SVCPOOL.
342177633Sdfr *
343177633Sdfr * A service pool contains a set of transports and service callbacks
344177633Sdfr * for a set of related RPC services. The pool handle should be passed
345177633Sdfr * when creating new transports etc. Future work may include extending
346177633Sdfr * this to support something similar to the Solaris multi-threaded RPC
347177633Sdfr * server.
348177633Sdfr */
349184588Sdfrtypedef SVCTHREAD *pool_assign_fn(SVCTHREAD *, struct svc_req *);
350184588Sdfrtypedef void pool_done_fn(SVCTHREAD *, struct svc_req *);
351267742Smav#define	SVC_MAXGROUPS	16
352177633Sdfrtypedef struct __rpc_svcpool {
353261055Smav	struct mtx_padalign sp_lock;	/* protect the transport lists */
354184588Sdfr	const char	*sp_name;	/* pool name (e.g. "nfsd", "NLM" */
355184588Sdfr	enum svcpool_state sp_state;	/* current pool state */
356184588Sdfr	struct proc	*sp_proc;	/* process which is in svc_run */
357177633Sdfr	struct svc_callout_list sp_callouts; /* (prog,vers)->dispatch list */
358261055Smav	struct svc_loss_callout_list sp_lcallouts; /* loss->dispatch list */
359184588Sdfr	int		sp_minthreads;	/* minimum service thread count */
360184588Sdfr	int		sp_maxthreads;	/* maximum service thread count */
361184588Sdfr
362184588Sdfr	/*
363184588Sdfr	 * Hooks to allow an application to control request to thread
364184588Sdfr	 * placement.
365184588Sdfr	 */
366184588Sdfr	pool_assign_fn	*sp_assign;
367184588Sdfr	pool_done_fn	*sp_done;
368184588Sdfr
369184588Sdfr	/*
370184588Sdfr	 * These variables are used to put an upper bound on the
371184588Sdfr	 * amount of memory used by RPC requests which are queued
372184588Sdfr	 * waiting for execution.
373184588Sdfr	 */
374290203Swollman	unsigned long	sp_space_low;
375290203Swollman	unsigned long	sp_space_high;
376290203Swollman	unsigned long	sp_space_used;
377290203Swollman	unsigned long	sp_space_used_highest;
378184588Sdfr	bool_t		sp_space_throttled;
379184588Sdfr	int		sp_space_throttle_count;
380184588Sdfr
381184588Sdfr	struct replay_cache *sp_rcache; /* optional replay cache */
382184588Sdfr	struct sysctl_ctx_list sp_sysctl;
383267742Smav
384267742Smav	int		sp_groupcount;	/* Number of groups in the pool. */
385267742Smav	int		sp_nextgroup;	/* Next group to assign port. */
386267742Smav	SVCGROUP	sp_groups[SVC_MAXGROUPS]; /* Thread/port groups. */
387177633Sdfr} SVCPOOL;
388177633Sdfr
389184588Sdfr#else
390177633Sdfr
391177633Sdfr/*
392177633Sdfr * Service request
393177633Sdfr */
394177633Sdfrstruct svc_req {
395177633Sdfr	uint32_t	rq_prog;	/* service program number */
396177633Sdfr	uint32_t	rq_vers;	/* service protocol version */
397177633Sdfr	uint32_t	rq_proc;	/* the desired procedure */
398177633Sdfr	struct opaque_auth rq_cred;	/* raw creds from the wire */
399177633Sdfr	void		*rq_clntcred;	/* read only cooked cred */
400177633Sdfr	SVCXPRT		*rq_xprt;	/* associated transport */
401177633Sdfr};
402177633Sdfr
403177633Sdfr/*
404177633Sdfr *  Approved way of getting address of caller
405177633Sdfr */
406177633Sdfr#define svc_getrpccaller(x) (&(x)->xp_rtaddr)
407177633Sdfr
408184588Sdfr#endif
409184588Sdfr
410177633Sdfr/*
411177633Sdfr * Operations defined on an SVCXPRT handle
412177633Sdfr *
413177633Sdfr * SVCXPRT		*xprt;
414177633Sdfr * struct rpc_msg	*msg;
415177633Sdfr * xdrproc_t		 xargs;
416177633Sdfr * void *		 argsp;
417177633Sdfr */
418184588Sdfr#ifdef _KERNEL
419184588Sdfr
420184588Sdfr#define SVC_ACQUIRE(xprt)			\
421184588Sdfr	refcount_acquire(&(xprt)->xp_refs)
422184588Sdfr
423184588Sdfr#define SVC_RELEASE(xprt)			\
424184588Sdfr	if (refcount_release(&(xprt)->xp_refs))	\
425184588Sdfr		SVC_DESTROY(xprt)
426184588Sdfr
427184588Sdfr#define SVC_RECV(xprt, msg, addr, args)			\
428184588Sdfr	(*(xprt)->xp_ops->xp_recv)((xprt), (msg), (addr), (args))
429184588Sdfr
430184588Sdfr#define SVC_STAT(xprt)					\
431184588Sdfr	(*(xprt)->xp_ops->xp_stat)(xprt)
432184588Sdfr
433261055Smav#define SVC_ACK(xprt, ack)				\
434261055Smav	((xprt)->xp_ops->xp_ack == NULL ? FALSE :	\
435261055Smav	    ((ack) == NULL ? TRUE : (*(xprt)->xp_ops->xp_ack)((xprt), (ack))))
436184588Sdfr
437261055Smav#define SVC_REPLY(xprt, msg, addr, m, seq)			\
438261055Smav	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg), (addr), (m), (seq))
439261055Smav
440184588Sdfr#define SVC_DESTROY(xprt)				\
441184588Sdfr	(*(xprt)->xp_ops->xp_destroy)(xprt)
442184588Sdfr
443184588Sdfr#define SVC_CONTROL(xprt, rq, in)			\
444184588Sdfr	(*(xprt)->xp_ops->xp_control)((xprt), (rq), (in))
445184588Sdfr
446184588Sdfr#else
447184588Sdfr
448177633Sdfr#define SVC_RECV(xprt, msg)				\
449177633Sdfr	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
450177633Sdfr#define svc_recv(xprt, msg)				\
451177633Sdfr	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
452177633Sdfr
453177633Sdfr#define SVC_STAT(xprt)					\
454177633Sdfr	(*(xprt)->xp_ops->xp_stat)(xprt)
455177633Sdfr#define svc_stat(xprt)					\
456177633Sdfr	(*(xprt)->xp_ops->xp_stat)(xprt)
457177633Sdfr
458177633Sdfr#define SVC_GETARGS(xprt, xargs, argsp)			\
459177633Sdfr	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
460177633Sdfr#define svc_getargs(xprt, xargs, argsp)			\
461177633Sdfr	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
462177633Sdfr
463177633Sdfr#define SVC_REPLY(xprt, msg)				\
464177633Sdfr	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
465177633Sdfr#define svc_reply(xprt, msg)				\
466177633Sdfr	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
467177633Sdfr
468177633Sdfr#define SVC_FREEARGS(xprt, xargs, argsp)		\
469177633Sdfr	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
470177633Sdfr#define svc_freeargs(xprt, xargs, argsp)		\
471177633Sdfr	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
472177633Sdfr
473177633Sdfr#define SVC_DESTROY(xprt)				\
474177633Sdfr	(*(xprt)->xp_ops->xp_destroy)(xprt)
475177633Sdfr#define svc_destroy(xprt)				\
476177633Sdfr	(*(xprt)->xp_ops->xp_destroy)(xprt)
477177633Sdfr
478177633Sdfr#define SVC_CONTROL(xprt, rq, in)			\
479177633Sdfr	(*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in))
480184588Sdfr
481177633Sdfr#endif
482177633Sdfr
483184588Sdfr#define SVC_EXT(xprt)					\
484184588Sdfr	((SVCXPRT_EXT *) xprt->xp_p3)
485184588Sdfr
486184588Sdfr#define SVC_AUTH(xprt)					\
487184588Sdfr	(SVC_EXT(xprt)->xp_auth)
488184588Sdfr
489177633Sdfr/*
490184588Sdfr * Operations defined on an SVCAUTH handle
491184588Sdfr */
492184588Sdfr#ifdef _KERNEL
493184588Sdfr#define SVCAUTH_WRAP(auth, mp)		\
494184588Sdfr	((auth)->svc_ah_ops->svc_ah_wrap(auth, mp))
495184588Sdfr#define SVCAUTH_UNWRAP(auth, mp)	\
496184588Sdfr	((auth)->svc_ah_ops->svc_ah_unwrap(auth, mp))
497184588Sdfr#define SVCAUTH_RELEASE(auth)	\
498184588Sdfr	((auth)->svc_ah_ops->svc_ah_release(auth))
499184588Sdfr#else
500184588Sdfr#define SVCAUTH_WRAP(auth, xdrs, xfunc, xwhere)		\
501184588Sdfr	((auth)->svc_ah_ops->svc_ah_wrap(auth, xdrs, xfunc, xwhere))
502184588Sdfr#define SVCAUTH_UNWRAP(auth, xdrs, xfunc, xwhere)	\
503184588Sdfr	((auth)->svc_ah_ops->svc_ah_unwrap(auth, xdrs, xfunc, xwhere))
504184588Sdfr#endif
505184588Sdfr
506184588Sdfr/*
507177633Sdfr * Service registration
508177633Sdfr *
509177633Sdfr * svc_reg(xprt, prog, vers, dispatch, nconf)
510177633Sdfr *	const SVCXPRT *xprt;
511177633Sdfr *	const rpcprog_t prog;
512177633Sdfr *	const rpcvers_t vers;
513177633Sdfr *	const void (*dispatch)();
514177633Sdfr *	const struct netconfig *nconf;
515177633Sdfr */
516177633Sdfr
517177633Sdfr__BEGIN_DECLS
518177633Sdfrextern bool_t	svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t,
519177633Sdfr			void (*)(struct svc_req *, SVCXPRT *),
520177633Sdfr			const struct netconfig *);
521177633Sdfr__END_DECLS
522177633Sdfr
523177633Sdfr/*
524177633Sdfr * Service un-registration
525177633Sdfr *
526177633Sdfr * svc_unreg(prog, vers)
527177633Sdfr *	const rpcprog_t prog;
528177633Sdfr *	const rpcvers_t vers;
529177633Sdfr */
530177633Sdfr
531177633Sdfr__BEGIN_DECLS
532177633Sdfr#ifdef _KERNEL
533177633Sdfrextern void	svc_unreg(SVCPOOL *, const rpcprog_t, const rpcvers_t);
534177633Sdfr#else
535177633Sdfrextern void	svc_unreg(const rpcprog_t, const rpcvers_t);
536177633Sdfr#endif
537177633Sdfr__END_DECLS
538177633Sdfr
539261055Smav#ifdef _KERNEL
540177633Sdfr/*
541261055Smav * Service connection loss registration
542261055Smav *
543261055Smav * svc_loss_reg(xprt, dispatch)
544261055Smav *	const SVCXPRT *xprt;
545261055Smav *	const void (*dispatch)();
546261055Smav */
547261055Smav
548261055Smav__BEGIN_DECLS
549261055Smavextern bool_t	svc_loss_reg(SVCXPRT *, void (*)(SVCXPRT *));
550261055Smav__END_DECLS
551261055Smav
552261055Smav/*
553261055Smav * Service connection loss un-registration
554261055Smav *
555261055Smav * svc_loss_unreg(xprt, dispatch)
556261055Smav *	const SVCXPRT *xprt;
557261055Smav *	const void (*dispatch)();
558261055Smav */
559261055Smav
560261055Smav__BEGIN_DECLS
561261055Smavextern void	svc_loss_unreg(SVCPOOL *, void (*)(SVCXPRT *));
562261055Smav__END_DECLS
563261055Smav#endif
564261055Smav
565261055Smav/*
566177633Sdfr * Transport registration.
567177633Sdfr *
568177633Sdfr * xprt_register(xprt)
569177633Sdfr *	SVCXPRT *xprt;
570177633Sdfr */
571177633Sdfr__BEGIN_DECLS
572177633Sdfrextern void	xprt_register(SVCXPRT *);
573177633Sdfr__END_DECLS
574177633Sdfr
575177633Sdfr/*
576177633Sdfr * Transport un-register
577177633Sdfr *
578177633Sdfr * xprt_unregister(xprt)
579177633Sdfr *	SVCXPRT *xprt;
580177633Sdfr */
581177633Sdfr__BEGIN_DECLS
582177633Sdfrextern void	xprt_unregister(SVCXPRT *);
583177633Sdfrextern void	__xprt_unregister_unlocked(SVCXPRT *);
584177633Sdfr__END_DECLS
585177633Sdfr
586177633Sdfr#ifdef _KERNEL
587177633Sdfr
588177633Sdfr/*
589177633Sdfr * Called when a transport has pending requests.
590177633Sdfr */
591177633Sdfr__BEGIN_DECLS
592177633Sdfrextern void	xprt_active(SVCXPRT *);
593177633Sdfrextern void	xprt_inactive(SVCXPRT *);
594184588Sdfrextern void	xprt_inactive_locked(SVCXPRT *);
595261053Smavextern void	xprt_inactive_self(SVCXPRT *);
596177633Sdfr__END_DECLS
597177633Sdfr
598177633Sdfr#endif
599177633Sdfr
600177633Sdfr/*
601177633Sdfr * When the service routine is called, it must first check to see if it
602177633Sdfr * knows about the procedure;  if not, it should call svcerr_noproc
603177633Sdfr * and return.  If so, it should deserialize its arguments via
604177633Sdfr * SVC_GETARGS (defined above).  If the deserialization does not work,
605177633Sdfr * svcerr_decode should be called followed by a return.  Successful
606177633Sdfr * decoding of the arguments should be followed the execution of the
607177633Sdfr * procedure's code and a call to svc_sendreply.
608177633Sdfr *
609177633Sdfr * Also, if the service refuses to execute the procedure due to too-
610177633Sdfr * weak authentication parameters, svcerr_weakauth should be called.
611177633Sdfr * Note: do not confuse access-control failure with weak authentication!
612177633Sdfr *
613177633Sdfr * NB: In pure implementations of rpc, the caller always waits for a reply
614177633Sdfr * msg.  This message is sent when svc_sendreply is called.
615177633Sdfr * Therefore pure service implementations should always call
616177633Sdfr * svc_sendreply even if the function logically returns void;  use
617177633Sdfr * xdr.h - xdr_void for the xdr routine.  HOWEVER, tcp based rpc allows
618177633Sdfr * for the abuse of pure rpc via batched calling or pipelining.  In the
619177633Sdfr * case of a batched call, svc_sendreply should NOT be called since
620177633Sdfr * this would send a return message, which is what batching tries to avoid.
621177633Sdfr * It is the service/protocol writer's responsibility to know which calls are
622177633Sdfr * batched and which are not.  Warning: responding to batch calls may
623177633Sdfr * deadlock the caller and server processes!
624177633Sdfr */
625177633Sdfr
626177633Sdfr__BEGIN_DECLS
627184588Sdfr#ifdef _KERNEL
628184588Sdfrextern bool_t	svc_sendreply(struct svc_req *, xdrproc_t, void *);
629184588Sdfrextern bool_t	svc_sendreply_mbuf(struct svc_req *, struct mbuf *);
630184588Sdfrextern void	svcerr_decode(struct svc_req *);
631184588Sdfrextern void	svcerr_weakauth(struct svc_req *);
632184588Sdfrextern void	svcerr_noproc(struct svc_req *);
633184588Sdfrextern void	svcerr_progvers(struct svc_req *, rpcvers_t, rpcvers_t);
634184588Sdfrextern void	svcerr_auth(struct svc_req *, enum auth_stat);
635184588Sdfrextern void	svcerr_noprog(struct svc_req *);
636184588Sdfrextern void	svcerr_systemerr(struct svc_req *);
637184588Sdfr#else
638177633Sdfrextern bool_t	svc_sendreply(SVCXPRT *, xdrproc_t, void *);
639177633Sdfrextern void	svcerr_decode(SVCXPRT *);
640177633Sdfrextern void	svcerr_weakauth(SVCXPRT *);
641177633Sdfrextern void	svcerr_noproc(SVCXPRT *);
642177633Sdfrextern void	svcerr_progvers(SVCXPRT *, rpcvers_t, rpcvers_t);
643177633Sdfrextern void	svcerr_auth(SVCXPRT *, enum auth_stat);
644177633Sdfrextern void	svcerr_noprog(SVCXPRT *);
645177633Sdfrextern void	svcerr_systemerr(SVCXPRT *);
646184588Sdfr#endif
647177633Sdfrextern int	rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t,
648177633Sdfr			char *(*)(char *), xdrproc_t, xdrproc_t,
649177633Sdfr			char *);
650177633Sdfr__END_DECLS
651177633Sdfr
652177633Sdfr/*
653177633Sdfr * Lowest level dispatching -OR- who owns this process anyway.
654177633Sdfr * Somebody has to wait for incoming requests and then call the correct
655177633Sdfr * service routine.  The routine svc_run does infinite waiting; i.e.,
656177633Sdfr * svc_run never returns.
657177633Sdfr * Since another (co-existant) package may wish to selectively wait for
658177633Sdfr * incoming calls or other events outside of the rpc architecture, the
659177633Sdfr * routine svc_getreq is provided.  It must be passed readfds, the
660177633Sdfr * "in-place" results of a select system call (see select, section 2).
661177633Sdfr */
662177633Sdfr
663177633Sdfr#ifndef _KERNEL
664177633Sdfr/*
665177633Sdfr * Global keeper of rpc service descriptors in use
666177633Sdfr * dynamic; must be inspected before each call to select
667177633Sdfr */
668177633Sdfrextern int svc_maxfd;
669177633Sdfr#ifdef FD_SETSIZE
670177633Sdfrextern fd_set svc_fdset;
671177633Sdfr#define svc_fds svc_fdset.fds_bits[0]	/* compatibility */
672177633Sdfr#else
673177633Sdfrextern int svc_fds;
674177633Sdfr#endif /* def FD_SETSIZE */
675177633Sdfr#endif
676177633Sdfr
677177633Sdfr/*
678177633Sdfr * a small program implemented by the svc_rpc implementation itself;
679177633Sdfr * also see clnt.h for protocol numbers.
680177633Sdfr */
681177633Sdfr__BEGIN_DECLS
682177633Sdfrextern void rpctest_service(void);
683177633Sdfr__END_DECLS
684177633Sdfr
685177633Sdfr__BEGIN_DECLS
686184588Sdfrextern SVCXPRT *svc_xprt_alloc(void);
687184588Sdfrextern void	svc_xprt_free(SVCXPRT *);
688177633Sdfr#ifndef _KERNEL
689177633Sdfrextern void	svc_getreq(int);
690177633Sdfrextern void	svc_getreqset(fd_set *);
691177633Sdfrextern void	svc_getreq_common(int);
692177633Sdfrstruct pollfd;
693177633Sdfrextern void	svc_getreq_poll(struct pollfd *, int);
694177633Sdfrextern void	svc_run(void);
695177633Sdfrextern void	svc_exit(void);
696177633Sdfr#else
697177633Sdfrextern void	svc_run(SVCPOOL *);
698177633Sdfrextern void	svc_exit(SVCPOOL *);
699184588Sdfrextern bool_t	svc_getargs(struct svc_req *, xdrproc_t, void *);
700184588Sdfrextern bool_t	svc_freeargs(struct svc_req *, xdrproc_t, void *);
701184588Sdfrextern void	svc_freereq(struct svc_req *);
702184588Sdfr
703177633Sdfr#endif
704177633Sdfr__END_DECLS
705177633Sdfr
706177633Sdfr/*
707177633Sdfr * Socket to use on svcxxx_create call to get default socket
708177633Sdfr */
709177633Sdfr#define	RPC_ANYSOCK	-1
710177633Sdfr#define RPC_ANYFD	RPC_ANYSOCK
711177633Sdfr
712177633Sdfr/*
713177633Sdfr * These are the existing service side transport implementations
714177633Sdfr */
715177633Sdfr
716177633Sdfr__BEGIN_DECLS
717177633Sdfr
718177633Sdfr#ifdef _KERNEL
719177633Sdfr
720177633Sdfr/*
721177633Sdfr * Create a new service pool.
722177633Sdfr */
723184588Sdfrextern SVCPOOL* svcpool_create(const char *name,
724184588Sdfr    struct sysctl_oid_list *sysctl_base);
725177633Sdfr
726177633Sdfr/*
727177633Sdfr * Destroy a service pool, including all registered transports.
728177633Sdfr */
729177633Sdfrextern void svcpool_destroy(SVCPOOL *pool);
730177633Sdfr
731177633Sdfr/*
732177633Sdfr * Transport independent svc_create routine.
733177633Sdfr */
734177633Sdfrextern int svc_create(SVCPOOL *, void (*)(struct svc_req *, SVCXPRT *),
735177633Sdfr    const rpcprog_t, const rpcvers_t, const char *);
736177633Sdfr/*
737177633Sdfr *      void (*dispatch)();             -- dispatch routine
738177633Sdfr *      const rpcprog_t prognum;        -- program number
739177633Sdfr *      const rpcvers_t versnum;        -- version number
740177633Sdfr *      const char *nettype;            -- network type
741177633Sdfr */
742177633Sdfr
743177633Sdfr
744177633Sdfr/*
745177633Sdfr * Generic server creation routine. It takes a netconfig structure
746177633Sdfr * instead of a nettype.
747177633Sdfr */
748177633Sdfr
749177633Sdfrextern SVCXPRT *svc_tp_create(SVCPOOL *, void (*)(struct svc_req *, SVCXPRT *),
750177633Sdfr    const rpcprog_t, const rpcvers_t, const char *uaddr,
751177633Sdfr    const struct netconfig *);
752177633Sdfr        /*
753177633Sdfr         * void (*dispatch)();            -- dispatch routine
754177633Sdfr         * const rpcprog_t prognum;       -- program number
755177633Sdfr         * const rpcvers_t versnum;       -- version number
756177633Sdfr	 * const char *uaddr;		  -- universal address of service
757177633Sdfr         * const struct netconfig *nconf; -- netconfig structure
758177633Sdfr         */
759177633Sdfr
760177633Sdfrextern SVCXPRT *svc_dg_create(SVCPOOL *, struct socket *,
761177633Sdfr    const size_t, const size_t);
762177633Sdfr        /*
763177633Sdfr         * struct socket *;                             -- open connection
764177633Sdfr         * const size_t sendsize;                        -- max send size
765177633Sdfr         * const size_t recvsize;                        -- max recv size
766177633Sdfr         */
767177633Sdfr
768177633Sdfrextern SVCXPRT *svc_vc_create(SVCPOOL *, struct socket *,
769177633Sdfr    const size_t, const size_t);
770177633Sdfr        /*
771177633Sdfr         * struct socket *;                             -- open connection
772177633Sdfr         * const size_t sendsize;                        -- max send size
773177633Sdfr         * const size_t recvsize;                        -- max recv size
774177633Sdfr         */
775177633Sdfr
776244008Srmacklemextern SVCXPRT *svc_vc_create_backchannel(SVCPOOL *);
777244008Srmacklem
778269398Srmacklemextern void *clnt_bck_create(struct socket *, const rpcprog_t, const rpcvers_t);
779269398Srmacklem	/*
780269398Srmacklem	 * struct socket *;			-- server transport socket
781269398Srmacklem	 * const rpcprog_t prog;		-- RPC program number
782269398Srmacklem	 * const rpcvers_t vers;		-- RPC program version
783269398Srmacklem	 */
784269398Srmacklem
785177633Sdfr/*
786177633Sdfr * Generic TLI create routine
787177633Sdfr */
788177633Sdfrextern SVCXPRT *svc_tli_create(SVCPOOL *, struct socket *,
789177633Sdfr    const struct netconfig *, const struct t_bind *, const size_t, const size_t);
790177633Sdfr/*
791177633Sdfr *      struct socket * so;             -- connection end point
792177633Sdfr *      const struct netconfig *nconf;  -- netconfig structure for network
793177633Sdfr *      const struct t_bind *bindaddr;  -- local bind address
794177633Sdfr *      const size_t sendsz;             -- max sendsize
795177633Sdfr *      const size_t recvsz;             -- max recvsize
796177633Sdfr */
797177633Sdfr
798177633Sdfr#else /* !_KERNEL */
799177633Sdfr
800177633Sdfr/*
801177633Sdfr * Transport independent svc_create routine.
802177633Sdfr */
803177633Sdfrextern int svc_create(void (*)(struct svc_req *, SVCXPRT *),
804177633Sdfr			   const rpcprog_t, const rpcvers_t, const char *);
805177633Sdfr/*
806177633Sdfr *      void (*dispatch)();             -- dispatch routine
807177633Sdfr *      const rpcprog_t prognum;        -- program number
808177633Sdfr *      const rpcvers_t versnum;        -- version number
809177633Sdfr *      const char *nettype;            -- network type
810177633Sdfr */
811177633Sdfr
812177633Sdfr
813177633Sdfr/*
814177633Sdfr * Generic server creation routine. It takes a netconfig structure
815177633Sdfr * instead of a nettype.
816177633Sdfr */
817177633Sdfr
818177633Sdfrextern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *),
819177633Sdfr				   const rpcprog_t, const rpcvers_t,
820177633Sdfr				   const struct netconfig *);
821177633Sdfr        /*
822177633Sdfr         * void (*dispatch)();            -- dispatch routine
823177633Sdfr         * const rpcprog_t prognum;       -- program number
824177633Sdfr         * const rpcvers_t versnum;       -- version number
825177633Sdfr         * const struct netconfig *nconf; -- netconfig structure
826177633Sdfr         */
827177633Sdfr
828177633Sdfr/*
829177633Sdfr * Generic TLI create routine
830177633Sdfr */
831177633Sdfrextern SVCXPRT *svc_tli_create(const int, const struct netconfig *,
832177633Sdfr			       const struct t_bind *, const u_int,
833177633Sdfr			       const u_int);
834177633Sdfr/*
835177633Sdfr *      const int fd;                   -- connection end point
836177633Sdfr *      const struct netconfig *nconf;  -- netconfig structure for network
837177633Sdfr *      const struct t_bind *bindaddr;  -- local bind address
838177633Sdfr *      const u_int sendsz;             -- max sendsize
839177633Sdfr *      const u_int recvsz;             -- max recvsize
840177633Sdfr */
841177633Sdfr
842177633Sdfr/*
843177633Sdfr * Connectionless and connectionful create routines
844177633Sdfr */
845177633Sdfr
846177633Sdfrextern SVCXPRT *svc_vc_create(const int, const u_int, const u_int);
847177633Sdfr/*
848177633Sdfr *      const int fd;                           -- open connection end point
849177633Sdfr *      const u_int sendsize;                   -- max send size
850177633Sdfr *      const u_int recvsize;                   -- max recv size
851177633Sdfr */
852177633Sdfr
853177633Sdfr/*
854177633Sdfr * Added for compatibility to old rpc 4.0. Obsoleted by svc_vc_create().
855177633Sdfr */
856177633Sdfrextern SVCXPRT *svcunix_create(int, u_int, u_int, char *);
857177633Sdfr
858177633Sdfrextern SVCXPRT *svc_dg_create(const int, const u_int, const u_int);
859177633Sdfr        /*
860177633Sdfr         * const int fd;                                -- open connection
861177633Sdfr         * const u_int sendsize;                        -- max send size
862177633Sdfr         * const u_int recvsize;                        -- max recv size
863177633Sdfr         */
864177633Sdfr
865177633Sdfr
866177633Sdfr/*
867177633Sdfr * the routine takes any *open* connection
868177633Sdfr * descriptor as its first input and is used for open connections.
869177633Sdfr */
870177633Sdfrextern SVCXPRT *svc_fd_create(const int, const u_int, const u_int);
871177633Sdfr/*
872177633Sdfr *      const int fd;                           -- open connection end point
873177633Sdfr *      const u_int sendsize;                   -- max send size
874177633Sdfr *      const u_int recvsize;                   -- max recv size
875177633Sdfr */
876177633Sdfr
877177633Sdfr/*
878177633Sdfr * Added for compatibility to old rpc 4.0. Obsoleted by svc_fd_create().
879177633Sdfr */
880177633Sdfrextern SVCXPRT *svcunixfd_create(int, u_int, u_int);
881177633Sdfr
882177633Sdfr/*
883177633Sdfr * Memory based rpc (for speed check and testing)
884177633Sdfr */
885177633Sdfrextern SVCXPRT *svc_raw_create(void);
886177633Sdfr
887177633Sdfr/*
888177633Sdfr * svc_dg_enable_cache() enables the cache on dg transports.
889177633Sdfr */
890177633Sdfrint svc_dg_enablecache(SVCXPRT *, const u_int);
891177633Sdfr
892177633Sdfrint __rpc_get_local_uid(SVCXPRT *_transp, uid_t *_uid);
893177633Sdfr
894177633Sdfr#endif	/* !_KERNEL */
895177633Sdfr
896177633Sdfr__END_DECLS
897177633Sdfr
898177633Sdfr#ifndef _KERNEL
899177633Sdfr/* for backward compatibility */
900177633Sdfr#include <rpc/svc_soc.h>
901177633Sdfr#endif
902177633Sdfr
903177633Sdfr#endif /* !_RPC_SVC_H */
904