xref: /illumos-gate/usr/src/uts/common/smbsrv/smb_dfs.h (revision 43da549e0419e2943d8bd143ebfb1db11a16c569)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
24  */
25 
26 #ifndef _SMB_DFS_H
27 #define	_SMB_DFS_H
28 
29 #include <sys/param.h>
30 #include <sys/uuid.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * DFS root or link states
38  *
39  * DFS_VOLUME_STATE_OK
40  *    The specified DFS root or DFS link is in the normal state.
41  *
42  * DFS_VOLUME_STATE_INCONSISTENT
43  *    The internal DFS database is inconsistent with the specified DFS root or
44  *    DFS link. Attempts to repair the inconsistency have failed. This is a
45  *    read-only state and MUST NOT be set by clients.
46  *
47  * DFS_VOLUME_STATE_OFFLINE
48  *    The specified DFS root or DFS link is offline or unavailable.
49  *
50  * DFS_VOLUME_STATE_ONLINE
51  *    The specified DFS root or DFS link is available.
52  *
53  * DFS_VOLUME_FLAVOR_STANDALONE	Standalone namespace
54  * DFS_VOLUME_FLAVOR_AD_BLOB	Domain-based namespace
55  */
56 #define	DFS_VOLUME_STATE_OK			0x00000001
57 #define	DFS_VOLUME_STATE_INCONSISTENT		0x00000002
58 #define	DFS_VOLUME_STATE_OFFLINE		0x00000003
59 #define	DFS_VOLUME_STATE_ONLINE			0x00000004
60 #define	DFS_VOLUME_STATE_RESYNCHRONIZE		0x00000010
61 #define	DFS_VOLUME_STATE_STANDBY		0x00000020
62 #define	DFS_VOLUME_STATE_FORCE_SYNC		0x00000040
63 
64 #define	DFS_VOLUME_FLAVOR_STANDALONE		0x00000100
65 #define	DFS_VOLUME_FLAVOR_AD_BLOB		0x00000200
66 
67 /*
68  * The following bitmasks is only relevant when reading the volume state, not
69  * for setting it.
70  */
71 #define	DFS_VOLUME_STATES			0x0000000F
72 #define	DFS_VOLUME_FLAVORS			0x00000300
73 
74 /*
75  * States specified by this mask are used to perform a server operation and are
76  * not persisted to the DFS metadata
77  */
78 #define	DFS_VOLUME_STATES_SRV_OPS		0x00000070
79 
80 /*
81  * DFS Storage state
82  */
83 #define	DFS_STORAGE_STATE_OFFLINE	1
84 #define	DFS_STORAGE_STATE_ONLINE	2
85 
86 /*
87  * Flags for NetrDfsAdd operation:
88  *
89  * 0x00000000		This creates a new link or adds a new target to an
90  * 			existing link.
91  *
92  * DFS_ADD_VOLUME	This creates a new link in the DFS namespace if one does
93  * 			not already exist or fails if a link already exists.
94  *
95  * DFS_RESTORE_VOLUME	This adds a target without verifying its existence.
96  */
97 #define	DFS_CREATE_VOLUME	0x00000000
98 #define	DFS_ADD_VOLUME		0x00000001
99 #define	DFS_RESTORE_VOLUME	0x00000002
100 
101 #define	DFS_MOVE_FLAG_REPLACE_IF_EXISTS		1
102 
103 /*
104  * See also: dfs_target_pclass_xdr()
105  */
106 typedef enum {
107 	DfsInvalidPriorityClass		= -1,
108 	DfsSiteCostNormalPriorityClass	= 0,
109 	DfsGlobalHighPriorityClass	= 1,
110 	DfsSiteCostHighPriorityClass	= 2,
111 	DfsSiteCostLowPriorityClass	= 3,
112 	DfsGlobalLowPriorityClass	= 4
113 } dfs_target_pclass_t;
114 
115 #define	DFS_PRIORITY_RANK_MAX		0x001F
116 
117 #define	DFS_PROPERTY_FLAG_INSITE_REFERRALS	0x00000001
118 #define	DFS_PROPERTY_FLAG_ROOT_SCALABILITY	0x00000002
119 #define	DFS_PROPERTY_FLAG_SITE_COSTING		0x00000004
120 #define	DFS_PROPERTY_FLAG_TARGET_FAILBACK	0x00000008
121 #define	DFS_PROPERTY_FLAG_CLUSTER_ENABLED	0x00000010
122 #define	DFS_PROPERTY_FLAG_ABDE			0x00000020
123 
124 #define	DFS_NAME_MAX			MAXNAMELEN
125 #define	DFS_PATH_MAX			MAXPATHLEN
126 #define	DFS_COMMENT_MAX			256
127 #define	DFS_SRVNAME_MAX			MAXNAMELEN
128 
129 #define	DFS_REPARSE_SVCTYPE		"SMB-DFS"
130 
131 #define	DFS_OBJECT_LINK		1
132 #define	DFS_OBJECT_ROOT		2
133 #define	DFS_OBJECT_ANY		3
134 
135 /*
136  * Referral Request Types
137  * See also: dfs_reftype_xdr()
138  */
139 typedef enum {
140 	DFS_REFERRAL_INVALID = 0,
141 	DFS_REFERRAL_DOMAIN,
142 	DFS_REFERRAL_DC,
143 	DFS_REFERRAL_SYSVOL,
144 	DFS_REFERRAL_ROOT,
145 	DFS_REFERRAL_LINK
146 } dfs_reftype_t;
147 
148 /*
149  * See also: dfs_target_priority_xdr()
150  */
151 typedef struct dfs_target_priority {
152 	dfs_target_pclass_t	p_class;
153 	uint16_t		p_rank;
154 } dfs_target_priority_t;
155 
156 /*
157  * t_server	a null-terminated Unicode string that specifies the DFS link
158  *		target host name.
159  *
160  * t_share	a null-terminated Unicode DFS link target share name string.
161  *		This may also be a share name with a path relative to the share,
162  *		for example, "share1\mydir1\mydir2". When specified this way,
163  *		each pathname component MUST be a directory
164  *
165  * t_state	valid states are online/offline (see DFS_STORAGE_STATE_XXX in
166  * 		lmdfs.h)
167  *
168  * t_priority	priority class and rank
169  *
170  * See also: dfs_target_xdr()
171  */
172 typedef struct dfs_target {
173 	char			t_server[DFS_SRVNAME_MAX];
174 	char			t_share[DFS_NAME_MAX];
175 	uint32_t		t_state;
176 	dfs_target_priority_t	t_priority;
177 } dfs_target_t;
178 
179 /*
180  * DFS referral response
181  * See also: dfs_info_xdr()
182  */
183 typedef struct dfs_info {
184 	char		i_uncpath[DFS_PATH_MAX];
185 	char		i_comment[DFS_COMMENT_MAX];
186 	char		i_guid[UUID_PRINTABLE_STRING_LENGTH];
187 	uint32_t	i_state;
188 	uint32_t	i_timeout;
189 	uint32_t	i_propflag_mask;
190 	uint32_t	i_propflags;
191 	uint32_t	i_type;
192 	uint32_t	i_ntargets;
193 	dfs_target_t	*i_targets;
194 	uint32_t	i_flavor;
195 } dfs_info_t;
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 
201 
202 #endif /* _SMB_DFS_H */
203