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 extern int nfsrvd_rdma_port; 354 extern int newnfs_numnfsd; 355 356 /* 357 * Operations defined on an SVCXPRT handle 358 * 359 * SVCXPRT *xprt; 360 * struct rpc_msg *msg; 361 * xdrproc_t xargs; 362 * void * argsp; 363 */ 364 #define SVC_ACQUIRE(xprt) \ 365 refcount_acquire(&(xprt)->xp_refs) 366 367 #define SVC_RELEASE(xprt) \ 368 if (refcount_release(&(xprt)->xp_refs)) \ 369 SVC_DESTROY(xprt) 370 371 #define SVC_RECV(xprt, msg, addr, args) \ 372 (*(xprt)->xp_ops->xp_recv)((xprt), (msg), (addr), (args)) 373 374 #define SVC_STAT(xprt) \ 375 (*(xprt)->xp_ops->xp_stat)(xprt) 376 377 #define SVC_ACK(xprt, ack) \ 378 ((xprt)->xp_ops->xp_ack == NULL ? FALSE : \ 379 ((ack) == NULL ? TRUE : (*(xprt)->xp_ops->xp_ack)((xprt), (ack)))) 380 381 #define SVC_REPLY(xprt, msg, addr, m, seq) \ 382 (*(xprt)->xp_ops->xp_reply) ((xprt), (msg), (addr), (m), (seq)) 383 384 #define SVC_DESTROY(xprt) \ 385 (*(xprt)->xp_ops->xp_destroy)(xprt) 386 387 #define SVC_CONTROL(xprt, rq, in) \ 388 (*(xprt)->xp_ops->xp_control)((xprt), (rq), (in)) 389 390 #define SVC_EXT(xprt) \ 391 ((SVCXPRT_EXT *) xprt->xp_p3) 392 393 #define SVC_AUTH(xprt) \ 394 (SVC_EXT(xprt)->xp_auth) 395 396 /* 397 * Operations defined on an SVCAUTH handle 398 */ 399 #define SVCAUTH_WRAP(auth, mp) \ 400 ((auth)->svc_ah_ops->svc_ah_wrap(auth, mp)) 401 #define SVCAUTH_UNWRAP(auth, mp) \ 402 ((auth)->svc_ah_ops->svc_ah_unwrap(auth, mp)) 403 #define SVCAUTH_RELEASE(auth) \ 404 ((auth)->svc_ah_ops->svc_ah_release(auth)) 405 406 /* 407 * Service registration 408 * 409 * svc_reg(xprt, prog, vers, dispatch, nconf) 410 * const SVCXPRT *xprt; 411 * const rpcprog_t prog; 412 * const rpcvers_t vers; 413 * const void (*dispatch)(); 414 * const struct netconfig *nconf; 415 */ 416 417 __BEGIN_DECLS 418 extern bool_t svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t, 419 void (*)(struct svc_req *, SVCXPRT *), 420 const struct netconfig *); 421 __END_DECLS 422 423 /* 424 * Service un-registration 425 * 426 * svc_unreg(prog, vers) 427 * const rpcprog_t prog; 428 * const rpcvers_t vers; 429 */ 430 431 __BEGIN_DECLS 432 extern void svc_unreg(SVCPOOL *, const rpcprog_t, const rpcvers_t); 433 __END_DECLS 434 435 /* 436 * Service connection loss registration 437 * 438 * svc_loss_reg(xprt, dispatch) 439 * const SVCXPRT *xprt; 440 * const void (*dispatch)(); 441 */ 442 443 __BEGIN_DECLS 444 extern bool_t svc_loss_reg(SVCXPRT *, void (*)(SVCXPRT *)); 445 __END_DECLS 446 447 /* 448 * Service connection loss un-registration 449 * 450 * svc_loss_unreg(xprt, dispatch) 451 * const SVCXPRT *xprt; 452 * const void (*dispatch)(); 453 */ 454 455 __BEGIN_DECLS 456 extern void svc_loss_unreg(SVCPOOL *, void (*)(SVCXPRT *)); 457 __END_DECLS 458 459 /* 460 * Transport registration. 461 * 462 * xprt_register(xprt) 463 * SVCXPRT *xprt; 464 */ 465 __BEGIN_DECLS 466 extern void xprt_register(SVCXPRT *); 467 __END_DECLS 468 469 /* 470 * Transport un-register 471 * 472 * xprt_unregister(xprt) 473 * SVCXPRT *xprt; 474 */ 475 __BEGIN_DECLS 476 extern void xprt_unregister(SVCXPRT *); 477 extern void __xprt_unregister_unlocked(SVCXPRT *); 478 __END_DECLS 479 480 /* 481 * Called when a transport has pending requests. 482 */ 483 __BEGIN_DECLS 484 extern void xprt_active(SVCXPRT *); 485 extern void xprt_inactive(SVCXPRT *); 486 extern void xprt_inactive_locked(SVCXPRT *); 487 extern void xprt_inactive_self(SVCXPRT *); 488 __END_DECLS 489 490 /* 491 * When the service routine is called, it must first check to see if it 492 * knows about the procedure; if not, it should call svcerr_noproc 493 * and return. If so, it should deserialize its arguments via 494 * SVC_GETARGS (defined above). If the deserialization does not work, 495 * svcerr_decode should be called followed by a return. Successful 496 * decoding of the arguments should be followed the execution of the 497 * procedure's code and a call to svc_sendreply. 498 * 499 * Also, if the service refuses to execute the procedure due to too- 500 * weak authentication parameters, svcerr_weakauth should be called. 501 * Note: do not confuse access-control failure with weak authentication! 502 * 503 * NB: In pure implementations of rpc, the caller always waits for a reply 504 * msg. This message is sent when svc_sendreply is called. 505 * Therefore pure service implementations should always call 506 * svc_sendreply even if the function logically returns void; use 507 * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows 508 * for the abuse of pure rpc via batched calling or pipelining. In the 509 * case of a batched call, svc_sendreply should NOT be called since 510 * this would send a return message, which is what batching tries to avoid. 511 * It is the service/protocol writer's responsibility to know which calls are 512 * batched and which are not. Warning: responding to batch calls may 513 * deadlock the caller and server processes! 514 */ 515 516 __BEGIN_DECLS 517 extern bool_t svc_sendreply(struct svc_req *, xdrproc_t, void *); 518 extern bool_t svc_sendreply_mbuf(struct svc_req *, struct mbuf *); 519 extern void svcerr_decode(struct svc_req *); 520 extern void svcerr_weakauth(struct svc_req *); 521 extern void svcerr_noproc(struct svc_req *); 522 extern void svcerr_progvers(struct svc_req *, rpcvers_t, rpcvers_t); 523 extern void svcerr_auth(struct svc_req *, enum auth_stat); 524 extern void svcerr_noprog(struct svc_req *); 525 extern void svcerr_systemerr(struct svc_req *); 526 extern int rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t, 527 char *(*)(char *), xdrproc_t, xdrproc_t, 528 char *); 529 __END_DECLS 530 531 /* 532 * Lowest level dispatching -OR- who owns this process anyway. 533 * Somebody has to wait for incoming requests and then call the correct 534 * service routine. The routine svc_run does infinite waiting; i.e., 535 * svc_run never returns. 536 * Since another (co-existent) package may wish to selectively wait for 537 * incoming calls or other events outside of the rpc architecture, the 538 * routine svc_getreq is provided. It must be passed readfds, the 539 * "in-place" results of a select system call (see select, section 2). 540 */ 541 542 /* 543 * a small program implemented by the svc_rpc implementation itself; 544 * also see clnt.h for protocol numbers. 545 */ 546 __BEGIN_DECLS 547 extern void rpctest_service(void); 548 __END_DECLS 549 550 __BEGIN_DECLS 551 extern SVCXPRT *svc_xprt_alloc(void); 552 extern void svc_xprt_free(SVCXPRT *); 553 extern void svc_run(SVCPOOL *); 554 extern void svc_exit(SVCPOOL *); 555 extern bool_t svc_getargs(struct svc_req *, xdrproc_t, void *); 556 extern bool_t svc_freeargs(struct svc_req *, xdrproc_t, void *); 557 extern void svc_freereq(struct svc_req *); 558 __END_DECLS 559 560 /* 561 * Socket to use on svcxxx_create call to get default socket 562 */ 563 #define RPC_ANYSOCK -1 564 #define RPC_ANYFD RPC_ANYSOCK 565 566 /* 567 * These are the existing service side transport implementations 568 */ 569 570 __BEGIN_DECLS 571 572 /* 573 * Create a new service pool. 574 */ 575 extern SVCPOOL* svcpool_create(const char *name, 576 struct sysctl_oid_list *sysctl_base); 577 578 /* 579 * Destroy a service pool, including all registered transports. 580 */ 581 extern void svcpool_destroy(SVCPOOL *pool); 582 583 /* 584 * Close a service pool. Similar to svcpool_destroy(), but it does not 585 * free the data structures. As such, the pool can be used again. 586 */ 587 extern void svcpool_close(SVCPOOL *pool); 588 589 /* 590 * Generic server creation routine. It takes a netconfig structure 591 * instead of a nettype. 592 */ 593 594 extern SVCXPRT *svc_tp_create(SVCPOOL *, void (*)(struct svc_req *, SVCXPRT *), 595 const rpcprog_t, const rpcvers_t, const char *uaddr, 596 const struct netconfig *); 597 /* 598 * void (*dispatch)(); -- dispatch routine 599 * const rpcprog_t prognum; -- program number 600 * const rpcvers_t versnum; -- version number 601 * const char *uaddr; -- universal address of service 602 * const struct netconfig *nconf; -- netconfig structure 603 */ 604 605 extern SVCXPRT *svc_dg_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(SVCPOOL *, struct socket *, 614 const size_t, const size_t); 615 /* 616 * struct socket *; -- open connection 617 * const size_t sendsize; -- max send size 618 * const size_t recvsize; -- max recv size 619 */ 620 621 extern SVCXPRT *svc_vc_create_backchannel(SVCPOOL *); 622 623 extern void *clnt_bck_create(struct socket *, const rpcprog_t, const rpcvers_t); 624 /* 625 * struct socket *; -- server transport socket 626 * const rpcprog_t prog; -- RPC program number 627 * const rpcvers_t vers; -- RPC program version 628 */ 629 630 /* 631 * Generic TLI create routine 632 */ 633 extern SVCXPRT *svc_tli_create(SVCPOOL *, const struct netconfig *, 634 const struct t_bind *, const size_t, const size_t); 635 /* 636 * const struct netconfig *nconf; -- netconfig structure for network 637 * const struct t_bind *bindaddr; -- local bind address 638 * const size_t sendsz; -- max sendsize 639 * const size_t recvsz; -- max recvsize 640 */ 641 __END_DECLS 642 643 #endif /* !_RPC_SVC_H */ 644