xref: /titanic_41/usr/src/uts/common/smbsrv/smb_dfs.h (revision c39526b769298791ff5b0b6c5e761f49aabaeb4e)
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 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
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 typedef enum {
104 	DfsInvalidPriorityClass		= -1,
105 	DfsSiteCostNormalPriorityClass	= 0,
106 	DfsGlobalHighPriorityClass	= 1,
107 	DfsSiteCostHighPriorityClass	= 2,
108 	DfsSiteCostLowPriorityClass	= 3,
109 	DfsGlobalLowPriorityClass	= 4
110 } dfs_target_pclass_t;
111 
112 #define	DFS_PROPERTY_FLAG_INSITE_REFERRALS	0x00000001
113 #define	DFS_PROPERTY_FLAG_ROOT_SCALABILITY	0x00000002
114 #define	DFS_PROPERTY_FLAG_SITE_COSTING		0x00000004
115 #define	DFS_PROPERTY_FLAG_TARGET_FAILBACK	0x00000008
116 #define	DFS_PROPERTY_FLAG_CLUSTER_ENABLED	0x00000010
117 #define	DFS_PROPERTY_FLAG_ABDE			0x00000020
118 
119 #define	DFS_NAME_MAX			MAXNAMELEN
120 #define	DFS_PATH_MAX			MAXPATHLEN
121 #define	DFS_COMMENT_MAX			256
122 #define	DFS_SRVNAME_MAX			MAXNAMELEN
123 
124 #define	DFS_REPARSE_SVCTYPE		"SMB-DFS"
125 
126 #define	DFS_OBJECT_LINK		1
127 #define	DFS_OBJECT_ROOT		2
128 #define	DFS_OBJECT_ANY		3
129 
130 /*
131  * Referral Request Types
132  */
133 typedef enum {
134 	DFS_REFERRAL_INVALID = 0,
135 	DFS_REFERRAL_DOMAIN,
136 	DFS_REFERRAL_DC,
137 	DFS_REFERRAL_SYSVOL,
138 	DFS_REFERRAL_ROOT,
139 	DFS_REFERRAL_LINK
140 } dfs_reftype_t;
141 
142 typedef struct dfs_target_priority {
143 	dfs_target_pclass_t	p_class;
144 	uint16_t		p_rank;
145 } dfs_target_priority_t;
146 
147 /*
148  * t_server	a null-terminated Unicode string that specifies the DFS link
149  *		target host name.
150  *
151  * t_share	a null-terminated Unicode DFS link target share name string.
152  *		This may also be a share name with a path relative to the share,
153  *		for example, "share1\mydir1\mydir2". When specified this way,
154  *		each pathname component MUST be a directory
155  *
156  * t_state	valid states are online/offline (see DFS_STORAGE_STATE_XXX in
157  * 		lmdfs.h)
158  *
159  * t_priority	priority class and rank
160  */
161 typedef struct dfs_target {
162 	char			t_server[DFS_SRVNAME_MAX];
163 	char			t_share[DFS_NAME_MAX];
164 	uint32_t		t_state;
165 	dfs_target_priority_t	t_priority;
166 } dfs_target_t;
167 
168 typedef struct dfs_info {
169 	char		i_uncpath[DFS_PATH_MAX];
170 	char		i_comment[DFS_COMMENT_MAX];
171 	char		i_guid[UUID_PRINTABLE_STRING_LENGTH];
172 	uint32_t	i_state;
173 	uint32_t	i_timeout;
174 	uint32_t	i_propflags;
175 	uint32_t	i_type;
176 	uint32_t	i_ntargets;
177 	dfs_target_t	*i_targets;
178 } dfs_info_t;
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 
185 #endif /* _SMB_DFS_H */
186