Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/ntirpc/rpc/svc.h
$ cat -n /usr/include/ntirpc/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 * Copyright (c) 2012-2018 Red Hat, Inc. and/or its affiliates. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are met: 10 * - Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * - Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * - Neither the name of Sun Microsystems, Inc. nor the names of its 16 * contributors may be used to endorse or promote products derived 17 * from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 * from: @(#)svc.h 1.35 88/12/17 SMI 32 * from: @(#)svc.h 1.27 94/04/25 SMI 33 * $FreeBSD: src/include/rpc/svc.h,v 1.24 2003/06/15 10:32:01 mbr Exp $ 34 */ 35 36 /* 37 * svc.h, Server-side remote procedure call interface. 38 * 39 * Copyright (C) 1986-1993 by Sun Microsystems, Inc. 40 */ 41 42 #ifndef _TIRPC_SVC_H 43 #define _TIRPC_SVC_H 44 45 #include
46 #include
47 #include
48 #include
49 #include
50 #include "reentrant.h" 51 #if defined(HAVE_BLKIN) 52 #include
53 #endif 54 #ifdef USE_LTTNG_NTIRPC 55 #include "lttng/xprt.h" 56 #endif 57 58 typedef struct svc_xprt SVCXPRT; 59 60 enum xprt_stat { 61 XPRT_IDLE = 0, 62 XPRT_MOREREQS, 63 XPRT_SUSPEND, 64 /* always last in this order for comparisons */ 65 XPRT_DIED, 66 XPRT_DESTROYED 67 }; 68 69 /* 70 * This interface must manage two items concerning remote procedure calling: 71 * 72 * 1) An arbitrary number of transport connections upon which rpc requests 73 * are received. The two most notable transports are TCP and UDP; they are 74 * created and registered by routines in svc_vc.c and svc_dg.c, respectively. 75 * 76 * 2) An arbitrary number of locally registered services. Services are 77 * described by the following four data: program number, version number, 78 * "service dispatch" function, a transport handle, and a boolean that 79 * indicates whether or not the exported program should be registered with a 80 * local binder service; if true the program's number and version and the 81 * port number from the transport handle are registered with the binder. 82 * These data are registered with the rpc svc system via svc_reg. 83 * 84 * A service's dispatch function is called whenever an rpc request comes in 85 * on a transport. The request's program and version numbers must match 86 * those of the registered service. The dispatch function is passed two 87 * parameters, struct svc_req * and SVCXPRT *, defined below. 88 */ 89 90 /* Package init flags */ 91 #define SVC_INIT_DEFAULT 0x0000 92 #define SVC_INIT_XPRTS 0x0001 93 #define SVC_INIT_EPOLL 0x0002 94 #define SVC_INIT_NOREG_XPRTS 0x0008 95 #define SVC_INIT_BLKIN 0x0010 96 97 #define SVC_SHUTDOWN_FLAG_NONE 0x0000 98 99 /* 100 * Service control requests 101 */ 102 #define SVCGET_VERSQUIET 1 103 #define SVCSET_VERSQUIET 2 104 #define SVCGET_CONNMAXREC 3 105 #define SVCSET_CONNMAXREC 4 106 #define SVCGET_XP_FLAGS 7 107 #define SVCSET_XP_FLAGS 8 108 #define SVCGET_XP_FREE_USER_DATA 15 109 #define SVCSET_XP_FREE_USER_DATA 16 110 111 /* 112 * Operations for rpc_control(). 113 */ 114 #define RPC_SVC_CONNMAXREC_SET 0 /* set max rec size, enable nonblock */ 115 #define RPC_SVC_CONNMAXREC_GET 1 116 #define RPC_SVC_XPRTS_GET 2 117 #define RPC_SVC_XPRTS_SET 3 118 #define RPC_SVC_FDSET_GET 4 119 #define RPC_SVC_FDSET_SET 5 120 121 typedef enum xprt_stat (*svc_xprt_fun_t) (SVCXPRT *); 122 typedef struct svc_req *(*svc_xprt_alloc_fun_t) (SVCXPRT *, XDR *); 123 typedef void (*svc_xprt_free_fun_t) (struct svc_req *, enum xprt_stat); 124 125 typedef struct svc_init_params { 126 svc_xprt_fun_t disconnect_cb; 127 svc_xprt_alloc_fun_t alloc_cb; 128 svc_xprt_free_fun_t free_cb; 129 130 u_long flags; 131 u_int max_connections; /* xprts */ 132 u_int max_events; /* evchan events */ 133 u_int ioq_send_max; 134 u_int ioq_thrd_max; 135 u_int ioq_thrd_min; 136 u_int gss_ctx_hash_partitions; 137 u_int gss_max_ctx; 138 u_int gss_max_idle_gen; 139 u_int gss_max_gc; 140 uint32_t channels; 141 int32_t idle_timeout; 142 } svc_init_params; 143 144 /* Svc param flags */ 145 #define SVC_FLAG_NONE 0x0000 146 #define SVC_FLAG_NOREG_XPRTS 0x0001 147 148 /* 149 * SVCXPRT xp_flags 150 */ 151 152 #define SVC_XPRT_FLAG_NONE 0x0000 153 /* uint16_t actually used */ 154 #define SVC_XPRT_FLAG_ADDED_RECV 0x0001 155 #define SVC_XPRT_FLAG_ADDED_SEND 0x0002 156 157 #define SVC_XPRT_FLAG_INITIAL 0x0004 158 #define SVC_XPRT_FLAG_INITIALIZED 0x0008 159 #define SVC_XPRT_FLAG_CLOSE 0x0010 160 #define SVC_XPRT_FLAG_DESTROYING 0x0020 /* SVC_DESTROY() was called */ 161 #define SVC_XPRT_FLAG_RELEASING 0x0040 /* (*xp_destroy) was called */ 162 #define SVC_XPRT_FLAG_UREG 0x0080 163 164 #define SVC_XPRT_FLAG_DESTROYED (SVC_XPRT_FLAG_DESTROYING \ 165 | SVC_XPRT_FLAG_RELEASING) 166 167 /* uint32_t instructions */ 168 #define SVC_XPRT_FLAG_LOCKED 0x00010000 169 #define SVC_XPRT_FLAG_UNLOCK 0x00020000 170 171 /* 172 * SVC_REF flags 173 */ 174 175 #define SVC_REF_FLAG_NONE SVC_XPRT_FLAG_NONE 176 #define SVC_REF_FLAG_LOCKED SVC_XPRT_FLAG_LOCKED 177 178 /* 179 * SVC_RELEASE flags 180 */ 181 182 #define SVC_RELEASE_FLAG_NONE SVC_XPRT_FLAG_NONE 183 #define SVC_RELEASE_FLAG_LOCKED SVC_XPRT_FLAG_LOCKED 184 185 /* Don't confuse with (currently incomplete) transport type, nee socktype. 186 */ 187 typedef enum xprt_type { 188 XPRT_UNKNOWN = 0, 189 XPRT_NON_RENDEZVOUS, 190 XPRT_UDP, 191 XPRT_UDP_RENDEZVOUS, 192 XPRT_TCP, 193 XPRT_TCP_RENDEZVOUS, 194 XPRT_SCTP, 195 XPRT_SCTP_RENDEZVOUS, 196 XPRT_RDMA, 197 XPRT_RDMA_RENDEZVOUS, 198 XPRT_VSOCK, 199 XPRT_VSOCK_RENDEZVOUS 200 } xprt_type_t; 201 202 struct SVCAUTH; /* forward decl. */ 203 struct svc_req; /* forward decl. */ 204 205 typedef enum xprt_stat (*svc_req_fun_t) (struct svc_req *); 206 207 /** 208 * Server side transport handle 209 */ 210 struct svc_xprt { 211 struct xp_ops { 212 /** receive incoming requests */ 213 svc_xprt_fun_t xp_recv; 214 215 /** get transport status */ 216 svc_xprt_fun_t xp_stat; 217 218 /** decode incoming message header (called by request_cb) */ 219 svc_req_fun_t xp_decode; 220 221 /** send reply */ 222 svc_req_fun_t xp_reply; 223 224 /** optional checksum (after authentication/decryption) */ 225 void (*xp_checksum) (struct svc_req *, void *, size_t); 226 227 /** Unlink xprt from it's lookup table. */ 228 void (*xp_unlink) (SVCXPRT *, u_int, const char *, const int); 229 /** actually destroy after xp_destroy_it and xp_release_it */ 230 void (*xp_destroy) (SVCXPRT *, u_int, const char *, const int); 231 232 /** catch-all function */ 233 bool (*xp_control) (SVCXPRT *, const u_int, void *); 234 235 /** free client user data */ 236 svc_xprt_fun_t xp_free_user_data; 237 } *xp_ops; 238 239 /* handle incoming connections (per xp_fd) */ 240 union { 241 svc_req_fun_t process_cb; 242 svc_xprt_fun_t rendezvous_cb; 243 } xp_dispatch; 244 SVCXPRT *xp_parent; 245 246 char *xp_tp; /* transport provider device name */ 247 char *xp_netid; /* network token */ 248 249 void *xp_p1; /* private: for use by svc ops */ 250 void *xp_p2; /* private: for use by svc ops */ 251 void *xp_p3; /* private: for use by svc lib */ 252 void *xp_u1; /* client user data */ 253 void *xp_u2; /* client user data */ 254 255 struct rpc_address xp_local; /* local address, length, port */ 256 struct rpc_address xp_remote; /* remote address, length, port */ 257 258 #if defined(HAVE_BLKIN) 259 /* blkin tracing */ 260 struct { 261 char *svc_name; 262 struct blkin_endpoint endp; 263 } blkin; 264 #endif 265 /* serialize private data */ 266 mutex_t xp_lock; 267 268 int xp_fd; 269 int xp_fd_send; /* Sometimes a dup of xp_fd needed for send */ 270 int xp_ifindex; /* interface index */ 271 int xp_si_type; /* si type */ 272 int xp_type; /* xprt type */ 273 274 int32_t xp_refcnt; /* handle reference count */ 275 uint16_t xp_flags; /* flags */ 276 277 union { 278 struct in_pktinfo in; 279 #ifdef INET6 280 struct in6_pktinfo in6; 281 #endif 282 } xp_pktinfo; 283 }; 284 285 /* Service record used by exported search routines */ 286 typedef struct svc_record { 287 rpcprog_t sc_prog; 288 rpcvers_t sc_vers; 289 char *sc_netid; 290 void (*sc_dispatch) (struct svc_req *); 291 } svc_rec_t; 292 293 typedef struct svc_vers_range { 294 rpcvers_t lowvers; 295 rpcvers_t highvers; 296 } svc_vers_range_t; 297 298 typedef enum svc_lookup_result { 299 SVC_LKP_SUCCESS = 0, 300 SVC_LKP_PROG_NOTFOUND = 1, 301 SVC_LKP_VERS_NOTFOUND = 2, 302 SVC_LKP_NETID_NOTFOUND = 3, 303 SVC_LKP_ERR = 667, 304 } svc_lookup_result_t; 305 306 /* 307 * Service request 308 */ 309 struct svc_req { 310 SVCXPRT *rq_xprt; /* associated transport */ 311 312 /* New with TI-RPC */ 313 char *rq_clntname; /* read only client name */ 314 char *rq_svcname; /* read only cooked service cred */ 315 316 /* New with N TI-RPC */ 317 XDR *rq_xdrs; 318 void *rq_u1; /* user data */ 319 void *rq_u2; /* user data */ 320 uint64_t rq_cksum; 321 322 /* Moved in N TI-RPC */ 323 struct SVCAUTH *rq_auth; /* auth handle */ 324 void *rq_ap1; /* auth private */ 325 void *rq_ap2; /* auth private */ 326 327 /* Handle resumed requests */ 328 svc_req_fun_t rq_resume_cb; 329 struct work_pool_entry rq_wpe; 330 331 /* avoid separate alloc/free */ 332 struct rpc_msg rq_msg; 333 334 #if defined(HAVE_BLKIN) 335 /* blkin tracing */ 336 struct blkin_trace bl_trace; 337 #endif 338 uint32_t rq_refcnt; 339 }; 340 341 /* 342 * Approved way of getting addresses 343 */ 344 #define svc_getcaller_netbuf(x) (&(x)->xp_remote.nb) 345 #define svc_getlocal_netbuf(x) (&(x)->xp_local.nb) 346 #define svc_getrpccaller(x) (&(x)->xp_remote.ss) 347 #define svc_getrpclocal(x) (&(x)->xp_local.ss) 348 349 extern void svc_resume(struct svc_req *req); 350 351 /* 352 * Ganesha. Get connected transport type. 353 */ 354 #define svc_get_xprt_type(x) ((x)->xp_type) 355 356 /* 357 * Ganesha. Original TI-RPC si type. 358 */ 359 #define svc_get_xprt_si_type(x) ((x)->xp_si_type) 360 361 /* 362 * Trace transport (de-)references, with remote address 363 */ 364 __BEGIN_DECLS 365 extern void svc_xprt_trace(SVCXPRT *, const char *, const char *, const int); 366 __END_DECLS 367 368 #define XPRT_TRACE(xprt, func, tag, line) \ 369 if (__ntirpc_pkg_params.debug_flags & TIRPC_DEBUG_FLAG_REFCNT) { \ 370 svc_xprt_trace((xprt), (func), (tag), (line)); \ 371 } 372 373 /* 374 * Operations defined on an SVCXPRT handle 375 * 376 * SVCXPRT *xprt; 377 * struct svc_req *req; 378 */ 379 #define SVC_RECV(xprt) \ 380 (*(xprt)->xp_ops->xp_recv)(xprt) 381 382 #define SVC_STAT(xprt) \ 383 (*(xprt)->xp_ops->xp_stat)(xprt) 384 385 #define SVC_DECODE(req) \ 386 (*((req)->rq_xprt)->xp_ops->xp_decode)(req) 387 388 #define SVC_REPLY(req) \ 389 (*((req)->rq_xprt)->xp_ops->xp_reply)(req) 390 391 #define SVC_CHECKSUM(req, what, length) \ 392 if (((req)->rq_xprt)->xp_ops->xp_checksum) \ 393 (*((req)->rq_xprt)->xp_ops->xp_checksum)(req, what, length) 394 395 /* Protect a SVCXPRT with SVC_REF() for each call, request, or task thread. 396 */ 397 static inline void svc_ref_it(SVCXPRT *xprt, u_int flags, 398 const char *tag, const int line) 399 { 400 #ifdef USE_LTTNG_NTIRPC 401 int32_t refs = 402 #endif /* USE_LTTNG_NTIRPC */ 403 atomic_inc_int32_t(&xprt->xp_refcnt); 404 405 if (flags & SVC_REF_FLAG_LOCKED) { 406 /* unlock before warning trace */ 407 mutex_unlock(&xprt->xp_lock); 408 } 409 XPRT_TRACE(xprt, __func__, tag, line); 410 #ifdef USE_LTTNG_NTIRPC 411 tracepoint(xprt, ref, tag, line, xprt, refs); 412 #endif /* USE_LTTNG_NTIRPC */ 413 } 414 #define SVC_REF2(xprt, flags, tag, line) \ 415 svc_ref_it(xprt, flags, tag, line) 416 #define SVC_REF(xprt, flags) \ 417 svc_ref_it(xprt, flags, __func__, __LINE__) 418 419 /* SVC_RELEASE() the SVC_REF(). 420 * Idempotent SVC_XPRT_FLAG_DESTROYED (bit SVC_XPRT_FLAG_RELEASING) 421 * indicates that more references should not be taken. 422 */ 423 static inline void svc_release_it(SVCXPRT *xprt, u_int flags, 424 const char *tag, const int line) 425 { 426 int32_t refs = atomic_dec_int32_t(&xprt->xp_refcnt); 427 uint16_t xp_flags; 428 429 if (flags & SVC_RELEASE_FLAG_LOCKED) { 430 /* unlock before warning trace */ 431 mutex_unlock(&xprt->xp_lock); 432 } 433 XPRT_TRACE(xprt, __func__, tag, line); 434 #ifdef USE_LTTNG_NTIRPC 435 tracepoint(xprt, unref, tag, line, xprt, refs); 436 #endif /* USE_LTTNG_NTIRPC */ 437 438 if (likely(refs > 0)) { 439 /* normal case */ 440 return; 441 } 442 443 /* enforce once-only semantic, trace others */ 444 xp_flags = atomic_postset_uint16_t_bits(&xprt->xp_flags, 445 SVC_XPRT_FLAG_RELEASING); 446 447 if (xp_flags & SVC_XPRT_FLAG_RELEASING) { 448 XPRT_TRACE(xprt, "WARNING! already destroying!", tag, line); 449 return; 450 } 451 452 /* Releasing last reference */ 453 (*(xprt)->xp_ops->xp_destroy)(xprt, flags, tag, line); 454 } 455 #define SVC_RELEASE2(xprt, flags, tag, line) \ 456 svc_release_it(xprt, flags, __func__, __LINE__) 457 #define SVC_RELEASE(xprt, flags) \ 458 svc_release_it(xprt, flags, __func__, __LINE__) 459 460 /* SVC_DESTROY() is SVC_RELEASE() with once-only semantics. 461 * Idempotent SVC_XPRT_FLAG_DESTROYED (bit SVC_XPRT_FLAG_DESTROYING) 462 * indicates that more references should not be taken. 463 */ 464 static inline void svc_destroy_it(SVCXPRT *xprt, 465 const char *tag, const int line) 466 { 467 uint16_t flags = atomic_postset_uint16_t_bits(&xprt->xp_flags, 468 SVC_XPRT_FLAG_DESTROYING); 469 470 XPRT_TRACE(xprt, __func__, tag, line); 471 472 #ifdef USE_LTTNG_NTIRPC 473 tracepoint(xprt, destroy, tag, line, xprt, flags); 474 #endif /* USE_LTTNG_NTIRPC */ 475 476 if (flags & SVC_XPRT_FLAG_DESTROYING) { 477 /* previously set, do nothing */ 478 return; 479 } 480 481 /* unlink before dropping last ref */ 482 (*(xprt)->xp_ops->xp_unlink)(xprt, flags, tag, line); 483 484 svc_release_it(xprt, SVC_RELEASE_FLAG_NONE, tag, line); 485 } 486 #define SVC_DESTROY(xprt) \ 487 svc_destroy_it(xprt, __func__, __LINE__) 488 489 #define SVC_CONTROL(xprt, rq, in) \ 490 (*(xprt)->xp_ops->xp_control)((xprt), (rq), (in)) 491 492 /* 493 * Service init (optional). 494 */ 495 496 __BEGIN_DECLS 497 extern struct work_pool svc_work_pool; 498 499 bool svc_init(struct svc_init_params *); 500 __END_DECLS 501 /* 502 * Service shutdown (optional). 503 */ 504 __BEGIN_DECLS 505 int svc_shutdown(u_long flags); 506 __END_DECLS 507 /* 508 * Service registration 509 * 510 * svc_reg(xprt, prog, vers, dispatch, nconf) 511 * const SVCXPRT *xprt; 512 * const rpcprog_t prog; 513 * const rpcvers_t vers; 514 * const void (*dispatch)(); 515 * const struct netconfig *nconf; 516 */ 517 __BEGIN_DECLS 518 extern bool svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t, 519 void (*)(struct svc_req *), 520 const struct netconfig *); 521 __END_DECLS 522 /* 523 * Service un-registration 524 * 525 * svc_unreg(prog, vers) 526 * const rpcprog_t prog; 527 * const rpcvers_t vers; 528 */ 529 __BEGIN_DECLS 530 extern void svc_unreg(const rpcprog_t, const rpcvers_t); 531 __END_DECLS 532 /* 533 * This is used to set local and remote addresses in a way legacy 534 * apps can deal with, at the same time setting up a corresponding 535 * netbuf -- with no alloc/free needed. 536 */ 537 __BEGIN_DECLS 538 extern u_int __rpc_address_port(struct rpc_address *); 539 extern void __rpc_address_set_length(struct rpc_address *, socklen_t); 540 541 static inline void 542 __rpc_address_setup(struct rpc_address *rpca) 543 { 544 rpca->nb.buf = &rpca->ss; 545 rpca->nb.len = 546 rpca->nb.maxlen = sizeof(struct sockaddr_storage); 547 } 548 __END_DECLS 549 /* 550 * When the service routine is called, it must first check to see if it 551 * knows about the procedure; if not, it should call svcerr_noproc 552 * and return. If so, it should deserialize its arguments via 553 * SVC_GETARGS (defined above). If the deserialization does not work, 554 * svcerr_decode should be called followed by a return. Successful 555 * decoding of the arguments should be followed the execution of the 556 * procedure's code and a call to svc_sendreply. 557 * 558 * Also, if the service refuses to execute the procedure due to too- 559 * weak authentication parameters, svcerr_weakauth should be called. 560 * Note: do not confuse access-control failure with weak authentication! 561 * 562 * NB: In pure implementations of rpc, the caller always waits for a reply 563 * msg. This message is sent when svc_sendreply is called. 564 * Therefore pure service implementations should always call 565 * svc_sendreply even if the function logically returns void; use 566 * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows 567 * for the abuse of pure rpc via batched calling or pipelining. In the 568 * case of a batched call, svc_sendreply should NOT be called since 569 * this would send a return message, which is what batching tries to avoid. 570 * It is the service/protocol writer's responsibility to know which calls are 571 * batched and which are not. Warning: responding to batch calls may 572 * deadlock the caller and server processes! 573 */ 574 __BEGIN_DECLS 575 extern enum xprt_stat svc_sendreply(struct svc_req *); 576 extern enum xprt_stat svcerr_decode(struct svc_req *); 577 extern enum xprt_stat svcerr_weakauth(struct svc_req *); 578 extern enum xprt_stat svcerr_noproc(struct svc_req *); 579 extern enum xprt_stat svcerr_progvers(struct svc_req *, rpcvers_t, rpcvers_t); 580 extern enum xprt_stat svcerr_auth(struct svc_req *, enum auth_stat); 581 extern enum xprt_stat svcerr_noprog(struct svc_req *); 582 extern enum xprt_stat svcerr_systemerr(struct svc_req *); 583 extern int rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t, char *(*)(char *), 584 xdrproc_t, xdrproc_t, char *); 585 __END_DECLS 586 /* 587 * a small program implemented by the svc_rpc implementation itself; 588 * also see clnt.h for protocol numbers. 589 */ 590 __BEGIN_DECLS 591 extern void rpctest_service(void); 592 __END_DECLS 593 /* 594 * Socket to use on svcxxx_ncreate call to get default socket 595 */ 596 #define RPC_ANYSOCK -1 597 #define RPC_ANYFD RPC_ANYSOCK 598 /* 599 * Usual sizes for svcxxx_ncreate 600 */ 601 #define RPC_MAXDATA_DEFAULT (8192) 602 #define RPC_MAXDATA_LEGACY (262144) 603 /* 604 * These are the existing service side transport implementations 605 */ 606 __BEGIN_DECLS 607 /* 608 * Transport independent svc_create routine. 609 */ 610 extern int svc_ncreate(void (*)(struct svc_req *), const rpcprog_t, 611 const rpcvers_t, const char *); 612 /* 613 * void (*dispatch)(); -- dispatch routine 614 * const rpcprog_t prognum; -- program number 615 * const rpcvers_t versnum; -- version number 616 * const char *nettype; -- network type 617 */ 618 619 /* 620 * Generic server creation routine. It takes a netconfig structure 621 * instead of a nettype. 622 */ 623 624 extern SVCXPRT *svc_tp_ncreate(void (*)(struct svc_req *), 625 const rpcprog_t, const rpcvers_t, 626 const struct netconfig *); 627 /* 628 * void (*dispatch)(); -- dispatch routine 629 * const rpcprog_t prognum; -- program number 630 * const rpcvers_t versnum; -- version number 631 * const struct netconfig *nconf; -- netconfig structure 632 */ 633 634 /* 635 * Generic TLI create routine 636 */ 637 extern SVCXPRT *svc_tli_ncreate(const int, const struct netconfig *, 638 const struct t_bind *, const u_int, 639 const u_int); 640 /* 641 * const int fd; -- connection end point 642 * const struct netconfig *nconf; -- netconfig structure for network 643 * const struct t_bind *bindaddr; -- local bind address 644 * const u_int sendsz; -- max sendsize 645 * const u_int recvsz; -- max recvsize 646 */ 647 __END_DECLS 648 649 /* 650 * Connectionless and connectionful create routines 651 */ 652 653 /* uint16_t actually used */ 654 #define SVC_CREATE_FLAG_NONE SVC_XPRT_FLAG_NONE 655 #define SVC_CREATE_FLAG_CLOSE SVC_XPRT_FLAG_CLOSE 656 657 /* uint32_t instructions */ 658 #define SVC_CREATE_FLAG_LISTEN 0x20000000 659 #define SVC_CREATE_FLAG_XPRT_DOREG 0x80000000 660 #define SVC_CREATE_FLAG_XPRT_NOREG 0x08000000 661 662 __BEGIN_DECLS 663 664 extern SVCXPRT *svc_vc_ncreatef(const int, const u_int, const u_int, 665 const uint32_t); 666 /* 667 * const int fd; -- open connection end point 668 * const u_int sendsize; -- max send size 669 * const u_int recvsize; -- max recv size 670 * const u_int flags; -- flags 671 */ 672 673 static inline SVCXPRT * 674 svc_vc_ncreate(const int fd, const u_int sendsize, const u_int recvsize) 675 { 676 return (svc_vc_ncreatef(fd, sendsize, recvsize, SVC_CREATE_FLAG_CLOSE)); 677 } 678 679 extern SVCXPRT *svc_dg_ncreatef(const int, const u_int, const u_int, 680 const uint32_t); 681 /* 682 * const int fd; -- open connection end point 683 * const u_int sendsize; -- max send size 684 * const u_int recvsize; -- max recv size 685 * const uint32_t flags; -- flags 686 */ 687 688 static inline SVCXPRT * 689 svc_dg_ncreate(const int fd, const u_int sendsize, const u_int recvsize) 690 { 691 return (svc_dg_ncreatef(fd, sendsize, recvsize, SVC_CREATE_FLAG_CLOSE)); 692 } 693 694 /* 695 * the routine takes any *open* connection 696 */ 697 extern SVCXPRT *svc_fd_ncreatef(const int, const u_int, const u_int, 698 const uint32_t); 699 /* 700 * const int fd; -- open connection end point 701 * const u_int sendsize; -- max send size 702 * const u_int recvsize; -- max recv size 703 * const uint32_t flags; -- flags 704 */ 705 706 static inline SVCXPRT * 707 svc_fd_ncreate(const int fd, const u_int sendsize, const u_int recvsize) 708 { 709 return (svc_fd_ncreatef(fd, sendsize, recvsize, SVC_CREATE_FLAG_NONE)); 710 } 711 712 /* 713 * Memory based rpc (for speed check and testing) 714 */ 715 extern SVCXPRT *svc_raw_ncreate(void); 716 717 /* 718 * RPC over RDMA 719 */ 720 struct rpc_rdma_attr { 721 char *statistics_prefix; 722 /* silly char * to pass to rdma_getaddrinfo() */ 723 char *node; /**< remote peer's hostname */ 724 char *port; /**< service port (or name) */ 725 726 u_int sq_depth; /**< depth of Send Queue */ 727 u_int max_send_sge; /**< s/g elements per send */ 728 u_int rq_depth; /**< depth of Receive Queue. */ 729 u_int max_recv_sge; /**< s/g elements per recv */ 730 731 u_int backlog; /**< connection backlog */ 732 u_int credits; /**< parallel messages */ 733 734 bool destroy_on_disconnect; /**< should perform cleanup */ 735 bool use_srq; /**< server use srq? */ 736 }; 737 738 extern SVCXPRT *rpc_rdma_ncreatef(const struct rpc_rdma_attr *, const u_int, 739 const u_int, const uint32_t); 740 /* 741 * const struct rpc_rdma_attr; -- RDMA configuration 742 * const u_int sendsize; -- max send size 743 * const u_int recvsize; -- max recv size 744 * const uint32_t flags; -- flags 745 */ 746 747 static inline SVCXPRT * 748 svc_rdma_ncreate(const struct rpc_rdma_attr *xa, const u_int sendsize, 749 const u_int recvsize) 750 { 751 return rpc_rdma_ncreatef(xa, sendsize, recvsize, SVC_CREATE_FLAG_CLOSE); 752 } 753 754 /* 755 * Convenience functions for implementing these 756 */ 757 extern bool svc_validate_xprt_list(SVCXPRT *); 758 759 int __rpc_get_local_uid(SVCXPRT *, uid_t *); 760 761 __END_DECLS 762 /* for backward compatibility */ 763 #include
764 #endif /* !_TIRPC_SVC_H */
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2025 MyWebUniversity.com ™