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 smb_version_t skc_version; 169 uint16_t skc_initial_credits; 170 uint16_t skc_maximum_credits; 171 uuid_t skc_machine_uuid; 172 uchar_t skc_negtok[SMB_PI_MAX_NEGTOK]; 173 char skc_native_os[SMB_PI_MAX_NATIVE_OS]; 174 char skc_native_lm[SMB_PI_MAX_LANMAN]; 175 char skc_nbdomain[NETBIOS_NAME_SZ]; 176 char skc_fqdn[SMB_PI_MAX_DOMAIN]; 177 char skc_hostname[SMB_PI_MAX_HOST]; 178 char skc_system_comment[SMB_PI_MAX_COMMENT]; 179 } smb_kmod_cfg_t; 180 181 #define SMB_EXEC_MAP 0x01 182 #define SMB_EXEC_UNMAP 0x02 183 #define SMB_EXEC_TERM 0x04 184 185 #define SMB_EXEC_DISP_CONTINUE "continue" 186 #define SMB_EXEC_DISP_TERMINATE "terminate" 187 188 /* 189 * Major version numbers 190 */ 191 #define SMB_MAJOR_NT 4 /* Windows 95/98/Me, Windows NT4.0 */ 192 #define SMB_MAJOR_2000 5 193 #define SMB_MAJOR_XP 5 194 #define SMB_MAJOR_2003 5 195 #define SMB_MAJOR_VISTA 6 196 #define SMB_MAJOR_2008 6 197 #define SMB_MAJOR_2008R2 6 198 #define SMB_MAJOR_7 6 199 200 /* 201 * Minor version numbers 202 */ 203 #define SMB_MINOR_NT 0 204 #define SMB_MINOR_2000 0 205 #define SMB_MINOR_XP 1 206 #define SMB_MINOR_2003 2 207 #define SMB_MINOR_VISTA 0 208 #define SMB_MINOR_2008 0 209 #define SMB_MINOR_2008R2 1 210 #define SMB_MINOR_7 1 211 212 /* 213 * Max version length in string format 214 */ 215 #define SMB_VERSTR_LEN 8 216 217 int smbnative_os_value(const char *); 218 int smbnative_lm_value(const char *); 219 int smbnative_pdc_value(const char *); 220 const char *smbnative_os_str(smb_version_t *); 221 const char *smbnative_lm_str(smb_version_t *); 222 223 /* 224 * Support for passthrough authentication. 225 */ 226 #define AUTH_USER_GRANT 0x00000000 227 #define AUTH_GUEST_GRANT 0x00000001 228 #define AUTH_IPC_ONLY_GRANT 0x00000002 229 230 /* 231 * Defined SMB1, SMB2(+) protocol versions, as returned by 232 * smb_config_get_max_protocol() 233 */ 234 #define SMB_VERS_1 1 /* arbitrary value < 0x200 */ 235 #define SMB_VERS_2_BASE 0x200 /* for (SMB2 or higher?) tests */ 236 #define SMB_VERS_2_002 0x202 /* "2.002" */ 237 #define SMB_VERS_2_1 0x210 /* "2.1" */ 238 #define SMB_VERS_3_0 0x300 /* "3.0" */ 239 #define SMB_VERS_3_02 0x302 /* "3.02" */ 240 #define SMB_VERS_3_11 0x311 /* "3.11" */ 241 242 /* 243 * Maxiumum currently supported encryption cipher. 244 */ 245 #define SMB3_CIPHER_MAX SMB3_CIPHER_AES256_GCM 246 247 /* 248 * SMB 3.x encryption ciphers bits. 249 */ 250 #define SMB3_CIPHER_BIT(c) (1 << ((c) - 1)) 251 #define SMB3_CIPHER_FLAGS_ALL ((1 << (SMB3_CIPHER_MAX)) - 1) 252 253 #define SMB3_CIPHER_FLAG_AES128_CCM SMB3_CIPHER_BIT(SMB3_CIPHER_AES128_CCM) 254 #define SMB3_CIPHER_FLAG_AES128_GCM SMB3_CIPHER_BIT(SMB3_CIPHER_AES128_GCM) 255 #define SMB3_CIPHER_FLAG_AES256_CCM SMB3_CIPHER_BIT(SMB3_CIPHER_AES256_CCM) 256 #define SMB3_CIPHER_FLAG_AES256_GCM SMB3_CIPHER_BIT(SMB3_CIPHER_AES256_GCM) 257 258 #ifdef __cplusplus 259 } 260 #endif 261 262 #endif /* _SMBSRV_SMBINFO_H */ 263