xref: /titanic_50/usr/src/uts/common/rpc/svc_auth.h (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
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 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
28 /*
29  * Portions of this source code were derived from Berkeley
30  * 4.3 BSD under license from the Regents of the University of
31  * California.
32  */
33 
34 #ifndef _RPC_SVC_AUTH_H
35 #define	_RPC_SVC_AUTH_H
36 
37 #pragma ident	"%Z%%M%	%I%	%E% SMI"
38 
39 /*
40  * svc_auth.h, Service side of rpc authentication.
41  */
42 #include <rpc/rpcsec_gss.h>
43 #include <rpc/rpc_msg.h>
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /*
50  * Server side authenticator
51  */
52 #ifdef _KERNEL
53 /*
54  * Copy of GSS parameters, needed for MT operation
55  */
56 typedef struct {
57 	bool_t			established;
58 	rpc_gss_service_t	service;
59 	uint_t			qop_rcvd;
60 	void			*context;
61 	uint_t			seq_num;
62 } svc_rpc_gss_parms_t;
63 
64 /*
65  * sec_svc_control() commands
66  */
67 #define	RPC_SVC_SET_GSS_CALLBACK	1  /* set rpcsec_gss callback routine */
68 extern bool_t sec_svc_control();
69 
70 /*
71  * Interface to server-side authentication flavors, may change on
72  * each request.
73  */
74 typedef struct {
75 	struct svc_auth_ops {
76 		int		(*svc_ah_wrap)();
77 		int		(*svc_ah_unwrap)();
78 	} svc_ah_ops;
79 	caddr_t			svc_ah_private;
80 	svc_rpc_gss_parms_t	svc_gss_parms;
81 	rpc_gss_rawcred_t	raw_cred;
82 } SVCAUTH;
83 
84 #define	SVCAUTH_GSSPARMS(auth)  ((svc_rpc_gss_parms_t *)&(auth)->svc_gss_parms)
85 
86 /*
87  * Auth flavors can now apply a transformation in addition to simple XDR
88  * on the body of a call/response in ways that depend on the flavor being
89  * used.  These interfaces provide a generic interface between the
90  * internal RPC frame and the auth flavor specific code to allow the
91  * auth flavor to encode (WRAP) or decode (UNWRAP) the body.
92  */
93 #define	SVCAUTH_WRAP(auth, xdrs, xfunc, xwhere) \
94 	((*((auth)->svc_ah_ops.svc_ah_wrap))(auth, xdrs, xfunc, xwhere))
95 #define	SVCAUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \
96 	((*((auth)->svc_ah_ops.svc_ah_unwrap))(auth, xdrs, xfunc, xwhere))
97 
98 /*
99  * Server side authenticator
100  */
101 #ifdef __STDC__
102 extern enum auth_stat sec_svc_msg(struct svc_req *, struct rpc_msg *,
103 				bool_t *);
104 #else
105 extern enum auth_stat sec_svc_msg();
106 #endif /* __STDC__ */
107 
108 #else
109 
110 #ifdef __STDC__
111 extern enum auth_stat __gss_authenticate(struct svc_req *, struct rpc_msg *,
112 				bool_t *);
113 extern enum auth_stat __authenticate(struct svc_req *, struct rpc_msg *);
114 #else
115 extern enum auth_stat __gss_authenticate();
116 extern enum auth_stat __authenticate();
117 #endif /* __STDC__ */
118 
119 #endif /* _KERNEL */
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif	/* _RPC_SVC_AUTH_H */
126