xref: /titanic_51/usr/src/uts/common/rpc/svc_mt.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _RPC_SVC_MT_H
28*7c478bd9Sstevel@tonic-gate #define	_RPC_SVC_MT_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #include <synch.h>		/* needed for mutex_t declaration */
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate /*
35*7c478bd9Sstevel@tonic-gate  * Private service definitions
36*7c478bd9Sstevel@tonic-gate  */
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
39*7c478bd9Sstevel@tonic-gate extern "C" {
40*7c478bd9Sstevel@tonic-gate #endif
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate /*
43*7c478bd9Sstevel@tonic-gate  * SVC flags
44*7c478bd9Sstevel@tonic-gate  */
45*7c478bd9Sstevel@tonic-gate #define	SVC_VERSQUIET	0x0001	/* keep quiet about version mismatch */
46*7c478bd9Sstevel@tonic-gate #define	SVC_DEFUNCT	0x0002	/* xprt is defunct, release asap */
47*7c478bd9Sstevel@tonic-gate #define	SVC_DGRAM	0x0004	/* datagram type */
48*7c478bd9Sstevel@tonic-gate #define	SVC_RENDEZVOUS	0x0008	/* rendezvous */
49*7c478bd9Sstevel@tonic-gate #define	SVC_CONNECTION	0x000c	/* connection */
50*7c478bd9Sstevel@tonic-gate #define	SVC_DOOR	0x0010	/* door ipc */
51*7c478bd9Sstevel@tonic-gate #define	SVC_TYPE_MASK	0x001c	/* type mask */
52*7c478bd9Sstevel@tonic-gate #define	SVC_FAILED	0x0020	/* send/receive failed, used for VC */
53*7c478bd9Sstevel@tonic-gate #define	SVC_ARGS_CHECK	0x0040	/* flag to check for argument completion */
54*7c478bd9Sstevel@tonic-gate 
55*7c478bd9Sstevel@tonic-gate #define	svc_flags(xprt)		(SVCEXT(xprt)->flags)
56*7c478bd9Sstevel@tonic-gate #define	version_keepquiet(xprt)	(svc_flags(xprt) & SVC_VERSQUIET)
57*7c478bd9Sstevel@tonic-gate #define	svc_defunct(xprt)	((svc_flags(xprt) & SVC_DEFUNCT) ? TRUE : FALSE)
58*7c478bd9Sstevel@tonic-gate #define	svc_failed(xprt)	((svc_flags(xprt) & SVC_FAILED) ? TRUE : FALSE)
59*7c478bd9Sstevel@tonic-gate #define	svc_type(xprt)		(svc_flags(xprt) & SVC_TYPE_MASK)
60*7c478bd9Sstevel@tonic-gate #define	svc_send_mutex(xprt)	(SVCEXT(xprt)->send_mutex)
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate /*
64*7c478bd9Sstevel@tonic-gate  * Copy of GSS parameters, needed for MT operation
65*7c478bd9Sstevel@tonic-gate  */
66*7c478bd9Sstevel@tonic-gate typedef struct {
67*7c478bd9Sstevel@tonic-gate 	bool_t			established;
68*7c478bd9Sstevel@tonic-gate 	rpc_gss_service_t	service;
69*7c478bd9Sstevel@tonic-gate 	uint_t			qop_rcvd;
70*7c478bd9Sstevel@tonic-gate 	void			*context;
71*7c478bd9Sstevel@tonic-gate 	uint_t			seq_num;
72*7c478bd9Sstevel@tonic-gate } svc_rpc_gss_parms_t;
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate /*
75*7c478bd9Sstevel@tonic-gate  * Interface to server-side authentication flavors, may vary with
76*7c478bd9Sstevel@tonic-gate  * each request.
77*7c478bd9Sstevel@tonic-gate  *
78*7c478bd9Sstevel@tonic-gate  * NOTE: This structure is part of an interface, and must not change.
79*7c478bd9Sstevel@tonic-gate  */
80*7c478bd9Sstevel@tonic-gate typedef struct {
81*7c478bd9Sstevel@tonic-gate 	struct svc_auth_ops {
82*7c478bd9Sstevel@tonic-gate 		int		(*svc_ah_wrap)();
83*7c478bd9Sstevel@tonic-gate 		int		(*svc_ah_unwrap)();
84*7c478bd9Sstevel@tonic-gate 	} svc_ah_ops;
85*7c478bd9Sstevel@tonic-gate 	caddr_t			svc_ah_private;
86*7c478bd9Sstevel@tonic-gate 	svc_rpc_gss_parms_t	svc_gss_parms;
87*7c478bd9Sstevel@tonic-gate 	rpc_gss_rawcred_t	raw_cred;
88*7c478bd9Sstevel@tonic-gate } SVCAUTH;
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate /*
91*7c478bd9Sstevel@tonic-gate  * The xp_p3 field the the service handle points to the SVCXPRT_EXT
92*7c478bd9Sstevel@tonic-gate  * extension structure.
93*7c478bd9Sstevel@tonic-gate  */
94*7c478bd9Sstevel@tonic-gate typedef struct svcxprt_list_t {
95*7c478bd9Sstevel@tonic-gate 	struct svcxprt_list_t	*next;
96*7c478bd9Sstevel@tonic-gate 	SVCXPRT			*xprt;
97*7c478bd9Sstevel@tonic-gate } SVCXPRT_LIST;
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate typedef struct svcxprt_ext_t {
100*7c478bd9Sstevel@tonic-gate 	int		flags;		/* VERSQUIET, DEFUNCT flag */
101*7c478bd9Sstevel@tonic-gate 	SVCXPRT		*parent;	/* points to parent (NULL in parent) */
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate 	struct rpc_msg	*msg;		/* message */
104*7c478bd9Sstevel@tonic-gate 	struct svc_req	*req;		/* request */
105*7c478bd9Sstevel@tonic-gate 	char		*cred_area;	/* auth work area */
106*7c478bd9Sstevel@tonic-gate 	int		refcnt;		/* number of parent references */
107*7c478bd9Sstevel@tonic-gate 	SVCXPRT_LIST	*my_xlist;	/* list header for this copy */
108*7c478bd9Sstevel@tonic-gate 	mutex_t		send_mutex;	/* for sequencing sends */
109*7c478bd9Sstevel@tonic-gate 	SVCAUTH		xp_auth;	/* flavor of current request */
110*7c478bd9Sstevel@tonic-gate } SVCXPRT_EXT;
111*7c478bd9Sstevel@tonic-gate 
112*7c478bd9Sstevel@tonic-gate #define	SVCEXT(xprt)		((SVCXPRT_EXT *)((xprt)->xp_p3))
113*7c478bd9Sstevel@tonic-gate #define	SVC_XP_AUTH(xprt)	(SVCEXT(xprt)->xp_auth)
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate #define	SVCAUTH_WRAP(auth, xdrs, xfunc, xwhere) \
116*7c478bd9Sstevel@tonic-gate 	((*((auth)->svc_ah_ops.svc_ah_wrap))(auth, xdrs, xfunc, xwhere))
117*7c478bd9Sstevel@tonic-gate #define	SVCAUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \
118*7c478bd9Sstevel@tonic-gate 	((*((auth)->svc_ah_ops.svc_ah_unwrap))(auth, xdrs, xfunc, xwhere))
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate /*
121*7c478bd9Sstevel@tonic-gate  * Global/module private data and functions
122*7c478bd9Sstevel@tonic-gate  */
123*7c478bd9Sstevel@tonic-gate extern SVCXPRT **svc_xports;
124*7c478bd9Sstevel@tonic-gate extern XDR **svc_xdrs;
125*7c478bd9Sstevel@tonic-gate extern int svc_mt_mode;
126*7c478bd9Sstevel@tonic-gate extern mutex_t svc_thr_mutex;
127*7c478bd9Sstevel@tonic-gate extern cond_t svc_thr_fdwait;
128*7c478bd9Sstevel@tonic-gate extern int svc_nfds;
129*7c478bd9Sstevel@tonic-gate extern int svc_nfds_set;
130*7c478bd9Sstevel@tonic-gate extern int svc_max_fd;
131*7c478bd9Sstevel@tonic-gate extern mutex_t svc_mutex;
132*7c478bd9Sstevel@tonic-gate extern mutex_t svc_exit_mutex;
133*7c478bd9Sstevel@tonic-gate extern int svc_pipe[2];
134*7c478bd9Sstevel@tonic-gate extern bool_t svc_polling;
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate SVCXPRT *svc_xprt_alloc();
137*7c478bd9Sstevel@tonic-gate SVCXPRT *svc_dg_xprtcopy();
138*7c478bd9Sstevel@tonic-gate SVCXPRT *svc_vc_xprtcopy();
139*7c478bd9Sstevel@tonic-gate SVCXPRT *svc_fd_xprtcopy();
140*7c478bd9Sstevel@tonic-gate SVCXPRT *svc_copy();
141*7c478bd9Sstevel@tonic-gate void svc_xprt_free();
142*7c478bd9Sstevel@tonic-gate void svc_xprt_destroy();
143*7c478bd9Sstevel@tonic-gate void svc_dg_xprtfree();
144*7c478bd9Sstevel@tonic-gate void svc_vc_xprtfree();
145*7c478bd9Sstevel@tonic-gate void svc_fd_xprtfree();
146*7c478bd9Sstevel@tonic-gate void svc_door_xprtfree();
147*7c478bd9Sstevel@tonic-gate void svc_args_done();
148*7c478bd9Sstevel@tonic-gate void _svc_dg_destroy_private();
149*7c478bd9Sstevel@tonic-gate void _svc_vc_destroy_private();
150*7c478bd9Sstevel@tonic-gate void _svc_destroy_private();
151*7c478bd9Sstevel@tonic-gate 
152*7c478bd9Sstevel@tonic-gate #define	RPC_DOOR_DIR		"/var/run/rpc_door"
153*7c478bd9Sstevel@tonic-gate #define	RPC_DOOR_RENDEZVOUS	"/var/run/rpc_door/rpc_%d.%d"
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
156*7c478bd9Sstevel@tonic-gate }
157*7c478bd9Sstevel@tonic-gate #endif
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate #endif /* !_RPC_SVC_MT_H */
160