18360efbdSAlfred Perlstein /* $NetBSD: svc.h,v 1.17 2000/06/02 22:57:56 fvdl Exp $ */ 28360efbdSAlfred Perlstein 32e322d37SHiroki Sato /*- 42321c474SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 52321c474SPedro F. Giffuni * 62e322d37SHiroki Sato * Copyright (c) 2009, Sun Microsystems, Inc. 72e322d37SHiroki Sato * All rights reserved. 8dba7a33eSGarrett Wollman * 92e322d37SHiroki Sato * Redistribution and use in source and binary forms, with or without 102e322d37SHiroki Sato * modification, are permitted provided that the following conditions are met: 112e322d37SHiroki Sato * - Redistributions of source code must retain the above copyright notice, 122e322d37SHiroki Sato * this list of conditions and the following disclaimer. 132e322d37SHiroki Sato * - Redistributions in binary form must reproduce the above copyright notice, 142e322d37SHiroki Sato * this list of conditions and the following disclaimer in the documentation 152e322d37SHiroki Sato * and/or other materials provided with the distribution. 162e322d37SHiroki Sato * - Neither the name of Sun Microsystems, Inc. nor the names of its 172e322d37SHiroki Sato * contributors may be used to endorse or promote products derived 182e322d37SHiroki Sato * from this software without specific prior written permission. 19dba7a33eSGarrett Wollman * 202e322d37SHiroki Sato * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 212e322d37SHiroki Sato * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 222e322d37SHiroki Sato * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 232e322d37SHiroki Sato * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 242e322d37SHiroki Sato * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 252e322d37SHiroki Sato * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 262e322d37SHiroki Sato * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 272e322d37SHiroki Sato * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 282e322d37SHiroki Sato * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 292e322d37SHiroki Sato * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 302e322d37SHiroki Sato * POSSIBILITY OF SUCH DAMAGE. 31dba7a33eSGarrett Wollman */ 32dba7a33eSGarrett Wollman 33dba7a33eSGarrett Wollman /* 34dba7a33eSGarrett Wollman * svc.h, Server-side remote procedure call interface. 35dba7a33eSGarrett Wollman * 368360efbdSAlfred Perlstein * Copyright (C) 1986-1993 by Sun Microsystems, Inc. 37dba7a33eSGarrett Wollman */ 38dba7a33eSGarrett Wollman 3986b9a9ccSGarrett Wollman #ifndef _RPC_SVC_H 4086b9a9ccSGarrett Wollman #define _RPC_SVC_H 4186b9a9ccSGarrett Wollman #include <sys/cdefs.h> 42dba7a33eSGarrett Wollman 43dba7a33eSGarrett Wollman /* 44dba7a33eSGarrett Wollman * This interface must manage two items concerning remote procedure calling: 45dba7a33eSGarrett Wollman * 46dba7a33eSGarrett Wollman * 1) An arbitrary number of transport connections upon which rpc requests 47dba7a33eSGarrett Wollman * are received. The two most notable transports are TCP and UDP; they are 48dba7a33eSGarrett Wollman * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; 49dba7a33eSGarrett Wollman * they in turn call xprt_register and xprt_unregister. 50dba7a33eSGarrett Wollman * 51dba7a33eSGarrett Wollman * 2) An arbitrary number of locally registered services. Services are 52dba7a33eSGarrett Wollman * described by the following four data: program number, version number, 53dba7a33eSGarrett Wollman * "service dispatch" function, a transport handle, and a boolean that 54dba7a33eSGarrett Wollman * indicates whether or not the exported program should be registered with a 55dba7a33eSGarrett Wollman * local binder service; if true the program's number and version and the 56dba7a33eSGarrett Wollman * port number from the transport handle are registered with the binder. 57dba7a33eSGarrett Wollman * These data are registered with the rpc svc system via svc_register. 58dba7a33eSGarrett Wollman * 59dba7a33eSGarrett Wollman * A service's dispatch function is called whenever an rpc request comes in 60dba7a33eSGarrett Wollman * on a transport. The request's program and version numbers must match 61dba7a33eSGarrett Wollman * those of the registered service. The dispatch function is passed two 62dba7a33eSGarrett Wollman * parameters, struct svc_req * and SVCXPRT *, defined below. 63dba7a33eSGarrett Wollman */ 64dba7a33eSGarrett Wollman 658360efbdSAlfred Perlstein /* 668360efbdSAlfred Perlstein * Service control requests 678360efbdSAlfred Perlstein */ 688360efbdSAlfred Perlstein #define SVCGET_VERSQUIET 1 698360efbdSAlfred Perlstein #define SVCSET_VERSQUIET 2 7008497c02SMartin Blapp #define SVCGET_CONNMAXREC 3 7108497c02SMartin Blapp #define SVCSET_CONNMAXREC 4 728360efbdSAlfred Perlstein 7308497c02SMartin Blapp /* 7408497c02SMartin Blapp * Operations for rpc_control(). 7508497c02SMartin Blapp */ 7608497c02SMartin Blapp #define RPC_SVC_CONNMAXREC_SET 0 /* set max rec size, enable nonblock */ 7708497c02SMartin Blapp #define RPC_SVC_CONNMAXREC_GET 1 788360efbdSAlfred Perlstein 79dba7a33eSGarrett Wollman enum xprt_stat { 80dba7a33eSGarrett Wollman XPRT_DIED, 81dba7a33eSGarrett Wollman XPRT_MOREREQS, 82dba7a33eSGarrett Wollman XPRT_IDLE 83dba7a33eSGarrett Wollman }; 84dba7a33eSGarrett Wollman 85dba7a33eSGarrett Wollman /* 86dba7a33eSGarrett Wollman * Server side transport handle 87dba7a33eSGarrett Wollman */ 8870de0abfSPeter Wemm typedef struct __rpc_svcxprt { 898360efbdSAlfred Perlstein int xp_fd; 90ceb5a304SPedro F. Giffuni #define xp_sock xp_fd 91dba7a33eSGarrett Wollman u_short xp_port; /* associated port number */ 928360efbdSAlfred Perlstein const struct xp_ops { 9370de0abfSPeter Wemm /* receive incoming requests */ 94bb28f3c2SWarner Losh bool_t (*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *); 9570de0abfSPeter Wemm /* get transport status */ 96bb28f3c2SWarner Losh enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *); 9770de0abfSPeter Wemm /* get arguments */ 98bb28f3c2SWarner Losh bool_t (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t, 99f249dbccSDag-Erling Smørgrav void *); 10070de0abfSPeter Wemm /* send reply */ 101bb28f3c2SWarner Losh bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *); 10270de0abfSPeter Wemm /* free mem allocated for args */ 103bb28f3c2SWarner Losh bool_t (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t, 104f249dbccSDag-Erling Smørgrav void *); 10570de0abfSPeter Wemm /* destroy this struct */ 106bb28f3c2SWarner Losh void (*xp_destroy)(struct __rpc_svcxprt *); 107dba7a33eSGarrett Wollman } *xp_ops; 108dba7a33eSGarrett Wollman int xp_addrlen; /* length of remote address */ 1098360efbdSAlfred Perlstein struct sockaddr_in xp_raddr; /* remote addr. (backward ABI compat) */ 1108360efbdSAlfred Perlstein /* XXX - fvdl stick this here for ABI backward compat reasons */ 1118360efbdSAlfred Perlstein const struct xp_ops2 { 1128360efbdSAlfred Perlstein /* catch-all function */ 113bb28f3c2SWarner Losh bool_t (*xp_control)(struct __rpc_svcxprt *, const u_int, 114bb28f3c2SWarner Losh void *); 1158360efbdSAlfred Perlstein } *xp_ops2; 1168360efbdSAlfred Perlstein char *xp_tp; /* transport provider device name */ 1178360efbdSAlfred Perlstein char *xp_netid; /* network token */ 1188360efbdSAlfred Perlstein struct netbuf xp_ltaddr; /* local transport address */ 1198360efbdSAlfred Perlstein struct netbuf xp_rtaddr; /* remote transport address */ 120dba7a33eSGarrett Wollman struct opaque_auth xp_verf; /* raw response verifier */ 1218360efbdSAlfred Perlstein void *xp_p1; /* private: for use by svc ops */ 1228360efbdSAlfred Perlstein void *xp_p2; /* private: for use by svc ops */ 1238360efbdSAlfred Perlstein void *xp_p3; /* private: for use by svc lib */ 1248360efbdSAlfred Perlstein int xp_type; /* transport type */ 125dba7a33eSGarrett Wollman } SVCXPRT; 126dba7a33eSGarrett Wollman 127dba7a33eSGarrett Wollman /* 1288f55a568SDoug Rabson * Interface to server-side authentication flavors. 1298f55a568SDoug Rabson */ 1308f55a568SDoug Rabson typedef struct __rpc_svcauth { 1318f55a568SDoug Rabson struct svc_auth_ops { 1328f55a568SDoug Rabson int (*svc_ah_wrap)(struct __rpc_svcauth *, XDR *, 1338f55a568SDoug Rabson xdrproc_t, caddr_t); 1348f55a568SDoug Rabson int (*svc_ah_unwrap)(struct __rpc_svcauth *, XDR *, 1358f55a568SDoug Rabson xdrproc_t, caddr_t); 1368f55a568SDoug Rabson } *svc_ah_ops; 1378f55a568SDoug Rabson void *svc_ah_private; 1388f55a568SDoug Rabson } SVCAUTH; 1398f55a568SDoug Rabson 1408f55a568SDoug Rabson /* 1418f55a568SDoug Rabson * Server transport extensions (accessed via xp_p3). 1428f55a568SDoug Rabson */ 1438f55a568SDoug Rabson typedef struct __rpc_svcxprt_ext { 1448f55a568SDoug Rabson int xp_flags; /* versquiet */ 1458f55a568SDoug Rabson SVCAUTH xp_auth; /* interface to auth methods */ 1468f55a568SDoug Rabson } SVCXPRT_EXT; 1478f55a568SDoug Rabson 1488f55a568SDoug Rabson /* 1498360efbdSAlfred Perlstein * Service request 1508360efbdSAlfred Perlstein */ 1518360efbdSAlfred Perlstein struct svc_req { 1528360efbdSAlfred Perlstein u_int32_t rq_prog; /* service program number */ 1538360efbdSAlfred Perlstein u_int32_t rq_vers; /* service protocol version */ 1548360efbdSAlfred Perlstein u_int32_t rq_proc; /* the desired procedure */ 1558360efbdSAlfred Perlstein struct opaque_auth rq_cred; /* raw creds from the wire */ 1568360efbdSAlfred Perlstein void *rq_clntcred; /* read only cooked cred */ 1578360efbdSAlfred Perlstein SVCXPRT *rq_xprt; /* associated transport */ 1588360efbdSAlfred Perlstein }; 1598360efbdSAlfred Perlstein 1608360efbdSAlfred Perlstein /* 161dba7a33eSGarrett Wollman * Approved way of getting address of caller 162dba7a33eSGarrett Wollman */ 1638360efbdSAlfred Perlstein #define svc_getrpccaller(x) (&(x)->xp_rtaddr) 1649f48eea3SDmitry Ovsyannikov /* 1659f48eea3SDmitry Ovsyannikov * Approved way of getting address of callee 1669f48eea3SDmitry Ovsyannikov */ 1679f48eea3SDmitry Ovsyannikov #define svc_getrpccallee(x) (&(x)->xp_ltaddr) 1688360efbdSAlfred Perlstein 1698360efbdSAlfred Perlstein /* 170dba7a33eSGarrett Wollman * Operations defined on an SVCXPRT handle 171dba7a33eSGarrett Wollman * 172dba7a33eSGarrett Wollman * SVCXPRT *xprt; 173dba7a33eSGarrett Wollman * struct rpc_msg *msg; 174dba7a33eSGarrett Wollman * xdrproc_t xargs; 175f249dbccSDag-Erling Smørgrav * void * argsp; 176dba7a33eSGarrett Wollman */ 177dba7a33eSGarrett Wollman #define SVC_RECV(xprt, msg) \ 178dba7a33eSGarrett Wollman (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) 179dba7a33eSGarrett Wollman #define svc_recv(xprt, msg) \ 180dba7a33eSGarrett Wollman (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) 181dba7a33eSGarrett Wollman 182dba7a33eSGarrett Wollman #define SVC_STAT(xprt) \ 183dba7a33eSGarrett Wollman (*(xprt)->xp_ops->xp_stat)(xprt) 184dba7a33eSGarrett Wollman #define svc_stat(xprt) \ 185dba7a33eSGarrett Wollman (*(xprt)->xp_ops->xp_stat)(xprt) 186dba7a33eSGarrett Wollman 187dba7a33eSGarrett Wollman #define SVC_GETARGS(xprt, xargs, argsp) \ 188dba7a33eSGarrett Wollman (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) 189dba7a33eSGarrett Wollman #define svc_getargs(xprt, xargs, argsp) \ 190dba7a33eSGarrett Wollman (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) 191dba7a33eSGarrett Wollman 192dba7a33eSGarrett Wollman #define SVC_REPLY(xprt, msg) \ 193dba7a33eSGarrett Wollman (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) 194dba7a33eSGarrett Wollman #define svc_reply(xprt, msg) \ 195dba7a33eSGarrett Wollman (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) 196dba7a33eSGarrett Wollman 197dba7a33eSGarrett Wollman #define SVC_FREEARGS(xprt, xargs, argsp) \ 198dba7a33eSGarrett Wollman (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) 199dba7a33eSGarrett Wollman #define svc_freeargs(xprt, xargs, argsp) \ 200dba7a33eSGarrett Wollman (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) 201dba7a33eSGarrett Wollman 202dba7a33eSGarrett Wollman #define SVC_DESTROY(xprt) \ 203dba7a33eSGarrett Wollman (*(xprt)->xp_ops->xp_destroy)(xprt) 204dba7a33eSGarrett Wollman #define svc_destroy(xprt) \ 205dba7a33eSGarrett Wollman (*(xprt)->xp_ops->xp_destroy)(xprt) 206dba7a33eSGarrett Wollman 2078360efbdSAlfred Perlstein #define SVC_CONTROL(xprt, rq, in) \ 2088360efbdSAlfred Perlstein (*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in)) 209dba7a33eSGarrett Wollman 2108f55a568SDoug Rabson #define SVC_EXT(xprt) \ 2118f55a568SDoug Rabson ((SVCXPRT_EXT *) xprt->xp_p3) 2128f55a568SDoug Rabson 2138f55a568SDoug Rabson #define SVC_AUTH(xprt) \ 2148f55a568SDoug Rabson (SVC_EXT(xprt)->xp_auth) 2158f55a568SDoug Rabson 2168f55a568SDoug Rabson /* 2178f55a568SDoug Rabson * Operations defined on an SVCAUTH handle 2188f55a568SDoug Rabson */ 2198f55a568SDoug Rabson #define SVCAUTH_WRAP(auth, xdrs, xfunc, xwhere) \ 2208f55a568SDoug Rabson ((auth)->svc_ah_ops->svc_ah_wrap(auth, xdrs, xfunc, xwhere)) 2218f55a568SDoug Rabson #define SVCAUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \ 2228f55a568SDoug Rabson ((auth)->svc_ah_ops->svc_ah_unwrap(auth, xdrs, xfunc, xwhere)) 2238f55a568SDoug Rabson 224dba7a33eSGarrett Wollman /* 225dba7a33eSGarrett Wollman * Service registration 226dba7a33eSGarrett Wollman * 2278360efbdSAlfred Perlstein * svc_reg(xprt, prog, vers, dispatch, nconf) 2288360efbdSAlfred Perlstein * const SVCXPRT *xprt; 2298360efbdSAlfred Perlstein * const rpcprog_t prog; 2308360efbdSAlfred Perlstein * const rpcvers_t vers; 231265f940aSTijl Coosemans * const void (*dispatch)(struct svc_req *, SVCXPRT *); 2328360efbdSAlfred Perlstein * const struct netconfig *nconf; 233dba7a33eSGarrett Wollman */ 2348360efbdSAlfred Perlstein 23586b9a9ccSGarrett Wollman __BEGIN_DECLS 236bb28f3c2SWarner Losh extern bool_t svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t, 237bb28f3c2SWarner Losh void (*)(struct svc_req *, SVCXPRT *), 238bb28f3c2SWarner Losh const struct netconfig *); 23986b9a9ccSGarrett Wollman __END_DECLS 240dba7a33eSGarrett Wollman 241dba7a33eSGarrett Wollman /* 242dba7a33eSGarrett Wollman * Service un-registration 243dba7a33eSGarrett Wollman * 2448360efbdSAlfred Perlstein * svc_unreg(prog, vers) 2458360efbdSAlfred Perlstein * const rpcprog_t prog; 2468360efbdSAlfred Perlstein * const rpcvers_t vers; 247dba7a33eSGarrett Wollman */ 2488360efbdSAlfred Perlstein 24986b9a9ccSGarrett Wollman __BEGIN_DECLS 250bb28f3c2SWarner Losh extern void svc_unreg(const rpcprog_t, const rpcvers_t); 25186b9a9ccSGarrett Wollman __END_DECLS 252dba7a33eSGarrett Wollman 253dba7a33eSGarrett Wollman /* 254dba7a33eSGarrett Wollman * Transport registration. 255dba7a33eSGarrett Wollman * 256dba7a33eSGarrett Wollman * xprt_register(xprt) 257dba7a33eSGarrett Wollman * SVCXPRT *xprt; 258dba7a33eSGarrett Wollman */ 25986b9a9ccSGarrett Wollman __BEGIN_DECLS 260bb28f3c2SWarner Losh extern void xprt_register(SVCXPRT *); 26186b9a9ccSGarrett Wollman __END_DECLS 262dba7a33eSGarrett Wollman 263dba7a33eSGarrett Wollman /* 264dba7a33eSGarrett Wollman * Transport un-register 265dba7a33eSGarrett Wollman * 266dba7a33eSGarrett Wollman * xprt_unregister(xprt) 267dba7a33eSGarrett Wollman * SVCXPRT *xprt; 268dba7a33eSGarrett Wollman */ 26986b9a9ccSGarrett Wollman __BEGIN_DECLS 270bb28f3c2SWarner Losh extern void xprt_unregister(SVCXPRT *); 27186b9a9ccSGarrett Wollman __END_DECLS 272dba7a33eSGarrett Wollman 273dba7a33eSGarrett Wollman 274dba7a33eSGarrett Wollman /* 275dba7a33eSGarrett Wollman * When the service routine is called, it must first check to see if it 276dba7a33eSGarrett Wollman * knows about the procedure; if not, it should call svcerr_noproc 277dba7a33eSGarrett Wollman * and return. If so, it should deserialize its arguments via 278dba7a33eSGarrett Wollman * SVC_GETARGS (defined above). If the deserialization does not work, 279dba7a33eSGarrett Wollman * svcerr_decode should be called followed by a return. Successful 280dba7a33eSGarrett Wollman * decoding of the arguments should be followed the execution of the 281dba7a33eSGarrett Wollman * procedure's code and a call to svc_sendreply. 282dba7a33eSGarrett Wollman * 283dba7a33eSGarrett Wollman * Also, if the service refuses to execute the procedure due to too- 284dba7a33eSGarrett Wollman * weak authentication parameters, svcerr_weakauth should be called. 285dba7a33eSGarrett Wollman * Note: do not confuse access-control failure with weak authentication! 286dba7a33eSGarrett Wollman * 287dba7a33eSGarrett Wollman * NB: In pure implementations of rpc, the caller always waits for a reply 288dba7a33eSGarrett Wollman * msg. This message is sent when svc_sendreply is called. 289dba7a33eSGarrett Wollman * Therefore pure service implementations should always call 290dba7a33eSGarrett Wollman * svc_sendreply even if the function logically returns void; use 291dba7a33eSGarrett Wollman * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows 292dba7a33eSGarrett Wollman * for the abuse of pure rpc via batched calling or pipelining. In the 293dba7a33eSGarrett Wollman * case of a batched call, svc_sendreply should NOT be called since 294dba7a33eSGarrett Wollman * this would send a return message, which is what batching tries to avoid. 295dba7a33eSGarrett Wollman * It is the service/protocol writer's responsibility to know which calls are 296dba7a33eSGarrett Wollman * batched and which are not. Warning: responding to batch calls may 297dba7a33eSGarrett Wollman * deadlock the caller and server processes! 298dba7a33eSGarrett Wollman */ 299dba7a33eSGarrett Wollman 30086b9a9ccSGarrett Wollman __BEGIN_DECLS 301f249dbccSDag-Erling Smørgrav extern bool_t svc_sendreply(SVCXPRT *, xdrproc_t, void *); 302bb28f3c2SWarner Losh extern void svcerr_decode(SVCXPRT *); 303bb28f3c2SWarner Losh extern void svcerr_weakauth(SVCXPRT *); 304bb28f3c2SWarner Losh extern void svcerr_noproc(SVCXPRT *); 305bb28f3c2SWarner Losh extern void svcerr_progvers(SVCXPRT *, rpcvers_t, rpcvers_t); 306bb28f3c2SWarner Losh extern void svcerr_auth(SVCXPRT *, enum auth_stat); 307bb28f3c2SWarner Losh extern void svcerr_noprog(SVCXPRT *); 308bb28f3c2SWarner Losh extern void svcerr_systemerr(SVCXPRT *); 309bb28f3c2SWarner Losh extern int rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t, 310bb28f3c2SWarner Losh char *(*)(char *), xdrproc_t, xdrproc_t, 311bb28f3c2SWarner Losh char *); 31286b9a9ccSGarrett Wollman __END_DECLS 313dba7a33eSGarrett Wollman 314dba7a33eSGarrett Wollman /* 315dba7a33eSGarrett Wollman * Lowest level dispatching -OR- who owns this process anyway. 316dba7a33eSGarrett Wollman * Somebody has to wait for incoming requests and then call the correct 317dba7a33eSGarrett Wollman * service routine. The routine svc_run does infinite waiting; i.e., 318dba7a33eSGarrett Wollman * svc_run never returns. 3192f98c0baSUlrich Spörlein * Since another (co-existent) package may wish to selectively wait for 320dba7a33eSGarrett Wollman * incoming calls or other events outside of the rpc architecture, the 321dba7a33eSGarrett Wollman * routine svc_getreq is provided. It must be passed readfds, the 322dba7a33eSGarrett Wollman * "in-place" results of a select system call (see select, section 2). 323dba7a33eSGarrett Wollman */ 324dba7a33eSGarrett Wollman 325dba7a33eSGarrett Wollman /* 326dba7a33eSGarrett Wollman * Global keeper of rpc service descriptors in use 327dba7a33eSGarrett Wollman * dynamic; must be inspected before each call to select 328dba7a33eSGarrett Wollman */ 32970de0abfSPeter Wemm extern int svc_maxfd; 3308360efbdSAlfred Perlstein #ifdef FD_SETSIZE 331dba7a33eSGarrett Wollman extern fd_set svc_fdset; 332dba7a33eSGarrett Wollman #define svc_fds svc_fdset.fds_bits[0] /* compatibility */ 3338360efbdSAlfred Perlstein #else 3348360efbdSAlfred Perlstein extern int svc_fds; 3358360efbdSAlfred Perlstein #endif /* def FD_SETSIZE */ 336dba7a33eSGarrett Wollman 337dba7a33eSGarrett Wollman /* 3388f55a568SDoug Rabson * A set of null auth methods used by any authentication protocols 3398f55a568SDoug Rabson * that don't need to inspect or modify the message body. 3408f55a568SDoug Rabson */ 3418f55a568SDoug Rabson extern SVCAUTH _svc_auth_null; 3428f55a568SDoug Rabson 3438f55a568SDoug Rabson /* 344dba7a33eSGarrett Wollman * a small program implemented by the svc_rpc implementation itself; 345dba7a33eSGarrett Wollman * also see clnt.h for protocol numbers. 346dba7a33eSGarrett Wollman */ 3478360efbdSAlfred Perlstein __BEGIN_DECLS 348bb28f3c2SWarner Losh extern void rpctest_service(void); 3498360efbdSAlfred Perlstein __END_DECLS 350dba7a33eSGarrett Wollman 35186b9a9ccSGarrett Wollman __BEGIN_DECLS 3528f55a568SDoug Rabson extern SVCXPRT *svc_xprt_alloc(void); 3538f55a568SDoug Rabson extern void svc_xprt_free(SVCXPRT *); 354bb28f3c2SWarner Losh extern void svc_getreq(int); 355bb28f3c2SWarner Losh extern void svc_getreqset(fd_set *); 356bb28f3c2SWarner Losh extern void svc_getreq_common(int); 3578360efbdSAlfred Perlstein struct pollfd; 358bb28f3c2SWarner Losh extern void svc_getreq_poll(struct pollfd *, int); 3598360efbdSAlfred Perlstein 360bb28f3c2SWarner Losh extern void svc_run(void); 361bb28f3c2SWarner Losh extern void svc_exit(void); 36286b9a9ccSGarrett Wollman __END_DECLS 363dba7a33eSGarrett Wollman 364dba7a33eSGarrett Wollman /* 365dba7a33eSGarrett Wollman * Socket to use on svcxxx_create call to get default socket 366dba7a33eSGarrett Wollman */ 367dba7a33eSGarrett Wollman #define RPC_ANYSOCK -1 3688360efbdSAlfred Perlstein #define RPC_ANYFD RPC_ANYSOCK 369dba7a33eSGarrett Wollman 370dba7a33eSGarrett Wollman /* 371dba7a33eSGarrett Wollman * These are the existing service side transport implementations 372dba7a33eSGarrett Wollman */ 373dba7a33eSGarrett Wollman 37486b9a9ccSGarrett Wollman __BEGIN_DECLS 3758360efbdSAlfred Perlstein /* 3768360efbdSAlfred Perlstein * Transport independent svc_create routine. 3778360efbdSAlfred Perlstein */ 378bb28f3c2SWarner Losh extern int svc_create(void (*)(struct svc_req *, SVCXPRT *), 379bb28f3c2SWarner Losh const rpcprog_t, const rpcvers_t, const char *); 3808360efbdSAlfred Perlstein /* 381265f940aSTijl Coosemans * void (*dispatch)(struct svc_req *, SVCXPRT *); 3828360efbdSAlfred Perlstein * const rpcprog_t prognum; -- program number 3838360efbdSAlfred Perlstein * const rpcvers_t versnum; -- version number 3848360efbdSAlfred Perlstein * const char *nettype; -- network type 3858360efbdSAlfred Perlstein */ 38686b9a9ccSGarrett Wollman 387dba7a33eSGarrett Wollman 388dba7a33eSGarrett Wollman /* 3898360efbdSAlfred Perlstein * Generic server creation routine. It takes a netconfig structure 3908360efbdSAlfred Perlstein * instead of a nettype. 391dba7a33eSGarrett Wollman */ 3928360efbdSAlfred Perlstein 393bb28f3c2SWarner Losh extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *), 3948360efbdSAlfred Perlstein const rpcprog_t, const rpcvers_t, 395bb28f3c2SWarner Losh const struct netconfig *); 3968360efbdSAlfred Perlstein /* 397265f940aSTijl Coosemans * void (*dispatch)(struct svc_req *, SVCXPRT *); 3988360efbdSAlfred Perlstein * const rpcprog_t prognum; -- program number 3998360efbdSAlfred Perlstein * const rpcvers_t versnum; -- version number 4008360efbdSAlfred Perlstein * const struct netconfig *nconf; -- netconfig structure 4018360efbdSAlfred Perlstein */ 40286b9a9ccSGarrett Wollman 403dba7a33eSGarrett Wollman 404dba7a33eSGarrett Wollman /* 4058360efbdSAlfred Perlstein * Generic TLI create routine 406dba7a33eSGarrett Wollman */ 407bb28f3c2SWarner Losh extern SVCXPRT *svc_tli_create(const int, const struct netconfig *, 4088360efbdSAlfred Perlstein const struct t_bind *, const u_int, 409bb28f3c2SWarner Losh const u_int); 4108360efbdSAlfred Perlstein /* 4118360efbdSAlfred Perlstein * const int fd; -- connection end point 4128360efbdSAlfred Perlstein * const struct netconfig *nconf; -- netconfig structure for network 4138360efbdSAlfred Perlstein * const struct t_bind *bindaddr; -- local bind address 4148360efbdSAlfred Perlstein * const u_int sendsz; -- max sendsize 4158360efbdSAlfred Perlstein * const u_int recvsz; -- max recvsize 4168360efbdSAlfred Perlstein */ 417dba7a33eSGarrett Wollman 41870de0abfSPeter Wemm /* 4198360efbdSAlfred Perlstein * Connectionless and connectionful create routines 42070de0abfSPeter Wemm */ 4218360efbdSAlfred Perlstein 422bb28f3c2SWarner Losh extern SVCXPRT *svc_vc_create(const int, const u_int, const u_int); 4238360efbdSAlfred Perlstein /* 4248360efbdSAlfred Perlstein * const int fd; -- open connection end point 4258360efbdSAlfred Perlstein * const u_int sendsize; -- max send size 4268360efbdSAlfred Perlstein * const u_int recvsize; -- max recv size 4278360efbdSAlfred Perlstein */ 4288360efbdSAlfred Perlstein 429e6f9ad07SBill Paul /* 430e6f9ad07SBill Paul * Added for compatibility to old rpc 4.0. Obsoleted by svc_vc_create(). 431e6f9ad07SBill Paul */ 432bb28f3c2SWarner Losh extern SVCXPRT *svcunix_create(int, u_int, u_int, char *); 433e6f9ad07SBill Paul 434bb28f3c2SWarner Losh extern SVCXPRT *svc_dg_create(const int, const u_int, const u_int); 4358360efbdSAlfred Perlstein /* 4368360efbdSAlfred Perlstein * const int fd; -- open connection 4378360efbdSAlfred Perlstein * const u_int sendsize; -- max send size 4388360efbdSAlfred Perlstein * const u_int recvsize; -- max recv size 4398360efbdSAlfred Perlstein */ 4408360efbdSAlfred Perlstein 4418360efbdSAlfred Perlstein 4428360efbdSAlfred Perlstein /* 4438360efbdSAlfred Perlstein * the routine takes any *open* connection 4448360efbdSAlfred Perlstein * descriptor as its first input and is used for open connections. 4458360efbdSAlfred Perlstein */ 446bb28f3c2SWarner Losh extern SVCXPRT *svc_fd_create(const int, const u_int, const u_int); 4478360efbdSAlfred Perlstein /* 4488360efbdSAlfred Perlstein * const int fd; -- open connection end point 4498360efbdSAlfred Perlstein * const u_int sendsize; -- max send size 4508360efbdSAlfred Perlstein * const u_int recvsize; -- max recv size 4518360efbdSAlfred Perlstein */ 4528360efbdSAlfred Perlstein 4538360efbdSAlfred Perlstein /* 454e6f9ad07SBill Paul * Added for compatibility to old rpc 4.0. Obsoleted by svc_fd_create(). 455e6f9ad07SBill Paul */ 456bb28f3c2SWarner Losh extern SVCXPRT *svcunixfd_create(int, u_int, u_int); 457e6f9ad07SBill Paul 458e6f9ad07SBill Paul /* 459c5d671b7SGleb Smirnoff * netlink(4) server creation. To be used to service requests that 460c5d671b7SGleb Smirnoff * originate from an in-kernel client. 461c5d671b7SGleb Smirnoff */ 462c5d671b7SGleb Smirnoff extern SVCXPRT *svc_nl_create(const char *); 463c5d671b7SGleb Smirnoff 464c5d671b7SGleb Smirnoff /* 465*c62ae124SGleb Smirnoff * Arguments to SVC_CONTROL(svc_nl) 466*c62ae124SGleb Smirnoff */ 467*c62ae124SGleb Smirnoff enum { 468*c62ae124SGleb Smirnoff SVCNL_GET_XIDKEY = 1, /* obtain pthread specific key for xid */ 469*c62ae124SGleb Smirnoff }; 470*c62ae124SGleb Smirnoff 471*c62ae124SGleb Smirnoff /* 4728360efbdSAlfred Perlstein * Memory based rpc (for speed check and testing) 4738360efbdSAlfred Perlstein */ 474bb28f3c2SWarner Losh extern SVCXPRT *svc_raw_create(void); 4758360efbdSAlfred Perlstein 4768360efbdSAlfred Perlstein /* 4778360efbdSAlfred Perlstein * svc_dg_enable_cache() enables the cache on dg transports. 4788360efbdSAlfred Perlstein */ 479bb28f3c2SWarner Losh int svc_dg_enablecache(SVCXPRT *, const u_int); 4808360efbdSAlfred Perlstein 481576da326SDag-Erling Smørgrav int __rpc_get_local_uid(SVCXPRT *_transp, uid_t *_uid); 482922ed949SAlfred Perlstein 48370de0abfSPeter Wemm __END_DECLS 48470de0abfSPeter Wemm 4858360efbdSAlfred Perlstein 4868360efbdSAlfred Perlstein /* for backward compatibility */ 4878360efbdSAlfred Perlstein #include <rpc/svc_soc.h> 4888360efbdSAlfred Perlstein 48986b9a9ccSGarrett Wollman #endif /* !_RPC_SVC_H */ 490