Sat Jan 23 02:36:57 2016 UTC ()
Needs sys/select.h for fd_set; fails only when _POSIX_SOURCE is defined,
because then something else doesn't include it. (I guess.)


(dholland)
diff -r1.31 -r1.32 src/include/rpc/svc.h

cvs diff -r1.31 -r1.32 src/include/rpc/svc.h (switch to unified diff)

--- src/include/rpc/svc.h 2016/01/23 02:34:09 1.31
+++ src/include/rpc/svc.h 2016/01/23 02:36:57 1.32
@@ -1,449 +1,450 @@ @@ -1,449 +1,450 @@
1/* $NetBSD: svc.h,v 1.31 2016/01/23 02:34:09 dholland Exp $ */ 1/* $NetBSD: svc.h,v 1.32 2016/01/23 02:36:57 dholland Exp $ */
2 2
3/* 3/*
4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5 * unrestricted use provided that this legend is included on all tape 5 * unrestricted use provided that this legend is included on all tape
6 * media and as a part of the software program in whole or part. Users 6 * media and as a part of the software program in whole or part. Users
7 * may copy or modify Sun RPC without charge, but are not authorized 7 * may copy or modify Sun RPC without charge, but are not authorized
8 * to license or distribute it to anyone else except as part of a product or 8 * to license or distribute it to anyone else except as part of a product or
9 * program developed by the user. 9 * program developed by the user.
10 * 10 *
11 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 11 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 12 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
13 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 13 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14 * 14 *
15 * Sun RPC is provided with no support and without any obligation on the 15 * Sun RPC is provided with no support and without any obligation on the
16 * part of Sun Microsystems, Inc. to assist in its use, correction, 16 * part of Sun Microsystems, Inc. to assist in its use, correction,
17 * modification or enhancement. 17 * modification or enhancement.
18 * 18 *
19 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 19 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 20 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21 * OR ANY PART THEREOF. 21 * OR ANY PART THEREOF.
22 * 22 *
23 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 23 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24 * or profits or other special, indirect and consequential damages, even if 24 * or profits or other special, indirect and consequential damages, even if
25 * Sun has been advised of the possibility of such damages. 25 * Sun has been advised of the possibility of such damages.
26 * 26 *
27 * Sun Microsystems, Inc. 27 * Sun Microsystems, Inc.
28 * 2550 Garcia Avenue 28 * 2550 Garcia Avenue
29 * Mountain View, California 94043 29 * Mountain View, California 94043
30 * 30 *
31 * from: @(#)svc.h 1.35 88/12/17 SMI 31 * from: @(#)svc.h 1.35 88/12/17 SMI
32 * @(#)svc.h 1.27 94/04/25 SMI 32 * @(#)svc.h 1.27 94/04/25 SMI
33 */ 33 */
34 34
35/* 35/*
36 * svc.h, Server-side remote procedure call interface. 36 * svc.h, Server-side remote procedure call interface.
37 * 37 *
38 * Copyright (C) 1986-1993 by Sun Microsystems, Inc. 38 * Copyright (C) 1986-1993 by Sun Microsystems, Inc.
39 */ 39 */
40 40
41#ifndef _RPC_SVC_H_ 41#ifndef _RPC_SVC_H_
42#define _RPC_SVC_H_ 42#define _RPC_SVC_H_
43#include <sys/cdefs.h> 43#include <sys/cdefs.h>
44 44
 45#include <sys/select.h>
45#include <rpc/rpc_com.h> 46#include <rpc/rpc_com.h>
46 47
47/* 48/*
48 * This interface must manage two items concerning remote procedure calling: 49 * This interface must manage two items concerning remote procedure calling:
49 * 50 *
50 * 1) An arbitrary number of transport connections upon which rpc requests 51 * 1) An arbitrary number of transport connections upon which rpc requests
51 * are received. The two most notable transports are TCP and UDP; they are 52 * are received. The two most notable transports are TCP and UDP; they are
52 * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; 53 * created and registered by routines in svc_tcp.c and svc_udp.c, respectively;
53 * they in turn call xprt_register and xprt_unregister. 54 * they in turn call xprt_register and xprt_unregister.
54 * 55 *
55 * 2) An arbitrary number of locally registered services. Services are 56 * 2) An arbitrary number of locally registered services. Services are
56 * described by the following four data: program number, version number, 57 * described by the following four data: program number, version number,
57 * "service dispatch" function, a transport handle, and a boolean that 58 * "service dispatch" function, a transport handle, and a boolean that
58 * indicates whether or not the exported program should be registered with a 59 * indicates whether or not the exported program should be registered with a
59 * local binder service; if true the program's number and version and the 60 * local binder service; if true the program's number and version and the
60 * port number from the transport handle are registered with the binder. 61 * port number from the transport handle are registered with the binder.
61 * These data are registered with the rpc svc system via svc_register. 62 * These data are registered with the rpc svc system via svc_register.
62 * 63 *
63 * A service's dispatch function is called whenever an rpc request comes in 64 * A service's dispatch function is called whenever an rpc request comes in
64 * on a transport. The request's program and version numbers must match 65 * on a transport. The request's program and version numbers must match
65 * those of the registered service. The dispatch function is passed two 66 * those of the registered service. The dispatch function is passed two
66 * parameters, struct svc_req * and SVCXPRT *, defined below. 67 * parameters, struct svc_req * and SVCXPRT *, defined below.
67 */ 68 */
68 69
69/* 70/*
70 * Service control requests 71 * Service control requests
71 */ 72 */
72#define SVCGET_VERSQUIET 1 73#define SVCGET_VERSQUIET 1
73#define SVCSET_VERSQUIET 2 74#define SVCSET_VERSQUIET 2
74#define SVCGET_CONNMAXREC 3 75#define SVCGET_CONNMAXREC 3
75#define SVCSET_CONNMAXREC 4 76#define SVCSET_CONNMAXREC 4
76 77
77 78
78enum xprt_stat { 79enum xprt_stat {
79 XPRT_DIED, 80 XPRT_DIED,
80 XPRT_MOREREQS, 81 XPRT_MOREREQS,
81 XPRT_IDLE 82 XPRT_IDLE
82}; 83};
83 84
84/* 85/*
85 * Server side transport handle 86 * Server side transport handle
86 */ 87 */
87typedef struct __rpc_svcxprt { 88typedef struct __rpc_svcxprt {
88 int xp_fd; 89 int xp_fd;
89 unsigned short xp_port; /* associated port number */ 90 unsigned short xp_port; /* associated port number */
90 const struct xp_ops { 91 const struct xp_ops {
91 /* receive incomming requests */ 92 /* receive incomming requests */
92 bool_t (*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *); 93 bool_t (*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *);
93 /* get transport status */ 94 /* get transport status */
94 enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *); 95 enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *);
95 /* get arguments */ 96 /* get arguments */
96 bool_t (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t, 97 bool_t (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t,
97 caddr_t); 98 caddr_t);
98 /* send reply */ 99 /* send reply */
99 bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *); 100 bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *);
100 /* free mem allocated for args */ 101 /* free mem allocated for args */
101 bool_t (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t, 102 bool_t (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t,
102 caddr_t); 103 caddr_t);
103 /* destroy this struct */ 104 /* destroy this struct */
104 void (*xp_destroy)(struct __rpc_svcxprt *); 105 void (*xp_destroy)(struct __rpc_svcxprt *);
105 } *xp_ops; 106 } *xp_ops;
106 int xp_addrlen; /* length of remote address */ 107 int xp_addrlen; /* length of remote address */
107 struct sockaddr_in xp_raddr; /* rem. addr. (backward ABI compat) */ 108 struct sockaddr_in xp_raddr; /* rem. addr. (backward ABI compat) */
108 /* XXX - fvdl stick this here for ABI backward compat reasons */ 109 /* XXX - fvdl stick this here for ABI backward compat reasons */
109 const struct xp_ops2 { 110 const struct xp_ops2 {
110 /* catch-all function */ 111 /* catch-all function */
111 bool_t (*xp_control)(struct __rpc_svcxprt *, 112 bool_t (*xp_control)(struct __rpc_svcxprt *,
112 const unsigned int, void *); 113 const unsigned int, void *);
113 } *xp_ops2; 114 } *xp_ops2;
114 char *xp_tp; /* transport provider device name */ 115 char *xp_tp; /* transport provider device name */
115 char *xp_netid; /* network token */ 116 char *xp_netid; /* network token */
116 struct netbuf xp_ltaddr; /* local transport address */ 117 struct netbuf xp_ltaddr; /* local transport address */
117 struct netbuf xp_rtaddr; /* remote transport address */ 118 struct netbuf xp_rtaddr; /* remote transport address */
118 struct opaque_auth xp_verf; /* raw response verifier */ 119 struct opaque_auth xp_verf; /* raw response verifier */
119 void *xp_p1; /* private: for use by svc ops */ 120 void *xp_p1; /* private: for use by svc ops */
120 void *xp_p2; /* private: for use by svc ops */ 121 void *xp_p2; /* private: for use by svc ops */
121 void *xp_p3; /* private: for use by svc lib */ 122 void *xp_p3; /* private: for use by svc lib */
122 int xp_type; /* transport type */ 123 int xp_type; /* transport type */
123} SVCXPRT; 124} SVCXPRT;
124 125
125/* 126/*
126 * Service request 127 * Service request
127 */ 128 */
128struct svc_req { 129struct svc_req {
129 uint32_t rq_prog; /* service program number */ 130 uint32_t rq_prog; /* service program number */
130 uint32_t rq_vers; /* service protocol version */ 131 uint32_t rq_vers; /* service protocol version */
131 uint32_t rq_proc; /* the desired procedure */ 132 uint32_t rq_proc; /* the desired procedure */
132 struct opaque_auth rq_cred; /* raw creds from the wire */ 133 struct opaque_auth rq_cred; /* raw creds from the wire */
133 void *rq_clntcred; /* read only cooked cred */ 134 void *rq_clntcred; /* read only cooked cred */
134 SVCXPRT *rq_xprt; /* associated transport */ 135 SVCXPRT *rq_xprt; /* associated transport */
135}; 136};
136 137
137/* 138/*
138 * Approved way of getting address of caller 139 * Approved way of getting address of caller
139 */ 140 */
140#define svc_getrpccaller(x) (&(x)->xp_rtaddr) 141#define svc_getrpccaller(x) (&(x)->xp_rtaddr)
141 142
142/* 143/*
143 * NetBSD-only definition to get the creds of the caller (AF_LOCAL). 144 * NetBSD-only definition to get the creds of the caller (AF_LOCAL).
144 */ 145 */
145#define __svc_getcallercreds(x) ((struct sockcred *)(x)->xp_p2) 146#define __svc_getcallercreds(x) ((struct sockcred *)(x)->xp_p2)
146 147
147/* 148/*
148 * Operations defined on an SVCXPRT handle 149 * Operations defined on an SVCXPRT handle
149 * 150 *
150 * SVCXPRT *xprt; 151 * SVCXPRT *xprt;
151 * struct rpc_msg *msg; 152 * struct rpc_msg *msg;
152 * xdrproc_t xargs; 153 * xdrproc_t xargs;
153 * caddr_t argsp; 154 * caddr_t argsp;
154 */ 155 */
155#define SVC_RECV(xprt, msg) \ 156#define SVC_RECV(xprt, msg) \
156 (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) 157 (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
157#define svc_recv(xprt, msg) \ 158#define svc_recv(xprt, msg) \
158 (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) 159 (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
159 160
160#define SVC_STAT(xprt) \ 161#define SVC_STAT(xprt) \
161 (*(xprt)->xp_ops->xp_stat)(xprt) 162 (*(xprt)->xp_ops->xp_stat)(xprt)
162#define svc_stat(xprt) \ 163#define svc_stat(xprt) \
163 (*(xprt)->xp_ops->xp_stat)(xprt) 164 (*(xprt)->xp_ops->xp_stat)(xprt)
164 165
165#define SVC_GETARGS(xprt, xargs, argsp) \ 166#define SVC_GETARGS(xprt, xargs, argsp) \
166 (*(xprt)->xp_ops->xp_getargs)((xprt), ((xdrproc_t)(xargs)), (argsp)) 167 (*(xprt)->xp_ops->xp_getargs)((xprt), ((xdrproc_t)(xargs)), (argsp))
167#define svc_getargs(xprt, xargs, argsp) \ 168#define svc_getargs(xprt, xargs, argsp) \
168 (*(xprt)->xp_ops->xp_getargs)((xprt), ((xdrproc_t)(xargs)), (argsp)) 169 (*(xprt)->xp_ops->xp_getargs)((xprt), ((xdrproc_t)(xargs)), (argsp))
169 170
170#define SVC_REPLY(xprt, msg) \ 171#define SVC_REPLY(xprt, msg) \
171 (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) 172 (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
172#define svc_reply(xprt, msg) \ 173#define svc_reply(xprt, msg) \
173 (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) 174 (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
174 175
175#define SVC_FREEARGS(xprt, xargs, argsp) \ 176#define SVC_FREEARGS(xprt, xargs, argsp) \
176 (*(xprt)->xp_ops->xp_freeargs)((xprt), ((xdrproc_t)(xargs)), (argsp)) 177 (*(xprt)->xp_ops->xp_freeargs)((xprt), ((xdrproc_t)(xargs)), (argsp))
177#define svc_freeargs(xprt, xargs, argsp) \ 178#define svc_freeargs(xprt, xargs, argsp) \
178 (*(xprt)->xp_ops->xp_freeargs)((xprt), ((xdrproc_t)(xargs)), (argsp)) 179 (*(xprt)->xp_ops->xp_freeargs)((xprt), ((xdrproc_t)(xargs)), (argsp))
179 180
180#define SVC_DESTROY(xprt) \ 181#define SVC_DESTROY(xprt) \
181 (*(xprt)->xp_ops->xp_destroy)(xprt) 182 (*(xprt)->xp_ops->xp_destroy)(xprt)
182#define svc_destroy(xprt) \ 183#define svc_destroy(xprt) \
183 (*(xprt)->xp_ops->xp_destroy)(xprt) 184 (*(xprt)->xp_ops->xp_destroy)(xprt)
184 185
185#define SVC_CONTROL(xprt, rq, in) \ 186#define SVC_CONTROL(xprt, rq, in) \
186 (*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in)) 187 (*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in))
187 188
188/* 189/*
189 * Service registration 190 * Service registration
190 * 191 *
191 * svc_reg(xprt, prog, vers, dispatch, nconf) 192 * svc_reg(xprt, prog, vers, dispatch, nconf)
192 * const SVCXPRT *xprt; 193 * const SVCXPRT *xprt;
193 * const rpcprog_t prog; 194 * const rpcprog_t prog;
194 * const rpcvers_t vers; 195 * const rpcvers_t vers;
195 * const void (*dispatch)(...); 196 * const void (*dispatch)(...);
196 * const struct netconfig *nconf; 197 * const struct netconfig *nconf;
197 */ 198 */
198 199
199__BEGIN_DECLS 200__BEGIN_DECLS
200extern bool_t svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t, 201extern bool_t svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t,
201 void (*)(struct svc_req *, SVCXPRT *), 202 void (*)(struct svc_req *, SVCXPRT *),
202 const struct netconfig *); 203 const struct netconfig *);
203__END_DECLS 204__END_DECLS
204 205
205/* 206/*
206 * Service un-registration 207 * Service un-registration
207 * 208 *
208 * svc_unreg(prog, vers) 209 * svc_unreg(prog, vers)
209 * const rpcprog_t prog; 210 * const rpcprog_t prog;
210 * const rpcvers_t vers; 211 * const rpcvers_t vers;
211 */ 212 */
212 213
213__BEGIN_DECLS 214__BEGIN_DECLS
214extern void svc_unreg(const rpcprog_t, const rpcvers_t); 215extern void svc_unreg(const rpcprog_t, const rpcvers_t);
215__END_DECLS 216__END_DECLS
216 217
217/* 218/*
218 * Transport registration. 219 * Transport registration.
219 * 220 *
220 * xprt_register(xprt) 221 * xprt_register(xprt)
221 * SVCXPRT *xprt; 222 * SVCXPRT *xprt;
222 */ 223 */
223__BEGIN_DECLS 224__BEGIN_DECLS
224extern bool_t xprt_register (SVCXPRT *); 225extern bool_t xprt_register (SVCXPRT *);
225__END_DECLS 226__END_DECLS
226 227
227/* 228/*
228 * Transport un-register 229 * Transport un-register
229 * 230 *
230 * xprt_unregister(xprt) 231 * xprt_unregister(xprt)
231 * SVCXPRT *xprt; 232 * SVCXPRT *xprt;
232 */ 233 */
233__BEGIN_DECLS 234__BEGIN_DECLS
234extern void xprt_unregister (SVCXPRT *); 235extern void xprt_unregister (SVCXPRT *);
235__END_DECLS 236__END_DECLS
236 237
237 238
238/* 239/*
239 * When the service routine is called, it must first check to see if it 240 * When the service routine is called, it must first check to see if it
240 * knows about the procedure; if not, it should call svcerr_noproc 241 * knows about the procedure; if not, it should call svcerr_noproc
241 * and return. If so, it should deserialize its arguments via 242 * and return. If so, it should deserialize its arguments via
242 * SVC_GETARGS (defined above). If the deserialization does not work, 243 * SVC_GETARGS (defined above). If the deserialization does not work,
243 * svcerr_decode should be called followed by a return. Successful 244 * svcerr_decode should be called followed by a return. Successful
244 * decoding of the arguments should be followed the execution of the 245 * decoding of the arguments should be followed the execution of the
245 * procedure's code and a call to svc_sendreply. 246 * procedure's code and a call to svc_sendreply.
246 * 247 *
247 * Also, if the service refuses to execute the procedure due to too- 248 * Also, if the service refuses to execute the procedure due to too-
248 * weak authentication parameters, svcerr_weakauth should be called. 249 * weak authentication parameters, svcerr_weakauth should be called.
249 * Note: do not confuse access-control failure with weak authentication! 250 * Note: do not confuse access-control failure with weak authentication!
250 * 251 *
251 * NB: In pure implementations of rpc, the caller always waits for a reply 252 * NB: In pure implementations of rpc, the caller always waits for a reply
252 * msg. This message is sent when svc_sendreply is called. 253 * msg. This message is sent when svc_sendreply is called.
253 * Therefore pure service implementations should always call 254 * Therefore pure service implementations should always call
254 * svc_sendreply even if the function logically returns void; use 255 * svc_sendreply even if the function logically returns void; use
255 * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows 256 * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows
256 * for the abuse of pure rpc via batched calling or pipelining. In the 257 * for the abuse of pure rpc via batched calling or pipelining. In the
257 * case of a batched call, svc_sendreply should NOT be called since 258 * case of a batched call, svc_sendreply should NOT be called since
258 * this would send a return message, which is what batching tries to avoid. 259 * this would send a return message, which is what batching tries to avoid.
259 * It is the service/protocol writer's responsibility to know which calls are 260 * It is the service/protocol writer's responsibility to know which calls are
260 * batched and which are not. Warning: responding to batch calls may 261 * batched and which are not. Warning: responding to batch calls may
261 * deadlock the caller and server processes! 262 * deadlock the caller and server processes!
262 */ 263 */
263 264
264__BEGIN_DECLS 265__BEGIN_DECLS
265extern bool_t svc_sendreply (SVCXPRT *, xdrproc_t, const char *); 266extern bool_t svc_sendreply (SVCXPRT *, xdrproc_t, const char *);
266extern void svcerr_decode (SVCXPRT *); 267extern void svcerr_decode (SVCXPRT *);
267extern void svcerr_weakauth (SVCXPRT *); 268extern void svcerr_weakauth (SVCXPRT *);
268extern void svcerr_noproc (SVCXPRT *); 269extern void svcerr_noproc (SVCXPRT *);
269extern void svcerr_progvers (SVCXPRT *, rpcvers_t, rpcvers_t); 270extern void svcerr_progvers (SVCXPRT *, rpcvers_t, rpcvers_t);
270extern void svcerr_auth (SVCXPRT *, enum auth_stat); 271extern void svcerr_auth (SVCXPRT *, enum auth_stat);
271extern void svcerr_noprog (SVCXPRT *); 272extern void svcerr_noprog (SVCXPRT *);
272extern void svcerr_systemerr(SVCXPRT *); 273extern void svcerr_systemerr(SVCXPRT *);
273extern int rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t, 274extern int rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t,
274 char *(*)(char *), xdrproc_t, xdrproc_t, 275 char *(*)(char *), xdrproc_t, xdrproc_t,
275 char *); 276 char *);
276__END_DECLS 277__END_DECLS
277 278
278/* 279/*
279 * Lowest level dispatching -OR- who owns this process anyway. 280 * Lowest level dispatching -OR- who owns this process anyway.
280 * Somebody has to wait for incoming requests and then call the correct 281 * Somebody has to wait for incoming requests and then call the correct
281 * service routine. The routine svc_run does infinite waiting; i.e., 282 * service routine. The routine svc_run does infinite waiting; i.e.,
282 * svc_run never returns. 283 * svc_run never returns.
283 * Since another (co-existent) package may wish to selectively wait for 284 * Since another (co-existent) package may wish to selectively wait for
284 * incoming calls or other events outside of the rpc architecture, the 285 * incoming calls or other events outside of the rpc architecture, the
285 * routine svc_getreq is provided. It must be passed readfds, the 286 * routine svc_getreq is provided. It must be passed readfds, the
286 * "in-place" results of a select system call (see select, section 2). 287 * "in-place" results of a select system call (see select, section 2).
287 */ 288 */
288 289
289/* 290/*
290 * Global keeper of rpc service descriptors in use 291 * Global keeper of rpc service descriptors in use
291 * dynamic; must be inspected before each call to select 292 * dynamic; must be inspected before each call to select
292 */ 293 */
293#ifdef SVC_LEGACY 294#ifdef SVC_LEGACY
294extern int svc_maxfd; 295extern int svc_maxfd;
295extern fd_set svc_fdset; 296extern fd_set svc_fdset;
296#else 297#else
297#define svc_maxfd (*svc_fdset_getmax()) 298#define svc_maxfd (*svc_fdset_getmax())
298#define svc_fdset (*svc_fdset_get()) 299#define svc_fdset (*svc_fdset_get())
299#define svc_pollfd svc_pollfd_get() 300#define svc_pollfd svc_pollfd_get()
300#define svc_max_pollfd (*svc_fdset_getmax()) 301#define svc_max_pollfd (*svc_fdset_getmax())
301#endif 302#endif
302 303
303#define svc_fds svc_fdset.fds_bits[0] /* compatibility */ 304#define svc_fds svc_fdset.fds_bits[0] /* compatibility */
304 305
305/* 306/*
306 * a small program implemented by the svc_rpc implementation itself; 307 * a small program implemented by the svc_rpc implementation itself;
307 * also see clnt.h for protocol numbers. 308 * also see clnt.h for protocol numbers.
308 */ 309 */
309__BEGIN_DECLS 310__BEGIN_DECLS
310extern void rpctest_service(void); 311extern void rpctest_service(void);
311__END_DECLS 312__END_DECLS
312 313
313__BEGIN_DECLS 314__BEGIN_DECLS
314 315
315#define SVC_FDSET_MT 1 /* each thread gets own fd_set/pollfd */ 316#define SVC_FDSET_MT 1 /* each thread gets own fd_set/pollfd */
316#define SVC_FDSET_POLL 2 /* use poll in svc_run */ 317#define SVC_FDSET_POLL 2 /* use poll in svc_run */
317extern void svc_fdset_init(int); 318extern void svc_fdset_init(int);
318 319
319 320
320extern void svc_fdset_zero(void); 321extern void svc_fdset_zero(void);
321extern int svc_fdset_isset(int); 322extern int svc_fdset_isset(int);
322extern int svc_fdset_clr(int); 323extern int svc_fdset_clr(int);
323extern int svc_fdset_set(int); 324extern int svc_fdset_set(int);
324 325
325extern fd_set *svc_fdset_get(void); 326extern fd_set *svc_fdset_get(void);
326extern int svc_fdset_getsize(int); 327extern int svc_fdset_getsize(int);
327extern int *svc_fdset_getmax(void); 328extern int *svc_fdset_getmax(void);
328extern fd_set *svc_fdset_copy(const fd_set *); 329extern fd_set *svc_fdset_copy(const fd_set *);
329 330
330extern struct pollfd *svc_pollfd_get(void); 331extern struct pollfd *svc_pollfd_get(void);
331extern int svc_pollfd_getsize(int); 332extern int svc_pollfd_getsize(int);
332extern int *svc_pollfd_getmax(void); 333extern int *svc_pollfd_getmax(void);
333extern struct pollfd *svc_pollfd_copy(const struct pollfd *); 334extern struct pollfd *svc_pollfd_copy(const struct pollfd *);
334 335
335extern void svc_getreq (int); 336extern void svc_getreq (int);
336extern void svc_getreqset (fd_set *); 337extern void svc_getreqset (fd_set *);
337extern void svc_getreqset2 (fd_set *, int); 338extern void svc_getreqset2 (fd_set *, int);
338extern void svc_getreq_common (int); 339extern void svc_getreq_common (int);
339struct pollfd; 340struct pollfd;
340extern void svc_getreq_poll(struct pollfd *, int); 341extern void svc_getreq_poll(struct pollfd *, int);
341 342
342extern void svc_run (void); 343extern void svc_run (void);
343extern void svc_exit (void); 344extern void svc_exit (void);
344__END_DECLS 345__END_DECLS
345 346
346/* 347/*
347 * Socket to use on svcxxx_create call to get default socket 348 * Socket to use on svcxxx_create call to get default socket
348 */ 349 */
349#define RPC_ANYSOCK -1 350#define RPC_ANYSOCK -1
350#define RPC_ANYFD RPC_ANYSOCK 351#define RPC_ANYFD RPC_ANYSOCK
351 352
352/* 353/*
353 * These are the existing service side transport implementations 354 * These are the existing service side transport implementations
354 */ 355 */
355 356
356__BEGIN_DECLS 357__BEGIN_DECLS
357/* 358/*
358 * Transport independent svc_create routine. 359 * Transport independent svc_create routine.
359 */ 360 */
360extern int svc_create(void (*)(struct svc_req *, SVCXPRT *), 361extern int svc_create(void (*)(struct svc_req *, SVCXPRT *),
361 const rpcprog_t, const rpcvers_t, const char *); 362 const rpcprog_t, const rpcvers_t, const char *);
362/* 363/*
363 * void (*dispatch)(...); -- dispatch routine 364 * void (*dispatch)(...); -- dispatch routine
364 * const rpcprog_t prognum; -- program number 365 * const rpcprog_t prognum; -- program number
365 * const rpcvers_t versnum; -- version number 366 * const rpcvers_t versnum; -- version number
366 * const char *nettype; -- network type 367 * const char *nettype; -- network type
367 */ 368 */
368 369
369 370
370/* 371/*
371 * Generic server creation routine. It takes a netconfig structure 372 * Generic server creation routine. It takes a netconfig structure
372 * instead of a nettype. 373 * instead of a nettype.
373 */ 374 */
374 375
375extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *), 376extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *),
376 const rpcprog_t, const rpcvers_t, 377 const rpcprog_t, const rpcvers_t,
377 const struct netconfig *); 378 const struct netconfig *);
378/* 379/*
379 * void (*dispatch)(...); -- dispatch routine 380 * void (*dispatch)(...); -- dispatch routine
380 * const rpcprog_t prognum; -- program number 381 * const rpcprog_t prognum; -- program number
381 * const rpcvers_t versnum; -- version number 382 * const rpcvers_t versnum; -- version number
382 * const struct netconfig *nconf; -- netconfig structure 383 * const struct netconfig *nconf; -- netconfig structure
383 */ 384 */
384 385
385 386
386/* 387/*
387 * Generic TLI create routine 388 * Generic TLI create routine
388 */ 389 */
389extern SVCXPRT *svc_tli_create(const int, const struct netconfig *, 390extern SVCXPRT *svc_tli_create(const int, const struct netconfig *,
390 const struct t_bind *, const unsigned int, 391 const struct t_bind *, const unsigned int,
391 const unsigned int); 392 const unsigned int);
392/* 393/*
393 * const int fd; -- connection end point 394 * const int fd; -- connection end point
394 * const struct netconfig *nconf; -- netconfig structure for network 395 * const struct netconfig *nconf; -- netconfig structure for network
395 * const struct t_bind *bindaddr; -- local bind address 396 * const struct t_bind *bindaddr; -- local bind address
396 * const unsigned sendsz; -- max sendsize 397 * const unsigned sendsz; -- max sendsize
397 * const unsigned recvsz; -- max recvsize 398 * const unsigned recvsz; -- max recvsize
398 */ 399 */
399 400
400/* 401/*
401 * Connectionless and connectionful create routines 402 * Connectionless and connectionful create routines
402 */ 403 */
403 404
404extern SVCXPRT *svc_vc_create(const int, const unsigned int, 405extern SVCXPRT *svc_vc_create(const int, const unsigned int,
405 const unsigned int); 406 const unsigned int);
406/* 407/*
407 * const int fd; -- open connection end point 408 * const int fd; -- open connection end point
408 * const unsigned sendsize; -- max send size 409 * const unsigned sendsize; -- max send size
409 * const unsigned recvsize; -- max recv size 410 * const unsigned recvsize; -- max recv size
410 */ 411 */
411 412
412extern SVCXPRT *svc_dg_create(const int, const unsigned int, 413extern SVCXPRT *svc_dg_create(const int, const unsigned int,
413 const unsigned int); 414 const unsigned int);
414/* 415/*
415 * const int fd; -- open connection 416 * const int fd; -- open connection
416 * const unsigned sendsize; -- max send size 417 * const unsigned sendsize; -- max send size
417 * const unsigned recvsize; -- max recv size 418 * const unsigned recvsize; -- max recv size
418 */ 419 */
419 420
420 421
421/* 422/*
422 * the routine takes any *open* connection 423 * the routine takes any *open* connection
423 * descriptor as its first input and is used for open connections. 424 * descriptor as its first input and is used for open connections.
424 */ 425 */
425extern SVCXPRT *svc_fd_create(const int, const unsigned int, 426extern SVCXPRT *svc_fd_create(const int, const unsigned int,
426 const unsigned int); 427 const unsigned int);
427/* 428/*
428 * const int fd; -- open connection end point 429 * const int fd; -- open connection end point
429 * const unsigned sendsize; -- max send size 430 * const unsigned sendsize; -- max send size
430 * const unsigned recvsize; -- max recv size 431 * const unsigned recvsize; -- max recv size
431 */ 432 */
432 433
433/* 434/*
434 * Memory based rpc (for speed check and testing) 435 * Memory based rpc (for speed check and testing)
435 */ 436 */
436extern SVCXPRT *svc_raw_create(void); 437extern SVCXPRT *svc_raw_create(void);
437 438
438/* 439/*
439 * svc_dg_enable_cache() enables the cache on dg transports. 440 * svc_dg_enable_cache() enables the cache on dg transports.
440 */ 441 */
441int svc_dg_enablecache(SVCXPRT *, const unsigned int); 442int svc_dg_enablecache(SVCXPRT *, const unsigned int);
442 443
443__END_DECLS 444__END_DECLS
444 445
445 446
446/* for backward compatibility */ 447/* for backward compatibility */
447#include <rpc/svc_soc.h> 448#include <rpc/svc_soc.h>
448 449
449#endif /* !_RPC_SVC_H_ */ 450#endif /* !_RPC_SVC_H_ */