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