1 /* $NetBSD: svc.h,v 1.17 2000/06/02 22:57:56 fvdl Exp $ */ 2 3 /*- 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 * Copyright (c) 2009, Sun Microsystems, Inc. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions are met: 11 * - Redistributions of source code must retain the above copyright notice, 12 * this list of conditions and the following disclaimer. 13 * - Redistributions in binary form must reproduce the above copyright notice, 14 * this list of conditions and the following disclaimer in the documentation 15 * and/or other materials provided with the distribution. 16 * - Neither the name of Sun Microsystems, Inc. nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 /* 34 * svc.h, Server-side remote procedure call interface. 35 * 36 * Copyright (C) 1986-1993 by Sun Microsystems, Inc. 37 */ 38 39 #ifndef _RPC_SVC_H 40 #define _RPC_SVC_H 41 #include <sys/cdefs.h> 42 43 #include <sys/queue.h> 44 #include <sys/_lock.h> 45 #include <sys/_mutex.h> 46 #include <sys/_sx.h> 47 #include <sys/condvar.h> 48 #include <sys/sysctl.h> 49 50 /* 51 * This interface must manage two items concerning remote procedure calling: 52 * 53 * 1) An arbitrary number of transport connections upon which rpc requests 54 * are received. The two most notable transports are TCP and UDP; they are 55 * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; 56 * they in turn call xprt_register and xprt_unregister. 57 * 58 * 2) An arbitrary number of locally registered services. Services are 59 * described by the following four data: program number, version number, 60 * "service dispatch" function, a transport handle, and a boolean that 61 * indicates whether or not the exported program should be registered with a 62 * local binder service; if true the program's number and version and the 63 * port number from the transport handle are registered with the binder. 64 * These data are registered with the rpc svc system via svc_register. 65 * 66 * A service's dispatch function is called whenever an rpc request comes in 67 * on a transport. The request's program and version numbers must match 68 * those of the registered service. The dispatch function is passed two 69 * parameters, struct svc_req * and SVCXPRT *, defined below. 70 */ 71 72 /* 73 * Service control requests 74 */ 75 #define SVCGET_VERSQUIET 1 76 #define SVCSET_VERSQUIET 2 77 #define SVCGET_CONNMAXREC 3 78 #define SVCSET_CONNMAXREC 4 79 #define SVCSET_READDDP 5 80 81 /* 82 * Operations for rpc_control(). 83 */ 84 #define RPC_SVC_CONNMAXREC_SET 0 /* set max rec size, enable nonblock */ 85 #define RPC_SVC_CONNMAXREC_GET 1 86 87 enum xprt_stat { 88 XPRT_DIED, 89 XPRT_MOREREQS, 90 XPRT_IDLE 91 }; 92 93 struct __rpc_svcxprt; 94 struct mbuf; 95 96 struct xp_ops { 97 /* receive incoming requests */ 98 bool_t (*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *, 99 struct sockaddr **, struct mbuf **); 100 /* get transport status */ 101 enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *); 102 /* get transport acknowledge sequence */ 103 bool_t (*xp_ack)(struct __rpc_svcxprt *, uint32_t *); 104 /* send reply */ 105 bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *, 106 struct sockaddr *, struct mbuf *, uint32_t *); 107 /* destroy this struct */ 108 void (*xp_destroy)(struct __rpc_svcxprt *); 109 /* catch-all function */ 110 bool_t (*xp_control)(struct __rpc_svcxprt *, const u_int, void *); 111 }; 112 113 struct __rpc_svcpool; 114 struct __rpc_svcgroup; 115 struct __rpc_svcthread; 116 117 /* 118 * Server side transport handle. In the kernel, transports have a 119 * reference count which tracks the number of currently assigned 120 * worker threads plus one for the service pool's reference. 121 * For NFSv4.1 sessions, a reference is also held for a backchannel. 122 * xp_p2 - Points to the CLIENT structure for the RPC server end 123 * (the client end for callbacks). 124 * Points to the private structure (cl_private) for the 125 * CLIENT structure for the RPC client end (the server 126 * end for callbacks). 127 */ 128 typedef struct __rpc_svcxprt { 129 volatile u_int xp_refs; 130 struct sx xp_lock; 131 struct __rpc_svcpool *xp_pool; /* owning pool (see below) */ 132 struct __rpc_svcgroup *xp_group; /* owning group (see below) */ 133 TAILQ_ENTRY(__rpc_svcxprt) xp_link; 134 TAILQ_ENTRY(__rpc_svcxprt) xp_alink; 135 bool_t xp_registered; /* xprt_register has been called */ 136 bool_t xp_active; /* xprt_active has been called */ 137 struct __rpc_svcthread *xp_thread; /* assigned service thread */ 138 struct socket* xp_socket; 139 const struct xp_ops *xp_ops; 140 char *xp_netid; /* network token */ 141 struct sockaddr_storage xp_ltaddr; /* local transport address */ 142 struct sockaddr_storage xp_rtaddr; /* remote transport address */ 143 void *xp_p1; /* private: for use by svc ops */ 144 void *xp_p2; /* private: for use by svc ops */ 145 void *xp_p3; /* private: for use by svc lib */ 146 int xp_type; /* transport type */ 147 int xp_idletimeout; /* idle time before closing */ 148 time_t xp_lastactive; /* time of last RPC */ 149 uint64_t xp_sockref; /* set by nfsv4 to identify socket */ 150 int xp_upcallset; /* socket upcall is set up */ 151 uint32_t xp_snd_cnt; /* # of bytes to send to socket */ 152 uint32_t xp_snt_cnt; /* # of bytes sent to socket */ 153 bool_t xp_dontrcv; /* Do not receive on the socket */ 154 uint32_t xp_tls; /* RPC-over-TLS on socket */ 155 int xp_ngrps; /* Cred. from TLS cert. */ 156 uid_t xp_uid; 157 gid_t *xp_gidp; 158 int xp_doneddp; 159 bool_t xp_extpg; /* Can use M_EXTPG mbufs. */ 160 } SVCXPRT; 161 162 /* 163 * Interface to server-side authentication flavors. 164 */ 165 typedef struct __rpc_svcauth { 166 const struct svc_auth_ops { 167 int (*svc_ah_wrap)(struct __rpc_svcauth *, struct mbuf **); 168 int (*svc_ah_unwrap)(struct __rpc_svcauth *, struct mbuf **); 169 void (*svc_ah_release)(struct __rpc_svcauth *); 170 } *svc_ah_ops; 171 void *svc_ah_private; 172 } SVCAUTH; 173 174 /* 175 * Server transport extensions (accessed via xp_p3). 176 */ 177 typedef struct __rpc_svcxprt_ext { 178 int xp_flags; /* versquiet */ 179 SVCAUTH xp_auth; /* interface to auth methods */ 180 } SVCXPRT_EXT; 181 182 /* 183 * The services list 184 * Each entry represents a set of procedures (an rpc program). 185 * The dispatch routine takes request structs and runs the 186 * appropriate procedure. 187 */ 188 struct svc_callout { 189 TAILQ_ENTRY(svc_callout) sc_link; 190 rpcprog_t sc_prog; 191 rpcvers_t sc_vers; 192 char *sc_netid; 193 void (*sc_dispatch)(struct svc_req *, SVCXPRT *); 194 }; 195 TAILQ_HEAD(svc_callout_list, svc_callout); 196 197 /* 198 * The services connection loss list 199 * The dispatch routine takes request structs and runs the 200 * appropriate procedure. 201 */ 202 struct svc_loss_callout { 203 TAILQ_ENTRY(svc_loss_callout) slc_link; 204 void (*slc_dispatch)(SVCXPRT *); 205 }; 206 TAILQ_HEAD(svc_loss_callout_list, svc_loss_callout); 207 208 /* 209 * Service request 210 */ 211 struct svc_req { 212 STAILQ_ENTRY(svc_req) rq_link; /* list of requests for a thread */ 213 struct __rpc_svcthread *rq_thread; /* thread which is to execute this */ 214 uint32_t rq_xid; /* RPC transaction ID */ 215 uint32_t rq_prog; /* service program number */ 216 uint32_t rq_vers; /* service protocol version */ 217 uint32_t rq_proc; /* the desired procedure */ 218 size_t rq_size; /* space used by request */ 219 struct mbuf *rq_args; /* XDR-encoded procedure arguments */ 220 struct opaque_auth rq_cred; /* raw creds from the wire */ 221 struct opaque_auth rq_verf; /* verifier for the reply */ 222 void *rq_clntcred; /* read only cooked cred */ 223 SVCAUTH rq_auth; /* interface to auth methods */ 224 SVCXPRT *rq_xprt; /* associated transport */ 225 struct sockaddr *rq_addr; /* reply address or NULL if connected */ 226 void *rq_p1; /* application workspace */ 227 int rq_p2; /* application workspace */ 228 uint64_t rq_p3; /* application workspace */ 229 uint32_t rq_reply_seq; /* reply socket sequence # */ 230 char rq_credarea[3*MAX_AUTH_BYTES]; 231 }; 232 STAILQ_HEAD(svc_reqlist, svc_req); 233 234 #define svc_getrpccaller(rq) \ 235 ((rq)->rq_addr ? (rq)->rq_addr : \ 236 (struct sockaddr *) &(rq)->rq_xprt->xp_rtaddr) 237 238 /* 239 * This structure is used to manage a thread which is executing 240 * requests from a service pool. A service thread is in one of three 241 * states: 242 * 243 * SVCTHREAD_SLEEPING waiting for a request to process 244 * SVCTHREAD_ACTIVE processing a request 245 * SVCTHREAD_EXITING exiting after finishing current request 246 * 247 * Threads which have no work to process sleep on the pool's sp_active 248 * list. When a transport becomes active, it is assigned a service 249 * thread to read and execute pending RPCs. 250 */ 251 typedef struct __rpc_svcthread { 252 struct mtx_padalign st_lock; /* protects st_reqs field */ 253 struct __rpc_svcpool *st_pool; 254 SVCXPRT *st_xprt; /* transport we are processing */ 255 struct svc_reqlist st_reqs; /* RPC requests to execute */ 256 struct cv st_cond; /* sleeping for work */ 257 LIST_ENTRY(__rpc_svcthread) st_ilink; /* idle threads list */ 258 LIST_ENTRY(__rpc_svcthread) st_alink; /* application thread list */ 259 int st_p2; /* application workspace */ 260 uint64_t st_p3; /* application workspace */ 261 } SVCTHREAD; 262 LIST_HEAD(svcthread_list, __rpc_svcthread); 263 264 /* 265 * A thread group contain all information needed to assign subset of 266 * transports to subset of threads. On systems with many CPUs and many 267 * threads that allows to reduce lock congestion and improve performance. 268 * Hundreds of threads on dozens of CPUs sharing the single pool lock do 269 * not scale well otherwise. 270 */ 271 TAILQ_HEAD(svcxprt_list, __rpc_svcxprt); 272 enum svcpool_state { 273 SVCPOOL_INIT, /* svc_run not called yet */ 274 SVCPOOL_ACTIVE, /* normal running state */ 275 SVCPOOL_THREADWANTED, /* new service thread requested */ 276 SVCPOOL_THREADSTARTING, /* new service thread started */ 277 SVCPOOL_CLOSING /* svc_exit called */ 278 }; 279 typedef struct __rpc_svcgroup { 280 struct mtx_padalign sg_lock; /* protect the thread/req lists */ 281 struct __rpc_svcpool *sg_pool; 282 enum svcpool_state sg_state; /* current pool state */ 283 struct svcxprt_list sg_xlist; /* all transports in the group */ 284 struct svcxprt_list sg_active; /* transports needing service */ 285 struct svcthread_list sg_idlethreads; /* idle service threads */ 286 287 int sg_minthreads; /* minimum service thread count */ 288 int sg_maxthreads; /* maximum service thread count */ 289 int sg_threadcount; /* current service thread count */ 290 time_t sg_lastcreatetime; /* when we last started a thread */ 291 time_t sg_lastidlecheck; /* when we last checked idle transports */ 292 } SVCGROUP; 293 294 /* 295 * In the kernel, we can't use global variables to store lists of 296 * transports etc. since otherwise we could not have two unrelated RPC 297 * services running, each on its own thread. We solve this by 298 * importing a tiny part of a Solaris kernel concept, SVCPOOL. 299 * 300 * A service pool contains a set of transports and service callbacks 301 * for a set of related RPC services. The pool handle should be passed 302 * when creating new transports etc. Future work may include extending 303 * this to support something similar to the Solaris multi-threaded RPC 304 * server. 305 */ 306 typedef SVCTHREAD *pool_assign_fn(SVCTHREAD *, struct svc_req *); 307 typedef void pool_done_fn(SVCTHREAD *, struct svc_req *); 308 #define SVC_MAXGROUPS 16 309 typedef struct __rpc_svcpool { 310 struct mtx_padalign sp_lock; /* protect the transport lists */ 311 const char *sp_name; /* pool name (e.g. "nfsd", "NLM" */ 312 enum svcpool_state sp_state; /* current pool state */ 313 struct proc *sp_proc; /* process which is in svc_run */ 314 struct svc_callout_list sp_callouts; /* (prog,vers)->dispatch list */ 315 struct svc_loss_callout_list sp_lcallouts; /* loss->dispatch list */ 316 int sp_minthreads; /* minimum service thread count */ 317 int sp_maxthreads; /* maximum service thread count */ 318 319 /* 320 * Hooks to allow an application to control request to thread 321 * placement. 322 */ 323 pool_assign_fn *sp_assign; 324 pool_done_fn *sp_done; 325 326 /* 327 * These variables are used to put an upper bound on the 328 * amount of memory used by RPC requests which are queued 329 * waiting for execution. 330 */ 331 unsigned long sp_space_low; 332 unsigned long sp_space_high; 333 unsigned long sp_space_used; 334 unsigned long sp_space_used_highest; 335 bool_t sp_space_throttled; 336 int sp_space_throttle_count; 337 338 struct replay_cache *sp_rcache; /* optional replay cache */ 339 struct sysctl_ctx_list sp_sysctl; 340 341 int sp_groupcount; /* Number of groups in the pool. */ 342 int sp_nextgroup; /* Next group to assign port. */ 343 SVCGROUP sp_groups[SVC_MAXGROUPS]; /* Thread/port groups. */ 344 } SVCPOOL; 345 346 /* 347 * svc_rdma_listen is the function in the nfsrdma.ko module called to 348 * enable the RDMA server side listener. 349 * nfsrvd_rdma_port - The port# that RDMA should listen on for the NFS server. 350 */ 351 typedef int svc_rdma_listen_ftype(SVCPOOL *pool, int port); 352 extern svc_rdma_listen_ftype *svc_rdma_listen; 353 354 /* 355 * Operations defined on an SVCXPRT handle 356 * 357 * SVCXPRT *xprt; 358 * struct rpc_msg *msg; 359 * xdrproc_t xargs; 360 * void * argsp; 361 */ 362 #define SVC_ACQUIRE(xprt) \ 363 refcount_acquire(&(xprt)->xp_refs) 364 365 #define SVC_RELEASE(xprt) \ 366 if (refcount_release(&(xprt)->xp_refs)) \ 367 SVC_DESTROY(xprt) 368 369 #define SVC_RECV(xprt, msg, addr, args) \ 370 (*(xprt)->xp_ops->xp_recv)((xprt), (msg), (addr), (args)) 371 372 #define SVC_STAT(xprt) \ 373 (*(xprt)->xp_ops->xp_stat)(xprt) 374 375 #define SVC_ACK(xprt, ack) \ 376 ((xprt)->xp_ops->xp_ack == NULL ? FALSE : \ 377 ((ack) == NULL ? TRUE : (*(xprt)->xp_ops->xp_ack)((xprt), (ack)))) 378 379 #define SVC_REPLY(xprt, msg, addr, m, seq) \ 380 (*(xprt)->xp_ops->xp_reply) ((xprt), (msg), (addr), (m), (seq)) 381 382 #define SVC_DESTROY(xprt) \ 383 (*(xprt)->xp_ops->xp_destroy)(xprt) 384 385 #define SVC_CONTROL(xprt, rq, in) \ 386 (*(xprt)->xp_ops->xp_control)((xprt), (rq), (in)) 387 388 #define SVC_EXT(xprt) \ 389 ((SVCXPRT_EXT *) xprt->xp_p3) 390 391 #define SVC_AUTH(xprt) \ 392 (SVC_EXT(xprt)->xp_auth) 393 394 /* 395 * Operations defined on an SVCAUTH handle 396 */ 397 #define SVCAUTH_WRAP(auth, mp) \ 398 ((auth)->svc_ah_ops->svc_ah_wrap(auth, mp)) 399 #define SVCAUTH_UNWRAP(auth, mp) \ 400 ((auth)->svc_ah_ops->svc_ah_unwrap(auth, mp)) 401 #define SVCAUTH_RELEASE(auth) \ 402 ((auth)->svc_ah_ops->svc_ah_release(auth)) 403 404 /* 405 * Service registration 406 * 407 * svc_reg(xprt, prog, vers, dispatch, nconf) 408 * const SVCXPRT *xprt; 409 * const rpcprog_t prog; 410 * const rpcvers_t vers; 411 * const void (*dispatch)(); 412 * const struct netconfig *nconf; 413 */ 414 415 __BEGIN_DECLS 416 extern bool_t svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t, 417 void (*)(struct svc_req *, SVCXPRT *), 418 const struct netconfig *); 419 __END_DECLS 420 421 /* 422 * Service un-registration 423 * 424 * svc_unreg(prog, vers) 425 * const rpcprog_t prog; 426 * const rpcvers_t vers; 427 */ 428 429 __BEGIN_DECLS 430 extern void svc_unreg(SVCPOOL *, const rpcprog_t, const rpcvers_t); 431 __END_DECLS 432 433 /* 434 * Service connection loss registration 435 * 436 * svc_loss_reg(xprt, dispatch) 437 * const SVCXPRT *xprt; 438 * const void (*dispatch)(); 439 */ 440 441 __BEGIN_DECLS 442 extern bool_t svc_loss_reg(SVCXPRT *, void (*)(SVCXPRT *)); 443 __END_DECLS 444 445 /* 446 * Service connection loss un-registration 447 * 448 * svc_loss_unreg(xprt, dispatch) 449 * const SVCXPRT *xprt; 450 * const void (*dispatch)(); 451 */ 452 453 __BEGIN_DECLS 454 extern void svc_loss_unreg(SVCPOOL *, void (*)(SVCXPRT *)); 455 __END_DECLS 456 457 /* 458 * Transport registration. 459 * 460 * xprt_register(xprt) 461 * SVCXPRT *xprt; 462 */ 463 __BEGIN_DECLS 464 extern void xprt_register(SVCXPRT *); 465 __END_DECLS 466 467 /* 468 * Transport un-register 469 * 470 * xprt_unregister(xprt) 471 * SVCXPRT *xprt; 472 */ 473 __BEGIN_DECLS 474 extern void xprt_unregister(SVCXPRT *); 475 extern void __xprt_unregister_unlocked(SVCXPRT *); 476 __END_DECLS 477 478 /* 479 * Called when a transport has pending requests. 480 */ 481 __BEGIN_DECLS 482 extern void xprt_active(SVCXPRT *); 483 extern void xprt_inactive(SVCXPRT *); 484 extern void xprt_inactive_locked(SVCXPRT *); 485 extern void xprt_inactive_self(SVCXPRT *); 486 __END_DECLS 487 488 /* 489 * When the service routine is called, it must first check to see if it 490 * knows about the procedure; if not, it should call svcerr_noproc 491 * and return. If so, it should deserialize its arguments via 492 * SVC_GETARGS (defined above). If the deserialization does not work, 493 * svcerr_decode should be called followed by a return. Successful 494 * decoding of the arguments should be followed the execution of the 495 * procedure's code and a call to svc_sendreply. 496 * 497 * Also, if the service refuses to execute the procedure due to too- 498 * weak authentication parameters, svcerr_weakauth should be called. 499 * Note: do not confuse access-control failure with weak authentication! 500 * 501 * NB: In pure implementations of rpc, the caller always waits for a reply 502 * msg. This message is sent when svc_sendreply is called. 503 * Therefore pure service implementations should always call 504 * svc_sendreply even if the function logically returns void; use 505 * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows 506 * for the abuse of pure rpc via batched calling or pipelining. In the 507 * case of a batched call, svc_sendreply should NOT be called since 508 * this would send a return message, which is what batching tries to avoid. 509 * It is the service/protocol writer's responsibility to know which calls are 510 * batched and which are not. Warning: responding to batch calls may 511 * deadlock the caller and server processes! 512 */ 513 514 __BEGIN_DECLS 515 extern bool_t svc_sendreply(struct svc_req *, xdrproc_t, void *); 516 extern bool_t svc_sendreply_mbuf(struct svc_req *, struct mbuf *); 517 extern void svcerr_decode(struct svc_req *); 518 extern void svcerr_weakauth(struct svc_req *); 519 extern void svcerr_noproc(struct svc_req *); 520 extern void svcerr_progvers(struct svc_req *, rpcvers_t, rpcvers_t); 521 extern void svcerr_auth(struct svc_req *, enum auth_stat); 522 extern void svcerr_noprog(struct svc_req *); 523 extern void svcerr_systemerr(struct svc_req *); 524 extern int rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t, 525 char *(*)(char *), xdrproc_t, xdrproc_t, 526 char *); 527 __END_DECLS 528 529 /* 530 * Lowest level dispatching -OR- who owns this process anyway. 531 * Somebody has to wait for incoming requests and then call the correct 532 * service routine. The routine svc_run does infinite waiting; i.e., 533 * svc_run never returns. 534 * Since another (co-existent) package may wish to selectively wait for 535 * incoming calls or other events outside of the rpc architecture, the 536 * routine svc_getreq is provided. It must be passed readfds, the 537 * "in-place" results of a select system call (see select, section 2). 538 */ 539 540 /* 541 * a small program implemented by the svc_rpc implementation itself; 542 * also see clnt.h for protocol numbers. 543 */ 544 __BEGIN_DECLS 545 extern void rpctest_service(void); 546 __END_DECLS 547 548 __BEGIN_DECLS 549 extern SVCXPRT *svc_xprt_alloc(void); 550 extern void svc_xprt_free(SVCXPRT *); 551 extern void svc_run(SVCPOOL *); 552 extern void svc_exit(SVCPOOL *); 553 extern bool_t svc_getargs(struct svc_req *, xdrproc_t, void *); 554 extern bool_t svc_freeargs(struct svc_req *, xdrproc_t, void *); 555 extern void svc_freereq(struct svc_req *); 556 __END_DECLS 557 558 /* 559 * Socket to use on svcxxx_create call to get default socket 560 */ 561 #define RPC_ANYSOCK -1 562 #define RPC_ANYFD RPC_ANYSOCK 563 564 /* 565 * These are the existing service side transport implementations 566 */ 567 568 __BEGIN_DECLS 569 570 /* 571 * Create a new service pool. 572 */ 573 extern SVCPOOL* svcpool_create(const char *name, 574 struct sysctl_oid_list *sysctl_base); 575 576 /* 577 * Destroy a service pool, including all registered transports. 578 */ 579 extern void svcpool_destroy(SVCPOOL *pool); 580 581 /* 582 * Close a service pool. Similar to svcpool_destroy(), but it does not 583 * free the data structures. As such, the pool can be used again. 584 */ 585 extern void svcpool_close(SVCPOOL *pool); 586 587 /* 588 * Generic server creation routine. It takes a netconfig structure 589 * instead of a nettype. 590 */ 591 592 extern SVCXPRT *svc_tp_create(SVCPOOL *, void (*)(struct svc_req *, SVCXPRT *), 593 const rpcprog_t, const rpcvers_t, const char *uaddr, 594 const struct netconfig *); 595 /* 596 * void (*dispatch)(); -- dispatch routine 597 * const rpcprog_t prognum; -- program number 598 * const rpcvers_t versnum; -- version number 599 * const char *uaddr; -- universal address of service 600 * const struct netconfig *nconf; -- netconfig structure 601 */ 602 603 extern SVCXPRT *svc_dg_create(SVCPOOL *, struct socket *, 604 const size_t, const size_t); 605 /* 606 * struct socket *; -- open connection 607 * const size_t sendsize; -- max send size 608 * const size_t recvsize; -- max recv size 609 */ 610 611 extern SVCXPRT *svc_vc_create(SVCPOOL *, struct socket *, 612 const size_t, const size_t); 613 /* 614 * struct socket *; -- open connection 615 * const size_t sendsize; -- max send size 616 * const size_t recvsize; -- max recv size 617 */ 618 619 extern SVCXPRT *svc_vc_create_backchannel(SVCPOOL *); 620 621 extern void *clnt_bck_create(struct socket *, const rpcprog_t, const rpcvers_t); 622 /* 623 * struct socket *; -- server transport socket 624 * const rpcprog_t prog; -- RPC program number 625 * const rpcvers_t vers; -- RPC program version 626 */ 627 628 /* 629 * Generic TLI create routine 630 */ 631 extern SVCXPRT *svc_tli_create(SVCPOOL *, const struct netconfig *, 632 const struct t_bind *, const size_t, const size_t); 633 /* 634 * const struct netconfig *nconf; -- netconfig structure for network 635 * const struct t_bind *bindaddr; -- local bind address 636 * const size_t sendsz; -- max sendsize 637 * const size_t recvsz; -- max recvsize 638 */ 639 __END_DECLS 640 641 #endif /* !_RPC_SVC_H */ 642