xref: /freebsd/include/rpc/svc.h (revision 8f55a568f69c5b2fadaa020a452c2043a7dcf65f)
18360efbdSAlfred Perlstein /*	$NetBSD: svc.h,v 1.17 2000/06/02 22:57:56 fvdl Exp $	*/
28360efbdSAlfred Perlstein 
3dba7a33eSGarrett Wollman /*
4dba7a33eSGarrett Wollman  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5dba7a33eSGarrett Wollman  * unrestricted use provided that this legend is included on all tape
6dba7a33eSGarrett Wollman  * media and as a part of the software program in whole or part.  Users
7dba7a33eSGarrett Wollman  * may copy or modify Sun RPC without charge, but are not authorized
8dba7a33eSGarrett Wollman  * to license or distribute it to anyone else except as part of a product or
9dba7a33eSGarrett Wollman  * program developed by the user.
10dba7a33eSGarrett Wollman  *
11dba7a33eSGarrett Wollman  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
1271d9c781SMike Pritchard  * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
13dba7a33eSGarrett Wollman  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14dba7a33eSGarrett Wollman  *
15dba7a33eSGarrett Wollman  * Sun RPC is provided with no support and without any obligation on the
16dba7a33eSGarrett Wollman  * part of Sun Microsystems, Inc. to assist in its use, correction,
17dba7a33eSGarrett Wollman  * modification or enhancement.
18dba7a33eSGarrett Wollman  *
19dba7a33eSGarrett Wollman  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20dba7a33eSGarrett Wollman  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21dba7a33eSGarrett Wollman  * OR ANY PART THEREOF.
22dba7a33eSGarrett Wollman  *
23dba7a33eSGarrett Wollman  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24dba7a33eSGarrett Wollman  * or profits or other special, indirect and consequential damages, even if
25dba7a33eSGarrett Wollman  * Sun has been advised of the possibility of such damages.
26dba7a33eSGarrett Wollman  *
27dba7a33eSGarrett Wollman  * Sun Microsystems, Inc.
28dba7a33eSGarrett Wollman  * 2550 Garcia Avenue
29dba7a33eSGarrett Wollman  * Mountain View, California  94043
3086b9a9ccSGarrett Wollman  *
318360efbdSAlfred Perlstein  *	from: @(#)svc.h 1.35 88/12/17 SMI
328360efbdSAlfred Perlstein  *	from: @(#)svc.h      1.27    94/04/25 SMI
33a4add9a9SPeter Wemm  * $FreeBSD$
34dba7a33eSGarrett Wollman  */
35dba7a33eSGarrett Wollman 
36dba7a33eSGarrett Wollman /*
37dba7a33eSGarrett Wollman  * svc.h, Server-side remote procedure call interface.
38dba7a33eSGarrett Wollman  *
398360efbdSAlfred Perlstein  * Copyright (C) 1986-1993 by Sun Microsystems, Inc.
40dba7a33eSGarrett Wollman  */
41dba7a33eSGarrett Wollman 
4286b9a9ccSGarrett Wollman #ifndef _RPC_SVC_H
4386b9a9ccSGarrett Wollman #define _RPC_SVC_H
4486b9a9ccSGarrett Wollman #include <sys/cdefs.h>
45dba7a33eSGarrett Wollman 
46dba7a33eSGarrett Wollman /*
47dba7a33eSGarrett Wollman  * This interface must manage two items concerning remote procedure calling:
48dba7a33eSGarrett Wollman  *
49dba7a33eSGarrett Wollman  * 1) An arbitrary number of transport connections upon which rpc requests
50dba7a33eSGarrett Wollman  * are received.  The two most notable transports are TCP and UDP;  they are
51dba7a33eSGarrett Wollman  * created and registered by routines in svc_tcp.c and svc_udp.c, respectively;
52dba7a33eSGarrett Wollman  * they in turn call xprt_register and xprt_unregister.
53dba7a33eSGarrett Wollman  *
54dba7a33eSGarrett Wollman  * 2) An arbitrary number of locally registered services.  Services are
55dba7a33eSGarrett Wollman  * described by the following four data: program number, version number,
56dba7a33eSGarrett Wollman  * "service dispatch" function, a transport handle, and a boolean that
57dba7a33eSGarrett Wollman  * indicates whether or not the exported program should be registered with a
58dba7a33eSGarrett Wollman  * local binder service;  if true the program's number and version and the
59dba7a33eSGarrett Wollman  * port number from the transport handle are registered with the binder.
60dba7a33eSGarrett Wollman  * These data are registered with the rpc svc system via svc_register.
61dba7a33eSGarrett Wollman  *
62dba7a33eSGarrett Wollman  * A service's dispatch function is called whenever an rpc request comes in
63dba7a33eSGarrett Wollman  * on a transport.  The request's program and version numbers must match
64dba7a33eSGarrett Wollman  * those of the registered service.  The dispatch function is passed two
65dba7a33eSGarrett Wollman  * parameters, struct svc_req * and SVCXPRT *, defined below.
66dba7a33eSGarrett Wollman  */
67dba7a33eSGarrett Wollman 
688360efbdSAlfred Perlstein /*
698360efbdSAlfred Perlstein  *      Service control requests
708360efbdSAlfred Perlstein  */
718360efbdSAlfred Perlstein #define SVCGET_VERSQUIET	1
728360efbdSAlfred Perlstein #define SVCSET_VERSQUIET	2
7308497c02SMartin Blapp #define SVCGET_CONNMAXREC	3
7408497c02SMartin Blapp #define SVCSET_CONNMAXREC	4
758360efbdSAlfred Perlstein 
7608497c02SMartin Blapp /*
7708497c02SMartin Blapp  * Operations for rpc_control().
7808497c02SMartin Blapp  */
7908497c02SMartin Blapp #define RPC_SVC_CONNMAXREC_SET  0	/* set max rec size, enable nonblock */
8008497c02SMartin Blapp #define RPC_SVC_CONNMAXREC_GET  1
818360efbdSAlfred Perlstein 
82dba7a33eSGarrett Wollman enum xprt_stat {
83dba7a33eSGarrett Wollman 	XPRT_DIED,
84dba7a33eSGarrett Wollman 	XPRT_MOREREQS,
85dba7a33eSGarrett Wollman 	XPRT_IDLE
86dba7a33eSGarrett Wollman };
87dba7a33eSGarrett Wollman 
88dba7a33eSGarrett Wollman /*
89dba7a33eSGarrett Wollman  * Server side transport handle
90dba7a33eSGarrett Wollman  */
9170de0abfSPeter Wemm typedef struct __rpc_svcxprt {
928360efbdSAlfred Perlstein 	int		xp_fd;
93dba7a33eSGarrett Wollman 	u_short		xp_port;	 /* associated port number */
948360efbdSAlfred Perlstein 	const struct xp_ops {
9570de0abfSPeter Wemm 	    /* receive incoming requests */
96bb28f3c2SWarner Losh 	    bool_t	(*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *);
9770de0abfSPeter Wemm 	    /* get transport status */
98bb28f3c2SWarner Losh 	    enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *);
9970de0abfSPeter Wemm 	    /* get arguments */
100bb28f3c2SWarner Losh 	    bool_t	(*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t,
101f249dbccSDag-Erling Smørgrav 				void *);
10270de0abfSPeter Wemm 	    /* send reply */
103bb28f3c2SWarner Losh 	    bool_t	(*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *);
10470de0abfSPeter Wemm 	    /* free mem allocated for args */
105bb28f3c2SWarner Losh 	    bool_t	(*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t,
106f249dbccSDag-Erling Smørgrav 				void *);
10770de0abfSPeter Wemm 	    /* destroy this struct */
108bb28f3c2SWarner Losh 	    void	(*xp_destroy)(struct __rpc_svcxprt *);
109dba7a33eSGarrett Wollman 	} *xp_ops;
110dba7a33eSGarrett Wollman 	int		xp_addrlen;	 /* length of remote address */
1118360efbdSAlfred Perlstein 	struct sockaddr_in xp_raddr;	 /* remote addr. (backward ABI compat) */
1128360efbdSAlfred Perlstein 	/* XXX - fvdl stick this here for ABI backward compat reasons */
1138360efbdSAlfred Perlstein 	const struct xp_ops2 {
1148360efbdSAlfred Perlstein 		/* catch-all function */
115bb28f3c2SWarner Losh 		bool_t  (*xp_control)(struct __rpc_svcxprt *, const u_int,
116bb28f3c2SWarner Losh 				void *);
1178360efbdSAlfred Perlstein 	} *xp_ops2;
1188360efbdSAlfred Perlstein 	char		*xp_tp;		 /* transport provider device name */
1198360efbdSAlfred Perlstein 	char		*xp_netid;	 /* network token */
1208360efbdSAlfred Perlstein 	struct netbuf	xp_ltaddr;	 /* local transport address */
1218360efbdSAlfred Perlstein 	struct netbuf	xp_rtaddr;	 /* remote transport address */
122dba7a33eSGarrett Wollman 	struct opaque_auth xp_verf;	 /* raw response verifier */
1238360efbdSAlfred Perlstein 	void		*xp_p1;		 /* private: for use by svc ops */
1248360efbdSAlfred Perlstein 	void		*xp_p2;		 /* private: for use by svc ops */
1258360efbdSAlfred Perlstein 	void		*xp_p3;		 /* private: for use by svc lib */
1268360efbdSAlfred Perlstein 	int		xp_type;	 /* transport type */
127dba7a33eSGarrett Wollman } SVCXPRT;
128dba7a33eSGarrett Wollman 
129dba7a33eSGarrett Wollman /*
1308f55a568SDoug Rabson  * Interface to server-side authentication flavors.
1318f55a568SDoug Rabson  */
1328f55a568SDoug Rabson typedef struct __rpc_svcauth {
1338f55a568SDoug Rabson 	struct svc_auth_ops {
1348f55a568SDoug Rabson 		int   (*svc_ah_wrap)(struct __rpc_svcauth *, XDR *,
1358f55a568SDoug Rabson 		    xdrproc_t, caddr_t);
1368f55a568SDoug Rabson 		int   (*svc_ah_unwrap)(struct __rpc_svcauth *, XDR *,
1378f55a568SDoug Rabson 		    xdrproc_t, caddr_t);
1388f55a568SDoug Rabson 	} *svc_ah_ops;
1398f55a568SDoug Rabson 	void *svc_ah_private;
1408f55a568SDoug Rabson } SVCAUTH;
1418f55a568SDoug Rabson 
1428f55a568SDoug Rabson /*
1438f55a568SDoug Rabson  * Server transport extensions (accessed via xp_p3).
1448f55a568SDoug Rabson  */
1458f55a568SDoug Rabson typedef struct __rpc_svcxprt_ext {
1468f55a568SDoug Rabson 	int		xp_flags;	/* versquiet */
1478f55a568SDoug Rabson 	SVCAUTH		xp_auth;	/* interface to auth methods */
1488f55a568SDoug Rabson } SVCXPRT_EXT;
1498f55a568SDoug Rabson 
1508f55a568SDoug Rabson /*
1518360efbdSAlfred Perlstein  * Service request
1528360efbdSAlfred Perlstein  */
1538360efbdSAlfred Perlstein struct svc_req {
1548360efbdSAlfred Perlstein 	u_int32_t	rq_prog;	/* service program number */
1558360efbdSAlfred Perlstein 	u_int32_t	rq_vers;	/* service protocol version */
1568360efbdSAlfred Perlstein 	u_int32_t	rq_proc;	/* the desired procedure */
1578360efbdSAlfred Perlstein 	struct opaque_auth rq_cred;	/* raw creds from the wire */
1588360efbdSAlfred Perlstein 	void		*rq_clntcred;	/* read only cooked cred */
1598360efbdSAlfred Perlstein 	SVCXPRT		*rq_xprt;	/* associated transport */
1608360efbdSAlfred Perlstein };
1618360efbdSAlfred Perlstein 
1628360efbdSAlfred Perlstein /*
163dba7a33eSGarrett Wollman  *  Approved way of getting address of caller
164dba7a33eSGarrett Wollman  */
1658360efbdSAlfred Perlstein #define svc_getrpccaller(x) (&(x)->xp_rtaddr)
1668360efbdSAlfred Perlstein 
1678360efbdSAlfred Perlstein /*
168dba7a33eSGarrett Wollman  * Operations defined on an SVCXPRT handle
169dba7a33eSGarrett Wollman  *
170dba7a33eSGarrett Wollman  * SVCXPRT		*xprt;
171dba7a33eSGarrett Wollman  * struct rpc_msg	*msg;
172dba7a33eSGarrett Wollman  * xdrproc_t		 xargs;
173f249dbccSDag-Erling Smørgrav  * void *		 argsp;
174dba7a33eSGarrett Wollman  */
175dba7a33eSGarrett Wollman #define SVC_RECV(xprt, msg)				\
176dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
177dba7a33eSGarrett Wollman #define svc_recv(xprt, msg)				\
178dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
179dba7a33eSGarrett Wollman 
180dba7a33eSGarrett Wollman #define SVC_STAT(xprt)					\
181dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_stat)(xprt)
182dba7a33eSGarrett Wollman #define svc_stat(xprt)					\
183dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_stat)(xprt)
184dba7a33eSGarrett Wollman 
185dba7a33eSGarrett Wollman #define SVC_GETARGS(xprt, xargs, argsp)			\
186dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
187dba7a33eSGarrett Wollman #define svc_getargs(xprt, xargs, argsp)			\
188dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
189dba7a33eSGarrett Wollman 
190dba7a33eSGarrett Wollman #define SVC_REPLY(xprt, msg)				\
191dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
192dba7a33eSGarrett Wollman #define svc_reply(xprt, msg)				\
193dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
194dba7a33eSGarrett Wollman 
195dba7a33eSGarrett Wollman #define SVC_FREEARGS(xprt, xargs, argsp)		\
196dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
197dba7a33eSGarrett Wollman #define svc_freeargs(xprt, xargs, argsp)		\
198dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
199dba7a33eSGarrett Wollman 
200dba7a33eSGarrett Wollman #define SVC_DESTROY(xprt)				\
201dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_destroy)(xprt)
202dba7a33eSGarrett Wollman #define svc_destroy(xprt)				\
203dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_destroy)(xprt)
204dba7a33eSGarrett Wollman 
2058360efbdSAlfred Perlstein #define SVC_CONTROL(xprt, rq, in)			\
2068360efbdSAlfred Perlstein 	(*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in))
207dba7a33eSGarrett Wollman 
2088f55a568SDoug Rabson #define SVC_EXT(xprt)					\
2098f55a568SDoug Rabson 	((SVCXPRT_EXT *) xprt->xp_p3)
2108f55a568SDoug Rabson 
2118f55a568SDoug Rabson #define SVC_AUTH(xprt)					\
2128f55a568SDoug Rabson 	(SVC_EXT(xprt)->xp_auth)
2138f55a568SDoug Rabson 
2148f55a568SDoug Rabson /*
2158f55a568SDoug Rabson  * Operations defined on an SVCAUTH handle
2168f55a568SDoug Rabson  */
2178f55a568SDoug Rabson #define SVCAUTH_WRAP(auth, xdrs, xfunc, xwhere)		\
2188f55a568SDoug Rabson 	((auth)->svc_ah_ops->svc_ah_wrap(auth, xdrs, xfunc, xwhere))
2198f55a568SDoug Rabson #define SVCAUTH_UNWRAP(auth, xdrs, xfunc, xwhere)	\
2208f55a568SDoug Rabson 	((auth)->svc_ah_ops->svc_ah_unwrap(auth, xdrs, xfunc, xwhere))
2218f55a568SDoug Rabson 
222dba7a33eSGarrett Wollman /*
223dba7a33eSGarrett Wollman  * Service registration
224dba7a33eSGarrett Wollman  *
2258360efbdSAlfred Perlstein  * svc_reg(xprt, prog, vers, dispatch, nconf)
2268360efbdSAlfred Perlstein  *	const SVCXPRT *xprt;
2278360efbdSAlfred Perlstein  *	const rpcprog_t prog;
2288360efbdSAlfred Perlstein  *	const rpcvers_t vers;
2298360efbdSAlfred Perlstein  *	const void (*dispatch)();
2308360efbdSAlfred Perlstein  *	const struct netconfig *nconf;
231dba7a33eSGarrett Wollman  */
2328360efbdSAlfred Perlstein 
23386b9a9ccSGarrett Wollman __BEGIN_DECLS
234bb28f3c2SWarner Losh extern bool_t	svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t,
235bb28f3c2SWarner Losh 			void (*)(struct svc_req *, SVCXPRT *),
236bb28f3c2SWarner Losh 			const struct netconfig *);
23786b9a9ccSGarrett Wollman __END_DECLS
238dba7a33eSGarrett Wollman 
239dba7a33eSGarrett Wollman /*
240dba7a33eSGarrett Wollman  * Service un-registration
241dba7a33eSGarrett Wollman  *
2428360efbdSAlfred Perlstein  * svc_unreg(prog, vers)
2438360efbdSAlfred Perlstein  *	const rpcprog_t prog;
2448360efbdSAlfred Perlstein  *	const rpcvers_t vers;
245dba7a33eSGarrett Wollman  */
2468360efbdSAlfred Perlstein 
24786b9a9ccSGarrett Wollman __BEGIN_DECLS
248bb28f3c2SWarner Losh extern void	svc_unreg(const rpcprog_t, const rpcvers_t);
24986b9a9ccSGarrett Wollman __END_DECLS
250dba7a33eSGarrett Wollman 
251dba7a33eSGarrett Wollman /*
252dba7a33eSGarrett Wollman  * Transport registration.
253dba7a33eSGarrett Wollman  *
254dba7a33eSGarrett Wollman  * xprt_register(xprt)
255dba7a33eSGarrett Wollman  *	SVCXPRT *xprt;
256dba7a33eSGarrett Wollman  */
25786b9a9ccSGarrett Wollman __BEGIN_DECLS
258bb28f3c2SWarner Losh extern void	xprt_register(SVCXPRT *);
25986b9a9ccSGarrett Wollman __END_DECLS
260dba7a33eSGarrett Wollman 
261dba7a33eSGarrett Wollman /*
262dba7a33eSGarrett Wollman  * Transport un-register
263dba7a33eSGarrett Wollman  *
264dba7a33eSGarrett Wollman  * xprt_unregister(xprt)
265dba7a33eSGarrett Wollman  *	SVCXPRT *xprt;
266dba7a33eSGarrett Wollman  */
26786b9a9ccSGarrett Wollman __BEGIN_DECLS
268bb28f3c2SWarner Losh extern void	xprt_unregister(SVCXPRT *);
26986b9a9ccSGarrett Wollman __END_DECLS
270dba7a33eSGarrett Wollman 
271dba7a33eSGarrett Wollman 
272dba7a33eSGarrett Wollman /*
273dba7a33eSGarrett Wollman  * When the service routine is called, it must first check to see if it
274dba7a33eSGarrett Wollman  * knows about the procedure;  if not, it should call svcerr_noproc
275dba7a33eSGarrett Wollman  * and return.  If so, it should deserialize its arguments via
276dba7a33eSGarrett Wollman  * SVC_GETARGS (defined above).  If the deserialization does not work,
277dba7a33eSGarrett Wollman  * svcerr_decode should be called followed by a return.  Successful
278dba7a33eSGarrett Wollman  * decoding of the arguments should be followed the execution of the
279dba7a33eSGarrett Wollman  * procedure's code and a call to svc_sendreply.
280dba7a33eSGarrett Wollman  *
281dba7a33eSGarrett Wollman  * Also, if the service refuses to execute the procedure due to too-
282dba7a33eSGarrett Wollman  * weak authentication parameters, svcerr_weakauth should be called.
283dba7a33eSGarrett Wollman  * Note: do not confuse access-control failure with weak authentication!
284dba7a33eSGarrett Wollman  *
285dba7a33eSGarrett Wollman  * NB: In pure implementations of rpc, the caller always waits for a reply
286dba7a33eSGarrett Wollman  * msg.  This message is sent when svc_sendreply is called.
287dba7a33eSGarrett Wollman  * Therefore pure service implementations should always call
288dba7a33eSGarrett Wollman  * svc_sendreply even if the function logically returns void;  use
289dba7a33eSGarrett Wollman  * xdr.h - xdr_void for the xdr routine.  HOWEVER, tcp based rpc allows
290dba7a33eSGarrett Wollman  * for the abuse of pure rpc via batched calling or pipelining.  In the
291dba7a33eSGarrett Wollman  * case of a batched call, svc_sendreply should NOT be called since
292dba7a33eSGarrett Wollman  * this would send a return message, which is what batching tries to avoid.
293dba7a33eSGarrett Wollman  * It is the service/protocol writer's responsibility to know which calls are
294dba7a33eSGarrett Wollman  * batched and which are not.  Warning: responding to batch calls may
295dba7a33eSGarrett Wollman  * deadlock the caller and server processes!
296dba7a33eSGarrett Wollman  */
297dba7a33eSGarrett Wollman 
29886b9a9ccSGarrett Wollman __BEGIN_DECLS
299f249dbccSDag-Erling Smørgrav extern bool_t	svc_sendreply(SVCXPRT *, xdrproc_t, void *);
300bb28f3c2SWarner Losh extern void	svcerr_decode(SVCXPRT *);
301bb28f3c2SWarner Losh extern void	svcerr_weakauth(SVCXPRT *);
302bb28f3c2SWarner Losh extern void	svcerr_noproc(SVCXPRT *);
303bb28f3c2SWarner Losh extern void	svcerr_progvers(SVCXPRT *, rpcvers_t, rpcvers_t);
304bb28f3c2SWarner Losh extern void	svcerr_auth(SVCXPRT *, enum auth_stat);
305bb28f3c2SWarner Losh extern void	svcerr_noprog(SVCXPRT *);
306bb28f3c2SWarner Losh extern void	svcerr_systemerr(SVCXPRT *);
307bb28f3c2SWarner Losh extern int	rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t,
308bb28f3c2SWarner Losh 			char *(*)(char *), xdrproc_t, xdrproc_t,
309bb28f3c2SWarner Losh 			char *);
31086b9a9ccSGarrett Wollman __END_DECLS
311dba7a33eSGarrett Wollman 
312dba7a33eSGarrett Wollman /*
313dba7a33eSGarrett Wollman  * Lowest level dispatching -OR- who owns this process anyway.
314dba7a33eSGarrett Wollman  * Somebody has to wait for incoming requests and then call the correct
315dba7a33eSGarrett Wollman  * service routine.  The routine svc_run does infinite waiting; i.e.,
316dba7a33eSGarrett Wollman  * svc_run never returns.
317dba7a33eSGarrett Wollman  * Since another (co-existant) package may wish to selectively wait for
318dba7a33eSGarrett Wollman  * incoming calls or other events outside of the rpc architecture, the
319dba7a33eSGarrett Wollman  * routine svc_getreq is provided.  It must be passed readfds, the
320dba7a33eSGarrett Wollman  * "in-place" results of a select system call (see select, section 2).
321dba7a33eSGarrett Wollman  */
322dba7a33eSGarrett Wollman 
323dba7a33eSGarrett Wollman /*
324dba7a33eSGarrett Wollman  * Global keeper of rpc service descriptors in use
325dba7a33eSGarrett Wollman  * dynamic; must be inspected before each call to select
326dba7a33eSGarrett Wollman  */
32770de0abfSPeter Wemm extern int svc_maxfd;
3288360efbdSAlfred Perlstein #ifdef FD_SETSIZE
329dba7a33eSGarrett Wollman extern fd_set svc_fdset;
330dba7a33eSGarrett Wollman #define svc_fds svc_fdset.fds_bits[0]	/* compatibility */
3318360efbdSAlfred Perlstein #else
3328360efbdSAlfred Perlstein extern int svc_fds;
3338360efbdSAlfred Perlstein #endif /* def FD_SETSIZE */
334dba7a33eSGarrett Wollman 
335dba7a33eSGarrett Wollman /*
3368f55a568SDoug Rabson  * A set of null auth methods used by any authentication protocols
3378f55a568SDoug Rabson  * that don't need to inspect or modify the message body.
3388f55a568SDoug Rabson  */
3398f55a568SDoug Rabson extern SVCAUTH _svc_auth_null;
3408f55a568SDoug Rabson 
3418f55a568SDoug Rabson /*
342dba7a33eSGarrett Wollman  * a small program implemented by the svc_rpc implementation itself;
343dba7a33eSGarrett Wollman  * also see clnt.h for protocol numbers.
344dba7a33eSGarrett Wollman  */
3458360efbdSAlfred Perlstein __BEGIN_DECLS
346bb28f3c2SWarner Losh extern void rpctest_service(void);
3478360efbdSAlfred Perlstein __END_DECLS
348dba7a33eSGarrett Wollman 
34986b9a9ccSGarrett Wollman __BEGIN_DECLS
3508f55a568SDoug Rabson extern SVCXPRT *svc_xprt_alloc(void);
3518f55a568SDoug Rabson extern void	svc_xprt_free(SVCXPRT *);
352bb28f3c2SWarner Losh extern void	svc_getreq(int);
353bb28f3c2SWarner Losh extern void	svc_getreqset(fd_set *);
354bb28f3c2SWarner Losh extern void	svc_getreq_common(int);
3558360efbdSAlfred Perlstein struct pollfd;
356bb28f3c2SWarner Losh extern void	svc_getreq_poll(struct pollfd *, int);
3578360efbdSAlfred Perlstein 
358bb28f3c2SWarner Losh extern void	svc_run(void);
359bb28f3c2SWarner Losh extern void	svc_exit(void);
36086b9a9ccSGarrett Wollman __END_DECLS
361dba7a33eSGarrett Wollman 
362dba7a33eSGarrett Wollman /*
363dba7a33eSGarrett Wollman  * Socket to use on svcxxx_create call to get default socket
364dba7a33eSGarrett Wollman  */
365dba7a33eSGarrett Wollman #define	RPC_ANYSOCK	-1
3668360efbdSAlfred Perlstein #define RPC_ANYFD	RPC_ANYSOCK
367dba7a33eSGarrett Wollman 
368dba7a33eSGarrett Wollman /*
369dba7a33eSGarrett Wollman  * These are the existing service side transport implementations
370dba7a33eSGarrett Wollman  */
371dba7a33eSGarrett Wollman 
37286b9a9ccSGarrett Wollman __BEGIN_DECLS
3738360efbdSAlfred Perlstein /*
3748360efbdSAlfred Perlstein  * Transport independent svc_create routine.
3758360efbdSAlfred Perlstein  */
376bb28f3c2SWarner Losh extern int svc_create(void (*)(struct svc_req *, SVCXPRT *),
377bb28f3c2SWarner Losh 			   const rpcprog_t, const rpcvers_t, const char *);
3788360efbdSAlfred Perlstein /*
3798360efbdSAlfred Perlstein  *      void (*dispatch)();             -- dispatch routine
3808360efbdSAlfred Perlstein  *      const rpcprog_t prognum;        -- program number
3818360efbdSAlfred Perlstein  *      const rpcvers_t versnum;        -- version number
3828360efbdSAlfred Perlstein  *      const char *nettype;            -- network type
3838360efbdSAlfred Perlstein  */
38486b9a9ccSGarrett Wollman 
385dba7a33eSGarrett Wollman 
386dba7a33eSGarrett Wollman /*
3878360efbdSAlfred Perlstein  * Generic server creation routine. It takes a netconfig structure
3888360efbdSAlfred Perlstein  * instead of a nettype.
389dba7a33eSGarrett Wollman  */
3908360efbdSAlfred Perlstein 
391bb28f3c2SWarner Losh extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *),
3928360efbdSAlfred Perlstein 				   const rpcprog_t, const rpcvers_t,
393bb28f3c2SWarner Losh 				   const struct netconfig *);
3948360efbdSAlfred Perlstein         /*
3958360efbdSAlfred Perlstein          * void (*dispatch)();            -- dispatch routine
3968360efbdSAlfred Perlstein          * const rpcprog_t prognum;       -- program number
3978360efbdSAlfred Perlstein          * const rpcvers_t versnum;       -- version number
3988360efbdSAlfred Perlstein          * const struct netconfig *nconf; -- netconfig structure
3998360efbdSAlfred Perlstein          */
40086b9a9ccSGarrett Wollman 
401dba7a33eSGarrett Wollman 
402dba7a33eSGarrett Wollman /*
4038360efbdSAlfred Perlstein  * Generic TLI create routine
404dba7a33eSGarrett Wollman  */
405bb28f3c2SWarner Losh extern SVCXPRT *svc_tli_create(const int, const struct netconfig *,
4068360efbdSAlfred Perlstein 			       const struct t_bind *, const u_int,
407bb28f3c2SWarner Losh 			       const u_int);
4088360efbdSAlfred Perlstein /*
4098360efbdSAlfred Perlstein  *      const int fd;                   -- connection end point
4108360efbdSAlfred Perlstein  *      const struct netconfig *nconf;  -- netconfig structure for network
4118360efbdSAlfred Perlstein  *      const struct t_bind *bindaddr;  -- local bind address
4128360efbdSAlfred Perlstein  *      const u_int sendsz;             -- max sendsize
4138360efbdSAlfred Perlstein  *      const u_int recvsz;             -- max recvsize
4148360efbdSAlfred Perlstein  */
415dba7a33eSGarrett Wollman 
41670de0abfSPeter Wemm /*
4178360efbdSAlfred Perlstein  * Connectionless and connectionful create routines
41870de0abfSPeter Wemm  */
4198360efbdSAlfred Perlstein 
420bb28f3c2SWarner Losh extern SVCXPRT *svc_vc_create(const int, const u_int, const u_int);
4218360efbdSAlfred Perlstein /*
4228360efbdSAlfred Perlstein  *      const int fd;                           -- open connection end point
4238360efbdSAlfred Perlstein  *      const u_int sendsize;                   -- max send size
4248360efbdSAlfred Perlstein  *      const u_int recvsize;                   -- max recv size
4258360efbdSAlfred Perlstein  */
4268360efbdSAlfred Perlstein 
427e6f9ad07SBill Paul /*
428e6f9ad07SBill Paul  * Added for compatibility to old rpc 4.0. Obsoleted by svc_vc_create().
429e6f9ad07SBill Paul  */
430bb28f3c2SWarner Losh extern SVCXPRT *svcunix_create(int, u_int, u_int, char *);
431e6f9ad07SBill Paul 
432bb28f3c2SWarner Losh extern SVCXPRT *svc_dg_create(const int, const u_int, const u_int);
4338360efbdSAlfred Perlstein         /*
4348360efbdSAlfred Perlstein          * const int fd;                                -- open connection
4358360efbdSAlfred Perlstein          * const u_int sendsize;                        -- max send size
4368360efbdSAlfred Perlstein          * const u_int recvsize;                        -- max recv size
4378360efbdSAlfred Perlstein          */
4388360efbdSAlfred Perlstein 
4398360efbdSAlfred Perlstein 
4408360efbdSAlfred Perlstein /*
4418360efbdSAlfred Perlstein  * the routine takes any *open* connection
4428360efbdSAlfred Perlstein  * descriptor as its first input and is used for open connections.
4438360efbdSAlfred Perlstein  */
444bb28f3c2SWarner Losh extern SVCXPRT *svc_fd_create(const int, const u_int, const u_int);
4458360efbdSAlfred Perlstein /*
4468360efbdSAlfred Perlstein  *      const int fd;                           -- open connection end point
4478360efbdSAlfred Perlstein  *      const u_int sendsize;                   -- max send size
4488360efbdSAlfred Perlstein  *      const u_int recvsize;                   -- max recv size
4498360efbdSAlfred Perlstein  */
4508360efbdSAlfred Perlstein 
4518360efbdSAlfred Perlstein /*
452e6f9ad07SBill Paul  * Added for compatibility to old rpc 4.0. Obsoleted by svc_fd_create().
453e6f9ad07SBill Paul  */
454bb28f3c2SWarner Losh extern SVCXPRT *svcunixfd_create(int, u_int, u_int);
455e6f9ad07SBill Paul 
456e6f9ad07SBill Paul /*
4578360efbdSAlfred Perlstein  * Memory based rpc (for speed check and testing)
4588360efbdSAlfred Perlstein  */
459bb28f3c2SWarner Losh extern SVCXPRT *svc_raw_create(void);
4608360efbdSAlfred Perlstein 
4618360efbdSAlfred Perlstein /*
4628360efbdSAlfred Perlstein  * svc_dg_enable_cache() enables the cache on dg transports.
4638360efbdSAlfred Perlstein  */
464bb28f3c2SWarner Losh int svc_dg_enablecache(SVCXPRT *, const u_int);
4658360efbdSAlfred Perlstein 
466576da326SDag-Erling Smørgrav int __rpc_get_local_uid(SVCXPRT *_transp, uid_t *_uid);
467922ed949SAlfred Perlstein 
46870de0abfSPeter Wemm __END_DECLS
46970de0abfSPeter Wemm 
4708360efbdSAlfred Perlstein 
4718360efbdSAlfred Perlstein /* for backward compatibility */
4728360efbdSAlfred Perlstein #include <rpc/svc_soc.h>
4738360efbdSAlfred Perlstein 
47486b9a9ccSGarrett Wollman #endif /* !_RPC_SVC_H */
475