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