xref: /freebsd/include/rpc/svc.h (revision bb28f3c29b4c91af1b0e79e456294bb08735648a)
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
738360efbdSAlfred Perlstein 
748360efbdSAlfred Perlstein 
75dba7a33eSGarrett Wollman enum xprt_stat {
76dba7a33eSGarrett Wollman 	XPRT_DIED,
77dba7a33eSGarrett Wollman 	XPRT_MOREREQS,
78dba7a33eSGarrett Wollman 	XPRT_IDLE
79dba7a33eSGarrett Wollman };
80dba7a33eSGarrett Wollman 
81dba7a33eSGarrett Wollman /*
82dba7a33eSGarrett Wollman  * Server side transport handle
83dba7a33eSGarrett Wollman  */
8470de0abfSPeter Wemm typedef struct __rpc_svcxprt {
858360efbdSAlfred Perlstein 	int		xp_fd;
86dba7a33eSGarrett Wollman 	u_short		xp_port;	 /* associated port number */
878360efbdSAlfred Perlstein 	const struct xp_ops {
8870de0abfSPeter Wemm 	    /* receive incoming requests */
89bb28f3c2SWarner Losh 	    bool_t	(*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *);
9070de0abfSPeter Wemm 	    /* get transport status */
91bb28f3c2SWarner Losh 	    enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *);
9270de0abfSPeter Wemm 	    /* get arguments */
93bb28f3c2SWarner Losh 	    bool_t	(*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t,
94bb28f3c2SWarner Losh 				caddr_t);
9570de0abfSPeter Wemm 	    /* send reply */
96bb28f3c2SWarner Losh 	    bool_t	(*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *);
9770de0abfSPeter Wemm 	    /* free mem allocated for args */
98bb28f3c2SWarner Losh 	    bool_t	(*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t,
99bb28f3c2SWarner Losh 				caddr_t);
10070de0abfSPeter Wemm 	    /* destroy this struct */
101bb28f3c2SWarner Losh 	    void	(*xp_destroy)(struct __rpc_svcxprt *);
102dba7a33eSGarrett Wollman 	} *xp_ops;
103dba7a33eSGarrett Wollman 	int		xp_addrlen;	 /* length of remote address */
1048360efbdSAlfred Perlstein 	struct sockaddr_in xp_raddr;	 /* remote addr. (backward ABI compat) */
1058360efbdSAlfred Perlstein 	/* XXX - fvdl stick this here for ABI backward compat reasons */
1068360efbdSAlfred Perlstein 	const struct xp_ops2 {
1078360efbdSAlfred Perlstein 		/* catch-all function */
108bb28f3c2SWarner Losh 		bool_t  (*xp_control)(struct __rpc_svcxprt *, const u_int,
109bb28f3c2SWarner Losh 				void *);
1108360efbdSAlfred Perlstein 	} *xp_ops2;
1118360efbdSAlfred Perlstein 	char		*xp_tp;		 /* transport provider device name */
1128360efbdSAlfred Perlstein 	char		*xp_netid;	 /* network token */
1138360efbdSAlfred Perlstein 	struct netbuf	xp_ltaddr;	 /* local transport address */
1148360efbdSAlfred Perlstein 	struct netbuf	xp_rtaddr;	 /* remote transport address */
115dba7a33eSGarrett Wollman 	struct opaque_auth xp_verf;	 /* raw response verifier */
1168360efbdSAlfred Perlstein 	void		*xp_p1;		 /* private: for use by svc ops */
1178360efbdSAlfred Perlstein 	void		*xp_p2;		 /* private: for use by svc ops */
1188360efbdSAlfred Perlstein 	void		*xp_p3;		 /* private: for use by svc lib */
1198360efbdSAlfred Perlstein 	int		xp_type;	 /* transport type */
120dba7a33eSGarrett Wollman } SVCXPRT;
121dba7a33eSGarrett Wollman 
122dba7a33eSGarrett Wollman /*
1238360efbdSAlfred Perlstein  * Service request
1248360efbdSAlfred Perlstein  */
1258360efbdSAlfred Perlstein struct svc_req {
1268360efbdSAlfred Perlstein 	u_int32_t	rq_prog;	/* service program number */
1278360efbdSAlfred Perlstein 	u_int32_t	rq_vers;	/* service protocol version */
1288360efbdSAlfred Perlstein 	u_int32_t	rq_proc;	/* the desired procedure */
1298360efbdSAlfred Perlstein 	struct opaque_auth rq_cred;	/* raw creds from the wire */
1308360efbdSAlfred Perlstein 	void		*rq_clntcred;	/* read only cooked cred */
1318360efbdSAlfred Perlstein 	SVCXPRT		*rq_xprt;	/* associated transport */
1328360efbdSAlfred Perlstein };
1338360efbdSAlfred Perlstein 
1348360efbdSAlfred Perlstein /*
135dba7a33eSGarrett Wollman  *  Approved way of getting address of caller
136dba7a33eSGarrett Wollman  */
1378360efbdSAlfred Perlstein #define svc_getrpccaller(x) (&(x)->xp_rtaddr)
1388360efbdSAlfred Perlstein 
1398360efbdSAlfred Perlstein /*
1408360efbdSAlfred Perlstein  * FreeBSD-only definition to get the creds of the caller (AF_LOCAL).
1418360efbdSAlfred Perlstein  */
1428360efbdSAlfred Perlstein #define __svc_getcallercreds(x) ((struct cmsgcred *)(x)->xp_p2)
143dba7a33eSGarrett Wollman 
144dba7a33eSGarrett Wollman /*
145dba7a33eSGarrett Wollman  * Operations defined on an SVCXPRT handle
146dba7a33eSGarrett Wollman  *
147dba7a33eSGarrett Wollman  * SVCXPRT		*xprt;
148dba7a33eSGarrett Wollman  * struct rpc_msg	*msg;
149dba7a33eSGarrett Wollman  * xdrproc_t		 xargs;
150dba7a33eSGarrett Wollman  * caddr_t		 argsp;
151dba7a33eSGarrett Wollman  */
152dba7a33eSGarrett Wollman #define SVC_RECV(xprt, msg)				\
153dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
154dba7a33eSGarrett Wollman #define svc_recv(xprt, msg)				\
155dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
156dba7a33eSGarrett Wollman 
157dba7a33eSGarrett Wollman #define SVC_STAT(xprt)					\
158dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_stat)(xprt)
159dba7a33eSGarrett Wollman #define svc_stat(xprt)					\
160dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_stat)(xprt)
161dba7a33eSGarrett Wollman 
162dba7a33eSGarrett Wollman #define SVC_GETARGS(xprt, xargs, argsp)			\
163dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
164dba7a33eSGarrett Wollman #define svc_getargs(xprt, xargs, argsp)			\
165dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
166dba7a33eSGarrett Wollman 
167dba7a33eSGarrett Wollman #define SVC_REPLY(xprt, msg)				\
168dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
169dba7a33eSGarrett Wollman #define svc_reply(xprt, msg)				\
170dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
171dba7a33eSGarrett Wollman 
172dba7a33eSGarrett Wollman #define SVC_FREEARGS(xprt, xargs, argsp)		\
173dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
174dba7a33eSGarrett Wollman #define svc_freeargs(xprt, xargs, argsp)		\
175dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
176dba7a33eSGarrett Wollman 
177dba7a33eSGarrett Wollman #define SVC_DESTROY(xprt)				\
178dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_destroy)(xprt)
179dba7a33eSGarrett Wollman #define svc_destroy(xprt)				\
180dba7a33eSGarrett Wollman 	(*(xprt)->xp_ops->xp_destroy)(xprt)
181dba7a33eSGarrett Wollman 
1828360efbdSAlfred Perlstein #define SVC_CONTROL(xprt, rq, in)			\
1838360efbdSAlfred Perlstein 	(*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in))
184dba7a33eSGarrett Wollman 
185dba7a33eSGarrett Wollman /*
186dba7a33eSGarrett Wollman  * Service registration
187dba7a33eSGarrett Wollman  *
1888360efbdSAlfred Perlstein  * svc_reg(xprt, prog, vers, dispatch, nconf)
1898360efbdSAlfred Perlstein  *	const SVCXPRT *xprt;
1908360efbdSAlfred Perlstein  *	const rpcprog_t prog;
1918360efbdSAlfred Perlstein  *	const rpcvers_t vers;
1928360efbdSAlfred Perlstein  *	const void (*dispatch)();
1938360efbdSAlfred Perlstein  *	const struct netconfig *nconf;
194dba7a33eSGarrett Wollman  */
1958360efbdSAlfred Perlstein 
19686b9a9ccSGarrett Wollman __BEGIN_DECLS
197bb28f3c2SWarner Losh extern bool_t	svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t,
198bb28f3c2SWarner Losh 			void (*)(struct svc_req *, SVCXPRT *),
199bb28f3c2SWarner Losh 			const struct netconfig *);
20086b9a9ccSGarrett Wollman __END_DECLS
201dba7a33eSGarrett Wollman 
202dba7a33eSGarrett Wollman /*
203dba7a33eSGarrett Wollman  * Service un-registration
204dba7a33eSGarrett Wollman  *
2058360efbdSAlfred Perlstein  * svc_unreg(prog, vers)
2068360efbdSAlfred Perlstein  *	const rpcprog_t prog;
2078360efbdSAlfred Perlstein  *	const rpcvers_t vers;
208dba7a33eSGarrett Wollman  */
2098360efbdSAlfred Perlstein 
21086b9a9ccSGarrett Wollman __BEGIN_DECLS
211bb28f3c2SWarner Losh extern void	svc_unreg(const rpcprog_t, const rpcvers_t);
21286b9a9ccSGarrett Wollman __END_DECLS
213dba7a33eSGarrett Wollman 
214dba7a33eSGarrett Wollman /*
215dba7a33eSGarrett Wollman  * Transport registration.
216dba7a33eSGarrett Wollman  *
217dba7a33eSGarrett Wollman  * xprt_register(xprt)
218dba7a33eSGarrett Wollman  *	SVCXPRT *xprt;
219dba7a33eSGarrett Wollman  */
22086b9a9ccSGarrett Wollman __BEGIN_DECLS
221bb28f3c2SWarner Losh extern void	xprt_register(SVCXPRT *);
22286b9a9ccSGarrett Wollman __END_DECLS
223dba7a33eSGarrett Wollman 
224dba7a33eSGarrett Wollman /*
225dba7a33eSGarrett Wollman  * Transport un-register
226dba7a33eSGarrett Wollman  *
227dba7a33eSGarrett Wollman  * xprt_unregister(xprt)
228dba7a33eSGarrett Wollman  *	SVCXPRT *xprt;
229dba7a33eSGarrett Wollman  */
23086b9a9ccSGarrett Wollman __BEGIN_DECLS
231bb28f3c2SWarner Losh extern void	xprt_unregister(SVCXPRT *);
23286b9a9ccSGarrett Wollman __END_DECLS
233dba7a33eSGarrett Wollman 
234dba7a33eSGarrett Wollman 
235dba7a33eSGarrett Wollman /*
236dba7a33eSGarrett Wollman  * When the service routine is called, it must first check to see if it
237dba7a33eSGarrett Wollman  * knows about the procedure;  if not, it should call svcerr_noproc
238dba7a33eSGarrett Wollman  * and return.  If so, it should deserialize its arguments via
239dba7a33eSGarrett Wollman  * SVC_GETARGS (defined above).  If the deserialization does not work,
240dba7a33eSGarrett Wollman  * svcerr_decode should be called followed by a return.  Successful
241dba7a33eSGarrett Wollman  * decoding of the arguments should be followed the execution of the
242dba7a33eSGarrett Wollman  * procedure's code and a call to svc_sendreply.
243dba7a33eSGarrett Wollman  *
244dba7a33eSGarrett Wollman  * Also, if the service refuses to execute the procedure due to too-
245dba7a33eSGarrett Wollman  * weak authentication parameters, svcerr_weakauth should be called.
246dba7a33eSGarrett Wollman  * Note: do not confuse access-control failure with weak authentication!
247dba7a33eSGarrett Wollman  *
248dba7a33eSGarrett Wollman  * NB: In pure implementations of rpc, the caller always waits for a reply
249dba7a33eSGarrett Wollman  * msg.  This message is sent when svc_sendreply is called.
250dba7a33eSGarrett Wollman  * Therefore pure service implementations should always call
251dba7a33eSGarrett Wollman  * svc_sendreply even if the function logically returns void;  use
252dba7a33eSGarrett Wollman  * xdr.h - xdr_void for the xdr routine.  HOWEVER, tcp based rpc allows
253dba7a33eSGarrett Wollman  * for the abuse of pure rpc via batched calling or pipelining.  In the
254dba7a33eSGarrett Wollman  * case of a batched call, svc_sendreply should NOT be called since
255dba7a33eSGarrett Wollman  * this would send a return message, which is what batching tries to avoid.
256dba7a33eSGarrett Wollman  * It is the service/protocol writer's responsibility to know which calls are
257dba7a33eSGarrett Wollman  * batched and which are not.  Warning: responding to batch calls may
258dba7a33eSGarrett Wollman  * deadlock the caller and server processes!
259dba7a33eSGarrett Wollman  */
260dba7a33eSGarrett Wollman 
26186b9a9ccSGarrett Wollman __BEGIN_DECLS
262bb28f3c2SWarner Losh extern bool_t	svc_sendreply(SVCXPRT *, xdrproc_t, char *);
263bb28f3c2SWarner Losh extern void	svcerr_decode(SVCXPRT *);
264bb28f3c2SWarner Losh extern void	svcerr_weakauth(SVCXPRT *);
265bb28f3c2SWarner Losh extern void	svcerr_noproc(SVCXPRT *);
266bb28f3c2SWarner Losh extern void	svcerr_progvers(SVCXPRT *, rpcvers_t, rpcvers_t);
267bb28f3c2SWarner Losh extern void	svcerr_auth(SVCXPRT *, enum auth_stat);
268bb28f3c2SWarner Losh extern void	svcerr_noprog(SVCXPRT *);
269bb28f3c2SWarner Losh extern void	svcerr_systemerr(SVCXPRT *);
270bb28f3c2SWarner Losh extern int	rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t,
271bb28f3c2SWarner Losh 			char *(*)(char *), xdrproc_t, xdrproc_t,
272bb28f3c2SWarner Losh 			char *);
27386b9a9ccSGarrett Wollman __END_DECLS
274dba7a33eSGarrett Wollman 
275dba7a33eSGarrett Wollman /*
276dba7a33eSGarrett Wollman  * Lowest level dispatching -OR- who owns this process anyway.
277dba7a33eSGarrett Wollman  * Somebody has to wait for incoming requests and then call the correct
278dba7a33eSGarrett Wollman  * service routine.  The routine svc_run does infinite waiting; i.e.,
279dba7a33eSGarrett Wollman  * svc_run never returns.
280dba7a33eSGarrett Wollman  * Since another (co-existant) package may wish to selectively wait for
281dba7a33eSGarrett Wollman  * incoming calls or other events outside of the rpc architecture, the
282dba7a33eSGarrett Wollman  * routine svc_getreq is provided.  It must be passed readfds, the
283dba7a33eSGarrett Wollman  * "in-place" results of a select system call (see select, section 2).
284dba7a33eSGarrett Wollman  */
285dba7a33eSGarrett Wollman 
286dba7a33eSGarrett Wollman /*
287dba7a33eSGarrett Wollman  * Global keeper of rpc service descriptors in use
288dba7a33eSGarrett Wollman  * dynamic; must be inspected before each call to select
289dba7a33eSGarrett Wollman  */
29070de0abfSPeter Wemm extern int svc_maxfd;
2918360efbdSAlfred Perlstein #ifdef FD_SETSIZE
292dba7a33eSGarrett Wollman extern fd_set svc_fdset;
293dba7a33eSGarrett Wollman #define svc_fds svc_fdset.fds_bits[0]	/* compatibility */
2948360efbdSAlfred Perlstein #else
2958360efbdSAlfred Perlstein extern int svc_fds;
2968360efbdSAlfred Perlstein #endif /* def FD_SETSIZE */
297dba7a33eSGarrett Wollman 
298dba7a33eSGarrett Wollman /*
299dba7a33eSGarrett Wollman  * a small program implemented by the svc_rpc implementation itself;
300dba7a33eSGarrett Wollman  * also see clnt.h for protocol numbers.
301dba7a33eSGarrett Wollman  */
3028360efbdSAlfred Perlstein __BEGIN_DECLS
303bb28f3c2SWarner Losh extern void rpctest_service(void);
3048360efbdSAlfred Perlstein __END_DECLS
305dba7a33eSGarrett Wollman 
30686b9a9ccSGarrett Wollman __BEGIN_DECLS
307bb28f3c2SWarner Losh extern void	svc_getreq(int);
308bb28f3c2SWarner Losh extern void	svc_getreqset(fd_set *);
309bb28f3c2SWarner Losh extern void	svc_getreq_common(int);
3108360efbdSAlfred Perlstein struct pollfd;
311bb28f3c2SWarner Losh extern void	svc_getreq_poll(struct pollfd *, int);
3128360efbdSAlfred Perlstein 
313bb28f3c2SWarner Losh extern void	svc_run(void);
314bb28f3c2SWarner Losh extern void	svc_exit(void);
31586b9a9ccSGarrett Wollman __END_DECLS
316dba7a33eSGarrett Wollman 
317dba7a33eSGarrett Wollman /*
318dba7a33eSGarrett Wollman  * Socket to use on svcxxx_create call to get default socket
319dba7a33eSGarrett Wollman  */
320dba7a33eSGarrett Wollman #define	RPC_ANYSOCK	-1
3218360efbdSAlfred Perlstein #define RPC_ANYFD	RPC_ANYSOCK
322dba7a33eSGarrett Wollman 
323dba7a33eSGarrett Wollman /*
324dba7a33eSGarrett Wollman  * These are the existing service side transport implementations
325dba7a33eSGarrett Wollman  */
326dba7a33eSGarrett Wollman 
32786b9a9ccSGarrett Wollman __BEGIN_DECLS
3288360efbdSAlfred Perlstein /*
3298360efbdSAlfred Perlstein  * Transport independent svc_create routine.
3308360efbdSAlfred Perlstein  */
331bb28f3c2SWarner Losh extern int svc_create(void (*)(struct svc_req *, SVCXPRT *),
332bb28f3c2SWarner Losh 			   const rpcprog_t, const rpcvers_t, const char *);
3338360efbdSAlfred Perlstein /*
3348360efbdSAlfred Perlstein  *      void (*dispatch)();             -- dispatch routine
3358360efbdSAlfred Perlstein  *      const rpcprog_t prognum;        -- program number
3368360efbdSAlfred Perlstein  *      const rpcvers_t versnum;        -- version number
3378360efbdSAlfred Perlstein  *      const char *nettype;            -- network type
3388360efbdSAlfred Perlstein  */
33986b9a9ccSGarrett Wollman 
340dba7a33eSGarrett Wollman 
341dba7a33eSGarrett Wollman /*
3428360efbdSAlfred Perlstein  * Generic server creation routine. It takes a netconfig structure
3438360efbdSAlfred Perlstein  * instead of a nettype.
344dba7a33eSGarrett Wollman  */
3458360efbdSAlfred Perlstein 
346bb28f3c2SWarner Losh extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *),
3478360efbdSAlfred Perlstein 				   const rpcprog_t, const rpcvers_t,
348bb28f3c2SWarner Losh 				   const struct netconfig *);
3498360efbdSAlfred Perlstein         /*
3508360efbdSAlfred Perlstein          * void (*dispatch)();            -- dispatch routine
3518360efbdSAlfred Perlstein          * const rpcprog_t prognum;       -- program number
3528360efbdSAlfred Perlstein          * const rpcvers_t versnum;       -- version number
3538360efbdSAlfred Perlstein          * const struct netconfig *nconf; -- netconfig structure
3548360efbdSAlfred Perlstein          */
35586b9a9ccSGarrett Wollman 
356dba7a33eSGarrett Wollman 
357dba7a33eSGarrett Wollman /*
3588360efbdSAlfred Perlstein  * Generic TLI create routine
359dba7a33eSGarrett Wollman  */
360bb28f3c2SWarner Losh extern SVCXPRT *svc_tli_create(const int, const struct netconfig *,
3618360efbdSAlfred Perlstein 			       const struct t_bind *, const u_int,
362bb28f3c2SWarner Losh 			       const u_int);
3638360efbdSAlfred Perlstein /*
3648360efbdSAlfred Perlstein  *      const int fd;                   -- connection end point
3658360efbdSAlfred Perlstein  *      const struct netconfig *nconf;  -- netconfig structure for network
3668360efbdSAlfred Perlstein  *      const struct t_bind *bindaddr;  -- local bind address
3678360efbdSAlfred Perlstein  *      const u_int sendsz;             -- max sendsize
3688360efbdSAlfred Perlstein  *      const u_int recvsz;             -- max recvsize
3698360efbdSAlfred Perlstein  */
370dba7a33eSGarrett Wollman 
37170de0abfSPeter Wemm /*
3728360efbdSAlfred Perlstein  * Connectionless and connectionful create routines
37370de0abfSPeter Wemm  */
3748360efbdSAlfred Perlstein 
375bb28f3c2SWarner Losh extern SVCXPRT *svc_vc_create(const int, const u_int, const u_int);
3768360efbdSAlfred Perlstein /*
3778360efbdSAlfred Perlstein  *      const int fd;                           -- open connection end point
3788360efbdSAlfred Perlstein  *      const u_int sendsize;                   -- max send size
3798360efbdSAlfred Perlstein  *      const u_int recvsize;                   -- max recv size
3808360efbdSAlfred Perlstein  */
3818360efbdSAlfred Perlstein 
382e6f9ad07SBill Paul /*
383e6f9ad07SBill Paul  * Added for compatibility to old rpc 4.0. Obsoleted by svc_vc_create().
384e6f9ad07SBill Paul  */
385bb28f3c2SWarner Losh extern SVCXPRT *svcunix_create(int, u_int, u_int, char *);
386e6f9ad07SBill Paul 
387bb28f3c2SWarner Losh extern SVCXPRT *svc_dg_create(const int, const u_int, const u_int);
3888360efbdSAlfred Perlstein         /*
3898360efbdSAlfred Perlstein          * const int fd;                                -- open connection
3908360efbdSAlfred Perlstein          * const u_int sendsize;                        -- max send size
3918360efbdSAlfred Perlstein          * const u_int recvsize;                        -- max recv size
3928360efbdSAlfred Perlstein          */
3938360efbdSAlfred Perlstein 
3948360efbdSAlfred Perlstein 
3958360efbdSAlfred Perlstein /*
3968360efbdSAlfred Perlstein  * the routine takes any *open* connection
3978360efbdSAlfred Perlstein  * descriptor as its first input and is used for open connections.
3988360efbdSAlfred Perlstein  */
399bb28f3c2SWarner Losh extern SVCXPRT *svc_fd_create(const int, const u_int, const u_int);
4008360efbdSAlfred Perlstein /*
4018360efbdSAlfred Perlstein  *      const int fd;                           -- open connection end point
4028360efbdSAlfred Perlstein  *      const u_int sendsize;                   -- max send size
4038360efbdSAlfred Perlstein  *      const u_int recvsize;                   -- max recv size
4048360efbdSAlfred Perlstein  */
4058360efbdSAlfred Perlstein 
4068360efbdSAlfred Perlstein /*
407e6f9ad07SBill Paul  * Added for compatibility to old rpc 4.0. Obsoleted by svc_fd_create().
408e6f9ad07SBill Paul  */
409bb28f3c2SWarner Losh extern SVCXPRT *svcunixfd_create(int, u_int, u_int);
410e6f9ad07SBill Paul 
411e6f9ad07SBill Paul /*
4128360efbdSAlfred Perlstein  * Memory based rpc (for speed check and testing)
4138360efbdSAlfred Perlstein  */
414bb28f3c2SWarner Losh extern SVCXPRT *svc_raw_create(void);
4158360efbdSAlfred Perlstein 
4168360efbdSAlfred Perlstein /*
4178360efbdSAlfred Perlstein  * svc_dg_enable_cache() enables the cache on dg transports.
4188360efbdSAlfred Perlstein  */
419bb28f3c2SWarner Losh int svc_dg_enablecache(SVCXPRT *, const u_int);
4208360efbdSAlfred Perlstein 
421576da326SDag-Erling Smørgrav int __rpc_get_local_uid(SVCXPRT *_transp, uid_t *_uid);
422922ed949SAlfred Perlstein 
42370de0abfSPeter Wemm __END_DECLS
42470de0abfSPeter Wemm 
4258360efbdSAlfred Perlstein 
4268360efbdSAlfred Perlstein /* for backward compatibility */
4278360efbdSAlfred Perlstein #include <rpc/svc_soc.h>
4288360efbdSAlfred Perlstein 
42986b9a9ccSGarrett Wollman #endif /* !_RPC_SVC_H */
430