xref: /freebsd/include/rpc/svc.h (revision 08497c026ce2b54dadb727e04f08b26f2ecb7663)
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 /*
1308360efbdSAlfred Perlstein  * Service request
1318360efbdSAlfred Perlstein  */
1328360efbdSAlfred Perlstein struct svc_req {
1338360efbdSAlfred Perlstein 	u_int32_t	rq_prog;	/* service program number */
1348360efbdSAlfred Perlstein 	u_int32_t	rq_vers;	/* service protocol version */
1358360efbdSAlfred Perlstein 	u_int32_t	rq_proc;	/* the desired procedure */
1368360efbdSAlfred Perlstein 	struct opaque_auth rq_cred;	/* raw creds from the wire */
1378360efbdSAlfred Perlstein 	void		*rq_clntcred;	/* read only cooked cred */
1388360efbdSAlfred Perlstein 	SVCXPRT		*rq_xprt;	/* associated transport */
1398360efbdSAlfred Perlstein };
1408360efbdSAlfred Perlstein 
1418360efbdSAlfred Perlstein /*
142dba7a33eSGarrett Wollman  *  Approved way of getting address of caller
143dba7a33eSGarrett Wollman  */
1448360efbdSAlfred Perlstein #define svc_getrpccaller(x) (&(x)->xp_rtaddr)
1458360efbdSAlfred Perlstein 
1468360efbdSAlfred Perlstein /*
1478360efbdSAlfred Perlstein  * FreeBSD-only definition to get the creds of the caller (AF_LOCAL).
1488360efbdSAlfred Perlstein  */
1498360efbdSAlfred Perlstein #define __svc_getcallercreds(x) ((struct cmsgcred *)(x)->xp_p2)
150dba7a33eSGarrett Wollman 
151dba7a33eSGarrett Wollman /*
152dba7a33eSGarrett Wollman  * Operations defined on an SVCXPRT handle
153dba7a33eSGarrett Wollman  *
154dba7a33eSGarrett Wollman  * SVCXPRT		*xprt;
155dba7a33eSGarrett Wollman  * struct rpc_msg	*msg;
156dba7a33eSGarrett Wollman  * xdrproc_t		 xargs;
157f249dbccSDag-Erling Smørgrav  * void *		 argsp;
158dba7a33eSGarrett Wollman  */
159dba7a33eSGarrett Wollman #define SVC_RECV(xprt, msg)				\
160dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
161dba7a33eSGarrett Wollman #define svc_recv(xprt, msg)				\
162dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
163dba7a33eSGarrett Wollman 
164dba7a33eSGarrett Wollman #define SVC_STAT(xprt)					\
165dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_stat)(xprt)
166dba7a33eSGarrett Wollman #define svc_stat(xprt)					\
167dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_stat)(xprt)
168dba7a33eSGarrett Wollman 
169dba7a33eSGarrett Wollman #define SVC_GETARGS(xprt, xargs, argsp)			\
170dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
171dba7a33eSGarrett Wollman #define svc_getargs(xprt, xargs, argsp)			\
172dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
173dba7a33eSGarrett Wollman 
174dba7a33eSGarrett Wollman #define SVC_REPLY(xprt, msg)				\
175dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
176dba7a33eSGarrett Wollman #define svc_reply(xprt, msg)				\
177dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
178dba7a33eSGarrett Wollman 
179dba7a33eSGarrett Wollman #define SVC_FREEARGS(xprt, xargs, argsp)		\
180dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
181dba7a33eSGarrett Wollman #define svc_freeargs(xprt, xargs, argsp)		\
182dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
183dba7a33eSGarrett Wollman 
184dba7a33eSGarrett Wollman #define SVC_DESTROY(xprt)				\
185dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_destroy)(xprt)
186dba7a33eSGarrett Wollman #define svc_destroy(xprt)				\
187dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_destroy)(xprt)
188dba7a33eSGarrett Wollman 
1898360efbdSAlfred Perlstein #define SVC_CONTROL(xprt, rq, in)			\
1908360efbdSAlfred Perlstein 	(*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in))
191dba7a33eSGarrett Wollman 
192dba7a33eSGarrett Wollman /*
193dba7a33eSGarrett Wollman  * Service registration
194dba7a33eSGarrett Wollman  *
1958360efbdSAlfred Perlstein  * svc_reg(xprt, prog, vers, dispatch, nconf)
1968360efbdSAlfred Perlstein  *	const SVCXPRT *xprt;
1978360efbdSAlfred Perlstein  *	const rpcprog_t prog;
1988360efbdSAlfred Perlstein  *	const rpcvers_t vers;
1998360efbdSAlfred Perlstein  *	const void (*dispatch)();
2008360efbdSAlfred Perlstein  *	const struct netconfig *nconf;
201dba7a33eSGarrett Wollman  */
2028360efbdSAlfred Perlstein 
20386b9a9ccSGarrett Wollman __BEGIN_DECLS
204bb28f3c2SWarner Losh extern bool_t	svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t,
205bb28f3c2SWarner Losh 			void (*)(struct svc_req *, SVCXPRT *),
206bb28f3c2SWarner Losh 			const struct netconfig *);
20786b9a9ccSGarrett Wollman __END_DECLS
208dba7a33eSGarrett Wollman 
209dba7a33eSGarrett Wollman /*
210dba7a33eSGarrett Wollman  * Service un-registration
211dba7a33eSGarrett Wollman  *
2128360efbdSAlfred Perlstein  * svc_unreg(prog, vers)
2138360efbdSAlfred Perlstein  *	const rpcprog_t prog;
2148360efbdSAlfred Perlstein  *	const rpcvers_t vers;
215dba7a33eSGarrett Wollman  */
2168360efbdSAlfred Perlstein 
21786b9a9ccSGarrett Wollman __BEGIN_DECLS
218bb28f3c2SWarner Losh extern void	svc_unreg(const rpcprog_t, const rpcvers_t);
21986b9a9ccSGarrett Wollman __END_DECLS
220dba7a33eSGarrett Wollman 
221dba7a33eSGarrett Wollman /*
222dba7a33eSGarrett Wollman  * Transport registration.
223dba7a33eSGarrett Wollman  *
224dba7a33eSGarrett Wollman  * xprt_register(xprt)
225dba7a33eSGarrett Wollman  *	SVCXPRT *xprt;
226dba7a33eSGarrett Wollman  */
22786b9a9ccSGarrett Wollman __BEGIN_DECLS
228bb28f3c2SWarner Losh extern void	xprt_register(SVCXPRT *);
22986b9a9ccSGarrett Wollman __END_DECLS
230dba7a33eSGarrett Wollman 
231dba7a33eSGarrett Wollman /*
232dba7a33eSGarrett Wollman  * Transport un-register
233dba7a33eSGarrett Wollman  *
234dba7a33eSGarrett Wollman  * xprt_unregister(xprt)
235dba7a33eSGarrett Wollman  *	SVCXPRT *xprt;
236dba7a33eSGarrett Wollman  */
23786b9a9ccSGarrett Wollman __BEGIN_DECLS
238bb28f3c2SWarner Losh extern void	xprt_unregister(SVCXPRT *);
23986b9a9ccSGarrett Wollman __END_DECLS
240dba7a33eSGarrett Wollman 
241dba7a33eSGarrett Wollman 
242dba7a33eSGarrett Wollman /*
243dba7a33eSGarrett Wollman  * When the service routine is called, it must first check to see if it
244dba7a33eSGarrett Wollman  * knows about the procedure;  if not, it should call svcerr_noproc
245dba7a33eSGarrett Wollman  * and return.  If so, it should deserialize its arguments via
246dba7a33eSGarrett Wollman  * SVC_GETARGS (defined above).  If the deserialization does not work,
247dba7a33eSGarrett Wollman  * svcerr_decode should be called followed by a return.  Successful
248dba7a33eSGarrett Wollman  * decoding of the arguments should be followed the execution of the
249dba7a33eSGarrett Wollman  * procedure's code and a call to svc_sendreply.
250dba7a33eSGarrett Wollman  *
251dba7a33eSGarrett Wollman  * Also, if the service refuses to execute the procedure due to too-
252dba7a33eSGarrett Wollman  * weak authentication parameters, svcerr_weakauth should be called.
253dba7a33eSGarrett Wollman  * Note: do not confuse access-control failure with weak authentication!
254dba7a33eSGarrett Wollman  *
255dba7a33eSGarrett Wollman  * NB: In pure implementations of rpc, the caller always waits for a reply
256dba7a33eSGarrett Wollman  * msg.  This message is sent when svc_sendreply is called.
257dba7a33eSGarrett Wollman  * Therefore pure service implementations should always call
258dba7a33eSGarrett Wollman  * svc_sendreply even if the function logically returns void;  use
259dba7a33eSGarrett Wollman  * xdr.h - xdr_void for the xdr routine.  HOWEVER, tcp based rpc allows
260dba7a33eSGarrett Wollman  * for the abuse of pure rpc via batched calling or pipelining.  In the
261dba7a33eSGarrett Wollman  * case of a batched call, svc_sendreply should NOT be called since
262dba7a33eSGarrett Wollman  * this would send a return message, which is what batching tries to avoid.
263dba7a33eSGarrett Wollman  * It is the service/protocol writer's responsibility to know which calls are
264dba7a33eSGarrett Wollman  * batched and which are not.  Warning: responding to batch calls may
265dba7a33eSGarrett Wollman  * deadlock the caller and server processes!
266dba7a33eSGarrett Wollman  */
267dba7a33eSGarrett Wollman 
26886b9a9ccSGarrett Wollman __BEGIN_DECLS
269f249dbccSDag-Erling Smørgrav extern bool_t	svc_sendreply(SVCXPRT *, xdrproc_t, void *);
270bb28f3c2SWarner Losh extern void	svcerr_decode(SVCXPRT *);
271bb28f3c2SWarner Losh extern void	svcerr_weakauth(SVCXPRT *);
272bb28f3c2SWarner Losh extern void	svcerr_noproc(SVCXPRT *);
273bb28f3c2SWarner Losh extern void	svcerr_progvers(SVCXPRT *, rpcvers_t, rpcvers_t);
274bb28f3c2SWarner Losh extern void	svcerr_auth(SVCXPRT *, enum auth_stat);
275bb28f3c2SWarner Losh extern void	svcerr_noprog(SVCXPRT *);
276bb28f3c2SWarner Losh extern void	svcerr_systemerr(SVCXPRT *);
277bb28f3c2SWarner Losh extern int	rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t,
278bb28f3c2SWarner Losh 			char *(*)(char *), xdrproc_t, xdrproc_t,
279bb28f3c2SWarner Losh 			char *);
28086b9a9ccSGarrett Wollman __END_DECLS
281dba7a33eSGarrett Wollman 
282dba7a33eSGarrett Wollman /*
283dba7a33eSGarrett Wollman  * Lowest level dispatching -OR- who owns this process anyway.
284dba7a33eSGarrett Wollman  * Somebody has to wait for incoming requests and then call the correct
285dba7a33eSGarrett Wollman  * service routine.  The routine svc_run does infinite waiting; i.e.,
286dba7a33eSGarrett Wollman  * svc_run never returns.
287dba7a33eSGarrett Wollman  * Since another (co-existant) package may wish to selectively wait for
288dba7a33eSGarrett Wollman  * incoming calls or other events outside of the rpc architecture, the
289dba7a33eSGarrett Wollman  * routine svc_getreq is provided.  It must be passed readfds, the
290dba7a33eSGarrett Wollman  * "in-place" results of a select system call (see select, section 2).
291dba7a33eSGarrett Wollman  */
292dba7a33eSGarrett Wollman 
293dba7a33eSGarrett Wollman /*
294dba7a33eSGarrett Wollman  * Global keeper of rpc service descriptors in use
295dba7a33eSGarrett Wollman  * dynamic; must be inspected before each call to select
296dba7a33eSGarrett Wollman  */
29770de0abfSPeter Wemm extern int svc_maxfd;
2988360efbdSAlfred Perlstein #ifdef FD_SETSIZE
299dba7a33eSGarrett Wollman extern fd_set svc_fdset;
300dba7a33eSGarrett Wollman #define svc_fds svc_fdset.fds_bits[0]	/* compatibility */
3018360efbdSAlfred Perlstein #else
3028360efbdSAlfred Perlstein extern int svc_fds;
3038360efbdSAlfred Perlstein #endif /* def FD_SETSIZE */
304dba7a33eSGarrett Wollman 
305dba7a33eSGarrett Wollman /*
306dba7a33eSGarrett Wollman  * a small program implemented by the svc_rpc implementation itself;
307dba7a33eSGarrett Wollman  * also see clnt.h for protocol numbers.
308dba7a33eSGarrett Wollman  */
3098360efbdSAlfred Perlstein __BEGIN_DECLS
310bb28f3c2SWarner Losh extern void rpctest_service(void);
3118360efbdSAlfred Perlstein __END_DECLS
312dba7a33eSGarrett Wollman 
31386b9a9ccSGarrett Wollman __BEGIN_DECLS
314bb28f3c2SWarner Losh extern void	svc_getreq(int);
315bb28f3c2SWarner Losh extern void	svc_getreqset(fd_set *);
316bb28f3c2SWarner Losh extern void	svc_getreq_common(int);
3178360efbdSAlfred Perlstein struct pollfd;
318bb28f3c2SWarner Losh extern void	svc_getreq_poll(struct pollfd *, int);
3198360efbdSAlfred Perlstein 
320bb28f3c2SWarner Losh extern void	svc_run(void);
321bb28f3c2SWarner Losh extern void	svc_exit(void);
32286b9a9ccSGarrett Wollman __END_DECLS
323dba7a33eSGarrett Wollman 
324dba7a33eSGarrett Wollman /*
325dba7a33eSGarrett Wollman  * Socket to use on svcxxx_create call to get default socket
326dba7a33eSGarrett Wollman  */
327dba7a33eSGarrett Wollman #define	RPC_ANYSOCK	-1
3288360efbdSAlfred Perlstein #define RPC_ANYFD	RPC_ANYSOCK
329dba7a33eSGarrett Wollman 
330dba7a33eSGarrett Wollman /*
331dba7a33eSGarrett Wollman  * These are the existing service side transport implementations
332dba7a33eSGarrett Wollman  */
333dba7a33eSGarrett Wollman 
33486b9a9ccSGarrett Wollman __BEGIN_DECLS
3358360efbdSAlfred Perlstein /*
3368360efbdSAlfred Perlstein  * Transport independent svc_create routine.
3378360efbdSAlfred Perlstein  */
338bb28f3c2SWarner Losh extern int svc_create(void (*)(struct svc_req *, SVCXPRT *),
339bb28f3c2SWarner Losh 			   const rpcprog_t, const rpcvers_t, const char *);
3408360efbdSAlfred Perlstein /*
3418360efbdSAlfred Perlstein  *      void (*dispatch)();             -- dispatch routine
3428360efbdSAlfred Perlstein  *      const rpcprog_t prognum;        -- program number
3438360efbdSAlfred Perlstein  *      const rpcvers_t versnum;        -- version number
3448360efbdSAlfred Perlstein  *      const char *nettype;            -- network type
3458360efbdSAlfred Perlstein  */
34686b9a9ccSGarrett Wollman 
347dba7a33eSGarrett Wollman 
348dba7a33eSGarrett Wollman /*
3498360efbdSAlfred Perlstein  * Generic server creation routine. It takes a netconfig structure
3508360efbdSAlfred Perlstein  * instead of a nettype.
351dba7a33eSGarrett Wollman  */
3528360efbdSAlfred Perlstein 
353bb28f3c2SWarner Losh extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *),
3548360efbdSAlfred Perlstein 				   const rpcprog_t, const rpcvers_t,
355bb28f3c2SWarner Losh 				   const struct netconfig *);
3568360efbdSAlfred Perlstein         /*
3578360efbdSAlfred Perlstein          * void (*dispatch)();            -- dispatch routine
3588360efbdSAlfred Perlstein          * const rpcprog_t prognum;       -- program number
3598360efbdSAlfred Perlstein          * const rpcvers_t versnum;       -- version number
3608360efbdSAlfred Perlstein          * const struct netconfig *nconf; -- netconfig structure
3618360efbdSAlfred Perlstein          */
36286b9a9ccSGarrett Wollman 
363dba7a33eSGarrett Wollman 
364dba7a33eSGarrett Wollman /*
3658360efbdSAlfred Perlstein  * Generic TLI create routine
366dba7a33eSGarrett Wollman  */
367bb28f3c2SWarner Losh extern SVCXPRT *svc_tli_create(const int, const struct netconfig *,
3688360efbdSAlfred Perlstein 			       const struct t_bind *, const u_int,
369bb28f3c2SWarner Losh 			       const u_int);
3708360efbdSAlfred Perlstein /*
3718360efbdSAlfred Perlstein  *      const int fd;                   -- connection end point
3728360efbdSAlfred Perlstein  *      const struct netconfig *nconf;  -- netconfig structure for network
3738360efbdSAlfred Perlstein  *      const struct t_bind *bindaddr;  -- local bind address
3748360efbdSAlfred Perlstein  *      const u_int sendsz;             -- max sendsize
3758360efbdSAlfred Perlstein  *      const u_int recvsz;             -- max recvsize
3768360efbdSAlfred Perlstein  */
377dba7a33eSGarrett Wollman 
37870de0abfSPeter Wemm /*
3798360efbdSAlfred Perlstein  * Connectionless and connectionful create routines
38070de0abfSPeter Wemm  */
3818360efbdSAlfred Perlstein 
382bb28f3c2SWarner Losh extern SVCXPRT *svc_vc_create(const int, const u_int, const u_int);
3838360efbdSAlfred Perlstein /*
3848360efbdSAlfred Perlstein  *      const int fd;                           -- open connection end point
3858360efbdSAlfred Perlstein  *      const u_int sendsize;                   -- max send size
3868360efbdSAlfred Perlstein  *      const u_int recvsize;                   -- max recv size
3878360efbdSAlfred Perlstein  */
3888360efbdSAlfred Perlstein 
389e6f9ad07SBill Paul /*
390e6f9ad07SBill Paul  * Added for compatibility to old rpc 4.0. Obsoleted by svc_vc_create().
391e6f9ad07SBill Paul  */
392bb28f3c2SWarner Losh extern SVCXPRT *svcunix_create(int, u_int, u_int, char *);
393e6f9ad07SBill Paul 
394bb28f3c2SWarner Losh extern SVCXPRT *svc_dg_create(const int, const u_int, const u_int);
3958360efbdSAlfred Perlstein         /*
3968360efbdSAlfred Perlstein          * const int fd;                                -- open connection
3978360efbdSAlfred Perlstein          * const u_int sendsize;                        -- max send size
3988360efbdSAlfred Perlstein          * const u_int recvsize;                        -- max recv size
3998360efbdSAlfred Perlstein          */
4008360efbdSAlfred Perlstein 
4018360efbdSAlfred Perlstein 
4028360efbdSAlfred Perlstein /*
4038360efbdSAlfred Perlstein  * the routine takes any *open* connection
4048360efbdSAlfred Perlstein  * descriptor as its first input and is used for open connections.
4058360efbdSAlfred Perlstein  */
406bb28f3c2SWarner Losh extern SVCXPRT *svc_fd_create(const int, const u_int, const u_int);
4078360efbdSAlfred Perlstein /*
4088360efbdSAlfred Perlstein  *      const int fd;                           -- open connection end point
4098360efbdSAlfred Perlstein  *      const u_int sendsize;                   -- max send size
4108360efbdSAlfred Perlstein  *      const u_int recvsize;                   -- max recv size
4118360efbdSAlfred Perlstein  */
4128360efbdSAlfred Perlstein 
4138360efbdSAlfred Perlstein /*
414e6f9ad07SBill Paul  * Added for compatibility to old rpc 4.0. Obsoleted by svc_fd_create().
415e6f9ad07SBill Paul  */
416bb28f3c2SWarner Losh extern SVCXPRT *svcunixfd_create(int, u_int, u_int);
417e6f9ad07SBill Paul 
418e6f9ad07SBill Paul /*
4198360efbdSAlfred Perlstein  * Memory based rpc (for speed check and testing)
4208360efbdSAlfred Perlstein  */
421bb28f3c2SWarner Losh extern SVCXPRT *svc_raw_create(void);
4228360efbdSAlfred Perlstein 
4238360efbdSAlfred Perlstein /*
4248360efbdSAlfred Perlstein  * svc_dg_enable_cache() enables the cache on dg transports.
4258360efbdSAlfred Perlstein  */
426bb28f3c2SWarner Losh int svc_dg_enablecache(SVCXPRT *, const u_int);
4278360efbdSAlfred Perlstein 
428576da326SDag-Erling Smørgrav int __rpc_get_local_uid(SVCXPRT *_transp, uid_t *_uid);
429922ed949SAlfred Perlstein 
43070de0abfSPeter Wemm __END_DECLS
43170de0abfSPeter Wemm 
4328360efbdSAlfred Perlstein 
4338360efbdSAlfred Perlstein /* for backward compatibility */
4348360efbdSAlfred Perlstein #include <rpc/svc_soc.h>
4358360efbdSAlfred Perlstein 
43686b9a9ccSGarrett Wollman #endif /* !_RPC_SVC_H */
437