1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 27*0Sstevel@tonic-gate /* All Rights Reserved */ 28*0Sstevel@tonic-gate /* 29*0Sstevel@tonic-gate * Portions of this source code were derived from Berkeley 30*0Sstevel@tonic-gate * 4.3 BSD under license from the Regents of the University of 31*0Sstevel@tonic-gate * California. 32*0Sstevel@tonic-gate */ 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate /* 35*0Sstevel@tonic-gate * svc.h, Server-side remote procedure call interface. 36*0Sstevel@tonic-gate */ 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate #ifndef _RPC_SVC_H 39*0Sstevel@tonic-gate #define _RPC_SVC_H 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate #include <rpc/rpc_com.h> 44*0Sstevel@tonic-gate #include <rpc/rpc_msg.h> 45*0Sstevel@tonic-gate #include <sys/tihdr.h> 46*0Sstevel@tonic-gate #include <sys/poll.h> 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gate #ifdef _KERNEL 49*0Sstevel@tonic-gate #include <rpc/svc_auth.h> 50*0Sstevel@tonic-gate #include <sys/callb.h> 51*0Sstevel@tonic-gate #endif /* _KERNEL */ 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate /* 54*0Sstevel@tonic-gate * This interface must manage two items concerning remote procedure calling: 55*0Sstevel@tonic-gate * 56*0Sstevel@tonic-gate * 1) An arbitrary number of transport connections upon which rpc requests 57*0Sstevel@tonic-gate * are received. They are created and registered by routines in svc_generic.c, 58*0Sstevel@tonic-gate * svc_vc.c and svc_dg.c; they in turn call xprt_register and 59*0Sstevel@tonic-gate * xprt_unregister. 60*0Sstevel@tonic-gate * 61*0Sstevel@tonic-gate * 2) An arbitrary number of locally registered services. Services are 62*0Sstevel@tonic-gate * described by the following four data: program number, version number, 63*0Sstevel@tonic-gate * "service dispatch" function, a transport handle, and a boolean that 64*0Sstevel@tonic-gate * indicates whether or not the exported program should be registered with a 65*0Sstevel@tonic-gate * local binder service; if true the program's number and version and the 66*0Sstevel@tonic-gate * address from the transport handle are registered with the binder. 67*0Sstevel@tonic-gate * These data are registered with rpcbind via svc_reg(). 68*0Sstevel@tonic-gate * 69*0Sstevel@tonic-gate * A service's dispatch function is called whenever an rpc request comes in 70*0Sstevel@tonic-gate * on a transport. The request's program and version numbers must match 71*0Sstevel@tonic-gate * those of the registered service. The dispatch function is passed two 72*0Sstevel@tonic-gate * parameters, struct svc_req * and SVCXPRT *, defined below. 73*0Sstevel@tonic-gate */ 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate #ifdef __cplusplus 76*0Sstevel@tonic-gate extern "C" { 77*0Sstevel@tonic-gate #endif 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate /* 80*0Sstevel@tonic-gate * Server-side transport handles. 81*0Sstevel@tonic-gate * The actual type definitions are below. 82*0Sstevel@tonic-gate */ 83*0Sstevel@tonic-gate #ifdef _KERNEL 84*0Sstevel@tonic-gate typedef struct __svcmasterxprt SVCMASTERXPRT; /* Master transport handle */ 85*0Sstevel@tonic-gate typedef struct __svcxprt SVCXPRT; /* Per-thread clone handle */ 86*0Sstevel@tonic-gate typedef struct __svcpool SVCPOOL; /* Kernel thread pool */ 87*0Sstevel@tonic-gate #else /* _KERNEL */ 88*0Sstevel@tonic-gate typedef struct __svcxprt SVCXPRT; /* Server transport handle */ 89*0Sstevel@tonic-gate #endif /* _KERNEL */ 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate /* 92*0Sstevel@tonic-gate * Prototype of error handler callback 93*0Sstevel@tonic-gate */ 94*0Sstevel@tonic-gate #ifndef _KERNEL 95*0Sstevel@tonic-gate typedef void (*svc_errorhandler_t)(const SVCXPRT* svc, const bool_t isAConn); 96*0Sstevel@tonic-gate #endif 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate /* 99*0Sstevel@tonic-gate * Service request. 100*0Sstevel@tonic-gate * 101*0Sstevel@tonic-gate * PSARC 2003/523 Contract Private Interface 102*0Sstevel@tonic-gate * svc_req 103*0Sstevel@tonic-gate * Changes must be reviewed by Solaris File Sharing 104*0Sstevel@tonic-gate * Changes must be communicated to contract-2003-523@sun.com 105*0Sstevel@tonic-gate */ 106*0Sstevel@tonic-gate struct svc_req { 107*0Sstevel@tonic-gate rpcprog_t rq_prog; /* service program number */ 108*0Sstevel@tonic-gate rpcvers_t rq_vers; /* service protocol version */ 109*0Sstevel@tonic-gate rpcproc_t rq_proc; /* the desired procedure */ 110*0Sstevel@tonic-gate struct opaque_auth rq_cred; /* raw creds from the wire */ 111*0Sstevel@tonic-gate caddr_t rq_clntcred; /* read only cooked cred */ 112*0Sstevel@tonic-gate SVCXPRT *rq_xprt; /* associated transport */ 113*0Sstevel@tonic-gate }; 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate #ifdef _KERNEL 116*0Sstevel@tonic-gate struct dupreq { 117*0Sstevel@tonic-gate uint32_t dr_xid; 118*0Sstevel@tonic-gate rpcproc_t dr_proc; 119*0Sstevel@tonic-gate rpcvers_t dr_vers; 120*0Sstevel@tonic-gate rpcprog_t dr_prog; 121*0Sstevel@tonic-gate struct netbuf dr_addr; 122*0Sstevel@tonic-gate struct netbuf dr_resp; 123*0Sstevel@tonic-gate void (*dr_resfree)(); 124*0Sstevel@tonic-gate int dr_status; 125*0Sstevel@tonic-gate struct dupreq *dr_next; 126*0Sstevel@tonic-gate struct dupreq *dr_chain; 127*0Sstevel@tonic-gate }; 128*0Sstevel@tonic-gate 129*0Sstevel@tonic-gate /* 130*0Sstevel@tonic-gate * States of requests for duplicate request caching. 131*0Sstevel@tonic-gate */ 132*0Sstevel@tonic-gate #define DUP_NEW 0x00 /* new entry */ 133*0Sstevel@tonic-gate #define DUP_INPROGRESS 0x01 /* request already going */ 134*0Sstevel@tonic-gate #define DUP_DONE 0x02 /* request done */ 135*0Sstevel@tonic-gate #define DUP_DROP 0x03 /* request dropped */ 136*0Sstevel@tonic-gate #define DUP_ERROR 0x04 /* error in dup req cache */ 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate /* 139*0Sstevel@tonic-gate * Prototype for a service dispatch routine. 140*0Sstevel@tonic-gate */ 141*0Sstevel@tonic-gate typedef void (SVC_DISPATCH)(struct svc_req *, SVCXPRT *); 142*0Sstevel@tonic-gate 143*0Sstevel@tonic-gate /* 144*0Sstevel@tonic-gate * The service provider callout. 145*0Sstevel@tonic-gate * Each entry identifies a dispatch routine to be called 146*0Sstevel@tonic-gate * for a given RPC program number and a version fitting 147*0Sstevel@tonic-gate * into the registered range. 148*0Sstevel@tonic-gate */ 149*0Sstevel@tonic-gate typedef struct { 150*0Sstevel@tonic-gate rpcprog_t sc_prog; /* RPC Program number */ 151*0Sstevel@tonic-gate rpcvers_t sc_versmin; /* Min version number */ 152*0Sstevel@tonic-gate rpcvers_t sc_versmax; /* Max version number */ 153*0Sstevel@tonic-gate SVC_DISPATCH *sc_dispatch; /* Dispatch routine */ 154*0Sstevel@tonic-gate } SVC_CALLOUT; 155*0Sstevel@tonic-gate 156*0Sstevel@tonic-gate /* 157*0Sstevel@tonic-gate * Table of service provider `callouts' for an RPC 158*0Sstevel@tonic-gate * transport handle. If sct_free is TRUE then transport 159*0Sstevel@tonic-gate * destructor is supposed to deallocate this table. 160*0Sstevel@tonic-gate */ 161*0Sstevel@tonic-gate typedef struct { 162*0Sstevel@tonic-gate size_t sct_size; /* Number of entries */ 163*0Sstevel@tonic-gate bool_t sct_free; /* Deallocate if true */ 164*0Sstevel@tonic-gate SVC_CALLOUT *sct_sc; /* Callout entries */ 165*0Sstevel@tonic-gate } SVC_CALLOUT_TABLE; 166*0Sstevel@tonic-gate 167*0Sstevel@tonic-gate struct svc_ops { 168*0Sstevel@tonic-gate bool_t (*xp_recv)(SVCXPRT *, mblk_t *, struct rpc_msg *); 169*0Sstevel@tonic-gate /* receive incoming requests */ 170*0Sstevel@tonic-gate bool_t (*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t); 171*0Sstevel@tonic-gate /* get arguments */ 172*0Sstevel@tonic-gate bool_t (*xp_reply)(SVCXPRT *, struct rpc_msg *); 173*0Sstevel@tonic-gate /* send reply */ 174*0Sstevel@tonic-gate bool_t (*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t); 175*0Sstevel@tonic-gate /* free mem allocated for args */ 176*0Sstevel@tonic-gate void (*xp_destroy)(SVCMASTERXPRT *); 177*0Sstevel@tonic-gate /* destroy this struct */ 178*0Sstevel@tonic-gate int (*xp_dup)(struct svc_req *, caddr_t, int, 179*0Sstevel@tonic-gate struct dupreq **, bool_t *); 180*0Sstevel@tonic-gate /* check for dup */ 181*0Sstevel@tonic-gate void (*xp_dupdone)(struct dupreq *, caddr_t, void (*)(), int, int); 182*0Sstevel@tonic-gate /* mark dup entry as completed */ 183*0Sstevel@tonic-gate int32_t *(*xp_getres)(SVCXPRT *, int); 184*0Sstevel@tonic-gate /* get pointer to response buffer */ 185*0Sstevel@tonic-gate void (*xp_freeres)(SVCXPRT *); 186*0Sstevel@tonic-gate /* destroy pre-serialized response */ 187*0Sstevel@tonic-gate void (*xp_clone_destroy)(SVCXPRT *); 188*0Sstevel@tonic-gate /* destroy a clone xprt */ 189*0Sstevel@tonic-gate void (*xp_start)(SVCMASTERXPRT *); 190*0Sstevel@tonic-gate /* `ready-to-receive' */ 191*0Sstevel@tonic-gate }; 192*0Sstevel@tonic-gate #else /* _KERNEL */ 193*0Sstevel@tonic-gate /* 194*0Sstevel@tonic-gate * Service control requests 195*0Sstevel@tonic-gate */ 196*0Sstevel@tonic-gate #define SVCGET_VERSQUIET 1 197*0Sstevel@tonic-gate #define SVCSET_VERSQUIET 2 198*0Sstevel@tonic-gate #define SVCGET_XID 4 199*0Sstevel@tonic-gate #define SVCSET_KEEPALIVE 5 200*0Sstevel@tonic-gate #define SVCSET_CONNMAXREC 6 201*0Sstevel@tonic-gate #define SVCGET_CONNMAXREC 7 202*0Sstevel@tonic-gate #define SVCGET_RECVERRHANDLER 8 203*0Sstevel@tonic-gate #define SVCSET_RECVERRHANDLER 9 204*0Sstevel@tonic-gate 205*0Sstevel@tonic-gate enum xprt_stat { 206*0Sstevel@tonic-gate XPRT_DIED, 207*0Sstevel@tonic-gate XPRT_MOREREQS, 208*0Sstevel@tonic-gate XPRT_IDLE 209*0Sstevel@tonic-gate }; 210*0Sstevel@tonic-gate 211*0Sstevel@tonic-gate struct xp_ops { 212*0Sstevel@tonic-gate #ifdef __STDC__ 213*0Sstevel@tonic-gate bool_t (*xp_recv)(SVCXPRT *, struct rpc_msg *); 214*0Sstevel@tonic-gate /* receive incoming requests */ 215*0Sstevel@tonic-gate enum xprt_stat (*xp_stat)(SVCXPRT *); 216*0Sstevel@tonic-gate /* get transport status */ 217*0Sstevel@tonic-gate bool_t (*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t); 218*0Sstevel@tonic-gate /* get arguments */ 219*0Sstevel@tonic-gate bool_t (*xp_reply)(SVCXPRT *, struct rpc_msg *); 220*0Sstevel@tonic-gate /* send reply */ 221*0Sstevel@tonic-gate bool_t (*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t); 222*0Sstevel@tonic-gate /* free mem allocated for args */ 223*0Sstevel@tonic-gate void (*xp_destroy)(SVCXPRT *); 224*0Sstevel@tonic-gate /* destroy this struct */ 225*0Sstevel@tonic-gate bool_t (*xp_control)(SVCXPRT *, const uint_t, void *); 226*0Sstevel@tonic-gate /* catch-all control function */ 227*0Sstevel@tonic-gate #else /* __STDC__ */ 228*0Sstevel@tonic-gate bool_t (*xp_recv)(); /* receive incoming requests */ 229*0Sstevel@tonic-gate enum xprt_stat (*xp_stat)(); /* get transport status */ 230*0Sstevel@tonic-gate bool_t (*xp_getargs)(); /* get arguments */ 231*0Sstevel@tonic-gate bool_t (*xp_reply)(); /* send reply */ 232*0Sstevel@tonic-gate bool_t (*xp_freeargs)(); /* free mem allocated for args */ 233*0Sstevel@tonic-gate void (*xp_destroy)(); /* destroy this struct */ 234*0Sstevel@tonic-gate bool_t (*xp_control)(); /* catch-all control function */ 235*0Sstevel@tonic-gate #endif /* __STDC__ */ 236*0Sstevel@tonic-gate }; 237*0Sstevel@tonic-gate #endif /* _KERNEL */ 238*0Sstevel@tonic-gate 239*0Sstevel@tonic-gate #ifdef _KERNEL 240*0Sstevel@tonic-gate /* 241*0Sstevel@tonic-gate * SVCPOOL 242*0Sstevel@tonic-gate * Kernel RPC server-side thread pool structure. 243*0Sstevel@tonic-gate */ 244*0Sstevel@tonic-gate typedef struct __svcxprt_qnode __SVCXPRT_QNODE; /* Defined in svc.c */ 245*0Sstevel@tonic-gate 246*0Sstevel@tonic-gate struct __svcpool { 247*0Sstevel@tonic-gate /* 248*0Sstevel@tonic-gate * Thread pool variables. 249*0Sstevel@tonic-gate * 250*0Sstevel@tonic-gate * The pool's thread lock p_thread_lock protects: 251*0Sstevel@tonic-gate * - p_threads, p_detached_threads, p_reserved_threads and p_closing 252*0Sstevel@tonic-gate * The pool's request lock protects: 253*0Sstevel@tonic-gate * - p_asleep, p_drowsy, p_reqs, p_walkers, p_req_cv. 254*0Sstevel@tonic-gate * The following fields are `initialized constants': 255*0Sstevel@tonic-gate * - p_id, p_stksize, p_timeout. 256*0Sstevel@tonic-gate * Access to p_next and p_prev is protected by the pool 257*0Sstevel@tonic-gate * list lock. 258*0Sstevel@tonic-gate */ 259*0Sstevel@tonic-gate SVCPOOL *p_next; /* Next pool in the list */ 260*0Sstevel@tonic-gate SVCPOOL *p_prev; /* Prev pool in the list */ 261*0Sstevel@tonic-gate int p_id; /* Pool id */ 262*0Sstevel@tonic-gate int p_threads; /* Non-detached threads */ 263*0Sstevel@tonic-gate int p_detached_threads; /* Detached threads */ 264*0Sstevel@tonic-gate int p_maxthreads; /* Max threads in the pool */ 265*0Sstevel@tonic-gate int p_redline; /* `Redline' for the pool */ 266*0Sstevel@tonic-gate int p_reserved_threads; /* Reserved threads */ 267*0Sstevel@tonic-gate kmutex_t p_thread_lock; /* Thread lock */ 268*0Sstevel@tonic-gate int p_asleep; /* Asleep threads */ 269*0Sstevel@tonic-gate int p_drowsy; /* Drowsy flag */ 270*0Sstevel@tonic-gate kcondvar_t p_req_cv; /* svc_poll() sleep var. */ 271*0Sstevel@tonic-gate clock_t p_timeout; /* svc_poll() timeout */ 272*0Sstevel@tonic-gate kmutex_t p_req_lock; /* Request lock */ 273*0Sstevel@tonic-gate int p_reqs; /* Pending requests */ 274*0Sstevel@tonic-gate int p_walkers; /* Walking threads */ 275*0Sstevel@tonic-gate int p_max_same_xprt; /* Max reqs from the xprt */ 276*0Sstevel@tonic-gate int p_stksize; /* Stack size for svc_run */ 277*0Sstevel@tonic-gate bool_t p_closing : 1; /* Pool is closing */ 278*0Sstevel@tonic-gate 279*0Sstevel@tonic-gate /* 280*0Sstevel@tonic-gate * Thread creator variables. 281*0Sstevel@tonic-gate * The `creator signaled' flag is turned on when a signal is send 282*0Sstevel@tonic-gate * to the creator thread (to create a new service thread). The 283*0Sstevel@tonic-gate * creator clears when the thread is created. The protocol is not 284*0Sstevel@tonic-gate * to signal the creator thread when the flag is on. However, 285*0Sstevel@tonic-gate * a new thread should signal the creator if there are more 286*0Sstevel@tonic-gate * requests in the queue. 287*0Sstevel@tonic-gate * 288*0Sstevel@tonic-gate * When the pool is closing (ie it has been already unregistered from 289*0Sstevel@tonic-gate * the pool list) the last thread on the last transport should turn 290*0Sstevel@tonic-gate * the p_creator_exit flag on. This tells the creator thread to 291*0Sstevel@tonic-gate * free the pool structure and exit. 292*0Sstevel@tonic-gate */ 293*0Sstevel@tonic-gate bool_t p_creator_signaled : 1; /* Create requested flag */ 294*0Sstevel@tonic-gate bool_t p_creator_exit : 1; /* If true creator exits */ 295*0Sstevel@tonic-gate kcondvar_t p_creator_cv; /* Creator cond. variable */ 296*0Sstevel@tonic-gate kmutex_t p_creator_lock; /* Creator lock */ 297*0Sstevel@tonic-gate 298*0Sstevel@tonic-gate /* 299*0Sstevel@tonic-gate * Doubly linked list containing `registered' master transport handles. 300*0Sstevel@tonic-gate * There is no special structure for a list node. Instead the 301*0Sstevel@tonic-gate * SVCMASTERXPRT structure has the xp_next and xp_prev fields. 302*0Sstevel@tonic-gate * 303*0Sstevel@tonic-gate * The p_lrwlock protects access to xprt->xp_next and xprt->xp_prev. 304*0Sstevel@tonic-gate * A service thread should also acquire a reader lock before accessing 305*0Sstevel@tonic-gate * any transports it is no longer linked to (to prevent them from 306*0Sstevel@tonic-gate * being destroyed). 307*0Sstevel@tonic-gate * 308*0Sstevel@tonic-gate * The list lock governs also the `pool is closing' flag. 309*0Sstevel@tonic-gate */ 310*0Sstevel@tonic-gate size_t p_lcount; /* Current count */ 311*0Sstevel@tonic-gate SVCMASTERXPRT *p_lhead; /* List head */ 312*0Sstevel@tonic-gate krwlock_t p_lrwlock; /* R/W lock */ 313*0Sstevel@tonic-gate 314*0Sstevel@tonic-gate /* 315*0Sstevel@tonic-gate * Circular linked list for the `xprt-ready' queue (FIFO). 316*0Sstevel@tonic-gate * Must be initialized with svc_xprt_qinit() before it is used. 317*0Sstevel@tonic-gate * 318*0Sstevel@tonic-gate * The writer's end is protected by the pool's request lock 319*0Sstevel@tonic-gate * (pool->p_req_lock). The reader's end is protected by q_end_lock. 320*0Sstevel@tonic-gate * 321*0Sstevel@tonic-gate * When the queue is full the p_qoverflow flag is raised. It stays 322*0Sstevel@tonic-gate * on until all the pending request are drained. 323*0Sstevel@tonic-gate */ 324*0Sstevel@tonic-gate size_t p_qsize; /* Number of queue nodes */ 325*0Sstevel@tonic-gate int p_qoverflow : 1; /* Overflow flag */ 326*0Sstevel@tonic-gate __SVCXPRT_QNODE *p_qbody; /* Queue body (array) */ 327*0Sstevel@tonic-gate __SVCXPRT_QNODE *p_qtop; /* Writer's end of FIFO */ 328*0Sstevel@tonic-gate __SVCXPRT_QNODE *p_qend; /* Reader's end of FIFO */ 329*0Sstevel@tonic-gate kmutex_t p_qend_lock; /* Reader's end lock */ 330*0Sstevel@tonic-gate 331*0Sstevel@tonic-gate /* 332*0Sstevel@tonic-gate * Userspace thread creator variables. 333*0Sstevel@tonic-gate * Thread creation is actually done in userland, via a thread 334*0Sstevel@tonic-gate * that is parked in the kernel. When that thread is signaled, 335*0Sstevel@tonic-gate * it returns back down to the daemon from whence it came and 336*0Sstevel@tonic-gate * does the lwp create. 337*0Sstevel@tonic-gate * 338*0Sstevel@tonic-gate * A parallel "creator" thread runs in the kernel. That is the 339*0Sstevel@tonic-gate * thread that will signal for the user thread to return to 340*0Sstevel@tonic-gate * userland and do its work. 341*0Sstevel@tonic-gate * 342*0Sstevel@tonic-gate * Since the thread doesn't always exist (there could be a race 343*0Sstevel@tonic-gate * if two threads are created in rapid succession), we set 344*0Sstevel@tonic-gate * p_signal_create_thread to FALSE when we're ready to accept work. 345*0Sstevel@tonic-gate * 346*0Sstevel@tonic-gate * p_user_exit is set to true when the service pool is about 347*0Sstevel@tonic-gate * to close. This is done so that the user creation thread 348*0Sstevel@tonic-gate * can be informed and cleanup any userland state. 349*0Sstevel@tonic-gate */ 350*0Sstevel@tonic-gate 351*0Sstevel@tonic-gate bool_t p_signal_create_thread : 1; /* Create requested flag */ 352*0Sstevel@tonic-gate bool_t p_user_exit : 1; /* If true creator exits */ 353*0Sstevel@tonic-gate bool_t p_user_waiting : 1; /* Thread waiting for work */ 354*0Sstevel@tonic-gate kcondvar_t p_user_cv; /* Creator cond. variable */ 355*0Sstevel@tonic-gate kmutex_t p_user_lock; /* Creator lock */ 356*0Sstevel@tonic-gate void (*p_offline)(); /* callout for unregister */ 357*0Sstevel@tonic-gate void (*p_shutdown)(); /* callout for shutdown */ 358*0Sstevel@tonic-gate }; 359*0Sstevel@tonic-gate 360*0Sstevel@tonic-gate /* 361*0Sstevel@tonic-gate * Server side transport handle (SVCMASTERXPRT). 362*0Sstevel@tonic-gate * xprt->xp_req_lock governs the following fields in xprt: 363*0Sstevel@tonic-gate * xp_req_head, xp_req_tail. 364*0Sstevel@tonic-gate * xprt->xp_thread_lock governs the following fields in xprt: 365*0Sstevel@tonic-gate * xp_threads, xp_detached_threads. 366*0Sstevel@tonic-gate * 367*0Sstevel@tonic-gate * xp_req_tail is only valid if xp_req_head is non-NULL 368*0Sstevel@tonic-gate * 369*0Sstevel@tonic-gate * The xp_threads count is the number of attached threads. These threads 370*0Sstevel@tonic-gate * are able to handle new requests, and it is expected that they will not 371*0Sstevel@tonic-gate * block for a very long time handling a given request. The 372*0Sstevel@tonic-gate * xp_detached_threads count is the number of threads that have detached 373*0Sstevel@tonic-gate * themselves from the transport. These threads can block indefinitely 374*0Sstevel@tonic-gate * while handling a request. Once they complete the request, they exit. 375*0Sstevel@tonic-gate * 376*0Sstevel@tonic-gate * A kernel service provider may register a callback function "closeproc" 377*0Sstevel@tonic-gate * for a transport. When the transport is closing the last exiting attached 378*0Sstevel@tonic-gate * thread - xp_threads goes to zero - it calls the callback function, passing 379*0Sstevel@tonic-gate * it a reference to the transport. This call is made with xp_thread_lock 380*0Sstevel@tonic-gate * held, so any cleanup bookkeeping it does should be done quickly. 381*0Sstevel@tonic-gate * 382*0Sstevel@tonic-gate * When the transport is closing the last exiting thread is supposed 383*0Sstevel@tonic-gate * to destroy/free the data structure. 384*0Sstevel@tonic-gate */ 385*0Sstevel@tonic-gate typedef struct __svcxprt_common { 386*0Sstevel@tonic-gate struct file *xpc_fp; 387*0Sstevel@tonic-gate struct svc_ops *xpc_ops; 388*0Sstevel@tonic-gate queue_t *xpc_wq; /* queue to write onto */ 389*0Sstevel@tonic-gate cred_t *xpc_cred; /* cached cred for server to use */ 390*0Sstevel@tonic-gate int32_t xpc_type; /* transport type */ 391*0Sstevel@tonic-gate int xpc_msg_size; /* TSDU or TIDU size */ 392*0Sstevel@tonic-gate struct netbuf xpc_rtaddr; /* remote transport address */ 393*0Sstevel@tonic-gate SVC_CALLOUT_TABLE *xpc_sct; 394*0Sstevel@tonic-gate } __SVCXPRT_COMMON; 395*0Sstevel@tonic-gate 396*0Sstevel@tonic-gate #define xp_fp xp_xpc.xpc_fp 397*0Sstevel@tonic-gate #define xp_ops xp_xpc.xpc_ops 398*0Sstevel@tonic-gate #define xp_wq xp_xpc.xpc_wq 399*0Sstevel@tonic-gate #define xp_cred xp_xpc.xpc_cred 400*0Sstevel@tonic-gate #define xp_type xp_xpc.xpc_type 401*0Sstevel@tonic-gate #define xp_msg_size xp_xpc.xpc_msg_size 402*0Sstevel@tonic-gate #define xp_rtaddr xp_xpc.xpc_rtaddr 403*0Sstevel@tonic-gate #define xp_sct xp_xpc.xpc_sct 404*0Sstevel@tonic-gate 405*0Sstevel@tonic-gate struct __svcmasterxprt { 406*0Sstevel@tonic-gate SVCMASTERXPRT *xp_next; /* Next transport in the list */ 407*0Sstevel@tonic-gate SVCMASTERXPRT *xp_prev; /* Prev transport in the list */ 408*0Sstevel@tonic-gate __SVCXPRT_COMMON xp_xpc; /* Fields common with the clone */ 409*0Sstevel@tonic-gate SVCPOOL *xp_pool; /* Pointer to the pool */ 410*0Sstevel@tonic-gate mblk_t *xp_req_head; /* Request queue head */ 411*0Sstevel@tonic-gate mblk_t *xp_req_tail; /* Request queue tail */ 412*0Sstevel@tonic-gate kmutex_t xp_req_lock; /* Request lock */ 413*0Sstevel@tonic-gate int xp_threads; /* Current num. of attached threads */ 414*0Sstevel@tonic-gate int xp_detached_threads; /* num. of detached threads */ 415*0Sstevel@tonic-gate kmutex_t xp_thread_lock; /* Thread count lock */ 416*0Sstevel@tonic-gate void (*xp_closeproc)(const SVCMASTERXPRT *); 417*0Sstevel@tonic-gate /* optional; see comments above */ 418*0Sstevel@tonic-gate char *xp_netid; /* network token */ 419*0Sstevel@tonic-gate struct netbuf xp_addrmask; /* address mask */ 420*0Sstevel@tonic-gate 421*0Sstevel@tonic-gate caddr_t xp_p2; /* private: for use by svc ops */ 422*0Sstevel@tonic-gate }; 423*0Sstevel@tonic-gate 424*0Sstevel@tonic-gate /* 425*0Sstevel@tonic-gate * Service thread `clone' transport handle (SVCXPRT) 426*0Sstevel@tonic-gate * 427*0Sstevel@tonic-gate * PSARC 2003/523 Contract Private Interface 428*0Sstevel@tonic-gate * SVCXPRT 429*0Sstevel@tonic-gate * Changes must be reviewed by Solaris File Sharing 430*0Sstevel@tonic-gate * Changes must be communicated to contract-2003-523@sun.com 431*0Sstevel@tonic-gate * 432*0Sstevel@tonic-gate * The xp_p2buf buffer is used as the storage for a transport type 433*0Sstevel@tonic-gate * specific structure. It is private for the svc ops for a given 434*0Sstevel@tonic-gate * transport type. 435*0Sstevel@tonic-gate */ 436*0Sstevel@tonic-gate 437*0Sstevel@tonic-gate #define SVC_P2LEN 64 438*0Sstevel@tonic-gate 439*0Sstevel@tonic-gate struct __svcxprt { 440*0Sstevel@tonic-gate __SVCXPRT_COMMON xp_xpc; 441*0Sstevel@tonic-gate SVCMASTERXPRT *xp_master; /* back ptr to master */ 442*0Sstevel@tonic-gate 443*0Sstevel@tonic-gate /* The following fileds are on a per-thread basis */ 444*0Sstevel@tonic-gate callb_cpr_t *xp_cprp; /* unused padding for Contract */ 445*0Sstevel@tonic-gate bool_t xp_reserved : 1; /* is thread reserved? */ 446*0Sstevel@tonic-gate bool_t xp_detached : 1; /* is thread detached? */ 447*0Sstevel@tonic-gate int xp_same_xprt; /* Reqs from the same xprt */ 448*0Sstevel@tonic-gate 449*0Sstevel@tonic-gate /* The following fields are used on a per-request basis */ 450*0Sstevel@tonic-gate struct opaque_auth xp_verf; /* raw response verifier */ 451*0Sstevel@tonic-gate SVCAUTH xp_auth; /* auth flavor of current req */ 452*0Sstevel@tonic-gate void *xp_cookie; /* a cookie */ 453*0Sstevel@tonic-gate uint32_t xp_xid; /* id */ 454*0Sstevel@tonic-gate XDR xp_xdrin; /* input xdr stream */ 455*0Sstevel@tonic-gate XDR xp_xdrout; /* output xdr stream */ 456*0Sstevel@tonic-gate 457*0Sstevel@tonic-gate /* Private for svc ops */ 458*0Sstevel@tonic-gate char xp_p2buf[SVC_P2LEN]; /* udp_data or cots_data_t */ 459*0Sstevel@tonic-gate /* or clone_rdma_data_t */ 460*0Sstevel@tonic-gate }; 461*0Sstevel@tonic-gate #else /* _KERNEL */ 462*0Sstevel@tonic-gate struct __svcxprt { 463*0Sstevel@tonic-gate int xp_fd; 464*0Sstevel@tonic-gate #define xp_sock xp_fd 465*0Sstevel@tonic-gate ushort_t xp_port; 466*0Sstevel@tonic-gate /* 467*0Sstevel@tonic-gate * associated port number. 468*0Sstevel@tonic-gate * Obsolete, but still used to 469*0Sstevel@tonic-gate * specify whether rendezvouser 470*0Sstevel@tonic-gate * or normal connection 471*0Sstevel@tonic-gate */ 472*0Sstevel@tonic-gate struct xp_ops *xp_ops; 473*0Sstevel@tonic-gate int xp_addrlen; /* length of remote addr. Obsoleted */ 474*0Sstevel@tonic-gate char *xp_tp; /* transport provider device name */ 475*0Sstevel@tonic-gate char *xp_netid; /* network token */ 476*0Sstevel@tonic-gate struct netbuf xp_ltaddr; /* local transport address */ 477*0Sstevel@tonic-gate struct netbuf xp_rtaddr; /* remote transport address */ 478*0Sstevel@tonic-gate char xp_raddr[16]; /* remote address. Now obsoleted */ 479*0Sstevel@tonic-gate struct opaque_auth xp_verf; /* raw response verifier */ 480*0Sstevel@tonic-gate caddr_t xp_p1; /* private: for use by svc ops */ 481*0Sstevel@tonic-gate caddr_t xp_p2; /* private: for use by svc ops */ 482*0Sstevel@tonic-gate caddr_t xp_p3; /* private: for use by svc lib */ 483*0Sstevel@tonic-gate int xp_type; /* transport type */ 484*0Sstevel@tonic-gate /* 485*0Sstevel@tonic-gate * callback on client death 486*0Sstevel@tonic-gate * First parameter is the current structure, 487*0Sstevel@tonic-gate * Second parameter : 488*0Sstevel@tonic-gate * - FALSE for the service listener 489*0Sstevel@tonic-gate * - TRUE for a real connected socket 490*0Sstevel@tonic-gate */ 491*0Sstevel@tonic-gate svc_errorhandler_t xp_closeclnt; 492*0Sstevel@tonic-gate }; 493*0Sstevel@tonic-gate #endif /* _KERNEL */ 494*0Sstevel@tonic-gate 495*0Sstevel@tonic-gate /* 496*0Sstevel@tonic-gate * Approved way of getting address of caller, 497*0Sstevel@tonic-gate * address mask, and netid of transport. 498*0Sstevel@tonic-gate */ 499*0Sstevel@tonic-gate #define svc_getrpccaller(x) (&(x)->xp_rtaddr) 500*0Sstevel@tonic-gate #ifdef _KERNEL 501*0Sstevel@tonic-gate #define svc_getcaller(x) (&(x)->xp_rtaddr.buf) 502*0Sstevel@tonic-gate #define svc_getaddrmask(x) (&(x)->xp_master->xp_addrmask) 503*0Sstevel@tonic-gate #define svc_getnetid(x) ((x)->xp_master->xp_netid) 504*0Sstevel@tonic-gate #endif /* _KERNEL */ 505*0Sstevel@tonic-gate 506*0Sstevel@tonic-gate /* 507*0Sstevel@tonic-gate * Operations defined on an SVCXPRT handle 508*0Sstevel@tonic-gate */ 509*0Sstevel@tonic-gate 510*0Sstevel@tonic-gate #ifdef _KERNEL 511*0Sstevel@tonic-gate #define SVC_RECV(clone_xprt, mp, msg) \ 512*0Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_recv)((clone_xprt), (mp), (msg)) 513*0Sstevel@tonic-gate 514*0Sstevel@tonic-gate /* 515*0Sstevel@tonic-gate * PSARC 2003/523 Contract Private Interface 516*0Sstevel@tonic-gate * SVC_GETARGS 517*0Sstevel@tonic-gate * Changes must be reviewed by Solaris File Sharing 518*0Sstevel@tonic-gate * Changes must be communicated to contract-2003-523@sun.com 519*0Sstevel@tonic-gate */ 520*0Sstevel@tonic-gate #define SVC_GETARGS(clone_xprt, xargs, argsp) \ 521*0Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_getargs)((clone_xprt), (xargs), (argsp)) 522*0Sstevel@tonic-gate 523*0Sstevel@tonic-gate #define SVC_REPLY(clone_xprt, msg) \ 524*0Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_reply) ((clone_xprt), (msg)) 525*0Sstevel@tonic-gate 526*0Sstevel@tonic-gate #define SVC_FREEARGS(clone_xprt, xargs, argsp) \ 527*0Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_freeargs)((clone_xprt), (xargs), (argsp)) 528*0Sstevel@tonic-gate 529*0Sstevel@tonic-gate #define SVC_GETRES(clone_xprt, size) \ 530*0Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_getres)((clone_xprt), (size)) 531*0Sstevel@tonic-gate 532*0Sstevel@tonic-gate #define SVC_FREERES(clone_xprt) \ 533*0Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_freeres)(clone_xprt) 534*0Sstevel@tonic-gate 535*0Sstevel@tonic-gate #define SVC_DESTROY(xprt) \ 536*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_destroy)(xprt) 537*0Sstevel@tonic-gate 538*0Sstevel@tonic-gate /* 539*0Sstevel@tonic-gate * PSARC 2003/523 Contract Private Interfaces 540*0Sstevel@tonic-gate * SVC_DUP, SVC_DUPDONE, SVC_DUP_EXT, SVC_DUPDONE_EXT 541*0Sstevel@tonic-gate * Changes must be reviewed by Solaris File Sharing 542*0Sstevel@tonic-gate * Changes must be communicated to contract-2003-523@sun.com 543*0Sstevel@tonic-gate * 544*0Sstevel@tonic-gate * SVC_DUP and SVC_DUPDONE are defined here for backward compatibility. 545*0Sstevel@tonic-gate */ 546*0Sstevel@tonic-gate #define SVC_DUP_EXT(clone_xprt, req, res, size, drpp, dupcachedp) \ 547*0Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, dupcachedp) 548*0Sstevel@tonic-gate 549*0Sstevel@tonic-gate #define SVC_DUPDONE_EXT(clone_xprt, dr, res, resfree, size, status) \ 550*0Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, resfree, size, status) 551*0Sstevel@tonic-gate 552*0Sstevel@tonic-gate #define SVC_DUP(clone_xprt, req, res, size, drpp) \ 553*0Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, NULL) 554*0Sstevel@tonic-gate 555*0Sstevel@tonic-gate #define SVC_DUPDONE(clone_xprt, dr, res, size, status) \ 556*0Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, NULL, size, status) 557*0Sstevel@tonic-gate 558*0Sstevel@tonic-gate #define SVC_CLONE_DESTROY(clone_xprt) \ 559*0Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_clone_destroy)(clone_xprt) 560*0Sstevel@tonic-gate 561*0Sstevel@tonic-gate 562*0Sstevel@tonic-gate #define SVC_START(xprt) \ 563*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_start)(xprt) 564*0Sstevel@tonic-gate 565*0Sstevel@tonic-gate #else /* _KERNEL */ 566*0Sstevel@tonic-gate 567*0Sstevel@tonic-gate #define SVC_RECV(xprt, msg) \ 568*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) 569*0Sstevel@tonic-gate #define svc_recv(xprt, msg) \ 570*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) 571*0Sstevel@tonic-gate 572*0Sstevel@tonic-gate #define SVC_STAT(xprt) \ 573*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_stat)(xprt) 574*0Sstevel@tonic-gate #define svc_stat(xprt) \ 575*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_stat)(xprt) 576*0Sstevel@tonic-gate 577*0Sstevel@tonic-gate #define SVC_GETARGS(xprt, xargs, argsp) \ 578*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) 579*0Sstevel@tonic-gate #define svc_getargs(xprt, xargs, argsp) \ 580*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) 581*0Sstevel@tonic-gate 582*0Sstevel@tonic-gate #define SVC_REPLY(xprt, msg) \ 583*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) 584*0Sstevel@tonic-gate #define svc_reply(xprt, msg) \ 585*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) 586*0Sstevel@tonic-gate 587*0Sstevel@tonic-gate #define SVC_FREEARGS(xprt, xargs, argsp) \ 588*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) 589*0Sstevel@tonic-gate #define svc_freeargs(xprt, xargs, argsp) \ 590*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) 591*0Sstevel@tonic-gate 592*0Sstevel@tonic-gate #define SVC_GETRES(xprt, size) \ 593*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_getres)((xprt), (size)) 594*0Sstevel@tonic-gate #define svc_getres(xprt, size) \ 595*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_getres)((xprt), (size)) 596*0Sstevel@tonic-gate 597*0Sstevel@tonic-gate #define SVC_FREERES(xprt) \ 598*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_freeres)(xprt) 599*0Sstevel@tonic-gate #define svc_freeres(xprt) \ 600*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_freeres)(xprt) 601*0Sstevel@tonic-gate 602*0Sstevel@tonic-gate #define SVC_DESTROY(xprt) \ 603*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_destroy)(xprt) 604*0Sstevel@tonic-gate #define svc_destroy(xprt) \ 605*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_destroy)(xprt) 606*0Sstevel@tonic-gate 607*0Sstevel@tonic-gate /* 608*0Sstevel@tonic-gate * PSARC 2003/523 Contract Private Interface 609*0Sstevel@tonic-gate * SVC_CONTROL 610*0Sstevel@tonic-gate * Changes must be reviewed by Solaris File Sharing 611*0Sstevel@tonic-gate * Changes must be communicated to contract-2003-523@sun.com 612*0Sstevel@tonic-gate */ 613*0Sstevel@tonic-gate #define SVC_CONTROL(xprt, rq, in) \ 614*0Sstevel@tonic-gate (*(xprt)->xp_ops->xp_control)((xprt), (rq), (in)) 615*0Sstevel@tonic-gate #endif /* _KERNEL */ 616*0Sstevel@tonic-gate 617*0Sstevel@tonic-gate /* 618*0Sstevel@tonic-gate * Pool id's reserved for NFS, NLM, and the NFSv4 callback program. 619*0Sstevel@tonic-gate */ 620*0Sstevel@tonic-gate #define NFS_SVCPOOL_ID 0x01 621*0Sstevel@tonic-gate #define NLM_SVCPOOL_ID 0x02 622*0Sstevel@tonic-gate #define NFS_CB_SVCPOOL_ID 0x03 623*0Sstevel@tonic-gate #define RDC_SVCPOOL_ID 0x05 /* SNDR, PSARC 2001/699 */ 624*0Sstevel@tonic-gate 625*0Sstevel@tonic-gate struct svcpool_args { 626*0Sstevel@tonic-gate uint32_t id; /* Pool id */ 627*0Sstevel@tonic-gate uint32_t maxthreads; /* Max threads in the pool */ 628*0Sstevel@tonic-gate uint32_t redline; /* `Redline' for the pool */ 629*0Sstevel@tonic-gate uint32_t qsize; /* `xprt-ready' queue size */ 630*0Sstevel@tonic-gate uint32_t timeout; /* svc_poll() timeout */ 631*0Sstevel@tonic-gate uint32_t stksize; /* svc_run() stack size */ 632*0Sstevel@tonic-gate uint32_t max_same_xprt; /* Max reqs from the same xprt */ 633*0Sstevel@tonic-gate }; 634*0Sstevel@tonic-gate 635*0Sstevel@tonic-gate 636*0Sstevel@tonic-gate #ifdef _KERNEL 637*0Sstevel@tonic-gate /* 638*0Sstevel@tonic-gate * Transport registration and thread pool creation. 639*0Sstevel@tonic-gate */ 640*0Sstevel@tonic-gate extern int svc_xprt_register(SVCMASTERXPRT *, int); 641*0Sstevel@tonic-gate extern void svc_xprt_unregister(SVCMASTERXPRT *); 642*0Sstevel@tonic-gate extern int svc_pool_create(struct svcpool_args *); 643*0Sstevel@tonic-gate extern int svc_wait(int); 644*0Sstevel@tonic-gate extern int svc_do_run(int); 645*0Sstevel@tonic-gate #define SVCPSET_SHUTDOWN_PROC 1 646*0Sstevel@tonic-gate #define SVCPSET_UNREGISTER_PROC 2 647*0Sstevel@tonic-gate extern int svc_pool_control(int, int, void *); 648*0Sstevel@tonic-gate #else /* _KERNEL */ 649*0Sstevel@tonic-gate #ifdef __STDC__ 650*0Sstevel@tonic-gate extern bool_t rpc_reg(const rpcprog_t, const rpcvers_t, const rpcproc_t, 651*0Sstevel@tonic-gate char *(*)(char *), const xdrproc_t, const xdrproc_t, 652*0Sstevel@tonic-gate const char *); 653*0Sstevel@tonic-gate 654*0Sstevel@tonic-gate /* 655*0Sstevel@tonic-gate * Service registration 656*0Sstevel@tonic-gate * 657*0Sstevel@tonic-gate * svc_reg(xprt, prog, vers, dispatch, nconf) 658*0Sstevel@tonic-gate * const SVCXPRT *xprt; 659*0Sstevel@tonic-gate * const rpcprog_t prog; 660*0Sstevel@tonic-gate * const rpcvers_t vers; 661*0Sstevel@tonic-gate * const void (*dispatch)(); 662*0Sstevel@tonic-gate * const struct netconfig *nconf; 663*0Sstevel@tonic-gate */ 664*0Sstevel@tonic-gate extern bool_t svc_reg(const SVCXPRT *, const rpcprog_t, const rpcvers_t, 665*0Sstevel@tonic-gate void (*)(struct svc_req *, SVCXPRT *), 666*0Sstevel@tonic-gate const struct netconfig *); 667*0Sstevel@tonic-gate 668*0Sstevel@tonic-gate /* 669*0Sstevel@tonic-gate * Service authentication registration 670*0Sstevel@tonic-gate * 671*0Sstevel@tonic-gate * svc_auth_reg(cred_flavor, handler) 672*0Sstevel@tonic-gate * int cred_flavor; 673*0Sstevel@tonic-gate * enum auth_stat (*handler)(); 674*0Sstevel@tonic-gate */ 675*0Sstevel@tonic-gate extern int svc_auth_reg(int, enum auth_stat (*)()); 676*0Sstevel@tonic-gate 677*0Sstevel@tonic-gate /* 678*0Sstevel@tonic-gate * Service un-registration 679*0Sstevel@tonic-gate * 680*0Sstevel@tonic-gate * svc_unreg(prog, vers) 681*0Sstevel@tonic-gate * const rpcprog_t prog; 682*0Sstevel@tonic-gate * const rpcvers_t vers; 683*0Sstevel@tonic-gate */ 684*0Sstevel@tonic-gate extern void svc_unreg(const rpcprog_t, const rpcvers_t); 685*0Sstevel@tonic-gate 686*0Sstevel@tonic-gate /* 687*0Sstevel@tonic-gate * Transport registration/unregistration. 688*0Sstevel@tonic-gate * 689*0Sstevel@tonic-gate * xprt_register(xprt) 690*0Sstevel@tonic-gate * const SVCXPRT *xprt; 691*0Sstevel@tonic-gate * 692*0Sstevel@tonic-gate * xprt_unregister(xprt) 693*0Sstevel@tonic-gate * const SVCXPRT *xprt; 694*0Sstevel@tonic-gate */ 695*0Sstevel@tonic-gate extern void xprt_register(const SVCXPRT *); 696*0Sstevel@tonic-gate extern void xprt_unregister(const SVCXPRT *); 697*0Sstevel@tonic-gate #else /* __STDC__ */ 698*0Sstevel@tonic-gate extern bool_t rpc_reg(); 699*0Sstevel@tonic-gate extern bool_t svc_reg(); 700*0Sstevel@tonic-gate extern bool_t svc_auth_reg(); 701*0Sstevel@tonic-gate extern void svc_unreg(); 702*0Sstevel@tonic-gate extern void xprt_register(); 703*0Sstevel@tonic-gate extern void xprt_unregister(); 704*0Sstevel@tonic-gate #endif /* __STDC__ */ 705*0Sstevel@tonic-gate #endif /* _KERNEL */ 706*0Sstevel@tonic-gate 707*0Sstevel@tonic-gate 708*0Sstevel@tonic-gate /* 709*0Sstevel@tonic-gate * When the service routine is called, it must first check to see if it 710*0Sstevel@tonic-gate * knows about the procedure; if not, it should call svcerr_noproc 711*0Sstevel@tonic-gate * and return. If so, it should deserialize its arguments via 712*0Sstevel@tonic-gate * SVC_GETARGS (defined above). If the deserialization does not work, 713*0Sstevel@tonic-gate * svcerr_decode should be called followed by a return. Successful 714*0Sstevel@tonic-gate * decoding of the arguments should be followed the execution of the 715*0Sstevel@tonic-gate * procedure's code and a call to svc_sendreply. 716*0Sstevel@tonic-gate * 717*0Sstevel@tonic-gate * Also, if the service refuses to execute the procedure due to too- 718*0Sstevel@tonic-gate * weak authentication parameters, svcerr_weakauth should be called. 719*0Sstevel@tonic-gate * Note: do not confuse access-control failure with weak authentication! 720*0Sstevel@tonic-gate * 721*0Sstevel@tonic-gate * NB: In pure implementations of rpc, the caller always waits for a reply 722*0Sstevel@tonic-gate * msg. This message is sent when svc_sendreply is called. 723*0Sstevel@tonic-gate * Therefore pure service implementations should always call 724*0Sstevel@tonic-gate * svc_sendreply even if the function logically returns void; use 725*0Sstevel@tonic-gate * xdr.h - xdr_void for the xdr routine. HOWEVER, connectionful rpc allows 726*0Sstevel@tonic-gate * for the abuse of pure rpc via batched calling or pipelining. In the 727*0Sstevel@tonic-gate * case of a batched call, svc_sendreply should NOT be called since 728*0Sstevel@tonic-gate * this would send a return message, which is what batching tries to avoid. 729*0Sstevel@tonic-gate * It is the service/protocol writer's responsibility to know which calls are 730*0Sstevel@tonic-gate * batched and which are not. Warning: responding to batch calls may 731*0Sstevel@tonic-gate * deadlock the caller and server processes! 732*0Sstevel@tonic-gate */ 733*0Sstevel@tonic-gate #ifdef __STDC__ 734*0Sstevel@tonic-gate extern bool_t svc_sendreply(const SVCXPRT *, const xdrproc_t, const caddr_t); 735*0Sstevel@tonic-gate extern void svcerr_decode(const SVCXPRT *); 736*0Sstevel@tonic-gate extern void svcerr_weakauth(const SVCXPRT *); 737*0Sstevel@tonic-gate extern void svcerr_noproc(const SVCXPRT *); 738*0Sstevel@tonic-gate extern void svcerr_progvers(const SVCXPRT *, const rpcvers_t, 739*0Sstevel@tonic-gate const rpcvers_t); 740*0Sstevel@tonic-gate extern void svcerr_auth(const SVCXPRT *, const enum auth_stat); 741*0Sstevel@tonic-gate extern void svcerr_noprog(const SVCXPRT *); 742*0Sstevel@tonic-gate extern void svcerr_systemerr(const SVCXPRT *); 743*0Sstevel@tonic-gate #else /* __STDC__ */ 744*0Sstevel@tonic-gate extern bool_t svc_sendreply(); 745*0Sstevel@tonic-gate extern void svcerr_decode(); 746*0Sstevel@tonic-gate extern void svcerr_weakauth(); 747*0Sstevel@tonic-gate extern void svcerr_noproc(); 748*0Sstevel@tonic-gate extern void svcerr_progvers(); 749*0Sstevel@tonic-gate extern void svcerr_auth(); 750*0Sstevel@tonic-gate extern void svcerr_noprog(); 751*0Sstevel@tonic-gate extern void svcerr_systemerr(); 752*0Sstevel@tonic-gate #endif /* __STDC__ */ 753*0Sstevel@tonic-gate 754*0Sstevel@tonic-gate #ifdef _KERNEL 755*0Sstevel@tonic-gate /* 756*0Sstevel@tonic-gate * Kernel RPC functions. 757*0Sstevel@tonic-gate */ 758*0Sstevel@tonic-gate extern void svc_init(void); 759*0Sstevel@tonic-gate extern void svc_cots_init(void); 760*0Sstevel@tonic-gate extern void svc_clts_init(void); 761*0Sstevel@tonic-gate extern void mt_kstat_init(void); 762*0Sstevel@tonic-gate extern void mt_kstat_fini(void); 763*0Sstevel@tonic-gate extern int svc_tli_kcreate(struct file *, uint_t, char *, 764*0Sstevel@tonic-gate struct netbuf *, SVCMASTERXPRT **, 765*0Sstevel@tonic-gate SVC_CALLOUT_TABLE *, 766*0Sstevel@tonic-gate void (*closeproc)(const SVCMASTERXPRT *), 767*0Sstevel@tonic-gate int, bool_t); 768*0Sstevel@tonic-gate extern int svc_clts_kcreate(struct file *, uint_t, struct T_info_ack *, 769*0Sstevel@tonic-gate SVCMASTERXPRT **); 770*0Sstevel@tonic-gate extern int svc_cots_kcreate(struct file *, uint_t, struct T_info_ack *, 771*0Sstevel@tonic-gate SVCMASTERXPRT **); 772*0Sstevel@tonic-gate extern void svc_queuereq(queue_t *, mblk_t *); 773*0Sstevel@tonic-gate extern void svc_queueclean(queue_t *); 774*0Sstevel@tonic-gate extern void svc_queueclose(queue_t *); 775*0Sstevel@tonic-gate extern int svc_reserve_thread(SVCXPRT *); 776*0Sstevel@tonic-gate extern void svc_unreserve_thread(SVCXPRT *); 777*0Sstevel@tonic-gate extern callb_cpr_t *svc_detach_thread(SVCXPRT *); 778*0Sstevel@tonic-gate 779*0Sstevel@tonic-gate /* 780*0Sstevel@tonic-gate * For RDMA based kRPC. 781*0Sstevel@tonic-gate * "rdma_xprt_record" is a reference to master transport handles 782*0Sstevel@tonic-gate * in kRPC thread pools. This is an easy way of tracking and shuting 783*0Sstevel@tonic-gate * down rdma based kRPC transports on demand. 784*0Sstevel@tonic-gate * "rdma_xprt_group" is a list of RDMA based mster transport handles 785*0Sstevel@tonic-gate * or records in a kRPC thread pool. 786*0Sstevel@tonic-gate */ 787*0Sstevel@tonic-gate typedef struct rdma_xprt_record rdma_xprt_record_t; 788*0Sstevel@tonic-gate struct rdma_xprt_record { 789*0Sstevel@tonic-gate int rtr_type; /* Type of rdma; IB/VI/RDDP */ 790*0Sstevel@tonic-gate SVCMASTERXPRT *rtr_xprt_ptr; /* Ptr to master xprt handle */ 791*0Sstevel@tonic-gate rdma_xprt_record_t *rtr_next; /* Ptr to next record */ 792*0Sstevel@tonic-gate }; 793*0Sstevel@tonic-gate 794*0Sstevel@tonic-gate typedef struct { 795*0Sstevel@tonic-gate int rtg_count; /* Number transport records */ 796*0Sstevel@tonic-gate int rtg_poolid; /* Pool Id for this group */ 797*0Sstevel@tonic-gate rdma_xprt_record_t *rtg_listhead; /* Head of the records list */ 798*0Sstevel@tonic-gate } rdma_xprt_group_t; 799*0Sstevel@tonic-gate 800*0Sstevel@tonic-gate extern int svc_rdma_kcreate(char *, SVC_CALLOUT_TABLE *, int, 801*0Sstevel@tonic-gate rdma_xprt_group_t *); 802*0Sstevel@tonic-gate extern void svc_rdma_kstop(SVCMASTERXPRT *); 803*0Sstevel@tonic-gate extern void svc_rdma_kdestroy(SVCMASTERXPRT *); 804*0Sstevel@tonic-gate extern void rdma_stop(rdma_xprt_group_t); 805*0Sstevel@tonic-gate 806*0Sstevel@tonic-gate /* 807*0Sstevel@tonic-gate * GSS cleanup method. 808*0Sstevel@tonic-gate */ 809*0Sstevel@tonic-gate extern void rpc_gss_cleanup(SVCXPRT *); 810*0Sstevel@tonic-gate #else /* _KERNEL */ 811*0Sstevel@tonic-gate /* 812*0Sstevel@tonic-gate * Lowest level dispatching -OR- who owns this process anyway. 813*0Sstevel@tonic-gate * Somebody has to wait for incoming requests and then call the correct 814*0Sstevel@tonic-gate * service routine. The routine svc_run does infinite waiting; i.e., 815*0Sstevel@tonic-gate * svc_run never returns. 816*0Sstevel@tonic-gate * Since another (co-existant) package may wish to selectively wait for 817*0Sstevel@tonic-gate * incoming calls or other events outside of the rpc architecture, the 818*0Sstevel@tonic-gate * routine svc_getreq_poll is provided. It must be passed pollfds, the 819*0Sstevel@tonic-gate * "in-place" results of a poll call (see poll, section 2). 820*0Sstevel@tonic-gate */ 821*0Sstevel@tonic-gate 822*0Sstevel@tonic-gate /* 823*0Sstevel@tonic-gate * Global keeper of rpc service descriptors in use 824*0Sstevel@tonic-gate * dynamic; must be inspected before each call to select or poll 825*0Sstevel@tonic-gate */ 826*0Sstevel@tonic-gate extern pollfd_t *svc_pollfd; 827*0Sstevel@tonic-gate extern int svc_max_pollfd; 828*0Sstevel@tonic-gate extern fd_set svc_fdset; 829*0Sstevel@tonic-gate #if !defined(_LP64) && FD_SETSIZE > 1024 830*0Sstevel@tonic-gate extern fd_set _new_svc_fdset; 831*0Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 832*0Sstevel@tonic-gate #pragma redefine_extname svc_fdset _new_svc_fdset 833*0Sstevel@tonic-gate #else /* __PRAGMA_REDEFINE_EXTNAME */ 834*0Sstevel@tonic-gate #define svc_fdset _new_svc_fdset 835*0Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */ 836*0Sstevel@tonic-gate #endif /* LP64 && FD_SETSIZE > 1024 */ 837*0Sstevel@tonic-gate #define svc_fds svc_fdset.fds_bits[0] /* compatibility */ 838*0Sstevel@tonic-gate 839*0Sstevel@tonic-gate /* 840*0Sstevel@tonic-gate * A small program implemented by the svc_rpc implementation itself. 841*0Sstevel@tonic-gate * Also see clnt.h for protocol numbers. 842*0Sstevel@tonic-gate */ 843*0Sstevel@tonic-gate #ifdef __STDC__ 844*0Sstevel@tonic-gate extern void svc_getreq(int); 845*0Sstevel@tonic-gate extern void svc_getreq_common(const int); 846*0Sstevel@tonic-gate extern void svc_getreqset(fd_set *); /* takes fdset instead of int */ 847*0Sstevel@tonic-gate extern void svc_getreq_poll(struct pollfd *, const int); 848*0Sstevel@tonic-gate extern void svc_run(void); 849*0Sstevel@tonic-gate extern void svc_exit(void); 850*0Sstevel@tonic-gate #else /* __STDC__ */ 851*0Sstevel@tonic-gate extern void rpctest_service(); 852*0Sstevel@tonic-gate extern void svc_getreqset(); 853*0Sstevel@tonic-gate extern void svc_getreq(); 854*0Sstevel@tonic-gate extern void svc_getreq_common(); 855*0Sstevel@tonic-gate extern void svc_getreqset(); /* takes fdset instead of int */ 856*0Sstevel@tonic-gate extern void svc_getreq_poll(); 857*0Sstevel@tonic-gate extern void svc_run(); 858*0Sstevel@tonic-gate extern void svc_exit(); 859*0Sstevel@tonic-gate #endif /* __STDC__ */ 860*0Sstevel@tonic-gate 861*0Sstevel@tonic-gate /* 862*0Sstevel@tonic-gate * Functions used to manage user file descriptors 863*0Sstevel@tonic-gate */ 864*0Sstevel@tonic-gate typedef int svc_input_id_t; 865*0Sstevel@tonic-gate typedef void (*svc_callback_t)(svc_input_id_t id, int fd, 866*0Sstevel@tonic-gate unsigned int events, void* cookie); 867*0Sstevel@tonic-gate 868*0Sstevel@tonic-gate #ifdef __STDC__ 869*0Sstevel@tonic-gate extern svc_input_id_t svc_add_input(int fd, unsigned int events, 870*0Sstevel@tonic-gate svc_callback_t user_callback, 871*0Sstevel@tonic-gate void* cookie); 872*0Sstevel@tonic-gate extern int svc_remove_input(svc_input_id_t id); 873*0Sstevel@tonic-gate #else /* __STDC__ */ 874*0Sstevel@tonic-gate extern svc_input_id_t svc_add_input(); 875*0Sstevel@tonic-gate extern int svc_remove_input(); 876*0Sstevel@tonic-gate #endif 877*0Sstevel@tonic-gate 878*0Sstevel@tonic-gate /* 879*0Sstevel@tonic-gate * These are the existing service side transport implementations. 880*0Sstevel@tonic-gate * 881*0Sstevel@tonic-gate * Transport independent svc_create routine. 882*0Sstevel@tonic-gate */ 883*0Sstevel@tonic-gate #ifdef __STDC__ 884*0Sstevel@tonic-gate extern int svc_create(void (*)(struct svc_req *, SVCXPRT *), 885*0Sstevel@tonic-gate const rpcprog_t, const rpcvers_t, 886*0Sstevel@tonic-gate const char *); 887*0Sstevel@tonic-gate /* 888*0Sstevel@tonic-gate * void (*dispatch)(); -- dispatch routine 889*0Sstevel@tonic-gate * const rpcprog_t prognum; -- program number 890*0Sstevel@tonic-gate * const rpcvers_t versnum; -- version number 891*0Sstevel@tonic-gate * const char *nettype; -- network type 892*0Sstevel@tonic-gate */ 893*0Sstevel@tonic-gate 894*0Sstevel@tonic-gate /* 895*0Sstevel@tonic-gate * Generic server creation routine. It takes a netconfig structure 896*0Sstevel@tonic-gate * instead of a nettype. 897*0Sstevel@tonic-gate */ 898*0Sstevel@tonic-gate extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *), 899*0Sstevel@tonic-gate const rpcprog_t, const rpcvers_t, 900*0Sstevel@tonic-gate const struct netconfig *); 901*0Sstevel@tonic-gate /* 902*0Sstevel@tonic-gate * void (*dispatch)(); -- dispatch routine 903*0Sstevel@tonic-gate * const rpcprog_t prognum; -- program number 904*0Sstevel@tonic-gate * const rpcvers_t versnum; -- version number 905*0Sstevel@tonic-gate * const struct netconfig *nconf; -- netconfig structure 906*0Sstevel@tonic-gate */ 907*0Sstevel@tonic-gate 908*0Sstevel@tonic-gate /* 909*0Sstevel@tonic-gate * Generic TLI create routine 910*0Sstevel@tonic-gate */ 911*0Sstevel@tonic-gate extern SVCXPRT *svc_tli_create(const int, const struct netconfig *, 912*0Sstevel@tonic-gate const struct t_bind *, const uint_t, 913*0Sstevel@tonic-gate const uint_t); 914*0Sstevel@tonic-gate /* 915*0Sstevel@tonic-gate * const int fd; -- connection end point 916*0Sstevel@tonic-gate * const struct netconfig *nconf; -- netconfig structure 917*0Sstevel@tonic-gate * const struct t_bind *bindaddr; -- local bind address 918*0Sstevel@tonic-gate * const uint_t sendsz; -- max sendsize 919*0Sstevel@tonic-gate * const uint_t recvsz; -- max recvsize 920*0Sstevel@tonic-gate */ 921*0Sstevel@tonic-gate 922*0Sstevel@tonic-gate /* 923*0Sstevel@tonic-gate * Connectionless and connectionful create routines. 924*0Sstevel@tonic-gate */ 925*0Sstevel@tonic-gate extern SVCXPRT *svc_vc_create(const int, const uint_t, const uint_t); 926*0Sstevel@tonic-gate /* 927*0Sstevel@tonic-gate * const int fd; -- open connection end point 928*0Sstevel@tonic-gate * const uint_t sendsize; -- max send size 929*0Sstevel@tonic-gate * const uint_t recvsize; -- max recv size 930*0Sstevel@tonic-gate */ 931*0Sstevel@tonic-gate 932*0Sstevel@tonic-gate extern SVCXPRT *svc_dg_create(const int, const uint_t, const uint_t); 933*0Sstevel@tonic-gate /* 934*0Sstevel@tonic-gate * const int fd; -- open connection 935*0Sstevel@tonic-gate * const uint_t sendsize; -- max send size 936*0Sstevel@tonic-gate * const uint_t recvsize; -- max recv size 937*0Sstevel@tonic-gate */ 938*0Sstevel@tonic-gate 939*0Sstevel@tonic-gate /* 940*0Sstevel@tonic-gate * the routine takes any *open* TLI file 941*0Sstevel@tonic-gate * descriptor as its first input and is used for open connections. 942*0Sstevel@tonic-gate */ 943*0Sstevel@tonic-gate extern SVCXPRT *svc_fd_create(const int, const uint_t, const uint_t); 944*0Sstevel@tonic-gate /* 945*0Sstevel@tonic-gate * const int fd; -- open connection end point 946*0Sstevel@tonic-gate * const uint_t sendsize; -- max send size 947*0Sstevel@tonic-gate * const uint_t recvsize; -- max recv size 948*0Sstevel@tonic-gate */ 949*0Sstevel@tonic-gate 950*0Sstevel@tonic-gate /* 951*0Sstevel@tonic-gate * Memory based rpc (for speed check and testing) 952*0Sstevel@tonic-gate */ 953*0Sstevel@tonic-gate extern SVCXPRT *svc_raw_create(void); 954*0Sstevel@tonic-gate 955*0Sstevel@tonic-gate /* 956*0Sstevel@tonic-gate * Creation of service over doors transport. 957*0Sstevel@tonic-gate */ 958*0Sstevel@tonic-gate extern SVCXPRT *svc_door_create(void (*)(struct svc_req *, SVCXPRT *), 959*0Sstevel@tonic-gate const rpcprog_t, const rpcvers_t, 960*0Sstevel@tonic-gate const uint_t); 961*0Sstevel@tonic-gate /* 962*0Sstevel@tonic-gate * void (*dispatch)(); -- dispatch routine 963*0Sstevel@tonic-gate * const rpcprog_t prognum; -- program number 964*0Sstevel@tonic-gate * const rpcvers_t versnum; -- version number 965*0Sstevel@tonic-gate * const uint_t sendsize; -- send buffer size 966*0Sstevel@tonic-gate */ 967*0Sstevel@tonic-gate 968*0Sstevel@tonic-gate /* 969*0Sstevel@tonic-gate * Service control interface 970*0Sstevel@tonic-gate */ 971*0Sstevel@tonic-gate extern bool_t svc_control(SVCXPRT *, const uint_t, void *); 972*0Sstevel@tonic-gate /* 973*0Sstevel@tonic-gate * SVCXPRT *svc; -- service to manipulate 974*0Sstevel@tonic-gate * const uint_t req; -- request 975*0Sstevel@tonic-gate * void *info; -- argument to request 976*0Sstevel@tonic-gate */ 977*0Sstevel@tonic-gate 978*0Sstevel@tonic-gate /* 979*0Sstevel@tonic-gate * svc_dg_enable_cache() enables the cache on dg transports. 980*0Sstevel@tonic-gate */ 981*0Sstevel@tonic-gate extern int svc_dg_enablecache(SVCXPRT *, const uint_t); 982*0Sstevel@tonic-gate #else /* __STDC__ */ 983*0Sstevel@tonic-gate extern int svc_create(); 984*0Sstevel@tonic-gate extern SVCXPRT *svc_tp_create(); 985*0Sstevel@tonic-gate extern SVCXPRT *svc_tli_create(); 986*0Sstevel@tonic-gate extern SVCXPRT *svc_vc_create(); 987*0Sstevel@tonic-gate extern SVCXPRT *svc_dg_create(); 988*0Sstevel@tonic-gate extern SVCXPRT *svc_fd_create(); 989*0Sstevel@tonic-gate extern SVCXPRT *svc_raw_create(); 990*0Sstevel@tonic-gate extern SVCXPRT *svc_door_create(); 991*0Sstevel@tonic-gate extern int svc_dg_enablecache(); 992*0Sstevel@tonic-gate #endif /* __STDC__ */ 993*0Sstevel@tonic-gate 994*0Sstevel@tonic-gate #ifdef PORTMAP 995*0Sstevel@tonic-gate /* For backward compatibility */ 996*0Sstevel@tonic-gate #include <rpc/svc_soc.h> 997*0Sstevel@tonic-gate #endif /* PORTMAP */ 998*0Sstevel@tonic-gate 999*0Sstevel@tonic-gate /* 1000*0Sstevel@tonic-gate * For user level MT hot server functions 1001*0Sstevel@tonic-gate */ 1002*0Sstevel@tonic-gate 1003*0Sstevel@tonic-gate /* 1004*0Sstevel@tonic-gate * Different MT modes 1005*0Sstevel@tonic-gate */ 1006*0Sstevel@tonic-gate #define RPC_SVC_MT_NONE 0 /* default, single-threaded */ 1007*0Sstevel@tonic-gate #define RPC_SVC_MT_AUTO 1 /* automatic MT mode */ 1008*0Sstevel@tonic-gate #define RPC_SVC_MT_USER 2 /* user MT mode */ 1009*0Sstevel@tonic-gate 1010*0Sstevel@tonic-gate #ifdef __STDC__ 1011*0Sstevel@tonic-gate extern void svc_done(SVCXPRT *); 1012*0Sstevel@tonic-gate #else 1013*0Sstevel@tonic-gate extern void svc_done(); 1014*0Sstevel@tonic-gate #endif /* __STDC__ */ 1015*0Sstevel@tonic-gate 1016*0Sstevel@tonic-gate /* 1017*0Sstevel@tonic-gate * Obtaining local credentials. 1018*0Sstevel@tonic-gate */ 1019*0Sstevel@tonic-gate typedef struct __svc_local_cred_t { 1020*0Sstevel@tonic-gate uid_t euid; /* effective uid */ 1021*0Sstevel@tonic-gate gid_t egid; /* effective gid */ 1022*0Sstevel@tonic-gate uid_t ruid; /* real uid */ 1023*0Sstevel@tonic-gate gid_t rgid; /* real gid */ 1024*0Sstevel@tonic-gate pid_t pid; /* caller's pid, or -1 if not available */ 1025*0Sstevel@tonic-gate } svc_local_cred_t; 1026*0Sstevel@tonic-gate 1027*0Sstevel@tonic-gate #ifdef __STDC__ 1028*0Sstevel@tonic-gate struct ucred_s; 1029*0Sstevel@tonic-gate extern void svc_fd_negotiate_ucred(int); 1030*0Sstevel@tonic-gate extern int svc_getcallerucred(const SVCXPRT *, struct ucred_s **); 1031*0Sstevel@tonic-gate extern bool_t svc_get_local_cred(SVCXPRT *, svc_local_cred_t *); 1032*0Sstevel@tonic-gate #else 1033*0Sstevel@tonic-gate extern void svc_fd_negotiate_ucred(); 1034*0Sstevel@tonic-gate extern int svc_getcallerucred(); 1035*0Sstevel@tonic-gate extern bool_t svc_get_local_cred(); 1036*0Sstevel@tonic-gate #endif /* __STDC__ */ 1037*0Sstevel@tonic-gate 1038*0Sstevel@tonic-gate /* 1039*0Sstevel@tonic-gate * Private interfaces and structures for user level duplicate request caching. 1040*0Sstevel@tonic-gate * The interfaces and data structures are not committed and subject to 1041*0Sstevel@tonic-gate * change in future releases. Currently only intended for use by automountd. 1042*0Sstevel@tonic-gate */ 1043*0Sstevel@tonic-gate struct dupreq { 1044*0Sstevel@tonic-gate uint32_t dr_xid; 1045*0Sstevel@tonic-gate rpcproc_t dr_proc; 1046*0Sstevel@tonic-gate rpcvers_t dr_vers; 1047*0Sstevel@tonic-gate rpcprog_t dr_prog; 1048*0Sstevel@tonic-gate struct netbuf dr_addr; 1049*0Sstevel@tonic-gate struct netbuf dr_resp; 1050*0Sstevel@tonic-gate int dr_status; 1051*0Sstevel@tonic-gate time_t dr_time; 1052*0Sstevel@tonic-gate uint_t dr_hash; 1053*0Sstevel@tonic-gate struct dupreq *dr_next; 1054*0Sstevel@tonic-gate struct dupreq *dr_prev; 1055*0Sstevel@tonic-gate struct dupreq *dr_chain; 1056*0Sstevel@tonic-gate struct dupreq *dr_prevchain; 1057*0Sstevel@tonic-gate }; 1058*0Sstevel@tonic-gate 1059*0Sstevel@tonic-gate /* 1060*0Sstevel@tonic-gate * The fixedtime state is defined if we want to expand the routines to 1061*0Sstevel@tonic-gate * handle and encompass fixed size caches. 1062*0Sstevel@tonic-gate */ 1063*0Sstevel@tonic-gate #define DUPCACHE_FIXEDTIME 0 1064*0Sstevel@tonic-gate 1065*0Sstevel@tonic-gate /* 1066*0Sstevel@tonic-gate * States of requests for duplicate request caching. 1067*0Sstevel@tonic-gate * These are the same as defined for the kernel. 1068*0Sstevel@tonic-gate */ 1069*0Sstevel@tonic-gate #define DUP_NEW 0x00 /* new entry */ 1070*0Sstevel@tonic-gate #define DUP_INPROGRESS 0x01 /* request already going */ 1071*0Sstevel@tonic-gate #define DUP_DONE 0x02 /* request done */ 1072*0Sstevel@tonic-gate #define DUP_DROP 0x03 /* request dropped */ 1073*0Sstevel@tonic-gate #define DUP_ERROR 0x04 /* error in dup req cache */ 1074*0Sstevel@tonic-gate 1075*0Sstevel@tonic-gate #ifdef __STDC__ 1076*0Sstevel@tonic-gate extern bool_t __svc_dupcache_init(void *, int, char **); 1077*0Sstevel@tonic-gate extern int __svc_dup(struct svc_req *, caddr_t *, uint_t *, char *); 1078*0Sstevel@tonic-gate extern int __svc_dupdone(struct svc_req *, caddr_t, uint_t, int, char *); 1079*0Sstevel@tonic-gate extern bool_t __svc_vc_dupcache_init(SVCXPRT *, void *, int); 1080*0Sstevel@tonic-gate extern int __svc_vc_dup(struct svc_req *, caddr_t *, uint_t *); 1081*0Sstevel@tonic-gate extern int __svc_vc_dupdone(struct svc_req *, caddr_t, uint_t, int); 1082*0Sstevel@tonic-gate #else 1083*0Sstevel@tonic-gate extern bool_t __svc_dupcache_init(); 1084*0Sstevel@tonic-gate extern int __svc_dup(); 1085*0Sstevel@tonic-gate extern int __svc_dupdone(); 1086*0Sstevel@tonic-gate extern bool_t __svc_vc_dupcache_init(); 1087*0Sstevel@tonic-gate extern int __svc_vc_dup(); 1088*0Sstevel@tonic-gate extern int __svc_vc_dupdone(); 1089*0Sstevel@tonic-gate #endif /* __STDC__ */ 1090*0Sstevel@tonic-gate #endif /* _KERNEL */ 1091*0Sstevel@tonic-gate 1092*0Sstevel@tonic-gate #ifdef __cplusplus 1093*0Sstevel@tonic-gate } 1094*0Sstevel@tonic-gate #endif 1095*0Sstevel@tonic-gate 1096*0Sstevel@tonic-gate #endif /* !_RPC_SVC_H */ 1097