| 1 |
/* SPDX-License-Identifier: LGPL-2.1 */ |
| 2 |
#ifndef _COMMON_SMB2PDU_H |
| 3 |
#define _COMMON_SMB2PDU_H |
| 4 |
|
| 5 |
#include <linux/types.h> |
| 6 |
#include <linux/build_bug.h> |
| 7 |
|
| 8 |
/* |
| 9 |
* Note that, due to trying to use names similar to the protocol specifications, |
| 10 |
* there are many mixed case field names in the structures below. Although |
| 11 |
* this does not match typical Linux kernel style, it is necessary to be |
| 12 |
* able to match against the protocol specification. |
| 13 |
* |
| 14 |
* SMB2 commands |
| 15 |
* Some commands have minimal (wct=0,bcc=0), or uninteresting, responses |
| 16 |
* (ie no useful data other than the SMB error code itself) and are marked such. |
| 17 |
* Knowing this helps avoid response buffer allocations and copy in some cases. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* List of commands in host endian */ |
| 21 |
#define SMB2_NEGOTIATE_HE 0x0000 |
| 22 |
#define SMB2_SESSION_SETUP_HE 0x0001 |
| 23 |
#define SMB2_LOGOFF_HE 0x0002 /* trivial request/resp */ |
| 24 |
#define SMB2_TREE_CONNECT_HE 0x0003 |
| 25 |
#define SMB2_TREE_DISCONNECT_HE 0x0004 /* trivial req/resp */ |
| 26 |
#define SMB2_CREATE_HE 0x0005 |
| 27 |
#define SMB2_CLOSE_HE 0x0006 |
| 28 |
#define SMB2_FLUSH_HE 0x0007 /* trivial resp */ |
| 29 |
#define SMB2_READ_HE 0x0008 |
| 30 |
#define SMB2_WRITE_HE 0x0009 |
| 31 |
#define SMB2_LOCK_HE 0x000A |
| 32 |
#define SMB2_IOCTL_HE 0x000B |
| 33 |
#define SMB2_CANCEL_HE 0x000C |
| 34 |
#define SMB2_ECHO_HE 0x000D |
| 35 |
#define SMB2_QUERY_DIRECTORY_HE 0x000E |
| 36 |
#define SMB2_CHANGE_NOTIFY_HE 0x000F |
| 37 |
#define SMB2_QUERY_INFO_HE 0x0010 |
| 38 |
#define SMB2_SET_INFO_HE 0x0011 |
| 39 |
#define SMB2_OPLOCK_BREAK_HE 0x0012 |
| 40 |
#define SMB2_SERVER_TO_CLIENT_NOTIFICATION 0x0013 |
| 41 |
|
| 42 |
/* The same list in little endian */ |
| 43 |
#define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE) |
| 44 |
#define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE) |
| 45 |
#define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE) |
| 46 |
#define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE) |
| 47 |
#define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE) |
| 48 |
#define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE) |
| 49 |
#define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE) |
| 50 |
#define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE) |
| 51 |
#define SMB2_READ cpu_to_le16(SMB2_READ_HE) |
| 52 |
#define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE) |
| 53 |
#define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE) |
| 54 |
#define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE) |
| 55 |
#define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE) |
| 56 |
#define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE) |
| 57 |
#define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE) |
| 58 |
#define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE) |
| 59 |
#define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE) |
| 60 |
#define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE) |
| 61 |
#define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE) |
| 62 |
|
| 63 |
#define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF) |
| 64 |
|
| 65 |
#define NUMBER_OF_SMB2_COMMANDS 0x0013 |
| 66 |
|
| 67 |
/* |
| 68 |
* Size of the session key (crypto key encrypted with the password |
| 69 |
*/ |
| 70 |
#define SMB2_NTLMV2_SESSKEY_SIZE 16 |
| 71 |
#define SMB2_SIGNATURE_SIZE 16 |
| 72 |
#define SMB2_HMACSHA256_SIZE 32 |
| 73 |
#define SMB2_CMACAES_SIZE 16 |
| 74 |
#define SMB3_GCM128_CRYPTKEY_SIZE 16 |
| 75 |
#define SMB3_GCM256_CRYPTKEY_SIZE 32 |
| 76 |
|
| 77 |
/* |
| 78 |
* Size of the smb3 encryption/decryption keys |
| 79 |
* This size is big enough to store any cipher key types. |
| 80 |
*/ |
| 81 |
#define SMB3_ENC_DEC_KEY_SIZE 32 |
| 82 |
|
| 83 |
/* |
| 84 |
* Size of the smb3 signing key |
| 85 |
*/ |
| 86 |
#define SMB3_SIGN_KEY_SIZE 16 |
| 87 |
|
| 88 |
#define CIFS_CLIENT_CHALLENGE_SIZE 8 |
| 89 |
|
| 90 |
/* Maximum buffer size value we can send with 1 credit */ |
| 91 |
#define SMB2_MAX_BUFFER_SIZE 65536 |
| 92 |
|
| 93 |
/* |
| 94 |
* The default wsize is 1M for SMB2 (and for some CIFS cases). |
| 95 |
* find_get_pages seems to return a maximum of 256 |
| 96 |
* pages in a single call. With PAGE_SIZE == 4k, this means we can |
| 97 |
* fill a single wsize request with a single call. |
| 98 |
*/ |
| 99 |
#define SMB3_DEFAULT_IOSIZE (4 * 1024 * 1024) |
| 100 |
|
| 101 |
/* According to MS-SMB2 specification The minimum recommended value is 65536.*/ |
| 102 |
#define CIFS_MIN_DEFAULT_IOSIZE (65536) |
| 103 |
|
| 104 |
/* |
| 105 |
* SMB2 Header Definition |
| 106 |
* |
| 107 |
* "MBZ" : Must be Zero |
| 108 |
* "BB" : BugBug, Something to check/review/analyze later |
| 109 |
* "PDU" : "Protocol Data Unit" (ie a network "frame") |
| 110 |
* |
| 111 |
*/ |
| 112 |
|
| 113 |
#define __SMB2_HEADER_STRUCTURE_SIZE 64 |
| 114 |
#define SMB2_HEADER_STRUCTURE_SIZE \ |
| 115 |
cpu_to_le16(__SMB2_HEADER_STRUCTURE_SIZE) |
| 116 |
|
| 117 |
#define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe) |
| 118 |
#define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd) |
| 119 |
#define SMB2_COMPRESSION_TRANSFORM_ID cpu_to_le32(0x424d53fc) |
| 120 |
|
| 121 |
/* |
| 122 |
* SMB2 flag definitions |
| 123 |
*/ |
| 124 |
#define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001) |
| 125 |
#define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002) |
| 126 |
#define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004) |
| 127 |
#define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008) |
| 128 |
#define SMB2_FLAGS_PRIORITY_MASK cpu_to_le32(0x00000070) /* SMB3.1.1 */ |
| 129 |
#define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000) |
| 130 |
#define SMB2_FLAGS_REPLAY_OPERATION cpu_to_le32(0x20000000) /* SMB3 & up */ |
| 131 |
|
| 132 |
/* |
| 133 |
* Definitions for SMB2 Protocol Data Units (network frames) |
| 134 |
* |
| 135 |
* See MS-SMB2.PDF specification for protocol details. |
| 136 |
* The Naming convention is the lower case version of the SMB2 |
| 137 |
* command code name for the struct. Note that structures must be packed. |
| 138 |
* |
| 139 |
*/ |
| 140 |
|
| 141 |
/* See MS-SMB2 section 2.2.1 */ |
| 142 |
struct smb2_hdr { |
| 143 |
__le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */ |
| 144 |
__le16 StructureSize; /* 64 */ |
| 145 |
__le16 CreditCharge; /* MBZ */ |
| 146 |
__le32 Status; /* Error from server */ |
| 147 |
__le16 Command; |
| 148 |
__le16 CreditRequest; /* CreditResponse */ |
| 149 |
__le32 Flags; |
| 150 |
__le32 NextCommand; |
| 151 |
__le64 MessageId; |
| 152 |
union { |
| 153 |
struct { |
| 154 |
__le32 ProcessId; |
| 155 |
__le32 TreeId; |
| 156 |
} __packed SyncId; |
| 157 |
__le64 AsyncId; |
| 158 |
} __packed Id; |
| 159 |
__le64 SessionId; |
| 160 |
__u8 Signature[16]; |
| 161 |
} __packed; |
| 162 |
|
| 163 |
struct smb3_hdr_req { |
| 164 |
__le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */ |
| 165 |
__le16 StructureSize; /* 64 */ |
| 166 |
__le16 CreditCharge; /* MBZ */ |
| 167 |
__le16 ChannelSequence; /* See MS-SMB2 3.2.4.1 and 3.2.7.1 */ |
| 168 |
__le16 Reserved; |
| 169 |
__le16 Command; |
| 170 |
__le16 CreditRequest; /* CreditResponse */ |
| 171 |
__le32 Flags; |
| 172 |
__le32 NextCommand; |
| 173 |
__le64 MessageId; |
| 174 |
union { |
| 175 |
struct { |
| 176 |
__le32 ProcessId; |
| 177 |
__le32 TreeId; |
| 178 |
} __packed SyncId; |
| 179 |
__le64 AsyncId; |
| 180 |
} __packed Id; |
| 181 |
__le64 SessionId; |
| 182 |
__u8 Signature[16]; |
| 183 |
} __packed; |
| 184 |
|
| 185 |
struct smb2_pdu { |
| 186 |
struct smb2_hdr hdr; |
| 187 |
__le16 StructureSize2; /* size of wct area (varies, request specific) */ |
| 188 |
} __packed; |
| 189 |
|
| 190 |
#define SMB2_ERROR_STRUCTURE_SIZE2 9 |
| 191 |
#define SMB2_ERROR_STRUCTURE_SIZE2_LE cpu_to_le16(SMB2_ERROR_STRUCTURE_SIZE2) |
| 192 |
|
| 193 |
struct smb2_err_rsp { |
| 194 |
struct smb2_hdr hdr; |
| 195 |
__le16 StructureSize; |
| 196 |
__u8 ErrorContextCount; |
| 197 |
__u8 Reserved; |
| 198 |
__le32 ByteCount; /* even if zero, at least one byte follows */ |
| 199 |
__u8 ErrorData[]; /* variable length */ |
| 200 |
} __packed; |
| 201 |
|
| 202 |
#define SMB3_AES_CCM_NONCE 11 |
| 203 |
#define SMB3_AES_GCM_NONCE 12 |
| 204 |
|
| 205 |
/* Transform flags (for 3.0 dialect this flag indicates CCM */ |
| 206 |
#define TRANSFORM_FLAG_ENCRYPTED 0x0001 |
| 207 |
struct smb2_transform_hdr { |
| 208 |
__le32 ProtocolId; /* 0xFD 'S' 'M' 'B' */ |
| 209 |
__u8 Signature[16]; |
| 210 |
__u8 Nonce[16]; |
| 211 |
__le32 OriginalMessageSize; |
| 212 |
__u16 Reserved1; |
| 213 |
__le16 Flags; /* EncryptionAlgorithm for 3.0, enc enabled for 3.1.1 */ |
| 214 |
__le64 SessionId; |
| 215 |
} __packed; |
| 216 |
|
| 217 |
/* |
| 218 |
* These are simplified versions from the spec, as we don't need a fully fledged |
| 219 |
* form of both unchained and chained structs. |
| 220 |
* |
| 221 |
* Moreover, even in chained compressed payloads, the initial compression header |
| 222 |
* has the form of the unchained one -- i.e. it never has the |
| 223 |
* OriginalPayloadSize field and ::Offset field always represent an offset |
| 224 |
* (instead of a length, as it is in the chained header). |
| 225 |
* |
| 226 |
* See MS-SMB2 2.2.42 for more details. |
| 227 |
*/ |
| 228 |
#define SMB2_COMPRESSION_FLAG_NONE 0x0000 |
| 229 |
#define SMB2_COMPRESSION_FLAG_CHAINED 0x0001 |
| 230 |
|
| 231 |
struct smb2_compression_hdr { |
| 232 |
__le32 ProtocolId; /* 0xFC 'S' 'M' 'B' */ |
| 233 |
__le32 OriginalCompressedSegmentSize; |
| 234 |
__le16 CompressionAlgorithm; |
| 235 |
__le16 Flags; |
| 236 |
__le32 Offset; /* this is the size of the uncompressed SMB2 header below */ |
| 237 |
/* uncompressed SMB2 header (READ or WRITE) goes here */ |
| 238 |
/* compressed data goes here */ |
| 239 |
} __packed; |
| 240 |
|
| 241 |
/* |
| 242 |
* ... OTOH, set compression payload header to always have OriginalPayloadSize |
| 243 |
* as it's easier to pass the struct size minus sizeof(OriginalPayloadSize) |
| 244 |
* than to juggle around the header/data memory. |
| 245 |
*/ |
| 246 |
struct smb2_compression_payload_hdr { |
| 247 |
__le16 CompressionAlgorithm; |
| 248 |
__le16 Flags; |
| 249 |
__le32 Length; /* length of compressed playload including field below if present */ |
| 250 |
__le32 OriginalPayloadSize; /* accounted when LZNT1, LZ77, LZ77+Huffman */ |
| 251 |
} __packed; |
| 252 |
|
| 253 |
struct smb2_compression_pattern_v1 { |
| 254 |
__u8 Pattern; |
| 255 |
__u8 Reserved1; |
| 256 |
__le16 Reserved2; |
| 257 |
__le32 Repetitions; |
| 258 |
} __packed; |
| 259 |
|
| 260 |
/* See MS-SMB2 section 2.2.9.2 */ |
| 261 |
/* Context Types */ |
| 262 |
#define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000 |
| 263 |
#define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001) |
| 264 |
|
| 265 |
struct tree_connect_contexts { |
| 266 |
__le16 ContextType; |
| 267 |
__le16 DataLength; |
| 268 |
__le32 Reserved; |
| 269 |
__u8 Data[]; |
| 270 |
} __packed; |
| 271 |
|
| 272 |
/* Remoted identity tree connect context structures - see MS-SMB2 2.2.9.2.1 */ |
| 273 |
struct smb3_blob_data { |
| 274 |
__le16 BlobSize; |
| 275 |
__u8 BlobData[]; |
| 276 |
} __packed; |
| 277 |
|
| 278 |
/* Valid values for Attr */ |
| 279 |
#define SE_GROUP_MANDATORY 0x00000001 |
| 280 |
#define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002 |
| 281 |
#define SE_GROUP_ENABLED 0x00000004 |
| 282 |
#define SE_GROUP_OWNER 0x00000008 |
| 283 |
#define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010 |
| 284 |
#define SE_GROUP_INTEGRITY 0x00000020 |
| 285 |
#define SE_GROUP_INTEGRITY_ENABLED 0x00000040 |
| 286 |
#define SE_GROUP_RESOURCE 0x20000000 |
| 287 |
#define SE_GROUP_LOGON_ID 0xC0000000 |
| 288 |
|
| 289 |
struct sid_array_data { |
| 290 |
__le16 SidAttrCount; |
| 291 |
/* SidAttrList - array of sid_attr_data structs */ |
| 292 |
} __packed; |
| 293 |
|
| 294 |
/* struct sid_attr_data is SidData array in BlobData format then le32 Attr */ |
| 295 |
struct sid_attr_data { |
| 296 |
__le16 BlobSize; |
| 297 |
__u8 BlobData[]; |
| 298 |
/* __le32 Attr */ |
| 299 |
} __packed; |
| 300 |
|
| 301 |
/* |
| 302 |
* struct privilege_data is the same as BLOB_DATA - see MS-SMB2 2.2.9.2.1.5 |
| 303 |
* but with size of LUID_ATTR_DATA struct and BlobData set to LUID_ATTR DATA |
| 304 |
*/ |
| 305 |
|
| 306 |
struct privilege_array_data { |
| 307 |
__le16 PrivilegeCount; |
| 308 |
/* array of privilege_data structs */ |
| 309 |
} __packed; |
| 310 |
|
| 311 |
struct remoted_identity_tcon_context { |
| 312 |
__le16 TicketType; /* must be 0x0001 */ |
| 313 |
__le16 TicketSize; /* total size of this struct */ |
| 314 |
__le16 User; /* offset to SID_ATTR_DATA struct with user info */ |
| 315 |
__le16 UserName; /* offset to null terminated Unicode username string */ |
| 316 |
__le16 Domain; /* offset to null terminated Unicode domain name */ |
| 317 |
__le16 Groups; /* offset to SID_ARRAY_DATA struct with group info */ |
| 318 |
__le16 RestrictedGroups; /* similar to above */ |
| 319 |
__le16 Privileges; /* offset to PRIVILEGE_ARRAY_DATA struct */ |
| 320 |
__le16 PrimaryGroup; /* offset to SID_ARRAY_DATA struct */ |
| 321 |
__le16 Owner; /* offset to BLOB_DATA struct */ |
| 322 |
__le16 DefaultDacl; /* offset to BLOB_DATA struct */ |
| 323 |
__le16 DeviceGroups; /* offset to SID_ARRAY_DATA struct */ |
| 324 |
__le16 UserClaims; /* offset to BLOB_DATA struct */ |
| 325 |
__le16 DeviceClaims; /* offset to BLOB_DATA struct */ |
| 326 |
__u8 TicketInfo[]; /* variable length buf - remoted identity data */ |
| 327 |
} __packed; |
| 328 |
|
| 329 |
struct smb2_tree_connect_req_extension { |
| 330 |
__le32 TreeConnectContextOffset; |
| 331 |
__le16 TreeConnectContextCount; |
| 332 |
__u8 Reserved[10]; |
| 333 |
__u8 PathName[]; /* variable sized array */ |
| 334 |
/* followed by array of TreeConnectContexts */ |
| 335 |
} __packed; |
| 336 |
|
| 337 |
/* Flags/Reserved for SMB3.1.1 */ |
| 338 |
#define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001) |
| 339 |
#define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002) |
| 340 |
#define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004) |
| 341 |
|
| 342 |
struct smb2_tree_connect_req { |
| 343 |
struct smb2_hdr hdr; |
| 344 |
__le16 StructureSize; /* Must be 9 */ |
| 345 |
__le16 Flags; /* Flags in SMB3.1.1 */ |
| 346 |
__le16 PathOffset; |
| 347 |
__le16 PathLength; |
| 348 |
__u8 Buffer[]; /* variable length */ |
| 349 |
} __packed; |
| 350 |
|
| 351 |
/* Possible ShareType values */ |
| 352 |
#define SMB2_SHARE_TYPE_DISK 0x01 |
| 353 |
#define SMB2_SHARE_TYPE_PIPE 0x02 |
| 354 |
#define SMB2_SHARE_TYPE_PRINT 0x03 |
| 355 |
|
| 356 |
/* |
| 357 |
* Possible ShareFlags - exactly one and only one of the first 4 caching flags |
| 358 |
* must be set (any of the remaining, SHI1005, flags may be set individually |
| 359 |
* or in combination. |
| 360 |
*/ |
| 361 |
#define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000 |
| 362 |
#define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010 |
| 363 |
#define SMB2_SHAREFLAG_VDO_CACHING 0x00000020 |
| 364 |
#define SMB2_SHAREFLAG_NO_CACHING 0x00000030 |
| 365 |
#define SHI1005_FLAGS_DFS 0x00000001 |
| 366 |
#define SHI1005_FLAGS_DFS_ROOT 0x00000002 |
| 367 |
#define SMB2_SHAREFLAG_RESTRICT_EXCLUSIVE_OPENS 0x00000100 |
| 368 |
#define SMB2_SHAREFLAG_FORCE_SHARED_DELETE 0x00000200 |
| 369 |
#define SMB2_SHAREFLAG_ALLOW_NAMESPACE_CACHING 0x00000400 |
| 370 |
#define SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM 0x00000800 |
| 371 |
#define SMB2_SHAREFLAG_FORCE_LEVELII_OPLOCK 0x00001000 |
| 372 |
#define SMB2_SHAREFLAG_ENABLE_HASH_V1 0x00002000 |
| 373 |
#define SMB2_SHAREFLAG_ENABLE_HASH_V2 0x00004000 |
| 374 |
#define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000 |
| 375 |
#define SMB2_SHAREFLAG_IDENTITY_REMOTING 0x00040000 /* 3.1.1 */ |
| 376 |
#define SMB2_SHAREFLAG_COMPRESS_DATA 0x00100000 /* 3.1.1 */ |
| 377 |
#define SMB2_SHAREFLAG_ISOLATED_TRANSPORT 0x00200000 |
| 378 |
#define SHI1005_FLAGS_ALL 0x0034FF33 |
| 379 |
|
| 380 |
/* Possible share capabilities */ |
| 381 |
#define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */ |
| 382 |
#define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */ |
| 383 |
#define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */ |
| 384 |
#define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */ |
| 385 |
#define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */ |
| 386 |
#define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100) /* 3.1.1 */ |
| 387 |
|
| 388 |
struct smb2_tree_connect_rsp { |
| 389 |
struct smb2_hdr hdr; |
| 390 |
__le16 StructureSize; /* Must be 16 */ |
| 391 |
__u8 ShareType; /* see below */ |
| 392 |
__u8 Reserved; |
| 393 |
__le32 ShareFlags; /* see below */ |
| 394 |
__le32 Capabilities; /* see below */ |
| 395 |
__le32 MaximalAccess; |
| 396 |
} __packed; |
| 397 |
|
| 398 |
struct smb2_tree_disconnect_req { |
| 399 |
struct smb2_hdr hdr; |
| 400 |
__le16 StructureSize; /* Must be 4 */ |
| 401 |
__le16 Reserved; |
| 402 |
} __packed; |
| 403 |
|
| 404 |
struct smb2_tree_disconnect_rsp { |
| 405 |
struct smb2_hdr hdr; |
| 406 |
__le16 StructureSize; /* Must be 4 */ |
| 407 |
__le16 Reserved; |
| 408 |
} __packed; |
| 409 |
|
| 410 |
|
| 411 |
/* |
| 412 |
* SMB2_NEGOTIATE_PROTOCOL See MS-SMB2 section 2.2.3 |
| 413 |
*/ |
| 414 |
/* SecurityMode flags */ |
| 415 |
#define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001 |
| 416 |
#define SMB2_NEGOTIATE_SIGNING_ENABLED_LE cpu_to_le16(0x0001) |
| 417 |
#define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002 |
| 418 |
#define SMB2_NEGOTIATE_SIGNING_REQUIRED_LE cpu_to_le16(0x0002) |
| 419 |
#define SMB2_SEC_MODE_FLAGS_ALL 0x0003 |
| 420 |
|
| 421 |
/* Capabilities flags */ |
| 422 |
#define SMB2_GLOBAL_CAP_DFS 0x00000001 |
| 423 |
#define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */ |
| 424 |
#define SMB2_GLOBAL_CAP_LARGE_MTU 0x00000004 /* Resp only New to SMB2.1 */ |
| 425 |
#define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */ |
| 426 |
#define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */ |
| 427 |
#define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */ |
| 428 |
#define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */ |
| 429 |
#define SMB2_GLOBAL_CAP_NOTIFICATIONS 0x00000080 /* New to SMB3.1.1 */ |
| 430 |
/* Internal types */ |
| 431 |
#define SMB2_NT_FIND 0x00100000 |
| 432 |
#define SMB2_LARGE_FILES 0x00200000 |
| 433 |
|
| 434 |
#define SMB2_CLIENT_GUID_SIZE 16 |
| 435 |
#define SMB2_CREATE_GUID_SIZE 16 |
| 436 |
|
| 437 |
/* Dialects */ |
| 438 |
#define SMB10_PROT_ID 0x0000 /* local only, not sent on wire w/CIFS negprot */ |
| 439 |
#define SMB20_PROT_ID 0x0202 |
| 440 |
#define SMB21_PROT_ID 0x0210 |
| 441 |
#define SMB2X_PROT_ID 0x02FF |
| 442 |
#define SMB30_PROT_ID 0x0300 |
| 443 |
#define SMB302_PROT_ID 0x0302 |
| 444 |
#define SMB311_PROT_ID 0x0311 |
| 445 |
#define BAD_PROT_ID 0xFFFF |
| 446 |
|
| 447 |
#define SMB311_SALT_SIZE 32 |
| 448 |
/* Hash Algorithm Types */ |
| 449 |
#define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001) |
| 450 |
#define SMB2_PREAUTH_HASH_SIZE 64 |
| 451 |
|
| 452 |
/* Negotiate Contexts - ContextTypes. See MS-SMB2 section 2.2.3.1 for details */ |
| 453 |
#define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1) |
| 454 |
#define SMB2_ENCRYPTION_CAPABILITIES cpu_to_le16(2) |
| 455 |
#define SMB2_COMPRESSION_CAPABILITIES cpu_to_le16(3) |
| 456 |
#define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID cpu_to_le16(5) |
| 457 |
#define SMB2_TRANSPORT_CAPABILITIES cpu_to_le16(6) |
| 458 |
#define SMB2_RDMA_TRANSFORM_CAPABILITIES cpu_to_le16(7) |
| 459 |
#define SMB2_SIGNING_CAPABILITIES cpu_to_le16(8) |
| 460 |
#define SMB2_POSIX_EXTENSIONS_AVAILABLE cpu_to_le16(0x100) |
| 461 |
|
| 462 |
struct smb2_neg_context { |
| 463 |
__le16 ContextType; |
| 464 |
__le16 DataLength; |
| 465 |
__le32 Reserved; |
| 466 |
/* Followed by array of data. NOTE: some servers require padding to 8 byte boundary */ |
| 467 |
} __packed; |
| 468 |
|
| 469 |
/* |
| 470 |
* SaltLength that the server send can be zero, so the only three required |
| 471 |
* fields (all __le16) end up six bytes total, so the minimum context data len |
| 472 |
* in the response is six bytes which accounts for |
| 473 |
* |
| 474 |
* HashAlgorithmCount, SaltLength, and 1 HashAlgorithm. |
| 475 |
*/ |
| 476 |
#define MIN_PREAUTH_CTXT_DATA_LEN 6 |
| 477 |
|
| 478 |
struct smb2_preauth_neg_context { |
| 479 |
__le16 ContextType; /* 1 */ |
| 480 |
__le16 DataLength; |
| 481 |
__le32 Reserved; |
| 482 |
__le16 HashAlgorithmCount; /* 1 */ |
| 483 |
__le16 SaltLength; |
| 484 |
__le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */ |
| 485 |
__u8 Salt[SMB311_SALT_SIZE]; |
| 486 |
} __packed; |
| 487 |
|
| 488 |
/* Encryption Algorithms Ciphers */ |
| 489 |
#define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001) |
| 490 |
#define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002) |
| 491 |
#define SMB2_ENCRYPTION_AES256_CCM cpu_to_le16(0x0003) |
| 492 |
#define SMB2_ENCRYPTION_AES256_GCM cpu_to_le16(0x0004) |
| 493 |
|
| 494 |
/* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */ |
| 495 |
#define MIN_ENCRYPT_CTXT_DATA_LEN 4 |
| 496 |
struct smb2_encryption_neg_context { |
| 497 |
__le16 ContextType; /* 2 */ |
| 498 |
__le16 DataLength; |
| 499 |
__le32 Reserved; |
| 500 |
/* CipherCount usually 2, but can be 3 when AES256-GCM enabled */ |
| 501 |
__le16 CipherCount; /* AES128-GCM and AES128-CCM by default */ |
| 502 |
__le16 Ciphers[]; |
| 503 |
} __packed; |
| 504 |
|
| 505 |
/* See MS-SMB2 2.2.3.1.3 */ |
| 506 |
#define SMB3_COMPRESS_NONE cpu_to_le16(0x0000) |
| 507 |
#define SMB3_COMPRESS_LZNT1 cpu_to_le16(0x0001) |
| 508 |
#define SMB3_COMPRESS_LZ77 cpu_to_le16(0x0002) |
| 509 |
#define SMB3_COMPRESS_LZ77_HUFF cpu_to_le16(0x0003) |
| 510 |
/* Pattern scanning algorithm See MS-SMB2 3.1.4.4.1 */ |
| 511 |
#define SMB3_COMPRESS_PATTERN cpu_to_le16(0x0004) /* Pattern_V1 */ |
| 512 |
#define SMB3_COMPRESS_LZ4 cpu_to_le16(0x0005) |
| 513 |
|
| 514 |
/* Compression Flags */ |
| 515 |
#define SMB2_COMPRESSION_CAPABILITIES_FLAG_NONE cpu_to_le32(0x00000000) |
| 516 |
#define SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED cpu_to_le32(0x00000001) |
| 517 |
|
| 518 |
struct smb2_compression_capabilities_context { |
| 519 |
__le16 ContextType; /* 3 */ |
| 520 |
__le16 DataLength; |
| 521 |
__le32 Reserved; |
| 522 |
__le16 CompressionAlgorithmCount; |
| 523 |
__le16 Padding; |
| 524 |
__le32 Flags; |
| 525 |
__le16 CompressionAlgorithms[3]; |
| 526 |
__u16 Pad; /* Some servers require pad to DataLen multiple of 8 */ |
| 527 |
/* Check if pad needed */ |
| 528 |
} __packed; |
| 529 |
|
| 530 |
/* |
| 531 |
* For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4. |
| 532 |
* Its struct simply contains NetName, an array of Unicode characters |
| 533 |
*/ |
| 534 |
struct smb2_netname_neg_context { |
| 535 |
__le16 ContextType; /* 5 */ |
| 536 |
__le16 DataLength; |
| 537 |
__le32 Reserved; |
| 538 |
__le16 NetName[]; /* hostname of target converted to UCS-2 */ |
| 539 |
} __packed; |
| 540 |
|
| 541 |
/* |
| 542 |
* For smb2_transport_capabilities context see MS-SMB2 2.2.3.1.5 |
| 543 |
* and 2.2.4.1.5 |
| 544 |
*/ |
| 545 |
|
| 546 |
/* Flags */ |
| 547 |
#define SMB2_ACCEPT_TRANSPORT_LEVEL_SECURITY 0x00000001 |
| 548 |
|
| 549 |
struct smb2_transport_capabilities_context { |
| 550 |
__le16 ContextType; /* 6 */ |
| 551 |
__le16 DataLength; |
| 552 |
__u32 Reserved; |
| 553 |
__le32 Flags; |
| 554 |
__u32 Pad; |
| 555 |
} __packed; |
| 556 |
|
| 557 |
/* |
| 558 |
* For rdma transform capabilities context see MS-SMB2 2.2.3.1.6 |
| 559 |
* and 2.2.4.1.6 |
| 560 |
*/ |
| 561 |
|
| 562 |
/* RDMA Transform IDs */ |
| 563 |
#define SMB2_RDMA_TRANSFORM_NONE 0x0000 |
| 564 |
#define SMB2_RDMA_TRANSFORM_ENCRYPTION 0x0001 |
| 565 |
#define SMB2_RDMA_TRANSFORM_SIGNING 0x0002 |
| 566 |
|
| 567 |
struct smb2_rdma_transform_capabilities_context { |
| 568 |
__le16 ContextType; /* 7 */ |
| 569 |
__le16 DataLength; |
| 570 |
__u32 Reserved; |
| 571 |
__le16 TransformCount; |
| 572 |
__u16 Reserved1; |
| 573 |
__u32 Reserved2; |
| 574 |
__le16 RDMATransformIds[]; |
| 575 |
} __packed; |
| 576 |
|
| 577 |
/* |
| 578 |
* For signing capabilities context see MS-SMB2 2.2.3.1.7 |
| 579 |
* and 2.2.4.1.7 |
| 580 |
*/ |
| 581 |
|
| 582 |
/* Signing algorithms */ |
| 583 |
#define SIGNING_ALG_HMAC_SHA256 0 |
| 584 |
#define SIGNING_ALG_HMAC_SHA256_LE cpu_to_le16(0) |
| 585 |
#define SIGNING_ALG_AES_CMAC 1 |
| 586 |
#define SIGNING_ALG_AES_CMAC_LE cpu_to_le16(1) |
| 587 |
#define SIGNING_ALG_AES_GMAC 2 |
| 588 |
#define SIGNING_ALG_AES_GMAC_LE cpu_to_le16(2) |
| 589 |
|
| 590 |
struct smb2_signing_capabilities { |
| 591 |
__le16 ContextType; /* 8 */ |
| 592 |
__le16 DataLength; |
| 593 |
__le32 Reserved; |
| 594 |
__le16 SigningAlgorithmCount; |
| 595 |
__le16 SigningAlgorithms[]; |
| 596 |
/* Followed by padding to 8 byte boundary (required by some servers) */ |
| 597 |
} __packed; |
| 598 |
|
| 599 |
#define POSIX_CTXT_DATA_LEN 16 |
| 600 |
struct smb2_posix_neg_context { |
| 601 |
__le16 ContextType; /* 0x100 */ |
| 602 |
__le16 DataLength; |
| 603 |
__le32 Reserved; |
| 604 |
__u8 Name[16]; /* POSIX ctxt GUID 93AD25509CB411E7B42383DE968BCD7C */ |
| 605 |
} __packed; |
| 606 |
|
| 607 |
struct smb2_negotiate_req { |
| 608 |
struct smb2_hdr hdr; |
| 609 |
__le16 StructureSize; /* Must be 36 */ |
| 610 |
__le16 DialectCount; |
| 611 |
__le16 SecurityMode; |
| 612 |
__le16 Reserved; /* MBZ */ |
| 613 |
__le32 Capabilities; |
| 614 |
__u8 ClientGUID[SMB2_CLIENT_GUID_SIZE]; |
| 615 |
/* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */ |
| 616 |
__le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */ |
| 617 |
__le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */ |
| 618 |
__le16 Reserved2; |
| 619 |
__le16 Dialects[]; |
| 620 |
} __packed; |
| 621 |
|
| 622 |
struct smb2_negotiate_rsp { |
| 623 |
struct smb2_hdr hdr; |
| 624 |
__le16 StructureSize; /* Must be 65 */ |
| 625 |
__le16 SecurityMode; |
| 626 |
__le16 DialectRevision; |
| 627 |
__le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */ |
| 628 |
__u8 ServerGUID[16]; |
| 629 |
__le32 Capabilities; |
| 630 |
__le32 MaxTransactSize; |
| 631 |
__le32 MaxReadSize; |
| 632 |
__le32 MaxWriteSize; |
| 633 |
__le64 SystemTime; /* MBZ */ |
| 634 |
__le64 ServerStartTime; |
| 635 |
__le16 SecurityBufferOffset; |
| 636 |
__le16 SecurityBufferLength; |
| 637 |
__le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */ |
| 638 |
__u8 Buffer[]; /* variable length GSS security buffer */ |
| 639 |
} __packed; |
| 640 |
|
| 641 |
|
| 642 |
/* |
| 643 |
* SMB2_SESSION_SETUP See MS-SMB2 section 2.2.5 |
| 644 |
*/ |
| 645 |
/* Flags */ |
| 646 |
#define SMB2_SESSION_REQ_FLAG_BINDING 0x01 |
| 647 |
#define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04 |
| 648 |
|
| 649 |
struct smb2_sess_setup_req { |
| 650 |
struct smb2_hdr hdr; |
| 651 |
__le16 StructureSize; /* Must be 25 */ |
| 652 |
__u8 Flags; |
| 653 |
__u8 SecurityMode; |
| 654 |
__le32 Capabilities; |
| 655 |
__le32 Channel; |
| 656 |
__le16 SecurityBufferOffset; |
| 657 |
__le16 SecurityBufferLength; |
| 658 |
__le64 PreviousSessionId; |
| 659 |
__u8 Buffer[]; /* variable length GSS security buffer */ |
| 660 |
} __packed; |
| 661 |
|
| 662 |
/* Currently defined SessionFlags */ |
| 663 |
#define SMB2_SESSION_FLAG_IS_GUEST 0x0001 |
| 664 |
#define SMB2_SESSION_FLAG_IS_GUEST_LE cpu_to_le16(0x0001) |
| 665 |
#define SMB2_SESSION_FLAG_IS_NULL 0x0002 |
| 666 |
#define SMB2_SESSION_FLAG_IS_NULL_LE cpu_to_le16(0x0002) |
| 667 |
#define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004 |
| 668 |
#define SMB2_SESSION_FLAG_ENCRYPT_DATA_LE cpu_to_le16(0x0004) |
| 669 |
|
| 670 |
struct smb2_sess_setup_rsp { |
| 671 |
struct smb2_hdr hdr; |
| 672 |
__le16 StructureSize; /* Must be 9 */ |
| 673 |
__le16 SessionFlags; |
| 674 |
__le16 SecurityBufferOffset; |
| 675 |
__le16 SecurityBufferLength; |
| 676 |
__u8 Buffer[]; /* variable length GSS security buffer */ |
| 677 |
} __packed; |
| 678 |
|
| 679 |
|
| 680 |
/* |
| 681 |
* SMB2_LOGOFF See MS-SMB2 section 2.2.7 |
| 682 |
*/ |
| 683 |
struct smb2_logoff_req { |
| 684 |
struct smb2_hdr hdr; |
| 685 |
__le16 StructureSize; /* Must be 4 */ |
| 686 |
__le16 Reserved; |
| 687 |
} __packed; |
| 688 |
|
| 689 |
struct smb2_logoff_rsp { |
| 690 |
struct smb2_hdr hdr; |
| 691 |
__le16 StructureSize; /* Must be 4 */ |
| 692 |
__le16 Reserved; |
| 693 |
} __packed; |
| 694 |
|
| 695 |
|
| 696 |
/* |
| 697 |
* SMB2_CLOSE See MS-SMB2 section 2.2.15 |
| 698 |
*/ |
| 699 |
/* Currently defined values for close flags */ |
| 700 |
#define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001) |
| 701 |
struct smb2_close_req { |
| 702 |
struct smb2_hdr hdr; |
| 703 |
__le16 StructureSize; /* Must be 24 */ |
| 704 |
__le16 Flags; |
| 705 |
__le32 Reserved; |
| 706 |
__u64 PersistentFileId; /* opaque endianness */ |
| 707 |
__u64 VolatileFileId; /* opaque endianness */ |
| 708 |
} __packed; |
| 709 |
|
| 710 |
/* |
| 711 |
* Maximum size of a SMB2_CLOSE response is 64 (smb2 header) + 60 (data) |
| 712 |
*/ |
| 713 |
#define MAX_SMB2_CLOSE_RESPONSE_SIZE 124 |
| 714 |
|
| 715 |
struct smb2_close_rsp { |
| 716 |
struct smb2_hdr hdr; |
| 717 |
__le16 StructureSize; /* 60 */ |
| 718 |
__le16 Flags; |
| 719 |
__le32 Reserved; |
| 720 |
struct_group_attr(network_open_info, __packed, |
| 721 |
__le64 CreationTime; |
| 722 |
__le64 LastAccessTime; |
| 723 |
__le64 LastWriteTime; |
| 724 |
__le64 ChangeTime; |
| 725 |
/* Beginning of FILE_STANDARD_INFO equivalent */ |
| 726 |
__le64 AllocationSize; |
| 727 |
__le64 EndOfFile; |
| 728 |
__le32 Attributes; |
| 729 |
); |
| 730 |
} __packed; |
| 731 |
|
| 732 |
|
| 733 |
/* |
| 734 |
* SMB2_READ See MS-SMB2 section 2.2.19 |
| 735 |
*/ |
| 736 |
/* For read request Flags field below, following flag is defined for SMB3.02 */ |
| 737 |
#define SMB2_READFLAG_READ_UNBUFFERED 0x01 |
| 738 |
#define SMB2_READFLAG_REQUEST_COMPRESSED 0x02 /* See MS-SMB2 2.2.19 */ |
| 739 |
|
| 740 |
/* Channel field for read and write: exactly one of following flags can be set*/ |
| 741 |
#define SMB2_CHANNEL_NONE cpu_to_le32(0x00000000) |
| 742 |
#define SMB2_CHANNEL_RDMA_V1 cpu_to_le32(0x00000001) |
| 743 |
#define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002) |
| 744 |
#define SMB2_CHANNEL_RDMA_TRANSFORM cpu_to_le32(0x00000003) |
| 745 |
|
| 746 |
/* SMB2 read request without RFC1001 length at the beginning */ |
| 747 |
struct smb2_read_req { |
| 748 |
struct smb2_hdr hdr; |
| 749 |
__le16 StructureSize; /* Must be 49 */ |
| 750 |
__u8 Padding; /* offset from start of SMB2 header to place read */ |
| 751 |
__u8 Flags; /* MBZ unless SMB3.02 or later */ |
| 752 |
__le32 Length; |
| 753 |
__le64 Offset; |
| 754 |
__u64 PersistentFileId; |
| 755 |
__u64 VolatileFileId; |
| 756 |
__le32 MinimumCount; |
| 757 |
__le32 Channel; /* MBZ except for SMB3 or later */ |
| 758 |
__le32 RemainingBytes; |
| 759 |
__le16 ReadChannelInfoOffset; |
| 760 |
__le16 ReadChannelInfoLength; |
| 761 |
__u8 Buffer[]; |
| 762 |
} __packed; |
| 763 |
|
| 764 |
/* Read flags */ |
| 765 |
#define SMB2_READFLAG_RESPONSE_NONE cpu_to_le32(0x00000000) |
| 766 |
#define SMB2_READFLAG_RESPONSE_RDMA_TRANSFORM cpu_to_le32(0x00000001) |
| 767 |
|
| 768 |
struct smb2_read_rsp { |
| 769 |
struct smb2_hdr hdr; |
| 770 |
__le16 StructureSize; /* Must be 17 */ |
| 771 |
__u8 DataOffset; |
| 772 |
__u8 Reserved; |
| 773 |
__le32 DataLength; |
| 774 |
__le32 DataRemaining; |
| 775 |
__le32 Flags; |
| 776 |
__u8 Buffer[]; |
| 777 |
} __packed; |
| 778 |
|
| 779 |
|
| 780 |
/* |
| 781 |
* SMB2_WRITE See MS-SMB2 section 2.2.21 |
| 782 |
*/ |
| 783 |
/* For write request Flags field below the following flags are defined: */ |
| 784 |
#define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */ |
| 785 |
#define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */ |
| 786 |
|
| 787 |
struct smb2_write_req { |
| 788 |
struct smb2_hdr hdr; |
| 789 |
__le16 StructureSize; /* Must be 49 */ |
| 790 |
__le16 DataOffset; /* offset from start of SMB2 header to write data */ |
| 791 |
__le32 Length; |
| 792 |
__le64 Offset; |
| 793 |
__u64 PersistentFileId; /* opaque endianness */ |
| 794 |
__u64 VolatileFileId; /* opaque endianness */ |
| 795 |
__le32 Channel; /* MBZ unless SMB3.02 or later */ |
| 796 |
__le32 RemainingBytes; |
| 797 |
__le16 WriteChannelInfoOffset; |
| 798 |
__le16 WriteChannelInfoLength; |
| 799 |
__le32 Flags; |
| 800 |
__u8 Buffer[]; |
| 801 |
} __packed; |
| 802 |
|
| 803 |
struct smb2_write_rsp { |
| 804 |
struct smb2_hdr hdr; |
| 805 |
__le16 StructureSize; /* Must be 17 */ |
| 806 |
__u8 DataOffset; |
| 807 |
__u8 Reserved; |
| 808 |
__le32 DataLength; |
| 809 |
__le32 DataRemaining; |
| 810 |
__u32 Reserved2; |
| 811 |
__u8 Buffer[]; |
| 812 |
} __packed; |
| 813 |
|
| 814 |
|
| 815 |
/* |
| 816 |
* SMB2_FLUSH See MS-SMB2 section 2.2.17 |
| 817 |
*/ |
| 818 |
struct smb2_flush_req { |
| 819 |
struct smb2_hdr hdr; |
| 820 |
__le16 StructureSize; /* Must be 24 */ |
| 821 |
__le16 Reserved1; |
| 822 |
__le32 Reserved2; |
| 823 |
__u64 PersistentFileId; |
| 824 |
__u64 VolatileFileId; |
| 825 |
} __packed; |
| 826 |
|
| 827 |
struct smb2_flush_rsp { |
| 828 |
struct smb2_hdr hdr; |
| 829 |
__le16 StructureSize; |
| 830 |
__le16 Reserved; |
| 831 |
} __packed; |
| 832 |
|
| 833 |
#define SMB2_LOCKFLAG_SHARED 0x0001 |
| 834 |
#define SMB2_LOCKFLAG_EXCLUSIVE 0x0002 |
| 835 |
#define SMB2_LOCKFLAG_UNLOCK 0x0004 |
| 836 |
#define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010 |
| 837 |
#define SMB2_LOCKFLAG_MASK 0x0007 |
| 838 |
|
| 839 |
struct smb2_lock_element { |
| 840 |
__le64 Offset; |
| 841 |
__le64 Length; |
| 842 |
__le32 Flags; |
| 843 |
__le32 Reserved; |
| 844 |
} __packed; |
| 845 |
|
| 846 |
struct smb2_lock_req { |
| 847 |
struct smb2_hdr hdr; |
| 848 |
__le16 StructureSize; /* Must be 48 */ |
| 849 |
__le16 LockCount; |
| 850 |
/* |
| 851 |
* The least significant four bits are the index, the other 28 bits are |
| 852 |
* the lock sequence number (0 to 64). See MS-SMB2 2.2.26 |
| 853 |
*/ |
| 854 |
__le32 LockSequenceNumber; |
| 855 |
__u64 PersistentFileId; |
| 856 |
__u64 VolatileFileId; |
| 857 |
/* Followed by at least one */ |
| 858 |
union { |
| 859 |
struct smb2_lock_element lock; |
| 860 |
DECLARE_FLEX_ARRAY(struct smb2_lock_element, locks); |
| 861 |
}; |
| 862 |
} __packed; |
| 863 |
|
| 864 |
struct smb2_lock_rsp { |
| 865 |
struct smb2_hdr hdr; |
| 866 |
__le16 StructureSize; /* Must be 4 */ |
| 867 |
__le16 Reserved; |
| 868 |
} __packed; |
| 869 |
|
| 870 |
struct smb2_echo_req { |
| 871 |
struct smb2_hdr hdr; |
| 872 |
__le16 StructureSize; /* Must be 4 */ |
| 873 |
__u16 Reserved; |
| 874 |
} __packed; |
| 875 |
|
| 876 |
struct smb2_echo_rsp { |
| 877 |
struct smb2_hdr hdr; |
| 878 |
__le16 StructureSize; /* Must be 4 */ |
| 879 |
__u16 Reserved; |
| 880 |
} __packed; |
| 881 |
|
| 882 |
/* |
| 883 |
* Valid FileInformation classes for query directory |
| 884 |
* |
| 885 |
* Note that these are a subset of the (file) QUERY_INFO levels defined |
| 886 |
* later in this file (but since QUERY_DIRECTORY uses equivalent numbers |
| 887 |
* we do not redefine them here) |
| 888 |
* |
| 889 |
* FileDirectoryInfomation 0x01 |
| 890 |
* FileFullDirectoryInformation 0x02 |
| 891 |
* FileIdFullDirectoryInformation 0x26 |
| 892 |
* FileBothDirectoryInformation 0x03 |
| 893 |
* FileIdBothDirectoryInformation 0x25 |
| 894 |
* FileNamesInformation 0x0C |
| 895 |
* FileIdExtdDirectoryInformation 0x3C |
| 896 |
*/ |
| 897 |
|
| 898 |
/* search (query_directory) Flags field */ |
| 899 |
#define SMB2_RESTART_SCANS 0x01 |
| 900 |
#define SMB2_RETURN_SINGLE_ENTRY 0x02 |
| 901 |
#define SMB2_INDEX_SPECIFIED 0x04 |
| 902 |
#define SMB2_REOPEN 0x10 |
| 903 |
|
| 904 |
struct smb2_query_directory_req { |
| 905 |
struct smb2_hdr hdr; |
| 906 |
__le16 StructureSize; /* Must be 33 */ |
| 907 |
__u8 FileInformationClass; |
| 908 |
__u8 Flags; |
| 909 |
__le32 FileIndex; |
| 910 |
__u64 PersistentFileId; |
| 911 |
__u64 VolatileFileId; |
| 912 |
__le16 FileNameOffset; |
| 913 |
__le16 FileNameLength; |
| 914 |
__le32 OutputBufferLength; |
| 915 |
__u8 Buffer[]; |
| 916 |
} __packed; |
| 917 |
|
| 918 |
struct smb2_query_directory_rsp { |
| 919 |
struct smb2_hdr hdr; |
| 920 |
__le16 StructureSize; /* Must be 9 */ |
| 921 |
__le16 OutputBufferOffset; |
| 922 |
__le32 OutputBufferLength; |
| 923 |
__u8 Buffer[]; |
| 924 |
} __packed; |
| 925 |
|
| 926 |
/* DeviceType Flags */ |
| 927 |
#define FILE_DEVICE_CD_ROM 0x00000002 |
| 928 |
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 |
| 929 |
#define FILE_DEVICE_DFS 0x00000006 |
| 930 |
#define FILE_DEVICE_DISK 0x00000007 |
| 931 |
#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 |
| 932 |
#define FILE_DEVICE_FILE_SYSTEM 0x00000009 |
| 933 |
#define FILE_DEVICE_NAMED_PIPE 0x00000011 |
| 934 |
#define FILE_DEVICE_NETWORK 0x00000012 |
| 935 |
#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 |
| 936 |
#define FILE_DEVICE_NULL 0x00000015 |
| 937 |
#define FILE_DEVICE_PARALLEL_PORT 0x00000016 |
| 938 |
#define FILE_DEVICE_PRINTER 0x00000018 |
| 939 |
#define FILE_DEVICE_SERIAL_PORT 0x0000001b |
| 940 |
#define FILE_DEVICE_STREAMS 0x0000001e |
| 941 |
#define FILE_DEVICE_TAPE 0x0000001f |
| 942 |
#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 |
| 943 |
#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 |
| 944 |
#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 |
| 945 |
|
| 946 |
/* Device Characteristics */ |
| 947 |
#define FILE_REMOVABLE_MEDIA 0x00000001 |
| 948 |
#define FILE_READ_ONLY_DEVICE 0x00000002 |
| 949 |
#define FILE_FLOPPY_DISKETTE 0x00000004 |
| 950 |
#define FILE_WRITE_ONCE_MEDIA 0x00000008 |
| 951 |
#define FILE_REMOTE_DEVICE 0x00000010 |
| 952 |
#define FILE_DEVICE_IS_MOUNTED 0x00000020 |
| 953 |
#define FILE_VIRTUAL_VOLUME 0x00000040 |
| 954 |
#define FILE_DEVICE_SECURE_OPEN 0x00000100 |
| 955 |
#define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000 |
| 956 |
#define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000 |
| 957 |
#define FILE_PORTABLE_DEVICE 0x00004000 |
| 958 |
#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000 |
| 959 |
|
| 960 |
/* |
| 961 |
* Maximum number of iovs we need for a set-info request. |
| 962 |
* The largest one is rename/hardlink |
| 963 |
* [0] : struct smb2_set_info_req + smb2_file_[rename|link]_info |
| 964 |
* [1] : path |
| 965 |
* [2] : compound padding |
| 966 |
*/ |
| 967 |
#define SMB2_SET_INFO_IOV_SIZE 3 |
| 968 |
|
| 969 |
struct smb2_set_info_req { |
| 970 |
struct smb2_hdr hdr; |
| 971 |
__le16 StructureSize; /* Must be 33 */ |
| 972 |
__u8 InfoType; |
| 973 |
__u8 FileInfoClass; |
| 974 |
__le32 BufferLength; |
| 975 |
__le16 BufferOffset; |
| 976 |
__u16 Reserved; |
| 977 |
__le32 AdditionalInformation; |
| 978 |
__u64 PersistentFileId; |
| 979 |
__u64 VolatileFileId; |
| 980 |
__u8 Buffer[]; |
| 981 |
} __packed; |
| 982 |
|
| 983 |
struct smb2_set_info_rsp { |
| 984 |
struct smb2_hdr hdr; |
| 985 |
__le16 StructureSize; /* Must be 2 */ |
| 986 |
} __packed; |
| 987 |
|
| 988 |
/* |
| 989 |
* SMB2_NOTIFY See MS-SMB2 section 2.2.35 |
| 990 |
*/ |
| 991 |
/* notify flags */ |
| 992 |
#define SMB2_WATCH_TREE 0x0001 |
| 993 |
|
| 994 |
/* notify completion filter flags. See MS-FSCC 2.6 and MS-SMB2 2.2.35 */ |
| 995 |
#define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001 |
| 996 |
#define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002 |
| 997 |
#define FILE_NOTIFY_CHANGE_NAME 0x00000003 |
| 998 |
#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004 |
| 999 |
#define FILE_NOTIFY_CHANGE_SIZE 0x00000008 |
| 1000 |
#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010 |
| 1001 |
#define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020 |
| 1002 |
#define FILE_NOTIFY_CHANGE_CREATION 0x00000040 |
| 1003 |
#define FILE_NOTIFY_CHANGE_EA 0x00000080 |
| 1004 |
#define FILE_NOTIFY_CHANGE_SECURITY 0x00000100 |
| 1005 |
#define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200 |
| 1006 |
#define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400 |
| 1007 |
#define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800 |
| 1008 |
|
| 1009 |
/* |
| 1010 |
* SMB2 Notify Action Flags |
| 1011 |
* See MS-FSCC 2.7.1 |
| 1012 |
*/ |
| 1013 |
#define FILE_ACTION_ADDED 0x00000001 |
| 1014 |
#define FILE_ACTION_REMOVED 0x00000002 |
| 1015 |
#define FILE_ACTION_MODIFIED 0x00000003 |
| 1016 |
#define FILE_ACTION_RENAMED_OLD_NAME 0x00000004 |
| 1017 |
#define FILE_ACTION_RENAMED_NEW_NAME 0x00000005 |
| 1018 |
#define FILE_ACTION_ADDED_STREAM 0x00000006 |
| 1019 |
#define FILE_ACTION_REMOVED_STREAM 0x00000007 |
| 1020 |
#define FILE_ACTION_MODIFIED_STREAM 0x00000008 |
| 1021 |
#define FILE_ACTION_REMOVED_BY_DELETE 0x00000009 |
| 1022 |
#define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000A |
| 1023 |
#define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000B |
| 1024 |
|
| 1025 |
/* See MS-SMB2 2.2.35 */ |
| 1026 |
struct smb2_change_notify_req { |
| 1027 |
struct smb2_hdr hdr; |
| 1028 |
__le16 StructureSize; |
| 1029 |
__le16 Flags; |
| 1030 |
__le32 OutputBufferLength; |
| 1031 |
__u64 PersistentFileId; /* opaque endianness */ |
| 1032 |
__u64 VolatileFileId; /* opaque endianness */ |
| 1033 |
__le32 CompletionFilter; |
| 1034 |
__u32 Reserved; |
| 1035 |
} __packed; |
| 1036 |
|
| 1037 |
/* See MS-SMB2 2.2.36 */ |
| 1038 |
struct smb2_change_notify_rsp { |
| 1039 |
struct smb2_hdr hdr; |
| 1040 |
__le16 StructureSize; /* Must be 9 */ |
| 1041 |
__le16 OutputBufferOffset; |
| 1042 |
__le32 OutputBufferLength; |
| 1043 |
__u8 Buffer[]; /* array of file notify structs */ |
| 1044 |
} __packed; |
| 1045 |
|
| 1046 |
/* |
| 1047 |
* SMB2_SERVER_TO_CLIENT_NOTIFICATION: See MS-SMB2 section 2.2.44 |
| 1048 |
*/ |
| 1049 |
|
| 1050 |
#define SMB2_NOTIFY_SESSION_CLOSED 0x0000 |
| 1051 |
|
| 1052 |
struct smb2_server_client_notification { |
| 1053 |
struct smb2_hdr hdr; |
| 1054 |
__le16 StructureSize; |
| 1055 |
__u16 Reserved; /* MBZ */ |
| 1056 |
__le32 NotificationType; |
| 1057 |
__u8 NotificationBuffer[4]; /* MBZ */ |
| 1058 |
} __packed; |
| 1059 |
|
| 1060 |
/* |
| 1061 |
* SMB2_CREATE See MS-SMB2 section 2.2.13 |
| 1062 |
*/ |
| 1063 |
/* Oplock levels */ |
| 1064 |
#define SMB2_OPLOCK_LEVEL_NONE 0x00 |
| 1065 |
#define SMB2_OPLOCK_LEVEL_II 0x01 |
| 1066 |
#define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08 |
| 1067 |
#define SMB2_OPLOCK_LEVEL_BATCH 0x09 |
| 1068 |
#define SMB2_OPLOCK_LEVEL_LEASE 0xFF |
| 1069 |
/* Non-spec internal type */ |
| 1070 |
#define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99 |
| 1071 |
|
| 1072 |
/* Impersonation Levels. See MS-WPO section 9.7 and MSDN-IMPERS */ |
| 1073 |
#define IL_ANONYMOUS cpu_to_le32(0x00000000) |
| 1074 |
#define IL_IDENTIFICATION cpu_to_le32(0x00000001) |
| 1075 |
#define IL_IMPERSONATION cpu_to_le32(0x00000002) |
| 1076 |
#define IL_DELEGATE cpu_to_le32(0x00000003) |
| 1077 |
|
| 1078 |
/* Desired Access Flags */ |
| 1079 |
#define FILE_READ_DATA_LE cpu_to_le32(0x00000001) |
| 1080 |
#define FILE_LIST_DIRECTORY_LE cpu_to_le32(0x00000001) |
| 1081 |
#define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002) |
| 1082 |
#define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004) |
| 1083 |
#define FILE_ADD_SUBDIRECTORY_LE cpu_to_le32(0x00000004) |
| 1084 |
#define FILE_READ_EA_LE cpu_to_le32(0x00000008) |
| 1085 |
#define FILE_WRITE_EA_LE cpu_to_le32(0x00000010) |
| 1086 |
#define FILE_EXECUTE_LE cpu_to_le32(0x00000020) |
| 1087 |
#define FILE_DELETE_CHILD_LE cpu_to_le32(0x00000040) |
| 1088 |
#define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080) |
| 1089 |
#define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100) |
| 1090 |
#define FILE_DELETE_LE cpu_to_le32(0x00010000) |
| 1091 |
#define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000) |
| 1092 |
#define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000) |
| 1093 |
#define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000) |
| 1094 |
#define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000) |
| 1095 |
#define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000) |
| 1096 |
#define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000) |
| 1097 |
#define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000) |
| 1098 |
#define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000) |
| 1099 |
#define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000) |
| 1100 |
#define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000) |
| 1101 |
#define DESIRED_ACCESS_MASK cpu_to_le32(0xF21F01FF) |
| 1102 |
|
| 1103 |
|
| 1104 |
#define FILE_READ_DESIRED_ACCESS_LE (FILE_READ_DATA_LE | \ |
| 1105 |
FILE_READ_EA_LE | \ |
| 1106 |
FILE_GENERIC_READ_LE) |
| 1107 |
#define FILE_WRITE_DESIRE_ACCESS_LE (FILE_WRITE_DATA_LE | \ |
| 1108 |
FILE_APPEND_DATA_LE | \ |
| 1109 |
FILE_WRITE_EA_LE | \ |
| 1110 |
FILE_WRITE_ATTRIBUTES_LE | \ |
| 1111 |
FILE_GENERIC_WRITE_LE) |
| 1112 |
|
| 1113 |
/* ShareAccess Flags */ |
| 1114 |
#define FILE_SHARE_READ_LE cpu_to_le32(0x00000001) |
| 1115 |
#define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002) |
| 1116 |
#define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004) |
| 1117 |
#define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007) |
| 1118 |
|
| 1119 |
/* CreateDisposition Flags */ |
| 1120 |
#define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000) |
| 1121 |
#define FILE_OPEN_LE cpu_to_le32(0x00000001) |
| 1122 |
#define FILE_CREATE_LE cpu_to_le32(0x00000002) |
| 1123 |
#define FILE_OPEN_IF_LE cpu_to_le32(0x00000003) |
| 1124 |
#define FILE_OVERWRITE_LE cpu_to_le32(0x00000004) |
| 1125 |
#define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005) |
| 1126 |
#define FILE_CREATE_MASK_LE cpu_to_le32(0x00000007) |
| 1127 |
|
| 1128 |
/* CreateOptions Flags */ |
| 1129 |
#define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001) |
| 1130 |
/* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */ |
| 1131 |
#define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002) |
| 1132 |
#define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004) |
| 1133 |
#define FILE_NO_INTERMEDIATE_BUFFERING_LE cpu_to_le32(0x00000008) |
| 1134 |
/* FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010) should be zero, ignored */ |
| 1135 |
/* FILE_SYNCHRONOUS_IO_NONALERT cpu_to_le32(0x00000020) should be zero, ignored */ |
| 1136 |
#define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040) |
| 1137 |
#define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100) |
| 1138 |
#define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200) |
| 1139 |
/* FILE_OPEN_REMOTE_INSTANCE cpu_to_le32(0x00000400) should be zero, ignored */ |
| 1140 |
#define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800) |
| 1141 |
#define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000) /* MBZ */ |
| 1142 |
#define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000) |
| 1143 |
#define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000) |
| 1144 |
#define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000) |
| 1145 |
/* FILE_OPEN_REQUIRING_OPLOCK cpu_to_le32(0x00010000) should be zero, ignored */ |
| 1146 |
/* FILE_DISALLOW_EXCLUSIVE cpu_to_le32(0x00020000) should be zero, ignored */ |
| 1147 |
/* FILE_RESERVE_OPFILTER cpu_to_le32(0x00100000) MBZ */ |
| 1148 |
#define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000) |
| 1149 |
#define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000) |
| 1150 |
/* #define FILE_OPEN_FOR_FREE_SPACE_QUERY cpu_to_le32(0x00800000) should be zero, ignored */ |
| 1151 |
#define CREATE_OPTIONS_MASK_LE cpu_to_le32(0x00FFFFFF) |
| 1152 |
|
| 1153 |
#define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \ |
| 1154 |
| FILE_READ_ATTRIBUTES_LE) |
| 1155 |
#define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \ |
| 1156 |
| FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE) |
| 1157 |
#define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE) |
| 1158 |
|
| 1159 |
/* Create Context Values */ |
| 1160 |
#define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */ |
| 1161 |
#define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */ |
| 1162 |
#define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ" |
| 1163 |
#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC" |
| 1164 |
#define SMB2_CREATE_ALLOCATION_SIZE "AlSi" |
| 1165 |
#define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc" |
| 1166 |
#define SMB2_CREATE_TIMEWARP_REQUEST "TWrp" |
| 1167 |
#define SMB2_CREATE_QUERY_ON_DISK_ID "QFid" |
| 1168 |
#define SMB2_CREATE_REQUEST_LEASE "RqLs" |
| 1169 |
#define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q" |
| 1170 |
#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C" |
| 1171 |
#define SMB2_CREATE_TAG_POSIX "\x93\xAD\x25\x50\x9C\xB4\x11\xE7\xB4\x23\x83\xDE\x96\x8B\xCD\x7C" |
| 1172 |
#define SMB2_CREATE_APP_INSTANCE_ID "\x45\xBC\xA6\x6A\xEF\xA7\xF7\x4A\x90\x08\xFA\x46\x2E\x14\x4D\x74" |
| 1173 |
#define SMB2_CREATE_APP_INSTANCE_VERSION "\xB9\x82\xD0\xB7\x3B\x56\x07\x4F\xA0\x7B\x52\x4A\x81\x16\xA0\x10" |
| 1174 |
#define SVHDX_OPEN_DEVICE_CONTEXT "\x9C\xCB\xCF\x9E\x04\xC1\xE6\x43\x98\x0E\x15\x8D\xA1\xF6\xEC\x83" |
| 1175 |
#define SMB2_CREATE_TAG_AAPL "AAPL" |
| 1176 |
|
| 1177 |
/* Flag (SMB3 open response) values */ |
| 1178 |
#define SMB2_CREATE_FLAG_REPARSEPOINT 0x01 |
| 1179 |
|
| 1180 |
struct create_context { |
| 1181 |
/* New members must be added within the struct_group() macro below. */ |
| 1182 |
__struct_group(create_context_hdr, hdr, __packed, |
| 1183 |
__le32 Next; |
| 1184 |
__le16 NameOffset; |
| 1185 |
__le16 NameLength; |
| 1186 |
__le16 Reserved; |
| 1187 |
__le16 DataOffset; |
| 1188 |
__le32 DataLength; |
| 1189 |
); |
| 1190 |
__u8 Buffer[]; |
| 1191 |
} __packed; |
| 1192 |
static_assert(offsetof(struct create_context, Buffer) == sizeof(struct create_context_hdr), |
| 1193 |
"struct member likely outside of __struct_group()"); |
| 1194 |
|
| 1195 |
struct smb2_create_req { |
| 1196 |
struct smb2_hdr hdr; |
| 1197 |
__le16 StructureSize; /* Must be 57 */ |
| 1198 |
__u8 SecurityFlags; |
| 1199 |
__u8 RequestedOplockLevel; |
| 1200 |
__le32 ImpersonationLevel; |
| 1201 |
__le64 SmbCreateFlags; |
| 1202 |
__le64 Reserved; |
| 1203 |
__le32 DesiredAccess; |
| 1204 |
__le32 FileAttributes; |
| 1205 |
__le32 ShareAccess; |
| 1206 |
__le32 CreateDisposition; |
| 1207 |
__le32 CreateOptions; |
| 1208 |
__le16 NameOffset; |
| 1209 |
__le16 NameLength; |
| 1210 |
__le32 CreateContextsOffset; |
| 1211 |
__le32 CreateContextsLength; |
| 1212 |
__u8 Buffer[]; |
| 1213 |
} __packed; |
| 1214 |
|
| 1215 |
struct smb2_create_rsp { |
| 1216 |
struct smb2_hdr hdr; |
| 1217 |
__le16 StructureSize; /* Must be 89 */ |
| 1218 |
__u8 OplockLevel; |
| 1219 |
__u8 Flags; /* 0x01 if reparse point */ |
| 1220 |
__le32 CreateAction; |
| 1221 |
__le64 CreationTime; |
| 1222 |
__le64 LastAccessTime; |
| 1223 |
__le64 LastWriteTime; |
| 1224 |
__le64 ChangeTime; |
| 1225 |
__le64 AllocationSize; |
| 1226 |
__le64 EndofFile; |
| 1227 |
__le32 FileAttributes; |
| 1228 |
__le32 Reserved2; |
| 1229 |
__u64 PersistentFileId; |
| 1230 |
__u64 VolatileFileId; |
| 1231 |
__le32 CreateContextsOffset; |
| 1232 |
__le32 CreateContextsLength; |
| 1233 |
__u8 Buffer[]; |
| 1234 |
} __packed; |
| 1235 |
|
| 1236 |
struct create_posix { |
| 1237 |
struct create_context_hdr ccontext; |
| 1238 |
__u8 Name[16]; |
| 1239 |
__le32 Mode; |
| 1240 |
__u32 Reserved; |
| 1241 |
} __packed; |
| 1242 |
|
| 1243 |
/* See MS-SMB2 2.2.13.2.3 and MS-SMB2 2.2.13.2.4 */ |
| 1244 |
typedef struct { |
| 1245 |
struct create_context_hdr ccontext; |
| 1246 |
__u8 Name[8]; |
| 1247 |
union { |
| 1248 |
__u8 Reserved[16]; |
| 1249 |
struct { |
| 1250 |
__u64 PersistentFileId; |
| 1251 |
__u64 VolatileFileId; |
| 1252 |
} Fid; |
| 1253 |
} Data; |
| 1254 |
} __packed create_durable_req_t, create_durable_reconn_t; |
| 1255 |
|
| 1256 |
/* See MS-SMB2 2.2.13.2.5 */ |
| 1257 |
struct create_mxac_req { |
| 1258 |
struct create_context_hdr ccontext; |
| 1259 |
__u8 Name[8]; |
| 1260 |
__le64 Timestamp; |
| 1261 |
} __packed; |
| 1262 |
|
| 1263 |
/* |
| 1264 |
* Flags |
| 1265 |
* See MS-SMB2 2.2.13.2.11 |
| 1266 |
* MS-SMB2 2.2.13.2.12 |
| 1267 |
* MS-SMB2 2.2.14.2.12 |
| 1268 |
*/ |
| 1269 |
#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 |
| 1270 |
|
| 1271 |
/* See MS-SMB2 2.2.13.2.11 */ |
| 1272 |
struct durable_context_v2_req { |
| 1273 |
__le32 Timeout; |
| 1274 |
__le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */ |
| 1275 |
__u64 Reserved; |
| 1276 |
__u8 CreateGuid[16]; |
| 1277 |
} __packed; |
| 1278 |
|
| 1279 |
struct create_durable_req_v2 { |
| 1280 |
struct create_context_hdr ccontext; |
| 1281 |
__u8 Name[8]; |
| 1282 |
struct durable_context_v2_req dcontext; |
| 1283 |
} __packed; |
| 1284 |
|
| 1285 |
/* See MS-SMB2 2.2.13.2.12 */ |
| 1286 |
struct durable_reconnect_context_v2 { |
| 1287 |
struct { |
| 1288 |
__u64 PersistentFileId; |
| 1289 |
__u64 VolatileFileId; |
| 1290 |
} Fid; |
| 1291 |
__u8 CreateGuid[16]; |
| 1292 |
__le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */ |
| 1293 |
} __packed; |
| 1294 |
|
| 1295 |
struct create_durable_handle_reconnect_v2 { |
| 1296 |
struct create_context_hdr ccontext; |
| 1297 |
__u8 Name[8]; |
| 1298 |
struct durable_reconnect_context_v2 dcontext; |
| 1299 |
__u8 Pad[4]; |
| 1300 |
} __packed; |
| 1301 |
|
| 1302 |
/* See MS-SMB2 2.2.14.2.12 */ |
| 1303 |
struct durable_context_v2_rsp { |
| 1304 |
__le32 Timeout; |
| 1305 |
__le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */ |
| 1306 |
} __packed; |
| 1307 |
|
| 1308 |
struct create_durable_rsp_v2 { |
| 1309 |
struct create_context_hdr ccontext; |
| 1310 |
__u8 Name[8]; |
| 1311 |
struct durable_context_v2_rsp dcontext; |
| 1312 |
} __packed; |
| 1313 |
|
| 1314 |
/* See MS-SMB2 2.2.14.2.5 */ |
| 1315 |
struct create_mxac_rsp { |
| 1316 |
struct create_context_hdr ccontext; |
| 1317 |
__u8 Name[8]; |
| 1318 |
__le32 QueryStatus; |
| 1319 |
__le32 MaximalAccess; |
| 1320 |
} __packed; |
| 1321 |
|
| 1322 |
#define SMB2_LEASE_NONE_LE cpu_to_le32(0x00) |
| 1323 |
#define SMB2_LEASE_READ_CACHING_LE cpu_to_le32(0x01) |
| 1324 |
#define SMB2_LEASE_HANDLE_CACHING_LE cpu_to_le32(0x02) |
| 1325 |
#define SMB2_LEASE_WRITE_CACHING_LE cpu_to_le32(0x04) |
| 1326 |
|
| 1327 |
#define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS_LE cpu_to_le32(0x02) |
| 1328 |
#define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET_LE cpu_to_le32(0x04) |
| 1329 |
|
| 1330 |
#define SMB2_LEASE_KEY_SIZE 16 |
| 1331 |
|
| 1332 |
/* See MS-SMB2 2.2.13.2.8 */ |
| 1333 |
struct lease_context { |
| 1334 |
__u8 LeaseKey[SMB2_LEASE_KEY_SIZE]; |
| 1335 |
__le32 LeaseState; |
| 1336 |
__le32 LeaseFlags; |
| 1337 |
__le64 LeaseDuration; |
| 1338 |
} __packed; |
| 1339 |
|
| 1340 |
/* See MS-SMB2 2.2.13.2.10 */ |
| 1341 |
struct lease_context_v2 { |
| 1342 |
__u8 LeaseKey[SMB2_LEASE_KEY_SIZE]; |
| 1343 |
__le32 LeaseState; |
| 1344 |
__le32 LeaseFlags; |
| 1345 |
__le64 LeaseDuration; |
| 1346 |
__u8 ParentLeaseKey[SMB2_LEASE_KEY_SIZE]; |
| 1347 |
__le16 Epoch; |
| 1348 |
__le16 Reserved; |
| 1349 |
} __packed; |
| 1350 |
|
| 1351 |
struct create_lease { |
| 1352 |
struct create_context_hdr ccontext; |
| 1353 |
__u8 Name[8]; |
| 1354 |
struct lease_context lcontext; |
| 1355 |
} __packed; |
| 1356 |
|
| 1357 |
struct create_lease_v2 { |
| 1358 |
struct create_context_hdr ccontext; |
| 1359 |
__u8 Name[8]; |
| 1360 |
struct lease_context_v2 lcontext; |
| 1361 |
__u8 Pad[4]; |
| 1362 |
} __packed; |
| 1363 |
|
| 1364 |
/* See MS-SMB2 2.2.14.2.9 */ |
| 1365 |
struct create_disk_id_rsp { |
| 1366 |
struct create_context_hdr ccontext; |
| 1367 |
__u8 Name[8]; |
| 1368 |
__le64 DiskFileId; |
| 1369 |
__le64 VolumeId; |
| 1370 |
__u8 Reserved[16]; |
| 1371 |
} __packed; |
| 1372 |
|
| 1373 |
/* See MS-SMB2 2.2.13.2.13 */ |
| 1374 |
struct create_app_inst_id { |
| 1375 |
struct create_context_hdr ccontext; |
| 1376 |
__u8 Name[16]; |
| 1377 |
__le32 StructureSize; /* Must be 20 */ |
| 1378 |
__u16 Reserved; |
| 1379 |
__u8 AppInstanceId[16]; |
| 1380 |
} __packed; |
| 1381 |
|
| 1382 |
/* See MS-SMB2 2.2.13.2.15 */ |
| 1383 |
struct create_app_inst_id_vers { |
| 1384 |
struct create_context_hdr ccontext; |
| 1385 |
__u8 Name[16]; |
| 1386 |
__le32 StructureSize; /* Must be 24 */ |
| 1387 |
__u16 Reserved; |
| 1388 |
__u32 Padding; |
| 1389 |
__le64 AppInstanceVersionHigh; |
| 1390 |
__le64 AppInstanceVersionLow; |
| 1391 |
} __packed; |
| 1392 |
|
| 1393 |
/* See MS-SMB2 2.2.31 and 2.2.32 */ |
| 1394 |
struct smb2_ioctl_req { |
| 1395 |
struct smb2_hdr hdr; |
| 1396 |
__le16 StructureSize; /* Must be 57 */ |
| 1397 |
__le16 Reserved; /* offset from start of SMB2 header to write data */ |
| 1398 |
__le32 CtlCode; |
| 1399 |
__u64 PersistentFileId; |
| 1400 |
__u64 VolatileFileId; |
| 1401 |
__le32 InputOffset; /* Reserved MBZ */ |
| 1402 |
__le32 InputCount; |
| 1403 |
__le32 MaxInputResponse; |
| 1404 |
__le32 OutputOffset; |
| 1405 |
__le32 OutputCount; |
| 1406 |
__le32 MaxOutputResponse; |
| 1407 |
__le32 Flags; |
| 1408 |
__le32 Reserved2; |
| 1409 |
__u8 Buffer[]; |
| 1410 |
} __packed; |
| 1411 |
|
| 1412 |
/* See MS-SMB2 2.2.31.1.1 */ |
| 1413 |
struct srv_copychunk { |
| 1414 |
__le64 SourceOffset; |
| 1415 |
__le64 TargetOffset; |
| 1416 |
__le32 Length; |
| 1417 |
__le32 Reserved; |
| 1418 |
} __packed; |
| 1419 |
|
| 1420 |
#define COPY_CHUNK_RES_KEY_SIZE 24 |
| 1421 |
|
| 1422 |
/* See MS-SMB2 2.2.31.1 */ |
| 1423 |
/* this goes in the ioctl buffer when doing a copychunk request */ |
| 1424 |
struct copychunk_ioctl_req { |
| 1425 |
union { |
| 1426 |
char SourceKey[COPY_CHUNK_RES_KEY_SIZE]; |
| 1427 |
__le64 SourceKeyU64[3]; |
| 1428 |
}; |
| 1429 |
__le32 ChunkCount; |
| 1430 |
__le32 Reserved; |
| 1431 |
struct srv_copychunk Chunks[] __counted_by_le(ChunkCount); |
| 1432 |
} __packed; |
| 1433 |
|
| 1434 |
/* See MS-SMB2 2.2.32.1 */ |
| 1435 |
struct copychunk_ioctl_rsp { |
| 1436 |
__le32 ChunksWritten; |
| 1437 |
__le32 ChunkBytesWritten; |
| 1438 |
__le32 TotalBytesWritten; |
| 1439 |
} __packed; |
| 1440 |
|
| 1441 |
/* See MS-SMB2 2.2.32.3 */ |
| 1442 |
struct resume_key_ioctl_rsp { |
| 1443 |
union { |
| 1444 |
char ResumeKey[COPY_CHUNK_RES_KEY_SIZE]; |
| 1445 |
__u64 ResumeKeyU64[3]; |
| 1446 |
}; |
| 1447 |
__le32 ContextLength; /* MBZ */ |
| 1448 |
char Context[]; /* ignored, Windows sets to 4 bytes of zero */ |
| 1449 |
} __packed; |
| 1450 |
|
| 1451 |
struct smb2_ioctl_rsp { |
| 1452 |
struct smb2_hdr hdr; |
| 1453 |
__le16 StructureSize; /* Must be 49 */ |
| 1454 |
__le16 Reserved; |
| 1455 |
__le32 CtlCode; |
| 1456 |
__u64 PersistentFileId; |
| 1457 |
__u64 VolatileFileId; |
| 1458 |
__le32 InputOffset; /* Reserved MBZ */ |
| 1459 |
__le32 InputCount; |
| 1460 |
__le32 OutputOffset; |
| 1461 |
__le32 OutputCount; |
| 1462 |
__le32 Flags; |
| 1463 |
__le32 Reserved2; |
| 1464 |
__u8 Buffer[]; |
| 1465 |
} __packed; |
| 1466 |
|
| 1467 |
/* See MS-SMB2 2.2.32.5.1.1 */ |
| 1468 |
struct smb_sockaddr_in { |
| 1469 |
__be16 Port; |
| 1470 |
__be32 IPv4Address; |
| 1471 |
__u8 Reserved[8]; |
| 1472 |
} __packed; |
| 1473 |
|
| 1474 |
/* See MS-SMB2 2.2.32.5.1.2 */ |
| 1475 |
struct smb_sockaddr_in6 { |
| 1476 |
__be16 Port; |
| 1477 |
__be32 FlowInfo; |
| 1478 |
__u8 IPv6Address[16]; |
| 1479 |
__be32 ScopeId; |
| 1480 |
} __packed; |
| 1481 |
|
| 1482 |
/* See MS-SMB2 2.2.32.5 and MS-SMB2 2.2.32.5.1 */ |
| 1483 |
#define RSS_CAPABLE cpu_to_le32(0x00000001) |
| 1484 |
#define RDMA_CAPABLE cpu_to_le32(0x00000002) |
| 1485 |
#define INTERNETWORK cpu_to_le16(0x0002) |
| 1486 |
#define INTERNETWORKV6 cpu_to_le16(0x0017) |
| 1487 |
struct network_interface_info_ioctl_rsp { |
| 1488 |
__le32 Next; /* next interface. zero if this is last one */ |
| 1489 |
__le32 IfIndex; |
| 1490 |
__le32 Capability; /* RSS or RDMA Capable */ |
| 1491 |
__le32 Reserved; |
| 1492 |
__le64 LinkSpeed; |
| 1493 |
union { |
| 1494 |
char SockAddr_Storage[128]; |
| 1495 |
struct { |
| 1496 |
__le16 Family; |
| 1497 |
__u8 Buffer[126]; |
| 1498 |
}; |
| 1499 |
}; |
| 1500 |
} __packed; |
| 1501 |
|
| 1502 |
/* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */ |
| 1503 |
struct file_zero_data_information { |
| 1504 |
__le64 FileOffset; |
| 1505 |
__le64 BeyondFinalZero; |
| 1506 |
} __packed; |
| 1507 |
|
| 1508 |
/* See MS-FSCC 2.3.7 */ |
| 1509 |
struct duplicate_extents_to_file { |
| 1510 |
__u64 PersistentFileHandle; /* source file handle, opaque endianness */ |
| 1511 |
__u64 VolatileFileHandle; |
| 1512 |
__le64 SourceFileOffset; |
| 1513 |
__le64 TargetFileOffset; |
| 1514 |
__le64 ByteCount; /* Bytes to be copied */ |
| 1515 |
} __packed; |
| 1516 |
|
| 1517 |
/* See MS-FSCC 2.3.9 */ |
| 1518 |
#define DUPLICATE_EXTENTS_DATA_EX_SOURCE_ATOMIC 0x00000001 |
| 1519 |
struct duplicate_extents_to_file_ex { |
| 1520 |
__le64 StructureSize; /* MUST be set to 0x30 */ |
| 1521 |
__u64 PersistentFileHandle; /* source file handle, opaque endianness */ |
| 1522 |
__u64 VolatileFileHandle; |
| 1523 |
__le64 SourceFileOffset; |
| 1524 |
__le64 TargetFileOffset; |
| 1525 |
__le64 ByteCount; /* Bytes to be copied */ |
| 1526 |
__le32 Flags; |
| 1527 |
__le32 Reserved; |
| 1528 |
} __packed; |
| 1529 |
|
| 1530 |
|
| 1531 |
/* See MS-FSCC 2.3.20 */ |
| 1532 |
struct fsctl_get_integrity_information_rsp { |
| 1533 |
__le16 ChecksumAlgorithm; |
| 1534 |
__le16 Reserved; |
| 1535 |
__le32 Flags; |
| 1536 |
__le32 ChecksumChunkSizeInBytes; |
| 1537 |
__le32 ClusterSizeInBytes; |
| 1538 |
} __packed; |
| 1539 |
|
| 1540 |
/* See MS-FSCC 2.3.55 */ |
| 1541 |
struct fsctl_query_file_regions_req { |
| 1542 |
__le64 FileOffset; |
| 1543 |
__le64 Length; |
| 1544 |
__le32 DesiredUsage; |
| 1545 |
__le32 Reserved; |
| 1546 |
} __packed; |
| 1547 |
|
| 1548 |
/* DesiredUsage flags see MS-FSCC 2.3.56.1 */ |
| 1549 |
#define FILE_USAGE_INVALID_RANGE 0x00000000 |
| 1550 |
#define FILE_USAGE_VALID_CACHED_DATA 0x00000001 |
| 1551 |
#define FILE_USAGE_NONCACHED_DATA 0x00000002 |
| 1552 |
|
| 1553 |
struct file_region_info { |
| 1554 |
__le64 FileOffset; |
| 1555 |
__le64 Length; |
| 1556 |
__le32 DesiredUsage; |
| 1557 |
__le32 Reserved; |
| 1558 |
} __packed; |
| 1559 |
|
| 1560 |
/* See MS-FSCC 2.3.56 */ |
| 1561 |
struct fsctl_query_file_region_rsp { |
| 1562 |
__le32 Flags; |
| 1563 |
__le32 TotalRegionEntryCount; |
| 1564 |
__le32 RegionEntryCount; |
| 1565 |
__u32 Reserved; |
| 1566 |
struct file_region_info Regions[]; |
| 1567 |
} __packed; |
| 1568 |
|
| 1569 |
/* See MS-FSCC 2.3.58 */ |
| 1570 |
struct fsctl_query_on_disk_vol_info_rsp { |
| 1571 |
__le64 DirectoryCount; |
| 1572 |
__le64 FileCount; |
| 1573 |
__le16 FsFormatMajVersion; |
| 1574 |
__le16 FsFormatMinVersion; |
| 1575 |
__u8 FsFormatName[24]; |
| 1576 |
__le64 FormatTime; |
| 1577 |
__le64 LastUpdateTime; |
| 1578 |
__u8 CopyrightInfo[68]; |
| 1579 |
__u8 AbstractInfo[68]; |
| 1580 |
__u8 FormatImplInfo[68]; |
| 1581 |
__u8 LastModifyImplInfo[68]; |
| 1582 |
} __packed; |
| 1583 |
|
| 1584 |
/* See MS-FSCC 2.3.73 */ |
| 1585 |
struct fsctl_set_integrity_information_req { |
| 1586 |
__le16 ChecksumAlgorithm; |
| 1587 |
__le16 Reserved; |
| 1588 |
__le32 Flags; |
| 1589 |
} __packed; |
| 1590 |
|
| 1591 |
/* See MS-FSCC 2.3.75 */ |
| 1592 |
struct fsctl_set_integrity_info_ex_req { |
| 1593 |
__u8 EnableIntegrity; |
| 1594 |
__u8 KeepState; |
| 1595 |
__u16 Reserved; |
| 1596 |
__le32 Flags; |
| 1597 |
__u8 Version; |
| 1598 |
__u8 Reserved2[7]; |
| 1599 |
} __packed; |
| 1600 |
|
| 1601 |
/* Integrity ChecksumAlgorithm choices for above */ |
| 1602 |
#define CHECKSUM_TYPE_NONE 0x0000 |
| 1603 |
#define CHECKSUM_TYPE_CRC64 0x0002 |
| 1604 |
#define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */ |
| 1605 |
|
| 1606 |
/* Integrity flags for above */ |
| 1607 |
#define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001 |
| 1608 |
|
| 1609 |
/* Reparse structures - see MS-FSCC 2.1.2 */ |
| 1610 |
|
| 1611 |
/* struct fsctl_reparse_info_req is empty, only response structs (see below) */ |
| 1612 |
struct reparse_data_buffer { |
| 1613 |
__le32 ReparseTag; |
| 1614 |
__le16 ReparseDataLength; |
| 1615 |
__u16 Reserved; |
| 1616 |
__u8 DataBuffer[]; /* Variable Length */ |
| 1617 |
} __packed; |
| 1618 |
|
| 1619 |
struct reparse_guid_data_buffer { |
| 1620 |
__le32 ReparseTag; |
| 1621 |
__le16 ReparseDataLength; |
| 1622 |
__u16 Reserved; |
| 1623 |
__u8 ReparseGuid[16]; |
| 1624 |
__u8 DataBuffer[]; /* Variable Length */ |
| 1625 |
} __packed; |
| 1626 |
|
| 1627 |
struct reparse_mount_point_data_buffer { |
| 1628 |
__le32 ReparseTag; |
| 1629 |
__le16 ReparseDataLength; |
| 1630 |
__u16 Reserved; |
| 1631 |
__le16 SubstituteNameOffset; |
| 1632 |
__le16 SubstituteNameLength; |
| 1633 |
__le16 PrintNameOffset; |
| 1634 |
__le16 PrintNameLength; |
| 1635 |
__u8 PathBuffer[]; /* Variable Length */ |
| 1636 |
} __packed; |
| 1637 |
|
| 1638 |
#define SYMLINK_FLAG_RELATIVE 0x00000001 |
| 1639 |
|
| 1640 |
struct reparse_symlink_data_buffer { |
| 1641 |
__le32 ReparseTag; |
| 1642 |
__le16 ReparseDataLength; |
| 1643 |
__u16 Reserved; |
| 1644 |
__le16 SubstituteNameOffset; |
| 1645 |
__le16 SubstituteNameLength; |
| 1646 |
__le16 PrintNameOffset; |
| 1647 |
__le16 PrintNameLength; |
| 1648 |
__le32 Flags; |
| 1649 |
__u8 PathBuffer[]; /* Variable Length */ |
| 1650 |
} __packed; |
| 1651 |
|
| 1652 |
/* For IO_REPARSE_TAG_NFS - see MS-FSCC 2.1.2.6 */ |
| 1653 |
#define NFS_SPECFILE_LNK 0x00000000014B4E4C |
| 1654 |
#define NFS_SPECFILE_CHR 0x0000000000524843 |
| 1655 |
#define NFS_SPECFILE_BLK 0x00000000004B4C42 |
| 1656 |
#define NFS_SPECFILE_FIFO 0x000000004F464946 |
| 1657 |
#define NFS_SPECFILE_SOCK 0x000000004B434F53 |
| 1658 |
struct reparse_nfs_data_buffer { |
| 1659 |
__le32 ReparseTag; |
| 1660 |
__le16 ReparseDataLength; |
| 1661 |
__u16 Reserved; |
| 1662 |
__le64 InodeType; /* NFS_SPECFILE_* */ |
| 1663 |
__u8 DataBuffer[]; |
| 1664 |
} __packed; |
| 1665 |
|
| 1666 |
/* For IO_REPARSE_TAG_LX_SYMLINK - see MS-FSCC 2.1.2.7 */ |
| 1667 |
struct reparse_wsl_symlink_data_buffer { |
| 1668 |
__le32 ReparseTag; |
| 1669 |
__le16 ReparseDataLength; |
| 1670 |
__u16 Reserved; |
| 1671 |
__le32 Version; /* Always 2 */ |
| 1672 |
__u8 Target[]; /* Variable Length UTF-8 string without nul-term */ |
| 1673 |
} __packed; |
| 1674 |
|
| 1675 |
struct validate_negotiate_info_req { |
| 1676 |
__le32 Capabilities; |
| 1677 |
__u8 Guid[SMB2_CLIENT_GUID_SIZE]; |
| 1678 |
__le16 SecurityMode; |
| 1679 |
__le16 DialectCount; |
| 1680 |
__le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */ |
| 1681 |
} __packed; |
| 1682 |
|
| 1683 |
struct validate_negotiate_info_rsp { |
| 1684 |
__le32 Capabilities; |
| 1685 |
__u8 Guid[SMB2_CLIENT_GUID_SIZE]; |
| 1686 |
__le16 SecurityMode; |
| 1687 |
__le16 Dialect; /* Dialect in use for the connection */ |
| 1688 |
} __packed; |
| 1689 |
|
| 1690 |
|
| 1691 |
/* Possible InfoType values */ |
| 1692 |
#define SMB2_O_INFO_FILE 0x01 |
| 1693 |
#define SMB2_O_INFO_FILESYSTEM 0x02 |
| 1694 |
#define SMB2_O_INFO_SECURITY 0x03 |
| 1695 |
#define SMB2_O_INFO_QUOTA 0x04 |
| 1696 |
|
| 1697 |
/* SMB2 Query Info see MS-SMB2 (2.2.37) or MS-DTYP */ |
| 1698 |
|
| 1699 |
/* List of QUERY INFO levels (those also valid for QUERY_DIR are noted below */ |
| 1700 |
#define FILE_DIRECTORY_INFORMATION 1 /* also for QUERY_DIR */ |
| 1701 |
#define FILE_FULL_DIRECTORY_INFORMATION 2 /* also for QUERY_DIR */ |
| 1702 |
#define FILE_BOTH_DIRECTORY_INFORMATION 3 /* also for QUERY_DIR */ |
| 1703 |
#define FILE_BASIC_INFORMATION 4 |
| 1704 |
#define FILE_STANDARD_INFORMATION 5 |
| 1705 |
#define FILE_INTERNAL_INFORMATION 6 |
| 1706 |
#define FILE_EA_INFORMATION 7 |
| 1707 |
#define FILE_ACCESS_INFORMATION 8 |
| 1708 |
#define FILE_NAME_INFORMATION 9 |
| 1709 |
#define FILE_RENAME_INFORMATION 10 |
| 1710 |
#define FILE_LINK_INFORMATION 11 |
| 1711 |
#define FILE_NAMES_INFORMATION 12 /* also for QUERY_DIR */ |
| 1712 |
#define FILE_DISPOSITION_INFORMATION 13 |
| 1713 |
#define FILE_POSITION_INFORMATION 14 |
| 1714 |
#define FILE_FULL_EA_INFORMATION 15 |
| 1715 |
#define FILE_MODE_INFORMATION 16 |
| 1716 |
#define FILE_ALIGNMENT_INFORMATION 17 |
| 1717 |
#define FILE_ALL_INFORMATION 18 |
| 1718 |
#define FILE_ALLOCATION_INFORMATION 19 |
| 1719 |
#define FILE_END_OF_FILE_INFORMATION 20 |
| 1720 |
#define FILE_ALTERNATE_NAME_INFORMATION 21 |
| 1721 |
#define FILE_STREAM_INFORMATION 22 |
| 1722 |
#define FILE_PIPE_INFORMATION 23 |
| 1723 |
#define FILE_PIPE_LOCAL_INFORMATION 24 |
| 1724 |
#define FILE_PIPE_REMOTE_INFORMATION 25 |
| 1725 |
#define FILE_MAILSLOT_QUERY_INFORMATION 26 |
| 1726 |
#define FILE_MAILSLOT_SET_INFORMATION 27 |
| 1727 |
#define FILE_COMPRESSION_INFORMATION 28 |
| 1728 |
#define FILE_OBJECT_ID_INFORMATION 29 |
| 1729 |
/* Number 30 not defined in documents */ |
| 1730 |
#define FILE_MOVE_CLUSTER_INFORMATION 31 |
| 1731 |
#define FILE_QUOTA_INFORMATION 32 |
| 1732 |
#define FILE_REPARSE_POINT_INFORMATION 33 |
| 1733 |
#define FILE_NETWORK_OPEN_INFORMATION 34 |
| 1734 |
#define FILE_ATTRIBUTE_TAG_INFORMATION 35 |
| 1735 |
#define FILE_TRACKING_INFORMATION 36 |
| 1736 |
#define FILEID_BOTH_DIRECTORY_INFORMATION 37 /* also for QUERY_DIR */ |
| 1737 |
#define FILEID_FULL_DIRECTORY_INFORMATION 38 /* also for QUERY_DIR */ |
| 1738 |
#define FILE_VALID_DATA_LENGTH_INFORMATION 39 |
| 1739 |
#define FILE_SHORT_NAME_INFORMATION 40 |
| 1740 |
#define FILE_SFIO_RESERVE_INFORMATION 44 |
| 1741 |
#define FILE_SFIO_VOLUME_INFORMATION 45 |
| 1742 |
#define FILE_HARD_LINK_INFORMATION 46 |
| 1743 |
#define FILE_NORMALIZED_NAME_INFORMATION 48 |
| 1744 |
#define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50 |
| 1745 |
#define FILE_STANDARD_LINK_INFORMATION 54 |
| 1746 |
#define FILE_ID_INFORMATION 59 |
| 1747 |
#define FILE_ID_EXTD_DIRECTORY_INFORMATION 60 /* also for QUERY_DIR */ |
| 1748 |
/* Used for Query Info and Find File POSIX Info for SMB3.1.1 and SMB1 */ |
| 1749 |
#define SMB_FIND_FILE_POSIX_INFO 0x064 |
| 1750 |
|
| 1751 |
/* Security info type additionalinfo flags. */ |
| 1752 |
#define OWNER_SECINFO 0x00000001 |
| 1753 |
#define GROUP_SECINFO 0x00000002 |
| 1754 |
#define DACL_SECINFO 0x00000004 |
| 1755 |
#define SACL_SECINFO 0x00000008 |
| 1756 |
#define LABEL_SECINFO 0x00000010 |
| 1757 |
#define ATTRIBUTE_SECINFO 0x00000020 |
| 1758 |
#define SCOPE_SECINFO 0x00000040 |
| 1759 |
#define BACKUP_SECINFO 0x00010000 |
| 1760 |
#define UNPROTECTED_SACL_SECINFO 0x10000000 |
| 1761 |
#define UNPROTECTED_DACL_SECINFO 0x20000000 |
| 1762 |
#define PROTECTED_SACL_SECINFO 0x40000000 |
| 1763 |
#define PROTECTED_DACL_SECINFO 0x80000000 |
| 1764 |
|
| 1765 |
/* Flags used for FileFullEAinfo */ |
| 1766 |
#define SL_RESTART_SCAN 0x00000001 |
| 1767 |
#define SL_RETURN_SINGLE_ENTRY 0x00000002 |
| 1768 |
#define SL_INDEX_SPECIFIED 0x00000004 |
| 1769 |
|
| 1770 |
struct smb2_query_info_req { |
| 1771 |
struct smb2_hdr hdr; |
| 1772 |
__le16 StructureSize; /* Must be 41 */ |
| 1773 |
__u8 InfoType; |
| 1774 |
__u8 FileInfoClass; |
| 1775 |
__le32 OutputBufferLength; |
| 1776 |
__le16 InputBufferOffset; |
| 1777 |
__u16 Reserved; |
| 1778 |
__le32 InputBufferLength; |
| 1779 |
__le32 AdditionalInformation; |
| 1780 |
__le32 Flags; |
| 1781 |
__u64 PersistentFileId; |
| 1782 |
__u64 VolatileFileId; |
| 1783 |
__u8 Buffer[]; |
| 1784 |
} __packed; |
| 1785 |
|
| 1786 |
struct smb2_query_info_rsp { |
| 1787 |
struct smb2_hdr hdr; |
| 1788 |
__le16 StructureSize; /* Must be 9 */ |
| 1789 |
__le16 OutputBufferOffset; |
| 1790 |
__le32 OutputBufferLength; |
| 1791 |
__u8 Buffer[]; |
| 1792 |
} __packed; |
| 1793 |
|
| 1794 |
/* |
| 1795 |
* PDU query infolevel structure definitions |
| 1796 |
*/ |
| 1797 |
|
| 1798 |
/* See MS-FSCC 2.3.52 */ |
| 1799 |
struct file_allocated_range_buffer { |
| 1800 |
__le64 file_offset; |
| 1801 |
__le64 length; |
| 1802 |
} __packed; |
| 1803 |
|
| 1804 |
struct smb2_file_internal_info { |
| 1805 |
__le64 IndexNumber; |
| 1806 |
} __packed; /* level 6 Query */ |
| 1807 |
|
| 1808 |
struct smb2_file_rename_info { /* encoding of request for level 10 */ |
| 1809 |
/* New members MUST be added within the struct_group() macro below. */ |
| 1810 |
__struct_group(smb2_file_rename_info_hdr, __hdr, __packed, |
| 1811 |
__u8 ReplaceIfExists; /* 1 = replace existing target with new */ |
| 1812 |
/* 0 = fail if target already exists */ |
| 1813 |
__u8 Reserved[7]; |
| 1814 |
__u64 RootDirectory; /* MBZ for network operations (why says spec?) */ |
| 1815 |
__le32 FileNameLength; |
| 1816 |
); |
| 1817 |
char FileName[]; /* New name to be assigned */ |
| 1818 |
/* padding - overall struct size must be >= 24 so filename + pad >= 6 */ |
| 1819 |
} __packed; /* level 10 Set */ |
| 1820 |
static_assert(offsetof(struct smb2_file_rename_info, FileName) == sizeof(struct smb2_file_rename_info_hdr), |
| 1821 |
"struct member likely outside of __struct_group()"); |
| 1822 |
|
| 1823 |
struct smb2_file_link_info { /* encoding of request for level 11 */ |
| 1824 |
/* New members MUST be added within the struct_group() macro below. */ |
| 1825 |
__struct_group(smb2_file_link_info_hdr, __hdr, __packed, |
| 1826 |
__u8 ReplaceIfExists; /* 1 = replace existing link with new */ |
| 1827 |
/* 0 = fail if link already exists */ |
| 1828 |
__u8 Reserved[7]; |
| 1829 |
__u64 RootDirectory; /* MBZ for network operations (why says spec?) */ |
| 1830 |
__le32 FileNameLength; |
| 1831 |
); |
| 1832 |
char FileName[]; /* Name to be assigned to new link */ |
| 1833 |
} __packed; /* level 11 Set */ |
| 1834 |
static_assert(offsetof(struct smb2_file_link_info, FileName) == sizeof(struct smb2_file_link_info_hdr), |
| 1835 |
"struct member likely outside of __struct_group()"); |
| 1836 |
|
| 1837 |
/* |
| 1838 |
* This level 18, although with struct with same name is different from cifs |
| 1839 |
* level 0x107. Level 0x107 has an extra u64 between AccessFlags and |
| 1840 |
* CurrentByteOffset. |
| 1841 |
*/ |
| 1842 |
struct smb2_file_all_info { /* data block encoding of response to level 18 */ |
| 1843 |
__le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ |
| 1844 |
__le64 LastAccessTime; |
| 1845 |
__le64 LastWriteTime; |
| 1846 |
__le64 ChangeTime; |
| 1847 |
__le32 Attributes; |
| 1848 |
__u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ |
| 1849 |
__le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ |
| 1850 |
__le64 EndOfFile; /* size ie offset to first free byte in file */ |
| 1851 |
__le32 NumberOfLinks; /* hard links */ |
| 1852 |
__u8 DeletePending; |
| 1853 |
__u8 Directory; |
| 1854 |
__u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */ |
| 1855 |
__le64 IndexNumber; |
| 1856 |
__le32 EASize; |
| 1857 |
__le32 AccessFlags; |
| 1858 |
__le64 CurrentByteOffset; |
| 1859 |
__le32 Mode; |
| 1860 |
__le32 AlignmentRequirement; |
| 1861 |
__le32 FileNameLength; |
| 1862 |
union { |
| 1863 |
char __pad; /* Legacy structure padding */ |
| 1864 |
DECLARE_FLEX_ARRAY(char, FileName); |
| 1865 |
}; |
| 1866 |
} __packed; /* level 18 Query */ |
| 1867 |
|
| 1868 |
struct smb2_file_eof_info { /* encoding of request for level 10 */ |
| 1869 |
__le64 EndOfFile; /* new end of file value */ |
| 1870 |
} __packed; /* level 20 Set */ |
| 1871 |
|
| 1872 |
/* Level 100 query info */ |
| 1873 |
struct smb311_posix_qinfo { |
| 1874 |
__le64 CreationTime; |
| 1875 |
__le64 LastAccessTime; |
| 1876 |
__le64 LastWriteTime; |
| 1877 |
__le64 ChangeTime; |
| 1878 |
__le64 EndOfFile; |
| 1879 |
__le64 AllocationSize; |
| 1880 |
__le32 DosAttributes; |
| 1881 |
__le64 Inode; |
| 1882 |
__le32 DeviceId; |
| 1883 |
__le32 Zero; |
| 1884 |
/* beginning of POSIX Create Context Response */ |
| 1885 |
__le32 HardLinks; |
| 1886 |
__le32 ReparseTag; |
| 1887 |
__le32 Mode; |
| 1888 |
u8 Sids[]; |
| 1889 |
/* |
| 1890 |
* var sized owner SID |
| 1891 |
* var sized group SID |
| 1892 |
* le32 filenamelength |
| 1893 |
* u8 filename[] |
| 1894 |
*/ |
| 1895 |
} __packed; |
| 1896 |
|
| 1897 |
/* File System Information Classes */ |
| 1898 |
#define FS_VOLUME_INFORMATION 1 /* Query */ |
| 1899 |
#define FS_LABEL_INFORMATION 2 /* Set */ |
| 1900 |
#define FS_SIZE_INFORMATION 3 /* Query */ |
| 1901 |
#define FS_DEVICE_INFORMATION 4 /* Query */ |
| 1902 |
#define FS_ATTRIBUTE_INFORMATION 5 /* Query */ |
| 1903 |
#define FS_CONTROL_INFORMATION 6 /* Query, Set */ |
| 1904 |
#define FS_FULL_SIZE_INFORMATION 7 /* Query */ |
| 1905 |
#define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */ |
| 1906 |
#define FS_DRIVER_PATH_INFORMATION 9 /* Query */ |
| 1907 |
#define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */ |
| 1908 |
#define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */ |
| 1909 |
|
| 1910 |
struct smb2_fs_full_size_info { |
| 1911 |
__le64 TotalAllocationUnits; |
| 1912 |
__le64 CallerAvailableAllocationUnits; |
| 1913 |
__le64 ActualAvailableAllocationUnits; |
| 1914 |
__le32 SectorsPerAllocationUnit; |
| 1915 |
__le32 BytesPerSector; |
| 1916 |
} __packed; |
| 1917 |
|
| 1918 |
#define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001 |
| 1919 |
#define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002 |
| 1920 |
#define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004 |
| 1921 |
#define SSINFO_FLAGS_TRIM_ENABLED 0x00000008 |
| 1922 |
|
| 1923 |
/* sector size info struct */ |
| 1924 |
struct smb3_fs_ss_info { |
| 1925 |
__le32 LogicalBytesPerSector; |
| 1926 |
__le32 PhysicalBytesPerSectorForAtomicity; |
| 1927 |
__le32 PhysicalBytesPerSectorForPerf; |
| 1928 |
__le32 FSEffPhysicalBytesPerSectorForAtomicity; |
| 1929 |
__le32 Flags; |
| 1930 |
__le32 ByteOffsetForSectorAlignment; |
| 1931 |
__le32 ByteOffsetForPartitionAlignment; |
| 1932 |
} __packed; |
| 1933 |
|
| 1934 |
/* File System Control Information */ |
| 1935 |
struct smb2_fs_control_info { |
| 1936 |
__le64 FreeSpaceStartFiltering; |
| 1937 |
__le64 FreeSpaceThreshold; |
| 1938 |
__le64 FreeSpaceStopFiltering; |
| 1939 |
__le64 DefaultQuotaThreshold; |
| 1940 |
__le64 DefaultQuotaLimit; |
| 1941 |
__le32 FileSystemControlFlags; |
| 1942 |
__le32 Padding; |
| 1943 |
} __packed; |
| 1944 |
|
| 1945 |
/* volume info struct - see MS-FSCC 2.5.9 */ |
| 1946 |
#define MAX_VOL_LABEL_LEN 32 |
| 1947 |
struct smb3_fs_vol_info { |
| 1948 |
__le64 VolumeCreationTime; |
| 1949 |
__u32 VolumeSerialNumber; |
| 1950 |
__le32 VolumeLabelLength; /* includes trailing null */ |
| 1951 |
__u8 SupportsObjects; /* True if eg like NTFS, supports objects */ |
| 1952 |
__u8 Reserved; |
| 1953 |
__u8 VolumeLabel[]; /* variable len */ |
| 1954 |
} __packed; |
| 1955 |
|
| 1956 |
/* See MS-SMB2 2.2.23 through 2.2.25 */ |
| 1957 |
struct smb2_oplock_break { |
| 1958 |
struct smb2_hdr hdr; |
| 1959 |
__le16 StructureSize; /* Must be 24 */ |
| 1960 |
__u8 OplockLevel; |
| 1961 |
__u8 Reserved; |
| 1962 |
__le32 Reserved2; |
| 1963 |
__u64 PersistentFid; |
| 1964 |
__u64 VolatileFid; |
| 1965 |
} __packed; |
| 1966 |
|
| 1967 |
#define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01) |
| 1968 |
|
| 1969 |
struct smb2_lease_break { |
| 1970 |
struct smb2_hdr hdr; |
| 1971 |
__le16 StructureSize; /* Must be 44 */ |
| 1972 |
__le16 Epoch; |
| 1973 |
__le32 Flags; |
| 1974 |
__u8 LeaseKey[16]; |
| 1975 |
__le32 CurrentLeaseState; |
| 1976 |
__le32 NewLeaseState; |
| 1977 |
__le32 BreakReason; |
| 1978 |
__le32 AccessMaskHint; |
| 1979 |
__le32 ShareMaskHint; |
| 1980 |
} __packed; |
| 1981 |
|
| 1982 |
struct smb2_lease_ack { |
| 1983 |
struct smb2_hdr hdr; |
| 1984 |
__le16 StructureSize; /* Must be 36 */ |
| 1985 |
__le16 Reserved; |
| 1986 |
__le32 Flags; |
| 1987 |
__u8 LeaseKey[16]; |
| 1988 |
__le32 LeaseState; |
| 1989 |
__le64 LeaseDuration; |
| 1990 |
} __packed; |
| 1991 |
|
| 1992 |
#define OP_BREAK_STRUCT_SIZE_20 24 |
| 1993 |
#define OP_BREAK_STRUCT_SIZE_21 36 |
| 1994 |
|
| 1995 |
/* |
| 1996 |
* See MS-SMB2 2.2.13.1.1 |
| 1997 |
* MS-SMB 2.2.1.4.1 |
| 1998 |
* These are the file access permission bits defined in CIFS for the |
| 1999 |
* NTCreateAndX as well as the level 0x107 |
| 2000 |
* TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO |
| 2001 |
* responds with the AccessFlags. |
| 2002 |
* The AccessFlags specifies the access permissions a caller has to the |
| 2003 |
* file and can have any suitable combination of the following values: |
| 2004 |
*/ |
| 2005 |
#define FILE_READ_DATA 0x00000001 /* Data can be read from the file */ |
| 2006 |
/* or directory child entries can */ |
| 2007 |
/* be listed together with the */ |
| 2008 |
/* associated child attributes */ |
| 2009 |
/* (so the FILE_READ_ATTRIBUTES on */ |
| 2010 |
/* the child entry is not needed) */ |
| 2011 |
#define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */ |
| 2012 |
/* or new file can be created in */ |
| 2013 |
/* the directory */ |
| 2014 |
#define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */ |
| 2015 |
/* (for non-local files over SMB it */ |
| 2016 |
/* is same as FILE_WRITE_DATA) */ |
| 2017 |
/* or new subdirectory can be */ |
| 2018 |
/* created in the directory */ |
| 2019 |
#define FILE_READ_EA 0x00000008 /* Extended attributes associated */ |
| 2020 |
/* with the file can be read */ |
| 2021 |
#define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */ |
| 2022 |
/* with the file can be written */ |
| 2023 |
#define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */ |
| 2024 |
/* the file using system paging I/O */ |
| 2025 |
/* for executing the file / script */ |
| 2026 |
/* or right to traverse directory */ |
| 2027 |
/* (but by default all users have */ |
| 2028 |
/* directory bypass traverse */ |
| 2029 |
/* privilege and do not need this */ |
| 2030 |
/* permission on directories at all)*/ |
| 2031 |
#define FILE_DELETE_CHILD 0x00000040 /* Child entry can be deleted from */ |
| 2032 |
/* the directory (so the DELETE on */ |
| 2033 |
/* the child entry is not needed) */ |
| 2034 |
#define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */ |
| 2035 |
/* file or directory can be read */ |
| 2036 |
#define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */ |
| 2037 |
/* file or directory can be written */ |
| 2038 |
#define DELETE 0x00010000 /* The file or dir can be deleted */ |
| 2039 |
#define READ_CONTROL 0x00020000 /* The discretionary access control */ |
| 2040 |
/* list and ownership associated */ |
| 2041 |
/* with the file or dir can be read */ |
| 2042 |
#define WRITE_DAC 0x00040000 /* The discretionary access control */ |
| 2043 |
/* list associated with the file or */ |
| 2044 |
/* directory can be written */ |
| 2045 |
#define WRITE_OWNER 0x00080000 /* Ownership information associated */ |
| 2046 |
/* with the file/dir can be written */ |
| 2047 |
#define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */ |
| 2048 |
/* synchronize with the completion */ |
| 2049 |
/* of an input/output request */ |
| 2050 |
#define SYSTEM_SECURITY 0x01000000 /* The system access control list */ |
| 2051 |
/* associated with the file or */ |
| 2052 |
/* directory can be read or written */ |
| 2053 |
/* (cannot be in DACL, can in SACL) */ |
| 2054 |
#define MAXIMUM_ALLOWED 0x02000000 /* Maximal subset of GENERIC_ALL */ |
| 2055 |
/* permissions which can be granted */ |
| 2056 |
/* (cannot be in DACL nor SACL) */ |
| 2057 |
#define GENERIC_ALL 0x10000000 /* Same as: GENERIC_EXECUTE | */ |
| 2058 |
/* GENERIC_WRITE | */ |
| 2059 |
/* GENERIC_READ | */ |
| 2060 |
/* FILE_DELETE_CHILD | */ |
| 2061 |
/* DELETE | */ |
| 2062 |
/* WRITE_DAC | */ |
| 2063 |
/* WRITE_OWNER */ |
| 2064 |
/* So GENERIC_ALL contains all bits */ |
| 2065 |
/* mentioned above except these two */ |
| 2066 |
/* SYSTEM_SECURITY MAXIMUM_ALLOWED */ |
| 2067 |
#define GENERIC_EXECUTE 0x20000000 /* Same as: FILE_EXECUTE | */ |
| 2068 |
/* FILE_READ_ATTRIBUTES | */ |
| 2069 |
/* READ_CONTROL | */ |
| 2070 |
/* SYNCHRONIZE */ |
| 2071 |
#define GENERIC_WRITE 0x40000000 /* Same as: FILE_WRITE_DATA | */ |
| 2072 |
/* FILE_APPEND_DATA | */ |
| 2073 |
/* FILE_WRITE_EA | */ |
| 2074 |
/* FILE_WRITE_ATTRIBUTES | */ |
| 2075 |
/* READ_CONTROL | */ |
| 2076 |
/* SYNCHRONIZE */ |
| 2077 |
#define GENERIC_READ 0x80000000 /* Same as: FILE_READ_DATA | */ |
| 2078 |
/* FILE_READ_EA | */ |
| 2079 |
/* FILE_READ_ATTRIBUTES | */ |
| 2080 |
/* READ_CONTROL | */ |
| 2081 |
/* SYNCHRONIZE */ |
| 2082 |
|
| 2083 |
/* Combinations of file access permission bits */ |
| 2084 |
#define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES) |
| 2085 |
#define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ |
| 2086 |
| FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES) |
| 2087 |
#define FILE_EXEC_RIGHTS (FILE_EXECUTE) |
| 2088 |
#define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \ |
| 2089 |
| FILE_READ_ATTRIBUTES \ |
| 2090 |
| FILE_WRITE_ATTRIBUTES \ |
| 2091 |
| DELETE | READ_CONTROL | WRITE_DAC \ |
| 2092 |
| WRITE_OWNER | SYNCHRONIZE) |
| 2093 |
#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \ |
| 2094 |
| READ_CONTROL | SYNCHRONIZE) |
| 2095 |
|
| 2096 |
#endif /* _COMMON_SMB2PDU_H */ |