Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/tirpc/rpc/svc.h
$ cat -n /usr/include/tirpc/rpc/svc.h 1 /* $NetBSD: svc.h,v 1.17 2000/06/02 22:57:56 fvdl Exp $ */ 2 3 /* 4 * Copyright (c) 2009, Sun Microsystems, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are met: 9 * - Redistributions of source code must retain the above copyright notice, 10 * this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions and the following disclaimer in the documentation 13 * and/or other materials provided with the distribution. 14 * - Neither the name of Sun Microsystems, Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived 16 * from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 * 30 * from: @(#)svc.h 1.35 88/12/17 SMI 31 * from: @(#)svc.h 1.27 94/04/25 SMI 32 * $FreeBSD: src/include/rpc/svc.h,v 1.24 2003/06/15 10:32:01 mbr Exp $ 33 */ 34 35 /* 36 * svc.h, Server-side remote procedure call interface. 37 * 38 * Copyright (C) 1986-1993 by Sun Microsystems, Inc. 39 */ 40 41 #ifndef _TIRPC_SVC_H 42 #define _TIRPC_SVC_H 43 44 /* 45 * This interface must manage two items concerning remote procedure calling: 46 * 47 * 1) An arbitrary number of transport connections upon which rpc requests 48 * are received. The two most notable transports are TCP and UDP; they are 49 * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; 50 * they in turn call xprt_register and xprt_unregister. 51 * 52 * 2) An arbitrary number of locally registered services. Services are 53 * described by the following four data: program number, version number, 54 * "service dispatch" function, a transport handle, and a boolean that 55 * indicates whether or not the exported program should be registered with a 56 * local binder service; if true the program's number and version and the 57 * port number from the transport handle are registered with the binder. 58 * These data are registered with the rpc svc system via svc_register. 59 * 60 * A service's dispatch function is called whenever an rpc request comes in 61 * on a transport. The request's program and version numbers must match 62 * those of the registered service. The dispatch function is passed two 63 * parameters, struct svc_req * and SVCXPRT *, defined below. 64 */ 65 66 /* 67 * Service control requests 68 */ 69 #define SVCGET_VERSQUIET 1 70 #define SVCSET_VERSQUIET 2 71 #define SVCGET_CONNMAXREC 3 72 #define SVCSET_CONNMAXREC 4 73 74 /* 75 * Operations for rpc_control(). 76 */ 77 #define RPC_SVC_CONNMAXREC_SET 0 /* set max rec size, enable nonblock */ 78 #define RPC_SVC_CONNMAXREC_GET 1 79 80 enum xprt_stat { 81 XPRT_DIED, 82 XPRT_MOREREQS, 83 XPRT_IDLE 84 }; 85 86 /* 87 * Server side transport handle 88 */ 89 typedef struct __rpc_svcxprt { 90 int xp_fd; 91 #define xp_sock xp_fd 92 u_short xp_port; /* associated port number */ 93 const struct xp_ops { 94 /* receive incoming requests */ 95 bool_t (*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *); 96 /* get transport status */ 97 enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *); 98 /* get arguments */ 99 bool_t (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t, 100 void *); 101 /* send reply */ 102 bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *); 103 /* free mem allocated for args */ 104 bool_t (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t, 105 void *); 106 /* destroy this struct */ 107 void (*xp_destroy)(struct __rpc_svcxprt *); 108 } *xp_ops; 109 int xp_addrlen; /* length of remote address */ 110 struct sockaddr_in6 xp_raddr; /* remote addr. (backward ABI compat) */ 111 /* XXX - fvdl stick this here for ABI backward compat reasons */ 112 const struct xp_ops2 { 113 /* catch-all function */ 114 bool_t (*xp_control)(struct __rpc_svcxprt *, const u_int, 115 void *); 116 } *xp_ops2; 117 char *xp_tp; /* transport provider device name */ 118 char *xp_netid; /* network token */ 119 struct netbuf xp_ltaddr; /* local transport address */ 120 struct netbuf xp_rtaddr; /* remote transport address */ 121 struct opaque_auth xp_verf; /* raw response verifier */ 122 void *xp_p1; /* private: for use by svc ops */ 123 void *xp_p2; /* private: for use by svc ops */ 124 void *xp_p3; /* private: for use by svc lib */ 125 int xp_type; /* transport type */ 126 } SVCXPRT; 127 128 /* 129 * Service request 130 */ 131 struct svc_req { 132 /* ORDER: compatibility with legacy RPC */ 133 u_int32_t rq_prog; /* service program number */ 134 u_int32_t rq_vers; /* service protocol version */ 135 u_int32_t rq_proc; /* the desired procedure */ 136 struct opaque_auth rq_cred; /* raw creds from the wire */ 137 void *rq_clntcred; /* read only cooked cred */ 138 SVCXPRT *rq_xprt; /* associated transport */ 139 140 /* New with TI-RPC */ 141 caddr_t rq_clntname; /* read only client name */ 142 caddr_t rq_svcname; /* read only cooked service cred */ 143 }; 144 145 /* 146 * Approved way of getting address of caller 147 */ 148 #define svc_getrpccaller(x) (&(x)->xp_rtaddr) 149 150 /* 151 * Operations defined on an SVCXPRT handle 152 * 153 * SVCXPRT *xprt; 154 * struct rpc_msg *msg; 155 * xdrproc_t xargs; 156 * void * argsp; 157 */ 158 #define SVC_RECV(xprt, msg) \ 159 (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) 160 #define svc_recv(xprt, msg) \ 161 (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) 162 163 #define SVC_STAT(xprt) \ 164 (*(xprt)->xp_ops->xp_stat)(xprt) 165 #define svc_stat(xprt) \ 166 (*(xprt)->xp_ops->xp_stat)(xprt) 167 168 #define SVC_GETARGS(xprt, xargs, argsp) \ 169 (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) 170 #define svc_getargs(xprt, xargs, argsp) \ 171 (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) 172 173 #define SVC_REPLY(xprt, msg) \ 174 (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) 175 #define svc_reply(xprt, msg) \ 176 (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) 177 178 #define SVC_FREEARGS(xprt, xargs, argsp) \ 179 (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) 180 #define svc_freeargs(xprt, xargs, argsp) \ 181 (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) 182 183 #define SVC_DESTROY(xprt) \ 184 (*(xprt)->xp_ops->xp_destroy)(xprt) 185 #define svc_destroy(xprt) \ 186 (*(xprt)->xp_ops->xp_destroy)(xprt) 187 188 #define SVC_CONTROL(xprt, rq, in) \ 189 (*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in)) 190 191 /* 192 * Service registration 193 * 194 * svc_reg(xprt, prog, vers, dispatch, nconf) 195 * const SVCXPRT *xprt; 196 * const rpcprog_t prog; 197 * const rpcvers_t vers; 198 * const void (*dispatch)(); 199 * const struct netconfig *nconf; 200 */ 201 202 #ifdef __cplusplus 203 extern "C" { 204 #endif 205 extern bool_t svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t, 206 void (*)(struct svc_req *, SVCXPRT *), 207 const struct netconfig *); 208 #ifdef __cplusplus 209 } 210 #endif 211 212 /* 213 * Service un-registration 214 * 215 * svc_unreg(prog, vers) 216 * const rpcprog_t prog; 217 * const rpcvers_t vers; 218 */ 219 220 #ifdef __cplusplus 221 extern "C" { 222 #endif 223 extern void svc_unreg(const rpcprog_t, const rpcvers_t); 224 #ifdef __cplusplus 225 } 226 #endif 227 228 /* 229 * Transport registration. 230 * 231 * xprt_register(xprt) 232 * SVCXPRT *xprt; 233 */ 234 #ifdef __cplusplus 235 extern "C" { 236 #endif 237 extern void xprt_register(SVCXPRT *); 238 #ifdef __cplusplus 239 } 240 #endif 241 242 /* 243 * Transport un-register 244 * 245 * xprt_unregister(xprt) 246 * SVCXPRT *xprt; 247 */ 248 #ifdef __cplusplus 249 extern "C" { 250 #endif 251 extern void xprt_unregister(SVCXPRT *); 252 #ifdef __cplusplus 253 } 254 #endif 255 256 257 /* 258 * When the service routine is called, it must first check to see if it 259 * knows about the procedure; if not, it should call svcerr_noproc 260 * and return. If so, it should deserialize its arguments via 261 * SVC_GETARGS (defined above). If the deserialization does not work, 262 * svcerr_decode should be called followed by a return. Successful 263 * decoding of the arguments should be followed the execution of the 264 * procedure's code and a call to svc_sendreply. 265 * 266 * Also, if the service refuses to execute the procedure due to too- 267 * weak authentication parameters, svcerr_weakauth should be called. 268 * Note: do not confuse access-control failure with weak authentication! 269 * 270 * NB: In pure implementations of rpc, the caller always waits for a reply 271 * msg. This message is sent when svc_sendreply is called. 272 * Therefore pure service implementations should always call 273 * svc_sendreply even if the function logically returns void; use 274 * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows 275 * for the abuse of pure rpc via batched calling or pipelining. In the 276 * case of a batched call, svc_sendreply should NOT be called since 277 * this would send a return message, which is what batching tries to avoid. 278 * It is the service/protocol writer's responsibility to know which calls are 279 * batched and which are not. Warning: responding to batch calls may 280 * deadlock the caller and server processes! 281 */ 282 283 #ifdef __cplusplus 284 extern "C" { 285 #endif 286 extern bool_t svc_sendreply(SVCXPRT *, xdrproc_t, void *); 287 extern void svcerr_decode(SVCXPRT *); 288 extern void svcerr_weakauth(SVCXPRT *); 289 extern void svcerr_noproc(SVCXPRT *); 290 extern void svcerr_progvers(SVCXPRT *, rpcvers_t, rpcvers_t); 291 extern void svcerr_auth(SVCXPRT *, enum auth_stat); 292 extern void svcerr_noprog(SVCXPRT *); 293 extern void svcerr_systemerr(SVCXPRT *); 294 extern int rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t, 295 char *(*)(char *), xdrproc_t, xdrproc_t, 296 char *); 297 #ifdef __cplusplus 298 } 299 #endif 300 301 /* 302 * Lowest level dispatching -OR- who owns this process anyway. 303 * Somebody has to wait for incoming requests and then call the correct 304 * service routine. The routine svc_run does infinite waiting; i.e., 305 * svc_run never returns. 306 * Since another (co-existant) package may wish to selectively wait for 307 * incoming calls or other events outside of the rpc architecture, the 308 * routine svc_getreq is provided. It must be passed readfds, the 309 * "in-place" results of a select system call (see select, section 2). 310 */ 311 312 /* 313 * Global keeper of rpc service descriptors in use 314 * dynamic; must be inspected before each call to select 315 */ 316 extern int svc_maxfd; 317 extern fd_set svc_fdset; 318 #define svc_fds svc_fdset.fds_bits[0] /* compatibility */ 319 extern struct pollfd *svc_pollfd; 320 extern int svc_max_pollfd; 321 322 /* 323 * a small program implemented by the svc_rpc implementation itself; 324 * also see clnt.h for protocol numbers. 325 */ 326 #ifdef __cplusplus 327 extern "C" { 328 #endif 329 extern void rpctest_service(void); 330 #ifdef __cplusplus 331 } 332 #endif 333 334 #ifdef __cplusplus 335 extern "C" { 336 #endif 337 extern void svc_getreq(int); 338 extern void svc_getreqset(fd_set *); 339 extern void svc_getreq_common(int); 340 struct pollfd; 341 extern void svc_getreq_poll(struct pollfd *, int); 342 343 extern void svc_run(void); 344 extern void svc_exit(void); 345 #ifdef __cplusplus 346 } 347 #endif 348 349 /* 350 * Socket to use on svcxxx_create call to get default socket 351 */ 352 #define RPC_ANYSOCK -1 353 #define RPC_ANYFD RPC_ANYSOCK 354 355 /* 356 * These are the existing service side transport implementations 357 */ 358 359 #ifdef __cplusplus 360 extern "C" { 361 #endif 362 /* 363 * Transport independent svc_create routine. 364 */ 365 extern int svc_create(void (*)(struct svc_req *, SVCXPRT *), 366 const rpcprog_t, const rpcvers_t, const char *); 367 /* 368 * void (*dispatch)(); -- dispatch routine 369 * const rpcprog_t prognum; -- program number 370 * const rpcvers_t versnum; -- version number 371 * const char *nettype; -- network type 372 */ 373 374 375 /* 376 * Generic server creation routine. It takes a netconfig structure 377 * instead of a nettype. 378 */ 379 380 extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *), 381 const rpcprog_t, const rpcvers_t, 382 const struct netconfig *); 383 /* 384 * void (*dispatch)(); -- dispatch routine 385 * const rpcprog_t prognum; -- program number 386 * const rpcvers_t versnum; -- version number 387 * const struct netconfig *nconf; -- netconfig structure 388 */ 389 390 391 /* 392 * Generic TLI create routine 393 */ 394 extern SVCXPRT *svc_tli_create(const int, const struct netconfig *, 395 const struct t_bind *, const u_int, 396 const u_int); 397 /* 398 * const int fd; -- connection end point 399 * const struct netconfig *nconf; -- netconfig structure for network 400 * const struct t_bind *bindaddr; -- local bind address 401 * const u_int sendsz; -- max sendsize 402 * const u_int recvsz; -- max recvsize 403 */ 404 405 /* 406 * Connectionless and connectionful create routines 407 */ 408 409 extern SVCXPRT *svc_vc_create(const int, const u_int, const u_int); 410 /* 411 * const int fd; -- open connection end point 412 * const u_int sendsize; -- max send size 413 * const u_int recvsize; -- max recv size 414 */ 415 416 /* 417 * Added for compatibility to old rpc 4.0. Obsoleted by svc_vc_create(). 418 */ 419 extern SVCXPRT *svcunix_create(int, u_int, u_int, char *); 420 421 extern SVCXPRT *svc_dg_create(const int, const u_int, const u_int); 422 /* 423 * const int fd; -- open connection 424 * const u_int sendsize; -- max send size 425 * const u_int recvsize; -- max recv size 426 */ 427 428 429 /* 430 * the routine takes any *open* connection 431 * descriptor as its first input and is used for open connections. 432 */ 433 extern SVCXPRT *svc_fd_create(const int, const u_int, const u_int); 434 /* 435 * const int fd; -- open connection end point 436 * const u_int sendsize; -- max send size 437 * const u_int recvsize; -- max recv size 438 */ 439 440 /* 441 * Added for compatibility to old rpc 4.0. Obsoleted by svc_fd_create(). 442 */ 443 extern SVCXPRT *svcunixfd_create(int, u_int, u_int); 444 445 /* 446 * Memory based rpc (for speed check and testing) 447 */ 448 extern SVCXPRT *svc_raw_create(void); 449 450 /* 451 * svc_dg_enable_cache() enables the cache on dg transports. 452 */ 453 int svc_dg_enablecache(SVCXPRT *, const u_int); 454 455 int __rpc_get_local_uid(SVCXPRT *_transp, uid_t *_uid); 456 457 #ifdef __cplusplus 458 } 459 #endif 460 461 462 /* for backward compatibility */ 463 #include
464 465 466 467 #endif /* !_TIRPC_SVC_H */
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2025 MyWebUniversity.com ™