svc.h revision 177633
1177633Sdfr/*	$NetBSD: svc.h,v 1.17 2000/06/02 22:57:56 fvdl Exp $	*/
2177633Sdfr
3177633Sdfr/*
4177633Sdfr * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5177633Sdfr * unrestricted use provided that this legend is included on all tape
6177633Sdfr * media and as a part of the software program in whole or part.  Users
7177633Sdfr * may copy or modify Sun RPC without charge, but are not authorized
8177633Sdfr * to license or distribute it to anyone else except as part of a product or
9177633Sdfr * program developed by the user.
10177633Sdfr *
11177633Sdfr * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12177633Sdfr * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
13177633Sdfr * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14177633Sdfr *
15177633Sdfr * Sun RPC is provided with no support and without any obligation on the
16177633Sdfr * part of Sun Microsystems, Inc. to assist in its use, correction,
17177633Sdfr * modification or enhancement.
18177633Sdfr *
19177633Sdfr * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20177633Sdfr * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21177633Sdfr * OR ANY PART THEREOF.
22177633Sdfr *
23177633Sdfr * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24177633Sdfr * or profits or other special, indirect and consequential damages, even if
25177633Sdfr * Sun has been advised of the possibility of such damages.
26177633Sdfr *
27177633Sdfr * Sun Microsystems, Inc.
28177633Sdfr * 2550 Garcia Avenue
29177633Sdfr * Mountain View, California  94043
30177633Sdfr *
31177633Sdfr *	from: @(#)svc.h 1.35 88/12/17 SMI
32177633Sdfr *	from: @(#)svc.h      1.27    94/04/25 SMI
33177633Sdfr * $FreeBSD: head/sys/rpc/svc.h 177633 2008-03-26 15:23:12Z dfr $
34177633Sdfr */
35177633Sdfr
36177633Sdfr/*
37177633Sdfr * svc.h, Server-side remote procedure call interface.
38177633Sdfr *
39177633Sdfr * Copyright (C) 1986-1993 by Sun Microsystems, Inc.
40177633Sdfr */
41177633Sdfr
42177633Sdfr#ifndef _RPC_SVC_H
43177633Sdfr#define _RPC_SVC_H
44177633Sdfr#include <sys/cdefs.h>
45177633Sdfr
46177633Sdfr#ifdef _KERNEL
47177633Sdfr#include <sys/queue.h>
48177633Sdfr#include <sys/_lock.h>
49177633Sdfr#include <sys/_mutex.h>
50177633Sdfr#endif
51177633Sdfr
52177633Sdfr/*
53177633Sdfr * This interface must manage two items concerning remote procedure calling:
54177633Sdfr *
55177633Sdfr * 1) An arbitrary number of transport connections upon which rpc requests
56177633Sdfr * are received.  The two most notable transports are TCP and UDP;  they are
57177633Sdfr * created and registered by routines in svc_tcp.c and svc_udp.c, respectively;
58177633Sdfr * they in turn call xprt_register and xprt_unregister.
59177633Sdfr *
60177633Sdfr * 2) An arbitrary number of locally registered services.  Services are
61177633Sdfr * described by the following four data: program number, version number,
62177633Sdfr * "service dispatch" function, a transport handle, and a boolean that
63177633Sdfr * indicates whether or not the exported program should be registered with a
64177633Sdfr * local binder service;  if true the program's number and version and the
65177633Sdfr * port number from the transport handle are registered with the binder.
66177633Sdfr * These data are registered with the rpc svc system via svc_register.
67177633Sdfr *
68177633Sdfr * A service's dispatch function is called whenever an rpc request comes in
69177633Sdfr * on a transport.  The request's program and version numbers must match
70177633Sdfr * those of the registered service.  The dispatch function is passed two
71177633Sdfr * parameters, struct svc_req * and SVCXPRT *, defined below.
72177633Sdfr */
73177633Sdfr
74177633Sdfr/*
75177633Sdfr *      Service control requests
76177633Sdfr */
77177633Sdfr#define SVCGET_VERSQUIET	1
78177633Sdfr#define SVCSET_VERSQUIET	2
79177633Sdfr#define SVCGET_CONNMAXREC	3
80177633Sdfr#define SVCSET_CONNMAXREC	4
81177633Sdfr
82177633Sdfr/*
83177633Sdfr * Operations for rpc_control().
84177633Sdfr */
85177633Sdfr#define RPC_SVC_CONNMAXREC_SET  0	/* set max rec size, enable nonblock */
86177633Sdfr#define RPC_SVC_CONNMAXREC_GET  1
87177633Sdfr
88177633Sdfrenum xprt_stat {
89177633Sdfr	XPRT_DIED,
90177633Sdfr	XPRT_MOREREQS,
91177633Sdfr	XPRT_IDLE
92177633Sdfr};
93177633Sdfr
94177633Sdfrstruct __rpc_svcxprt;
95177633Sdfr
96177633Sdfrstruct xp_ops {
97177633Sdfr	/* receive incoming requests */
98177633Sdfr	bool_t	(*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *);
99177633Sdfr	/* get transport status */
100177633Sdfr	enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *);
101177633Sdfr	/* get arguments */
102177633Sdfr	bool_t	(*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t, void *);
103177633Sdfr	/* send reply */
104177633Sdfr	bool_t	(*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *);
105177633Sdfr	/* free mem allocated for args */
106177633Sdfr	bool_t	(*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t, void *);
107177633Sdfr	/* destroy this struct */
108177633Sdfr	void	(*xp_destroy)(struct __rpc_svcxprt *);
109177633Sdfr#ifdef _KERNEL
110177633Sdfr	/* catch-all function */
111177633Sdfr	bool_t  (*xp_control)(struct __rpc_svcxprt *, const u_int, void *);
112177633Sdfr#endif
113177633Sdfr};
114177633Sdfr
115177633Sdfr#ifndef _KERNEL
116177633Sdfrstruct xp_ops2 {
117177633Sdfr	/* catch-all function */
118177633Sdfr	bool_t  (*xp_control)(struct __rpc_svcxprt *, const u_int, void *);
119177633Sdfr};
120177633Sdfr#endif
121177633Sdfr
122177633Sdfr#ifdef _KERNEL
123177633Sdfrstruct __rpc_svcpool;
124177633Sdfr#endif
125177633Sdfr
126177633Sdfr/*
127177633Sdfr * Server side transport handle
128177633Sdfr */
129177633Sdfrtypedef struct __rpc_svcxprt {
130177633Sdfr#ifdef _KERNEL
131177633Sdfr	struct mtx	xp_lock;
132177633Sdfr	struct __rpc_svcpool *xp_pool;  /* owning pool (see below) */
133177633Sdfr	TAILQ_ENTRY(__rpc_svcxprt) xp_link;
134177633Sdfr	TAILQ_ENTRY(__rpc_svcxprt) xp_alink;
135177633Sdfr	bool_t		xp_registered;	/* xprt_register has been called */
136177633Sdfr	bool_t		xp_active;	/* xprt_active has been called */
137177633Sdfr	struct socket*	xp_socket;
138177633Sdfr	const struct xp_ops *xp_ops;
139177633Sdfr	char		*xp_netid;	/* network token */
140177633Sdfr	struct netbuf	xp_ltaddr;	/* local transport address */
141177633Sdfr	struct netbuf	xp_rtaddr;	/* remote transport address */
142177633Sdfr	struct opaque_auth xp_verf;	/* raw response verifier */
143177633Sdfr	uint32_t	xp_xid;		/* current transaction ID */
144177633Sdfr	XDR		xp_xdrreq;	/* xdr stream for decoding request */
145177633Sdfr	XDR		xp_xdrrep;	/* xdr stream for encoding reply */
146177633Sdfr	void		*xp_p1;		/* private: for use by svc ops */
147177633Sdfr	void		*xp_p2;		/* private: for use by svc ops */
148177633Sdfr	void		*xp_p3;		/* private: for use by svc lib */
149177633Sdfr	int		xp_type;	/* transport type */
150177633Sdfr#else
151177633Sdfr	int		xp_fd;
152177633Sdfr	u_short		xp_port;	 /* associated port number */
153177633Sdfr	const struct xp_ops *xp_ops;
154177633Sdfr	int		xp_addrlen;	 /* length of remote address */
155177633Sdfr	struct sockaddr_in xp_raddr;	 /* remote addr. (backward ABI compat) */
156177633Sdfr	/* XXX - fvdl stick this here for ABI backward compat reasons */
157177633Sdfr	const struct xp_ops2 *xp_ops2;
158177633Sdfr	char		*xp_tp;		 /* transport provider device name */
159177633Sdfr	char		*xp_netid;	 /* network token */
160177633Sdfr	struct netbuf	xp_ltaddr;	 /* local transport address */
161177633Sdfr	struct netbuf	xp_rtaddr;	 /* remote transport address */
162177633Sdfr	struct opaque_auth xp_verf;	 /* raw response verifier */
163177633Sdfr	void		*xp_p1;		 /* private: for use by svc ops */
164177633Sdfr	void		*xp_p2;		 /* private: for use by svc ops */
165177633Sdfr	void		*xp_p3;		 /* private: for use by svc lib */
166177633Sdfr	int		xp_type;	 /* transport type */
167177633Sdfr#endif
168177633Sdfr} SVCXPRT;
169177633Sdfr
170177633Sdfr#ifdef _KERNEL
171177633Sdfr
172177633Sdfr/*
173177633Sdfr * The services list
174177633Sdfr * Each entry represents a set of procedures (an rpc program).
175177633Sdfr * The dispatch routine takes request structs and runs the
176177633Sdfr * apropriate procedure.
177177633Sdfr */
178177633Sdfrstruct svc_callout {
179177633Sdfr	TAILQ_ENTRY(svc_callout) sc_link;
180177633Sdfr	rpcprog_t	    sc_prog;
181177633Sdfr	rpcvers_t	    sc_vers;
182177633Sdfr	char		   *sc_netid;
183177633Sdfr	void		    (*sc_dispatch)(struct svc_req *, SVCXPRT *);
184177633Sdfr};
185177633SdfrTAILQ_HEAD(svc_callout_list, svc_callout);
186177633Sdfr
187177633Sdfr/*
188177633Sdfr * In the kernel, we can't use global variables to store lists of
189177633Sdfr * transports etc. since otherwise we could not have two unrelated RPC
190177633Sdfr * services running, each on its own thread. We solve this by
191177633Sdfr * importing a tiny part of a Solaris kernel concept, SVCPOOL.
192177633Sdfr *
193177633Sdfr * A service pool contains a set of transports and service callbacks
194177633Sdfr * for a set of related RPC services. The pool handle should be passed
195177633Sdfr * when creating new transports etc. Future work may include extending
196177633Sdfr * this to support something similar to the Solaris multi-threaded RPC
197177633Sdfr * server.
198177633Sdfr */
199177633SdfrTAILQ_HEAD(svcxprt_list, __rpc_svcxprt);
200177633Sdfrtypedef struct __rpc_svcpool {
201177633Sdfr	struct mtx	sp_lock;	/* protect the transport lists */
202177633Sdfr	struct svcxprt_list sp_xlist;	/* all transports in the pool */
203177633Sdfr	struct svcxprt_list sp_active;	/* transports needing service */
204177633Sdfr	struct svc_callout_list sp_callouts; /* (prog,vers)->dispatch list */
205177633Sdfr	bool_t		sp_exited;	/* true if shutting down */
206177633Sdfr} SVCPOOL;
207177633Sdfr
208177633Sdfr#endif
209177633Sdfr
210177633Sdfr/*
211177633Sdfr * Service request
212177633Sdfr */
213177633Sdfrstruct svc_req {
214177633Sdfr	uint32_t	rq_prog;	/* service program number */
215177633Sdfr	uint32_t	rq_vers;	/* service protocol version */
216177633Sdfr	uint32_t	rq_proc;	/* the desired procedure */
217177633Sdfr	struct opaque_auth rq_cred;	/* raw creds from the wire */
218177633Sdfr	void		*rq_clntcred;	/* read only cooked cred */
219177633Sdfr	SVCXPRT		*rq_xprt;	/* associated transport */
220177633Sdfr};
221177633Sdfr
222177633Sdfr/*
223177633Sdfr *  Approved way of getting address of caller
224177633Sdfr */
225177633Sdfr#define svc_getrpccaller(x) (&(x)->xp_rtaddr)
226177633Sdfr
227177633Sdfr/*
228177633Sdfr * Operations defined on an SVCXPRT handle
229177633Sdfr *
230177633Sdfr * SVCXPRT		*xprt;
231177633Sdfr * struct rpc_msg	*msg;
232177633Sdfr * xdrproc_t		 xargs;
233177633Sdfr * void *		 argsp;
234177633Sdfr */
235177633Sdfr#define SVC_RECV(xprt, msg)				\
236177633Sdfr	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
237177633Sdfr#define svc_recv(xprt, msg)				\
238177633Sdfr	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
239177633Sdfr
240177633Sdfr#define SVC_STAT(xprt)					\
241177633Sdfr	(*(xprt)->xp_ops->xp_stat)(xprt)
242177633Sdfr#define svc_stat(xprt)					\
243177633Sdfr	(*(xprt)->xp_ops->xp_stat)(xprt)
244177633Sdfr
245177633Sdfr#define SVC_GETARGS(xprt, xargs, argsp)			\
246177633Sdfr	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
247177633Sdfr#define svc_getargs(xprt, xargs, argsp)			\
248177633Sdfr	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
249177633Sdfr
250177633Sdfr#define SVC_REPLY(xprt, msg)				\
251177633Sdfr	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
252177633Sdfr#define svc_reply(xprt, msg)				\
253177633Sdfr	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
254177633Sdfr
255177633Sdfr#define SVC_FREEARGS(xprt, xargs, argsp)		\
256177633Sdfr	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
257177633Sdfr#define svc_freeargs(xprt, xargs, argsp)		\
258177633Sdfr	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
259177633Sdfr
260177633Sdfr#define SVC_DESTROY(xprt)				\
261177633Sdfr	(*(xprt)->xp_ops->xp_destroy)(xprt)
262177633Sdfr#define svc_destroy(xprt)				\
263177633Sdfr	(*(xprt)->xp_ops->xp_destroy)(xprt)
264177633Sdfr
265177633Sdfr#ifdef _KERNEL
266177633Sdfr#define SVC_CONTROL(xprt, rq, in)			\
267177633Sdfr	(*(xprt)->xp_ops->xp_control)((xprt), (rq), (in))
268177633Sdfr#else
269177633Sdfr#define SVC_CONTROL(xprt, rq, in)			\
270177633Sdfr	(*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in))
271177633Sdfr#endif
272177633Sdfr
273177633Sdfr/*
274177633Sdfr * Service registration
275177633Sdfr *
276177633Sdfr * svc_reg(xprt, prog, vers, dispatch, nconf)
277177633Sdfr *	const SVCXPRT *xprt;
278177633Sdfr *	const rpcprog_t prog;
279177633Sdfr *	const rpcvers_t vers;
280177633Sdfr *	const void (*dispatch)();
281177633Sdfr *	const struct netconfig *nconf;
282177633Sdfr */
283177633Sdfr
284177633Sdfr__BEGIN_DECLS
285177633Sdfrextern bool_t	svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t,
286177633Sdfr			void (*)(struct svc_req *, SVCXPRT *),
287177633Sdfr			const struct netconfig *);
288177633Sdfr__END_DECLS
289177633Sdfr
290177633Sdfr/*
291177633Sdfr * Service un-registration
292177633Sdfr *
293177633Sdfr * svc_unreg(prog, vers)
294177633Sdfr *	const rpcprog_t prog;
295177633Sdfr *	const rpcvers_t vers;
296177633Sdfr */
297177633Sdfr
298177633Sdfr__BEGIN_DECLS
299177633Sdfr#ifdef _KERNEL
300177633Sdfrextern void	svc_unreg(SVCPOOL *, const rpcprog_t, const rpcvers_t);
301177633Sdfr#else
302177633Sdfrextern void	svc_unreg(const rpcprog_t, const rpcvers_t);
303177633Sdfr#endif
304177633Sdfr__END_DECLS
305177633Sdfr
306177633Sdfr/*
307177633Sdfr * Transport registration.
308177633Sdfr *
309177633Sdfr * xprt_register(xprt)
310177633Sdfr *	SVCXPRT *xprt;
311177633Sdfr */
312177633Sdfr__BEGIN_DECLS
313177633Sdfrextern void	xprt_register(SVCXPRT *);
314177633Sdfr__END_DECLS
315177633Sdfr
316177633Sdfr/*
317177633Sdfr * Transport un-register
318177633Sdfr *
319177633Sdfr * xprt_unregister(xprt)
320177633Sdfr *	SVCXPRT *xprt;
321177633Sdfr */
322177633Sdfr__BEGIN_DECLS
323177633Sdfrextern void	xprt_unregister(SVCXPRT *);
324177633Sdfrextern void	__xprt_unregister_unlocked(SVCXPRT *);
325177633Sdfr__END_DECLS
326177633Sdfr
327177633Sdfr#ifdef _KERNEL
328177633Sdfr
329177633Sdfr/*
330177633Sdfr * Called when a transport has pending requests.
331177633Sdfr */
332177633Sdfr__BEGIN_DECLS
333177633Sdfrextern void	xprt_active(SVCXPRT *);
334177633Sdfrextern void	xprt_inactive(SVCXPRT *);
335177633Sdfr__END_DECLS
336177633Sdfr
337177633Sdfr#endif
338177633Sdfr
339177633Sdfr/*
340177633Sdfr * When the service routine is called, it must first check to see if it
341177633Sdfr * knows about the procedure;  if not, it should call svcerr_noproc
342177633Sdfr * and return.  If so, it should deserialize its arguments via
343177633Sdfr * SVC_GETARGS (defined above).  If the deserialization does not work,
344177633Sdfr * svcerr_decode should be called followed by a return.  Successful
345177633Sdfr * decoding of the arguments should be followed the execution of the
346177633Sdfr * procedure's code and a call to svc_sendreply.
347177633Sdfr *
348177633Sdfr * Also, if the service refuses to execute the procedure due to too-
349177633Sdfr * weak authentication parameters, svcerr_weakauth should be called.
350177633Sdfr * Note: do not confuse access-control failure with weak authentication!
351177633Sdfr *
352177633Sdfr * NB: In pure implementations of rpc, the caller always waits for a reply
353177633Sdfr * msg.  This message is sent when svc_sendreply is called.
354177633Sdfr * Therefore pure service implementations should always call
355177633Sdfr * svc_sendreply even if the function logically returns void;  use
356177633Sdfr * xdr.h - xdr_void for the xdr routine.  HOWEVER, tcp based rpc allows
357177633Sdfr * for the abuse of pure rpc via batched calling or pipelining.  In the
358177633Sdfr * case of a batched call, svc_sendreply should NOT be called since
359177633Sdfr * this would send a return message, which is what batching tries to avoid.
360177633Sdfr * It is the service/protocol writer's responsibility to know which calls are
361177633Sdfr * batched and which are not.  Warning: responding to batch calls may
362177633Sdfr * deadlock the caller and server processes!
363177633Sdfr */
364177633Sdfr
365177633Sdfr__BEGIN_DECLS
366177633Sdfrextern bool_t	svc_sendreply(SVCXPRT *, xdrproc_t, void *);
367177633Sdfrextern void	svcerr_decode(SVCXPRT *);
368177633Sdfrextern void	svcerr_weakauth(SVCXPRT *);
369177633Sdfrextern void	svcerr_noproc(SVCXPRT *);
370177633Sdfrextern void	svcerr_progvers(SVCXPRT *, rpcvers_t, rpcvers_t);
371177633Sdfrextern void	svcerr_auth(SVCXPRT *, enum auth_stat);
372177633Sdfrextern void	svcerr_noprog(SVCXPRT *);
373177633Sdfrextern void	svcerr_systemerr(SVCXPRT *);
374177633Sdfrextern int	rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t,
375177633Sdfr			char *(*)(char *), xdrproc_t, xdrproc_t,
376177633Sdfr			char *);
377177633Sdfr__END_DECLS
378177633Sdfr
379177633Sdfr/*
380177633Sdfr * Lowest level dispatching -OR- who owns this process anyway.
381177633Sdfr * Somebody has to wait for incoming requests and then call the correct
382177633Sdfr * service routine.  The routine svc_run does infinite waiting; i.e.,
383177633Sdfr * svc_run never returns.
384177633Sdfr * Since another (co-existant) package may wish to selectively wait for
385177633Sdfr * incoming calls or other events outside of the rpc architecture, the
386177633Sdfr * routine svc_getreq is provided.  It must be passed readfds, the
387177633Sdfr * "in-place" results of a select system call (see select, section 2).
388177633Sdfr */
389177633Sdfr
390177633Sdfr#ifndef _KERNEL
391177633Sdfr/*
392177633Sdfr * Global keeper of rpc service descriptors in use
393177633Sdfr * dynamic; must be inspected before each call to select
394177633Sdfr */
395177633Sdfrextern int svc_maxfd;
396177633Sdfr#ifdef FD_SETSIZE
397177633Sdfrextern fd_set svc_fdset;
398177633Sdfr#define svc_fds svc_fdset.fds_bits[0]	/* compatibility */
399177633Sdfr#else
400177633Sdfrextern int svc_fds;
401177633Sdfr#endif /* def FD_SETSIZE */
402177633Sdfr#endif
403177633Sdfr
404177633Sdfr/*
405177633Sdfr * a small program implemented by the svc_rpc implementation itself;
406177633Sdfr * also see clnt.h for protocol numbers.
407177633Sdfr */
408177633Sdfr__BEGIN_DECLS
409177633Sdfrextern void rpctest_service(void);
410177633Sdfr__END_DECLS
411177633Sdfr
412177633Sdfr__BEGIN_DECLS
413177633Sdfr#ifndef _KERNEL
414177633Sdfrextern void	svc_getreq(int);
415177633Sdfrextern void	svc_getreqset(fd_set *);
416177633Sdfrextern void	svc_getreq_common(int);
417177633Sdfrstruct pollfd;
418177633Sdfrextern void	svc_getreq_poll(struct pollfd *, int);
419177633Sdfrextern void	svc_run(void);
420177633Sdfrextern void	svc_exit(void);
421177633Sdfr#else
422177633Sdfrextern void	svc_run(SVCPOOL *);
423177633Sdfrextern void	svc_exit(SVCPOOL *);
424177633Sdfr#endif
425177633Sdfr__END_DECLS
426177633Sdfr
427177633Sdfr/*
428177633Sdfr * Socket to use on svcxxx_create call to get default socket
429177633Sdfr */
430177633Sdfr#define	RPC_ANYSOCK	-1
431177633Sdfr#define RPC_ANYFD	RPC_ANYSOCK
432177633Sdfr
433177633Sdfr/*
434177633Sdfr * These are the existing service side transport implementations
435177633Sdfr */
436177633Sdfr
437177633Sdfr__BEGIN_DECLS
438177633Sdfr
439177633Sdfr#ifdef _KERNEL
440177633Sdfr
441177633Sdfr/*
442177633Sdfr * Create a new service pool.
443177633Sdfr */
444177633Sdfrextern SVCPOOL* svcpool_create(void);
445177633Sdfr
446177633Sdfr/*
447177633Sdfr * Destroy a service pool, including all registered transports.
448177633Sdfr */
449177633Sdfrextern void svcpool_destroy(SVCPOOL *pool);
450177633Sdfr
451177633Sdfr/*
452177633Sdfr * Transport independent svc_create routine.
453177633Sdfr */
454177633Sdfrextern int svc_create(SVCPOOL *, void (*)(struct svc_req *, SVCXPRT *),
455177633Sdfr    const rpcprog_t, const rpcvers_t, const char *);
456177633Sdfr/*
457177633Sdfr *      void (*dispatch)();             -- dispatch routine
458177633Sdfr *      const rpcprog_t prognum;        -- program number
459177633Sdfr *      const rpcvers_t versnum;        -- version number
460177633Sdfr *      const char *nettype;            -- network type
461177633Sdfr */
462177633Sdfr
463177633Sdfr
464177633Sdfr/*
465177633Sdfr * Generic server creation routine. It takes a netconfig structure
466177633Sdfr * instead of a nettype.
467177633Sdfr */
468177633Sdfr
469177633Sdfrextern SVCXPRT *svc_tp_create(SVCPOOL *, void (*)(struct svc_req *, SVCXPRT *),
470177633Sdfr    const rpcprog_t, const rpcvers_t, const char *uaddr,
471177633Sdfr    const struct netconfig *);
472177633Sdfr        /*
473177633Sdfr         * void (*dispatch)();            -- dispatch routine
474177633Sdfr         * const rpcprog_t prognum;       -- program number
475177633Sdfr         * const rpcvers_t versnum;       -- version number
476177633Sdfr	 * const char *uaddr;		  -- universal address of service
477177633Sdfr         * const struct netconfig *nconf; -- netconfig structure
478177633Sdfr         */
479177633Sdfr
480177633Sdfrextern SVCXPRT *svc_dg_create(SVCPOOL *, struct socket *,
481177633Sdfr    const size_t, const size_t);
482177633Sdfr        /*
483177633Sdfr         * struct socket *;                             -- open connection
484177633Sdfr         * const size_t sendsize;                        -- max send size
485177633Sdfr         * const size_t recvsize;                        -- max recv size
486177633Sdfr         */
487177633Sdfr
488177633Sdfrextern SVCXPRT *svc_vc_create(SVCPOOL *, struct socket *,
489177633Sdfr    const size_t, const size_t);
490177633Sdfr        /*
491177633Sdfr         * struct socket *;                             -- open connection
492177633Sdfr         * const size_t sendsize;                        -- max send size
493177633Sdfr         * const size_t recvsize;                        -- max recv size
494177633Sdfr         */
495177633Sdfr
496177633Sdfr/*
497177633Sdfr * Generic TLI create routine
498177633Sdfr */
499177633Sdfrextern SVCXPRT *svc_tli_create(SVCPOOL *, struct socket *,
500177633Sdfr    const struct netconfig *, const struct t_bind *, const size_t, const size_t);
501177633Sdfr/*
502177633Sdfr *      struct socket * so;             -- connection end point
503177633Sdfr *      const struct netconfig *nconf;  -- netconfig structure for network
504177633Sdfr *      const struct t_bind *bindaddr;  -- local bind address
505177633Sdfr *      const size_t sendsz;             -- max sendsize
506177633Sdfr *      const size_t recvsz;             -- max recvsize
507177633Sdfr */
508177633Sdfr
509177633Sdfr#else /* !_KERNEL */
510177633Sdfr
511177633Sdfr/*
512177633Sdfr * Transport independent svc_create routine.
513177633Sdfr */
514177633Sdfrextern int svc_create(void (*)(struct svc_req *, SVCXPRT *),
515177633Sdfr			   const rpcprog_t, const rpcvers_t, const char *);
516177633Sdfr/*
517177633Sdfr *      void (*dispatch)();             -- dispatch routine
518177633Sdfr *      const rpcprog_t prognum;        -- program number
519177633Sdfr *      const rpcvers_t versnum;        -- version number
520177633Sdfr *      const char *nettype;            -- network type
521177633Sdfr */
522177633Sdfr
523177633Sdfr
524177633Sdfr/*
525177633Sdfr * Generic server creation routine. It takes a netconfig structure
526177633Sdfr * instead of a nettype.
527177633Sdfr */
528177633Sdfr
529177633Sdfrextern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *),
530177633Sdfr				   const rpcprog_t, const rpcvers_t,
531177633Sdfr				   const struct netconfig *);
532177633Sdfr        /*
533177633Sdfr         * void (*dispatch)();            -- dispatch routine
534177633Sdfr         * const rpcprog_t prognum;       -- program number
535177633Sdfr         * const rpcvers_t versnum;       -- version number
536177633Sdfr         * const struct netconfig *nconf; -- netconfig structure
537177633Sdfr         */
538177633Sdfr
539177633Sdfr/*
540177633Sdfr * Generic TLI create routine
541177633Sdfr */
542177633Sdfrextern SVCXPRT *svc_tli_create(const int, const struct netconfig *,
543177633Sdfr			       const struct t_bind *, const u_int,
544177633Sdfr			       const u_int);
545177633Sdfr/*
546177633Sdfr *      const int fd;                   -- connection end point
547177633Sdfr *      const struct netconfig *nconf;  -- netconfig structure for network
548177633Sdfr *      const struct t_bind *bindaddr;  -- local bind address
549177633Sdfr *      const u_int sendsz;             -- max sendsize
550177633Sdfr *      const u_int recvsz;             -- max recvsize
551177633Sdfr */
552177633Sdfr
553177633Sdfr/*
554177633Sdfr * Connectionless and connectionful create routines
555177633Sdfr */
556177633Sdfr
557177633Sdfrextern SVCXPRT *svc_vc_create(const int, const u_int, const u_int);
558177633Sdfr/*
559177633Sdfr *      const int fd;                           -- open connection end point
560177633Sdfr *      const u_int sendsize;                   -- max send size
561177633Sdfr *      const u_int recvsize;                   -- max recv size
562177633Sdfr */
563177633Sdfr
564177633Sdfr/*
565177633Sdfr * Added for compatibility to old rpc 4.0. Obsoleted by svc_vc_create().
566177633Sdfr */
567177633Sdfrextern SVCXPRT *svcunix_create(int, u_int, u_int, char *);
568177633Sdfr
569177633Sdfrextern SVCXPRT *svc_dg_create(const int, const u_int, const u_int);
570177633Sdfr        /*
571177633Sdfr         * const int fd;                                -- open connection
572177633Sdfr         * const u_int sendsize;                        -- max send size
573177633Sdfr         * const u_int recvsize;                        -- max recv size
574177633Sdfr         */
575177633Sdfr
576177633Sdfr
577177633Sdfr/*
578177633Sdfr * the routine takes any *open* connection
579177633Sdfr * descriptor as its first input and is used for open connections.
580177633Sdfr */
581177633Sdfrextern SVCXPRT *svc_fd_create(const int, const u_int, const u_int);
582177633Sdfr/*
583177633Sdfr *      const int fd;                           -- open connection end point
584177633Sdfr *      const u_int sendsize;                   -- max send size
585177633Sdfr *      const u_int recvsize;                   -- max recv size
586177633Sdfr */
587177633Sdfr
588177633Sdfr/*
589177633Sdfr * Added for compatibility to old rpc 4.0. Obsoleted by svc_fd_create().
590177633Sdfr */
591177633Sdfrextern SVCXPRT *svcunixfd_create(int, u_int, u_int);
592177633Sdfr
593177633Sdfr/*
594177633Sdfr * Memory based rpc (for speed check and testing)
595177633Sdfr */
596177633Sdfrextern SVCXPRT *svc_raw_create(void);
597177633Sdfr
598177633Sdfr/*
599177633Sdfr * svc_dg_enable_cache() enables the cache on dg transports.
600177633Sdfr */
601177633Sdfrint svc_dg_enablecache(SVCXPRT *, const u_int);
602177633Sdfr
603177633Sdfrint __rpc_get_local_uid(SVCXPRT *_transp, uid_t *_uid);
604177633Sdfr
605177633Sdfr#endif	/* !_KERNEL */
606177633Sdfr
607177633Sdfr__END_DECLS
608177633Sdfr
609177633Sdfr#ifndef _KERNEL
610177633Sdfr/* for backward compatibility */
611177633Sdfr#include <rpc/svc_soc.h>
612177633Sdfr#endif
613177633Sdfr
614177633Sdfr#endif /* !_RPC_SVC_H */
615