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