summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/rpc/rpcsec_defs.h
blob: 98bf6e05be4faf7f4f2e33b02bac888a29320bf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1996,1997-1998 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef	_RPCSEC_DEFS_H
#define	_RPCSEC_DEFS_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

/*
 * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved.
 *
 * $Id: auth_gssapi.h,v 1.11 1994/10/27 12:39:14 jik Exp $
 */

#ifndef _KERNEL
#include <libintl.h>
#include <locale.h>
#endif
#include <gssapi/gssapi.h>
#include <rpc/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

#ifdef _KERNEL

#if defined(DEBUG) && !defined(RPCGSS_DEBUG)
#define	RPCGSS_DEBUG
#endif

#ifdef RPCGSS_DEBUG
extern uint_t rpcgss_log;

#define	RPCGSS_LOG1(A, B, C, D) \
	((void)((rpcgss_log) && (rpcgss_log & (A)) && (printf((B), \
	    (C), (D)), TRUE)))
#define	RPCGSS_LOG(A, B, C) \
	((void)((rpcgss_log) && (rpcgss_log & (A)) && (printf((B), (C)), TRUE)))
#define	RPCGSS_LOG0(A, B)   \
	((void)((rpcgss_log) && (rpcgss_log & (A)) && (printf(B), TRUE)))
#else
#define	RPCGSS_LOG1(A, B, C, D)
#define	RPCGSS_LOG(A, B, C)
#define	RPCGSS_LOG0(A, B)
#endif

#else /* _KERNEL */

extern bool_t locale_set;
#if !defined(TEXT_DOMAIN)
#define	TEXT_DOMAIN "SUNW_OST_OSCMD"
#endif

#endif /* _KERNEL */


typedef struct _rpc_gss_creds {
	uint_t version;
	uint_t gss_proc;
	uint_t seq_num;
	rpc_gss_service_t service;
	gss_buffer_desc ctx_handle;
} rpc_gss_creds;

typedef gss_buffer_desc rpc_gss_init_arg;

typedef struct _rpc_gss_init_res {
	gss_buffer_desc ctx_handle;
	OM_uint32 gss_major, gss_minor;
	OM_uint32 seq_window;
	gss_buffer_desc token;
} rpc_gss_init_res;


/*
 * Convenience macros.
 */

#define	GSS_COPY_BUFFER(dest, src) { \
	(dest).length = (src).length; \
	(dest).value = (src).value; }

#define	GSS_DUP_BUFFER(dest, src) { \
	(dest).length = (src).length; \
	(dest).value = (void *) mem_alloc((dest).length); \
	bcopy((src).value, (dest).value, (dest).length); }

#define	GSS_BUFFERS_EQUAL(b1, b2) (((b1).length == (b2).length) && \
			(bcmp((b1).value, (b2).value, (b1.length)) == 0))

#define	GSS_OIDS_EQUAL(o1, o2) \
	((((gss_OID)(o1))->length == ((gss_OID)(o2))->length) && \
		(bcmp(((gss_OID)(o1))->elements, ((gss_OID)(o2))->elements, \
			((gss_OID)(o1))->length) == 0))

#define	MAX_GSS_NAME			128

/*
 * Private interfaces for user and kernel space.
 */
bool_t __xdr_gss_buf();
bool_t __xdr_rpc_gss_creds();
bool_t __xdr_rpc_gss_init_arg();
bool_t __xdr_rpc_gss_init_res();

bool_t __rpc_gss_wrap_data();
bool_t __rpc_gss_unwrap_data();

#ifdef	_KERNEL
/*
 * kernel-level RPCSEC_GSS definitions.
 */

void __rpc_gss_dup_oid(gss_OID, gss_OID *);
bool_t __rpc_gss_oids_equal(gss_OID oid1, gss_OID oid2);
void rpc_gss_display_status(OM_uint32 major, OM_uint32 minor,
			    rpc_gss_OID mechanism, uid_t uid,
			    char *function_name);
#else
/*
 * user-level RPCSEC_GSS definitions.
 */

#define	MAX_MECH_OID_PAIRS		32

typedef struct _rpc_gss_name {
	char *name;
	rpc_gss_OID type;
} rpc_gss_name;

#ifdef	_REENTRANT
extern rpc_gss_error_t	*__rpc_gss_err();
#define	rpc_gss_err	(*(__rpc_gss_err()))
#else
extern rpc_gss_error_t rpc_gss_err;
#endif	/* _REENTRANT */

/*
 * Private interfaces in user space.
 */
bool_t __rpc_gss_qop_to_num();
char *__rpc_gss_num_to_qop();
bool_t __rpc_gss_mech_to_oid();
char *__rpc_gss_oid_to_mech();
bool_t __rpc_gss_svc_to_num();
char *__rpc_gss_num_to_svc();

void __rpc_gss_xdrdynamic_create();
caddr_t __rpc_gss_xdrdynamic_getdata();

bool_t __rpcsec_init();
rpc_gss_OID __get_gss_oid();
void __rpc_gss_bind_error();
int __find_max_data_length(rpc_gss_service_t service, gss_ctx_id_t context,
	OM_uint32 qop, int max_tp_unit_len);

#endif /* _KERNEL */

#ifdef	__cplusplus
}
#endif

#endif	/* _RPCSEC_DEFS_H */