xref: /illumos-gate/usr/src/uts/common/smbsrv/smbinfo.h (revision d5b563f27eb78296f57dddced6755afe7445c4b9)
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) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23  * Copyright 2020 Tintri by DDN, Inc. All rights reserved.
24  * Copyright 2022 RackTop Systems, Inc.
25  */
26 
27 #ifndef	_SMBSRV_SMBINFO_H
28 #define	_SMBSRV_SMBINFO_H
29 
30 #include <sys/types.h>
31 #include <sys/uuid.h>
32 #include <smbsrv/netbios.h>
33 #include <netinet/in.h>
34 #include <smbsrv/smb_inet.h>
35 #include <smbsrv/smb2.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * Native OS types used in SmbSessionSetupX.
43  */
44 #ifndef NATIVE_OS_DEFINED
45 #define	NATIVE_OS_DEFINED
46 
47 #define	NATIVE_OS_UNKNOWN	0x00000000
48 #define	NATIVE_OS_WINNT		0x00000001
49 #define	NATIVE_OS_WIN95		0x00000002
50 #define	NATIVE_OS_MACOS		0x00000003
51 #define	NATIVE_OS_WIN2000	0x00000004
52 
53 #endif /* NATIVE_OS_DEFINED */
54 
55 
56 /*
57  * Native lanman types in SmbSessionSetupX. Note that these values
58  * are not directly related to the negotiated protocol dialect.
59  */
60 #ifndef NATIVE_LANMAN_DEFINED
61 #define	NATIVE_LANMAN_DEFINED
62 
63 #define	NATIVE_LM_NONE		0x00000000
64 #define	NATIVE_LM_NT		0x00000001
65 #define	NATIVE_LM_WIN2000	0x00000002
66 
67 #endif /* NATIVE_LANMAN_DEFINED */
68 
69 
70 /* PDC types to be used in user authentication process */
71 
72 #define	PDC_UNKNOWN		0
73 #define	PDC_WINNT		1
74 #define	PDC_WIN2000		2
75 #define	PDC_WINXP		3
76 #define	PDC_SAMBA		4
77 
78 /*
79  * Please replace the use of MAX_NETWORKS with SMB_PI_MAX_NETWORKS if
80  * you find it used in conjunction with smbparm_info and maybe one day
81  * there will be just a single definition (here) throughout the code.
82  */
83 #ifndef MAX_NETWORKS
84 #define	MAX_NETWORKS		36
85 #endif /* MAX_NETWORKS */
86 
87 #define	SMB_PI_MAX_NETWORKS	36
88 #define	SMB_PI_MAX_WINS		2
89 
90 #define	SMB_SECMODE_WORKGRP	1
91 #define	SMB_SECMODE_DOMAIN	2
92 
93 #define	SMB_PI_MAX_HOST		48
94 #define	SMB_PI_MAX_DOMAIN	256
95 #define	SMB_PI_MAX_SCOPE	16
96 #define	SMB_PI_MAX_COMMENT	58
97 #define	SMB_PI_MAX_NATIVE_OS	32
98 #define	SMB_PI_MAX_LANMAN	32
99 #define	SMB_PI_MAX_NEGTOK	256	/* GUID and SMB negotiate token */
100 
101 #define	SMB_PI_KEEP_ALIVE_MIN		(90 * 60)
102 /*
103  * Some older clients (Windows 98) only handle the low byte
104  * of the max workers value. If the low byte is less than
105  * SMB_PI_MAX_WORKERS_MIN we set it to SMB_PI_MAX_WORKERS_MIN.
106  * SMB_PI_MAX_WORKERS_MIN must therefore be < 256
107  */
108 #define	SMB_PI_MAX_WORKERS_MIN		64
109 #define	SMB_PI_MAX_WORKERS_DEF		1024
110 #define	SMB_PI_MAX_WORKERS_MAX		16384
111 
112 /*
113  * Min/max initial credit grant and credit limit we allow to be
114  * configured via SMB_CI_INITIAL_CREDITS, SMB_CI_MAXIMUM_CREDITS
115  */
116 #define	SMB_PI_INITIAL_CREDITS_MIN	16
117 #define	SMB_PI_INITIAL_CREDITS_DEF	20
118 #define	SMB_PI_INITIAL_CREDITS_MAX	256
119 
120 #define	SMB_PI_MAXIMUM_CREDITS_MIN	64
121 #define	SMB_PI_MAXIMUM_CREDITS_DEF	1000
122 #define	SMB_PI_MAXIMUM_CREDITS_MAX	1024
123 
124 #define	SMB_PI_NETLOGON_FLAGS_DEFAULT	0x00000000
125 
126 /*
127  * sv_size is used by the RPC services and should be set to
128  * sizeof (smb_version_t).
129  */
130 typedef struct smb_version {
131 	uint32_t	sv_size;
132 	uint32_t	sv_major;
133 	uint32_t	sv_minor;
134 	uint32_t	sv_build_number;
135 	uint32_t	sv_platform_id;
136 } smb_version_t;
137 
138 typedef enum smb_cfg_val {
139 	SMB_CONFIG_DISABLED = 0,
140 	SMB_CONFIG_ENABLED = 1,
141 	SMB_CONFIG_REQUIRED = 2
142 } smb_cfg_val_t;
143 
144 void smb_cfg_set_require(const char *, smb_cfg_val_t *);
145 
146 /* See also: smb_ioc_cfg_t */
147 typedef struct smb_kmod_cfg {
148 	uint32_t skc_maxworkers;
149 	uint32_t skc_maxconnections;
150 	uint32_t skc_keepalive;
151 	int32_t skc_restrict_anon;
152 	int32_t skc_signing_enable;
153 	int32_t skc_signing_required;
154 	int32_t skc_oplock_enable;
155 	int32_t skc_sync_enable;
156 	int32_t skc_secmode;
157 	int32_t skc_netbios_enable;
158 	int32_t skc_ipv6_enable;
159 	int32_t skc_print_enable;
160 	int32_t skc_traverse_mounts;
161 	int32_t skc_short_names;
162 	uint32_t skc_max_protocol;	/* SMB_VERS_... */
163 	uint32_t skc_min_protocol;	/* SMB_VERS_... */
164 	smb_cfg_val_t skc_encrypt; /* EncryptData and RejectUnencryptedAccess */
165 	uint32_t skc_encrypt_ciphers;	/* 3.1.1 encryption ciphers */
166 	uint32_t skc_execflags;
167 	uint32_t skc_negtok_len;
168 	uint32_t skc_max_opens;		/* per client */
169 	smb_version_t skc_version;
170 	uint16_t skc_initial_credits;
171 	uint16_t skc_maximum_credits;
172 	uuid_t skc_machine_uuid;
173 	uchar_t skc_negtok[SMB_PI_MAX_NEGTOK];
174 	char skc_native_os[SMB_PI_MAX_NATIVE_OS];
175 	char skc_native_lm[SMB_PI_MAX_LANMAN];
176 	char skc_nbdomain[NETBIOS_NAME_SZ];
177 	char skc_fqdn[SMB_PI_MAX_DOMAIN];
178 	char skc_hostname[SMB_PI_MAX_HOST];
179 	char skc_system_comment[SMB_PI_MAX_COMMENT];
180 } smb_kmod_cfg_t;
181 
182 #define	SMB_EXEC_MAP	0x01
183 #define	SMB_EXEC_UNMAP	0x02
184 #define	SMB_EXEC_TERM	0x04
185 
186 #define	SMB_EXEC_DISP_CONTINUE	"continue"
187 #define	SMB_EXEC_DISP_TERMINATE	"terminate"
188 
189 /*
190  * Major version numbers
191  */
192 #define	SMB_MAJOR_NT		4	/* Windows 95/98/Me, Windows NT4.0 */
193 #define	SMB_MAJOR_2000		5
194 #define	SMB_MAJOR_XP		5
195 #define	SMB_MAJOR_2003		5
196 #define	SMB_MAJOR_VISTA		6
197 #define	SMB_MAJOR_2008		6
198 #define	SMB_MAJOR_2008R2	6
199 #define	SMB_MAJOR_7		6
200 
201 /*
202  * Minor version numbers
203  */
204 #define	SMB_MINOR_NT		0
205 #define	SMB_MINOR_2000		0
206 #define	SMB_MINOR_XP		1
207 #define	SMB_MINOR_2003		2
208 #define	SMB_MINOR_VISTA		0
209 #define	SMB_MINOR_2008		0
210 #define	SMB_MINOR_2008R2	1
211 #define	SMB_MINOR_7		1
212 
213 /*
214  * Max version length in string format
215  */
216 #define	SMB_VERSTR_LEN		8
217 
218 int smbnative_os_value(const char *);
219 int smbnative_lm_value(const char *);
220 int smbnative_pdc_value(const char *);
221 const char *smbnative_os_str(smb_version_t *);
222 const char *smbnative_lm_str(smb_version_t *);
223 
224 /*
225  * Support for passthrough authentication.
226  */
227 #define	AUTH_USER_GRANT			0x00000000
228 #define	AUTH_GUEST_GRANT		0x00000001
229 #define	AUTH_IPC_ONLY_GRANT		0x00000002
230 
231 /*
232  * Defined SMB1, SMB2(+) protocol versions, as returned by
233  * smb_config_get_max_protocol()
234  */
235 #define	SMB_VERS_1		1	/* arbitrary value < 0x200 */
236 #define	SMB_VERS_2_BASE		0x200	/* for (SMB2 or higher?) tests */
237 #define	SMB_VERS_2_002		0x202	/* "2.002" */
238 #define	SMB_VERS_2_1		0x210	/* "2.1" */
239 #define	SMB_VERS_3_0		0x300	/* "3.0" */
240 #define	SMB_VERS_3_02		0x302	/* "3.02" */
241 #define	SMB_VERS_3_11		0x311	/* "3.11" */
242 
243 /*
244  * Maxiumum currently supported encryption cipher.
245  */
246 #define	SMB3_CIPHER_MAX		SMB3_CIPHER_AES256_GCM
247 
248 /*
249  * SMB 3.x encryption ciphers bits.
250  */
251 #define	SMB3_CIPHER_BIT(c)	(1 << ((c) - 1))
252 #define	SMB3_CIPHER_FLAGS_ALL	((1 << (SMB3_CIPHER_MAX)) - 1)
253 
254 #define	SMB3_CIPHER_FLAG_AES128_CCM	SMB3_CIPHER_BIT(SMB3_CIPHER_AES128_CCM)
255 #define	SMB3_CIPHER_FLAG_AES128_GCM	SMB3_CIPHER_BIT(SMB3_CIPHER_AES128_GCM)
256 #define	SMB3_CIPHER_FLAG_AES256_CCM	SMB3_CIPHER_BIT(SMB3_CIPHER_AES256_CCM)
257 #define	SMB3_CIPHER_FLAG_AES256_GCM	SMB3_CIPHER_BIT(SMB3_CIPHER_AES256_GCM)
258 
259 #ifdef __cplusplus
260 }
261 #endif
262 
263 #endif /* _SMBSRV_SMBINFO_H */
264