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 27*0Sstevel@tonic-gate #ifndef _RPC_SVC_MT_H 28*0Sstevel@tonic-gate #define _RPC_SVC_MT_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <synch.h> /* needed for mutex_t declaration */ 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate /* 35*0Sstevel@tonic-gate * Private service definitions 36*0Sstevel@tonic-gate */ 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate #ifdef __cplusplus 39*0Sstevel@tonic-gate extern "C" { 40*0Sstevel@tonic-gate #endif 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate /* 43*0Sstevel@tonic-gate * SVC flags 44*0Sstevel@tonic-gate */ 45*0Sstevel@tonic-gate #define SVC_VERSQUIET 0x0001 /* keep quiet about version mismatch */ 46*0Sstevel@tonic-gate #define SVC_DEFUNCT 0x0002 /* xprt is defunct, release asap */ 47*0Sstevel@tonic-gate #define SVC_DGRAM 0x0004 /* datagram type */ 48*0Sstevel@tonic-gate #define SVC_RENDEZVOUS 0x0008 /* rendezvous */ 49*0Sstevel@tonic-gate #define SVC_CONNECTION 0x000c /* connection */ 50*0Sstevel@tonic-gate #define SVC_DOOR 0x0010 /* door ipc */ 51*0Sstevel@tonic-gate #define SVC_TYPE_MASK 0x001c /* type mask */ 52*0Sstevel@tonic-gate #define SVC_FAILED 0x0020 /* send/receive failed, used for VC */ 53*0Sstevel@tonic-gate #define SVC_ARGS_CHECK 0x0040 /* flag to check for argument completion */ 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate #define svc_flags(xprt) (SVCEXT(xprt)->flags) 56*0Sstevel@tonic-gate #define version_keepquiet(xprt) (svc_flags(xprt) & SVC_VERSQUIET) 57*0Sstevel@tonic-gate #define svc_defunct(xprt) ((svc_flags(xprt) & SVC_DEFUNCT) ? TRUE : FALSE) 58*0Sstevel@tonic-gate #define svc_failed(xprt) ((svc_flags(xprt) & SVC_FAILED) ? TRUE : FALSE) 59*0Sstevel@tonic-gate #define svc_type(xprt) (svc_flags(xprt) & SVC_TYPE_MASK) 60*0Sstevel@tonic-gate #define svc_send_mutex(xprt) (SVCEXT(xprt)->send_mutex) 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate /* 64*0Sstevel@tonic-gate * Copy of GSS parameters, needed for MT operation 65*0Sstevel@tonic-gate */ 66*0Sstevel@tonic-gate typedef struct { 67*0Sstevel@tonic-gate bool_t established; 68*0Sstevel@tonic-gate rpc_gss_service_t service; 69*0Sstevel@tonic-gate uint_t qop_rcvd; 70*0Sstevel@tonic-gate void *context; 71*0Sstevel@tonic-gate uint_t seq_num; 72*0Sstevel@tonic-gate } svc_rpc_gss_parms_t; 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate /* 75*0Sstevel@tonic-gate * Interface to server-side authentication flavors, may vary with 76*0Sstevel@tonic-gate * each request. 77*0Sstevel@tonic-gate * 78*0Sstevel@tonic-gate * NOTE: This structure is part of an interface, and must not change. 79*0Sstevel@tonic-gate */ 80*0Sstevel@tonic-gate typedef struct { 81*0Sstevel@tonic-gate struct svc_auth_ops { 82*0Sstevel@tonic-gate int (*svc_ah_wrap)(); 83*0Sstevel@tonic-gate int (*svc_ah_unwrap)(); 84*0Sstevel@tonic-gate } svc_ah_ops; 85*0Sstevel@tonic-gate caddr_t svc_ah_private; 86*0Sstevel@tonic-gate svc_rpc_gss_parms_t svc_gss_parms; 87*0Sstevel@tonic-gate rpc_gss_rawcred_t raw_cred; 88*0Sstevel@tonic-gate } SVCAUTH; 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gate /* 91*0Sstevel@tonic-gate * The xp_p3 field the the service handle points to the SVCXPRT_EXT 92*0Sstevel@tonic-gate * extension structure. 93*0Sstevel@tonic-gate */ 94*0Sstevel@tonic-gate typedef struct svcxprt_list_t { 95*0Sstevel@tonic-gate struct svcxprt_list_t *next; 96*0Sstevel@tonic-gate SVCXPRT *xprt; 97*0Sstevel@tonic-gate } SVCXPRT_LIST; 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate typedef struct svcxprt_ext_t { 100*0Sstevel@tonic-gate int flags; /* VERSQUIET, DEFUNCT flag */ 101*0Sstevel@tonic-gate SVCXPRT *parent; /* points to parent (NULL in parent) */ 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate struct rpc_msg *msg; /* message */ 104*0Sstevel@tonic-gate struct svc_req *req; /* request */ 105*0Sstevel@tonic-gate char *cred_area; /* auth work area */ 106*0Sstevel@tonic-gate int refcnt; /* number of parent references */ 107*0Sstevel@tonic-gate SVCXPRT_LIST *my_xlist; /* list header for this copy */ 108*0Sstevel@tonic-gate mutex_t send_mutex; /* for sequencing sends */ 109*0Sstevel@tonic-gate SVCAUTH xp_auth; /* flavor of current request */ 110*0Sstevel@tonic-gate } SVCXPRT_EXT; 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate #define SVCEXT(xprt) ((SVCXPRT_EXT *)((xprt)->xp_p3)) 113*0Sstevel@tonic-gate #define SVC_XP_AUTH(xprt) (SVCEXT(xprt)->xp_auth) 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate #define SVCAUTH_WRAP(auth, xdrs, xfunc, xwhere) \ 116*0Sstevel@tonic-gate ((*((auth)->svc_ah_ops.svc_ah_wrap))(auth, xdrs, xfunc, xwhere)) 117*0Sstevel@tonic-gate #define SVCAUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \ 118*0Sstevel@tonic-gate ((*((auth)->svc_ah_ops.svc_ah_unwrap))(auth, xdrs, xfunc, xwhere)) 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate /* 121*0Sstevel@tonic-gate * Global/module private data and functions 122*0Sstevel@tonic-gate */ 123*0Sstevel@tonic-gate extern SVCXPRT **svc_xports; 124*0Sstevel@tonic-gate extern XDR **svc_xdrs; 125*0Sstevel@tonic-gate extern int svc_mt_mode; 126*0Sstevel@tonic-gate extern mutex_t svc_thr_mutex; 127*0Sstevel@tonic-gate extern cond_t svc_thr_fdwait; 128*0Sstevel@tonic-gate extern int svc_nfds; 129*0Sstevel@tonic-gate extern int svc_nfds_set; 130*0Sstevel@tonic-gate extern int svc_max_fd; 131*0Sstevel@tonic-gate extern mutex_t svc_mutex; 132*0Sstevel@tonic-gate extern mutex_t svc_exit_mutex; 133*0Sstevel@tonic-gate extern int svc_pipe[2]; 134*0Sstevel@tonic-gate extern bool_t svc_polling; 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate SVCXPRT *svc_xprt_alloc(); 137*0Sstevel@tonic-gate SVCXPRT *svc_dg_xprtcopy(); 138*0Sstevel@tonic-gate SVCXPRT *svc_vc_xprtcopy(); 139*0Sstevel@tonic-gate SVCXPRT *svc_fd_xprtcopy(); 140*0Sstevel@tonic-gate SVCXPRT *svc_copy(); 141*0Sstevel@tonic-gate void svc_xprt_free(); 142*0Sstevel@tonic-gate void svc_xprt_destroy(); 143*0Sstevel@tonic-gate void svc_dg_xprtfree(); 144*0Sstevel@tonic-gate void svc_vc_xprtfree(); 145*0Sstevel@tonic-gate void svc_fd_xprtfree(); 146*0Sstevel@tonic-gate void svc_door_xprtfree(); 147*0Sstevel@tonic-gate void svc_args_done(); 148*0Sstevel@tonic-gate void _svc_dg_destroy_private(); 149*0Sstevel@tonic-gate void _svc_vc_destroy_private(); 150*0Sstevel@tonic-gate void _svc_destroy_private(); 151*0Sstevel@tonic-gate 152*0Sstevel@tonic-gate #define RPC_DOOR_DIR "/var/run/rpc_door" 153*0Sstevel@tonic-gate #define RPC_DOOR_RENDEZVOUS "/var/run/rpc_door/rpc_%d.%d" 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate #ifdef __cplusplus 156*0Sstevel@tonic-gate } 157*0Sstevel@tonic-gate #endif 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate #endif /* !_RPC_SVC_MT_H */ 160