summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/smbsrv/smb_dfs.h
blob: 25e80838c7af342998be533b883970909dafc526 (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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (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) 2010, Oracle and/or its affiliates. All rights reserved.
 * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
 */

#ifndef _SMB_DFS_H
#define	_SMB_DFS_H

#include <sys/param.h>
#include <sys/uuid.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * DFS root or link states
 *
 * DFS_VOLUME_STATE_OK
 *    The specified DFS root or DFS link is in the normal state.
 *
 * DFS_VOLUME_STATE_INCONSISTENT
 *    The internal DFS database is inconsistent with the specified DFS root or
 *    DFS link. Attempts to repair the inconsistency have failed. This is a
 *    read-only state and MUST NOT be set by clients.
 *
 * DFS_VOLUME_STATE_OFFLINE
 *    The specified DFS root or DFS link is offline or unavailable.
 *
 * DFS_VOLUME_STATE_ONLINE
 *    The specified DFS root or DFS link is available.
 *
 * DFS_VOLUME_FLAVOR_STANDALONE	Standalone namespace
 * DFS_VOLUME_FLAVOR_AD_BLOB	Domain-based namespace
 */
#define	DFS_VOLUME_STATE_OK			0x00000001
#define	DFS_VOLUME_STATE_INCONSISTENT		0x00000002
#define	DFS_VOLUME_STATE_OFFLINE		0x00000003
#define	DFS_VOLUME_STATE_ONLINE			0x00000004
#define	DFS_VOLUME_STATE_RESYNCHRONIZE		0x00000010
#define	DFS_VOLUME_STATE_STANDBY		0x00000020
#define	DFS_VOLUME_STATE_FORCE_SYNC		0x00000040

#define	DFS_VOLUME_FLAVOR_STANDALONE		0x00000100
#define	DFS_VOLUME_FLAVOR_AD_BLOB		0x00000200

/*
 * The following bitmasks is only relevant when reading the volume state, not
 * for setting it.
 */
#define	DFS_VOLUME_STATES			0x0000000F
#define	DFS_VOLUME_FLAVORS			0x00000300

/*
 * States specified by this mask are used to perform a server operation and are
 * not persisted to the DFS metadata
 */
#define	DFS_VOLUME_STATES_SRV_OPS		0x00000070

/*
 * DFS Storage state
 */
#define	DFS_STORAGE_STATE_OFFLINE	1
#define	DFS_STORAGE_STATE_ONLINE	2

/*
 * Flags for NetrDfsAdd operation:
 *
 * 0x00000000		This creates a new link or adds a new target to an
 * 			existing link.
 *
 * DFS_ADD_VOLUME	This creates a new link in the DFS namespace if one does
 * 			not already exist or fails if a link already exists.
 *
 * DFS_RESTORE_VOLUME	This adds a target without verifying its existence.
 */
#define	DFS_CREATE_VOLUME	0x00000000
#define	DFS_ADD_VOLUME		0x00000001
#define	DFS_RESTORE_VOLUME	0x00000002

#define	DFS_MOVE_FLAG_REPLACE_IF_EXISTS		1

/*
 * See also: dfs_target_pclass_xdr()
 */
typedef enum {
	DfsInvalidPriorityClass		= -1,
	DfsSiteCostNormalPriorityClass	= 0,
	DfsGlobalHighPriorityClass	= 1,
	DfsSiteCostHighPriorityClass	= 2,
	DfsSiteCostLowPriorityClass	= 3,
	DfsGlobalLowPriorityClass	= 4
} dfs_target_pclass_t;

#define	DFS_PRIORITY_RANK_MAX		0x001F

#define	DFS_PROPERTY_FLAG_INSITE_REFERRALS	0x00000001
#define	DFS_PROPERTY_FLAG_ROOT_SCALABILITY	0x00000002
#define	DFS_PROPERTY_FLAG_SITE_COSTING		0x00000004
#define	DFS_PROPERTY_FLAG_TARGET_FAILBACK	0x00000008
#define	DFS_PROPERTY_FLAG_CLUSTER_ENABLED	0x00000010
#define	DFS_PROPERTY_FLAG_ABDE			0x00000020

#define	DFS_NAME_MAX			MAXNAMELEN
#define	DFS_PATH_MAX			MAXPATHLEN
#define	DFS_COMMENT_MAX			256
#define	DFS_SRVNAME_MAX			MAXNAMELEN

#define	DFS_REPARSE_SVCTYPE		"SMB-DFS"

#define	DFS_OBJECT_LINK		1
#define	DFS_OBJECT_ROOT		2
#define	DFS_OBJECT_ANY		3

/*
 * Referral Request Types
 * See also: dfs_reftype_xdr()
 */
typedef enum {
	DFS_REFERRAL_INVALID = 0,
	DFS_REFERRAL_DOMAIN,
	DFS_REFERRAL_DC,
	DFS_REFERRAL_SYSVOL,
	DFS_REFERRAL_ROOT,
	DFS_REFERRAL_LINK
} dfs_reftype_t;

/*
 * See also: dfs_target_priority_xdr()
 */
typedef struct dfs_target_priority {
	dfs_target_pclass_t	p_class;
	uint16_t		p_rank;
} dfs_target_priority_t;

/*
 * t_server	a null-terminated Unicode string that specifies the DFS link
 *		target host name.
 *
 * t_share	a null-terminated Unicode DFS link target share name string.
 *		This may also be a share name with a path relative to the share,
 *		for example, "share1\mydir1\mydir2". When specified this way,
 *		each pathname component MUST be a directory
 *
 * t_state	valid states are online/offline (see DFS_STORAGE_STATE_XXX in
 * 		lmdfs.h)
 *
 * t_priority	priority class and rank
 *
 * See also: dfs_target_xdr()
 */
typedef struct dfs_target {
	char			t_server[DFS_SRVNAME_MAX];
	char			t_share[DFS_NAME_MAX];
	uint32_t		t_state;
	dfs_target_priority_t	t_priority;
} dfs_target_t;

/*
 * DFS referral response
 * See also: dfs_info_xdr()
 */
typedef struct dfs_info {
	char		i_uncpath[DFS_PATH_MAX];
	char		i_comment[DFS_COMMENT_MAX];
	char		i_guid[UUID_PRINTABLE_STRING_LENGTH];
	uint32_t	i_state;
	uint32_t	i_timeout;
	uint32_t	i_propflag_mask;
	uint32_t	i_propflags;
	uint32_t	i_type;
	uint32_t	i_ntargets;
	dfs_target_t	*i_targets;
	uint32_t	i_flavor;
} dfs_info_t;

#ifdef __cplusplus
}
#endif


#endif /* _SMB_DFS_H */