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