1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2016 Namjae Jeon <linkinjeon@kernel.org>
4 * Copyright (C) 2018 Samsung Electronics Co., Ltd.
13 /*Create Action Flags*/
14 #define FILE_SUPERSEDED 0x00000000
15 #define FILE_OPENED 0x00000001
16 #define FILE_CREATED 0x00000002
17 #define FILE_OVERWRITTEN 0x00000003
20 * Size of the session key (crypto key encrypted with the password
22 #define SMB2_NTLMV2_SESSKEY_SIZE 16
23 #define SMB2_SIGNATURE_SIZE 16
24 #define SMB2_HMACSHA256_SIZE 32
25 #define SMB2_CMACAES_SIZE 16
26 #define SMB3_GCM128_CRYPTKEY_SIZE 16
27 #define SMB3_GCM256_CRYPTKEY_SIZE 32
30 * Size of the smb3 encryption/decryption keys
32 #define SMB3_ENC_DEC_KEY_SIZE 32
35 * Size of the smb3 signing key
37 #define SMB3_SIGN_KEY_SIZE 16
39 #define CIFS_CLIENT_CHALLENGE_SIZE 8
40 #define SMB_SERVER_CHALLENGE_SIZE 8
42 /* SMB2 Max Credits */
43 #define SMB2_MAX_CREDITS 8192
45 /* Maximum buffer size value we can send with 1 credit */
46 #define SMB2_MAX_BUFFER_SIZE 65536
48 #define NUMBER_OF_SMB2_COMMANDS 0x0013
50 /* BB FIXME - analyze following length BB */
51 #define MAX_SMB2_HDR_SIZE 0x78 /* 4 len + 64 hdr + (2*24 wct) + 2 bct + 2 pad */
53 #define SMB21_DEFAULT_IOSIZE (1024 * 1024)
54 #define SMB3_DEFAULT_IOSIZE (4 * 1024 * 1024)
55 #define SMB3_DEFAULT_TRANS_SIZE (1024 * 1024)
56 #define SMB3_MIN_IOSIZE (64 * 1024)
57 #define SMB3_MAX_IOSIZE (8 * 1024 * 1024)
60 * Definitions for SMB2 Protocol Data Units (network frames)
62 * See MS-SMB2.PDF specification for protocol details.
63 * The Naming convention is the lower case version of the SMB2
64 * command code name for the struct. Note that structures must be packed.
68 #define SMB2_ERROR_STRUCTURE_SIZE2 9
69 #define SMB2_ERROR_STRUCTURE_SIZE2_LE cpu_to_le16(SMB2_ERROR_STRUCTURE_SIZE2)
74 __u8 ErrorContextCount;
76 __le32 ByteCount; /* even if zero, at least one byte follows */
77 __u8 ErrorData[1]; /* variable length */
80 struct preauth_integrity_info {
81 /* PreAuth integrity Hash ID */
82 __le16 Preauth_HashId;
83 /* PreAuth integrity Hash Value */
84 __u8 Preauth_HashValue[SMB2_PREAUTH_HASH_SIZE];
87 /* offset is sizeof smb2_negotiate_rsp but rounded up to 8 bytes. */
88 #ifdef CONFIG_SMB_SERVER_KERBEROS5
89 /* sizeof(struct smb2_negotiate_rsp) =
90 * header(64) + response(64) + GSS_LENGTH(96) + GSS_PADDING(0)
92 #define OFFSET_OF_NEG_CONTEXT 0xe0
94 /* sizeof(struct smb2_negotiate_rsp) =
95 * header(64) + response(64) + GSS_LENGTH(74) + GSS_PADDING(6)
97 #define OFFSET_OF_NEG_CONTEXT 0xd0
100 #define SMB2_SESSION_EXPIRED (0)
101 #define SMB2_SESSION_IN_PROGRESS BIT(0)
102 #define SMB2_SESSION_VALID BIT(1)
104 struct create_durable_req_v2 {
105 struct create_context ccontext;
113 struct create_durable_reconn_req {
114 struct create_context ccontext;
119 __le64 PersistentFileId;
120 __le64 VolatileFileId;
125 struct create_durable_reconn_v2_req {
126 struct create_context ccontext;
129 __le64 PersistentFileId;
130 __le64 VolatileFileId;
136 struct create_app_inst_id {
137 struct create_context ccontext;
140 __u8 AppInstanceId[16];
143 struct create_app_inst_id_vers {
144 struct create_context ccontext;
148 __le64 AppInstanceVersionHigh;
149 __le64 AppInstanceVersionLow;
152 struct create_mxac_req {
153 struct create_context ccontext;
158 struct create_alloc_size_req {
159 struct create_context ccontext;
161 __le64 AllocationSize;
164 struct create_posix {
165 struct create_context ccontext;
171 struct create_durable_rsp {
172 struct create_context ccontext;
180 struct create_durable_v2_rsp {
181 struct create_context ccontext;
187 struct create_mxac_rsp {
188 struct create_context ccontext;
191 __le32 MaximalAccess;
194 struct create_disk_id_rsp {
195 struct create_context ccontext;
202 /* equivalent of the contents of SMB3.1.1 POSIX open context response */
203 struct create_posix_rsp {
204 struct create_context ccontext;
212 #define SMB2_LEASE_NONE_LE cpu_to_le32(0x00)
213 #define SMB2_LEASE_READ_CACHING_LE cpu_to_le32(0x01)
214 #define SMB2_LEASE_HANDLE_CACHING_LE cpu_to_le32(0x02)
215 #define SMB2_LEASE_WRITE_CACHING_LE cpu_to_le32(0x04)
217 #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS_LE cpu_to_le32(0x02)
219 #define SMB2_LEASE_KEY_SIZE 16
221 struct lease_context {
222 __u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
225 __le64 LeaseDuration;
228 struct lease_context_v2 {
229 __u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
232 __le64 LeaseDuration;
233 __u8 ParentLeaseKey[SMB2_LEASE_KEY_SIZE];
238 struct create_lease {
239 struct create_context ccontext;
241 struct lease_context lcontext;
244 struct create_lease_v2 {
245 struct create_context ccontext;
247 struct lease_context_v2 lcontext;
251 struct smb2_buffer_desc_v1 {
257 #define SMB2_0_IOCTL_IS_FSCTL 0x00000001
259 struct duplicate_extents_to_file {
260 __u64 PersistentFileHandle; /* source file handle, opaque endianness */
261 __u64 VolatileFileHandle;
262 __le64 SourceFileOffset;
263 __le64 TargetFileOffset;
264 __le64 ByteCount; /* Bytes to be copied */
267 struct smb2_ioctl_req {
269 __le16 StructureSize; /* Must be 57 */
270 __le16 Reserved; /* offset from start of SMB2 header to write data */
272 __le64 PersistentFileId;
273 __le64 VolatileFileId;
274 __le32 InputOffset; /* Reserved MBZ */
276 __le32 MaxInputResponse;
279 __le32 MaxOutputResponse;
285 struct smb2_ioctl_rsp {
287 __le16 StructureSize; /* Must be 49 */
288 __le16 Reserved; /* offset from start of SMB2 header to write data */
290 __le64 PersistentFileId;
291 __le64 VolatileFileId;
292 __le32 InputOffset; /* Reserved MBZ */
301 struct validate_negotiate_info_req {
303 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
306 __le16 Dialects[1]; /* dialect (someday maybe list) client asked for */
309 struct validate_negotiate_info_rsp {
311 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
313 __le16 Dialect; /* Dialect in use for the connection */
316 struct smb_sockaddr_in {
322 struct smb_sockaddr_in6 {
325 __u8 IPv6address[16];
329 #define INTERNETWORK 0x0002
330 #define INTERNETWORKV6 0x0017
332 struct sockaddr_storage_rsp {
335 struct smb_sockaddr_in addr4;
336 struct smb_sockaddr_in6 addr6;
340 #define RSS_CAPABLE 0x00000001
341 #define RDMA_CAPABLE 0x00000002
343 struct network_interface_info_ioctl_rsp {
344 __le32 Next; /* next interface. zero if this is last one */
346 __le32 Capability; /* RSS or RDMA Capable */
349 char SockAddr_Storage[128];
352 struct file_object_buf_type1_ioctl_rsp {
354 __u8 BirthVolumeId[16];
355 __u8 BirthObjectId[16];
359 struct resume_key_ioctl_rsp {
361 __le32 ContextLength;
362 __u8 Context[4]; /* ignored, Windows sets to 4 bytes of zero */
365 struct copychunk_ioctl_req {
369 __u8 Chunks[1]; /* array of srv_copychunk */
372 struct srv_copychunk {
379 struct copychunk_ioctl_rsp {
380 __le32 ChunksWritten;
381 __le32 ChunkBytesWritten;
382 __le32 TotalBytesWritten;
389 struct file_zero_data_information {
391 __le64 BeyondFinalZero;
394 struct file_allocated_range_buffer {
399 struct reparse_data_buffer {
401 __le16 ReparseDataLength;
403 __u8 DataBuffer[]; /* Variable Length */
406 /* SMB2 Notify Action Flags */
407 #define FILE_ACTION_ADDED 0x00000001
408 #define FILE_ACTION_REMOVED 0x00000002
409 #define FILE_ACTION_MODIFIED 0x00000003
410 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
411 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
412 #define FILE_ACTION_ADDED_STREAM 0x00000006
413 #define FILE_ACTION_REMOVED_STREAM 0x00000007
414 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
415 #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009
417 #define SMB2_LOCKFLAG_SHARED 0x0001
418 #define SMB2_LOCKFLAG_EXCLUSIVE 0x0002
419 #define SMB2_LOCKFLAG_UNLOCK 0x0004
420 #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
421 #define SMB2_LOCKFLAG_MASK 0x0007
423 struct smb2_lock_element {
430 struct smb2_lock_req {
432 __le16 StructureSize; /* Must be 48 */
435 __le64 PersistentFileId;
436 __le64 VolatileFileId;
437 /* Followed by at least one */
438 struct smb2_lock_element locks[1];
441 struct smb2_lock_rsp {
443 __le16 StructureSize; /* Must be 4 */
447 struct smb2_echo_req {
449 __le16 StructureSize; /* Must be 4 */
453 struct smb2_echo_rsp {
455 __le16 StructureSize; /* Must be 4 */
459 /* search (query_directory) Flags field */
460 #define SMB2_RESTART_SCANS 0x01
461 #define SMB2_RETURN_SINGLE_ENTRY 0x02
462 #define SMB2_INDEX_SPECIFIED 0x04
463 #define SMB2_REOPEN 0x10
465 struct smb2_query_directory_req {
467 __le16 StructureSize; /* Must be 33 */
468 __u8 FileInformationClass;
471 __le64 PersistentFileId;
472 __le64 VolatileFileId;
473 __le16 FileNameOffset;
474 __le16 FileNameLength;
475 __le32 OutputBufferLength;
479 struct smb2_query_directory_rsp {
481 __le16 StructureSize; /* Must be 9 */
482 __le16 OutputBufferOffset;
483 __le32 OutputBufferLength;
487 /* Possible InfoType values */
488 #define SMB2_O_INFO_FILE 0x01
489 #define SMB2_O_INFO_FILESYSTEM 0x02
490 #define SMB2_O_INFO_SECURITY 0x03
491 #define SMB2_O_INFO_QUOTA 0x04
493 /* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */
494 #define OWNER_SECINFO 0x00000001
495 #define GROUP_SECINFO 0x00000002
496 #define DACL_SECINFO 0x00000004
497 #define SACL_SECINFO 0x00000008
498 #define LABEL_SECINFO 0x00000010
499 #define ATTRIBUTE_SECINFO 0x00000020
500 #define SCOPE_SECINFO 0x00000040
501 #define BACKUP_SECINFO 0x00010000
502 #define UNPROTECTED_SACL_SECINFO 0x10000000
503 #define UNPROTECTED_DACL_SECINFO 0x20000000
504 #define PROTECTED_SACL_SECINFO 0x40000000
505 #define PROTECTED_DACL_SECINFO 0x80000000
507 struct smb2_query_info_req {
509 __le16 StructureSize; /* Must be 41 */
512 __le32 OutputBufferLength;
513 __le16 InputBufferOffset;
515 __le32 InputBufferLength;
516 __le32 AdditionalInformation;
518 __le64 PersistentFileId;
519 __le64 VolatileFileId;
523 struct smb2_query_info_rsp {
525 __le16 StructureSize; /* Must be 9 */
526 __le16 OutputBufferOffset;
527 __le32 OutputBufferLength;
531 struct smb2_set_info_req {
533 __le16 StructureSize; /* Must be 33 */
539 __le32 AdditionalInformation;
540 __le64 PersistentFileId;
541 __le64 VolatileFileId;
545 struct smb2_set_info_rsp {
547 __le16 StructureSize; /* Must be 2 */
550 /* FILE Info response size */
551 #define FILE_DIRECTORY_INFORMATION_SIZE 1
552 #define FILE_FULL_DIRECTORY_INFORMATION_SIZE 2
553 #define FILE_BOTH_DIRECTORY_INFORMATION_SIZE 3
554 #define FILE_BASIC_INFORMATION_SIZE 40
555 #define FILE_STANDARD_INFORMATION_SIZE 24
556 #define FILE_INTERNAL_INFORMATION_SIZE 8
557 #define FILE_EA_INFORMATION_SIZE 4
558 #define FILE_ACCESS_INFORMATION_SIZE 4
559 #define FILE_NAME_INFORMATION_SIZE 9
560 #define FILE_RENAME_INFORMATION_SIZE 10
561 #define FILE_LINK_INFORMATION_SIZE 11
562 #define FILE_NAMES_INFORMATION_SIZE 12
563 #define FILE_DISPOSITION_INFORMATION_SIZE 13
564 #define FILE_POSITION_INFORMATION_SIZE 14
565 #define FILE_FULL_EA_INFORMATION_SIZE 15
566 #define FILE_MODE_INFORMATION_SIZE 4
567 #define FILE_ALIGNMENT_INFORMATION_SIZE 4
568 #define FILE_ALL_INFORMATION_SIZE 104
569 #define FILE_ALLOCATION_INFORMATION_SIZE 19
570 #define FILE_END_OF_FILE_INFORMATION_SIZE 20
571 #define FILE_ALTERNATE_NAME_INFORMATION_SIZE 8
572 #define FILE_STREAM_INFORMATION_SIZE 32
573 #define FILE_PIPE_INFORMATION_SIZE 23
574 #define FILE_PIPE_LOCAL_INFORMATION_SIZE 24
575 #define FILE_PIPE_REMOTE_INFORMATION_SIZE 25
576 #define FILE_MAILSLOT_QUERY_INFORMATION_SIZE 26
577 #define FILE_MAILSLOT_SET_INFORMATION_SIZE 27
578 #define FILE_COMPRESSION_INFORMATION_SIZE 16
579 #define FILE_OBJECT_ID_INFORMATION_SIZE 29
580 /* Number 30 not defined in documents */
581 #define FILE_MOVE_CLUSTER_INFORMATION_SIZE 31
582 #define FILE_QUOTA_INFORMATION_SIZE 32
583 #define FILE_REPARSE_POINT_INFORMATION_SIZE 33
584 #define FILE_NETWORK_OPEN_INFORMATION_SIZE 56
585 #define FILE_ATTRIBUTE_TAG_INFORMATION_SIZE 8
587 /* FS Info response size */
588 #define FS_DEVICE_INFORMATION_SIZE 8
589 #define FS_ATTRIBUTE_INFORMATION_SIZE 16
590 #define FS_VOLUME_INFORMATION_SIZE 24
591 #define FS_SIZE_INFORMATION_SIZE 24
592 #define FS_FULL_SIZE_INFORMATION_SIZE 32
593 #define FS_SECTOR_SIZE_INFORMATION_SIZE 28
594 #define FS_OBJECT_ID_INFORMATION_SIZE 64
595 #define FS_CONTROL_INFORMATION_SIZE 48
596 #define FS_POSIX_INFORMATION_SIZE 56
598 /* FS_ATTRIBUTE_File_System_Name */
599 #define FS_TYPE_SUPPORT_SIZE 44
600 struct fs_type_info {
605 struct smb2_oplock_break {
607 __le16 StructureSize; /* Must be 24 */
611 __le64 PersistentFid;
615 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
617 struct smb2_lease_break {
619 __le16 StructureSize; /* Must be 44 */
623 __le32 CurrentLeaseState;
624 __le32 NewLeaseState;
626 __le32 AccessMaskHint;
627 __le32 ShareMaskHint;
630 struct smb2_lease_ack {
632 __le16 StructureSize; /* Must be 36 */
637 __le64 LeaseDuration;
641 * PDU infolevel structure definitions
642 * BB consider moving to a different header
645 /* File System Information Classes */
646 #define FS_VOLUME_INFORMATION 1 /* Query */
647 #define FS_LABEL_INFORMATION 2 /* Set */
648 #define FS_SIZE_INFORMATION 3 /* Query */
649 #define FS_DEVICE_INFORMATION 4 /* Query */
650 #define FS_ATTRIBUTE_INFORMATION 5 /* Query */
651 #define FS_CONTROL_INFORMATION 6 /* Query, Set */
652 #define FS_FULL_SIZE_INFORMATION 7 /* Query */
653 #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
654 #define FS_DRIVER_PATH_INFORMATION 9 /* Query */
655 #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
656 #define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */
658 struct smb2_fs_full_size_info {
659 __le64 TotalAllocationUnits;
660 __le64 CallerAvailableAllocationUnits;
661 __le64 ActualAvailableAllocationUnits;
662 __le32 SectorsPerAllocationUnit;
663 __le32 BytesPerSector;
666 #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
667 #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
668 #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
669 #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
671 /* sector size info struct */
672 struct smb3_fs_ss_info {
673 __le32 LogicalBytesPerSector;
674 __le32 PhysicalBytesPerSectorForAtomicity;
675 __le32 PhysicalBytesPerSectorForPerf;
676 __le32 FSEffPhysicalBytesPerSectorForAtomicity;
678 __le32 ByteOffsetForSectorAlignment;
679 __le32 ByteOffsetForPartitionAlignment;
682 /* File System Control Information */
683 struct smb2_fs_control_info {
684 __le64 FreeSpaceStartFiltering;
685 __le64 FreeSpaceThreshold;
686 __le64 FreeSpaceStopFiltering;
687 __le64 DefaultQuotaThreshold;
688 __le64 DefaultQuotaLimit;
689 __le32 FileSystemControlFlags;
693 /* partial list of QUERY INFO levels */
694 #define FILE_DIRECTORY_INFORMATION 1
695 #define FILE_FULL_DIRECTORY_INFORMATION 2
696 #define FILE_BOTH_DIRECTORY_INFORMATION 3
697 #define FILE_BASIC_INFORMATION 4
698 #define FILE_STANDARD_INFORMATION 5
699 #define FILE_INTERNAL_INFORMATION 6
700 #define FILE_EA_INFORMATION 7
701 #define FILE_ACCESS_INFORMATION 8
702 #define FILE_NAME_INFORMATION 9
703 #define FILE_RENAME_INFORMATION 10
704 #define FILE_LINK_INFORMATION 11
705 #define FILE_NAMES_INFORMATION 12
706 #define FILE_DISPOSITION_INFORMATION 13
707 #define FILE_POSITION_INFORMATION 14
708 #define FILE_FULL_EA_INFORMATION 15
709 #define FILE_MODE_INFORMATION 16
710 #define FILE_ALIGNMENT_INFORMATION 17
711 #define FILE_ALL_INFORMATION 18
712 #define FILE_ALLOCATION_INFORMATION 19
713 #define FILE_END_OF_FILE_INFORMATION 20
714 #define FILE_ALTERNATE_NAME_INFORMATION 21
715 #define FILE_STREAM_INFORMATION 22
716 #define FILE_PIPE_INFORMATION 23
717 #define FILE_PIPE_LOCAL_INFORMATION 24
718 #define FILE_PIPE_REMOTE_INFORMATION 25
719 #define FILE_MAILSLOT_QUERY_INFORMATION 26
720 #define FILE_MAILSLOT_SET_INFORMATION 27
721 #define FILE_COMPRESSION_INFORMATION 28
722 #define FILE_OBJECT_ID_INFORMATION 29
723 /* Number 30 not defined in documents */
724 #define FILE_MOVE_CLUSTER_INFORMATION 31
725 #define FILE_QUOTA_INFORMATION 32
726 #define FILE_REPARSE_POINT_INFORMATION 33
727 #define FILE_NETWORK_OPEN_INFORMATION 34
728 #define FILE_ATTRIBUTE_TAG_INFORMATION 35
729 #define FILE_TRACKING_INFORMATION 36
730 #define FILEID_BOTH_DIRECTORY_INFORMATION 37
731 #define FILEID_FULL_DIRECTORY_INFORMATION 38
732 #define FILE_VALID_DATA_LENGTH_INFORMATION 39
733 #define FILE_SHORT_NAME_INFORMATION 40
734 #define FILE_SFIO_RESERVE_INFORMATION 44
735 #define FILE_SFIO_VOLUME_INFORMATION 45
736 #define FILE_HARD_LINK_INFORMATION 46
737 #define FILE_NORMALIZED_NAME_INFORMATION 48
738 #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
739 #define FILE_STANDARD_LINK_INFORMATION 54
741 #define OP_BREAK_STRUCT_SIZE_20 24
742 #define OP_BREAK_STRUCT_SIZE_21 36
744 struct smb2_file_access_info {
748 struct smb2_file_alignment_info {
749 __le32 AlignmentRequirement;
752 struct smb2_file_internal_info {
754 } __packed; /* level 6 Query */
756 struct smb2_file_rename_info { /* encoding of request for level 10 */
757 __u8 ReplaceIfExists; /* 1 = replace existing target with new */
758 /* 0 = fail if target already exists */
760 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
761 __le32 FileNameLength;
762 char FileName[0]; /* New name to be assigned */
763 } __packed; /* level 10 Set */
765 struct smb2_file_link_info { /* encoding of request for level 11 */
766 __u8 ReplaceIfExists; /* 1 = replace existing link with new */
767 /* 0 = fail if link already exists */
769 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
770 __le32 FileNameLength;
771 char FileName[0]; /* Name to be assigned to new link */
772 } __packed; /* level 11 Set */
775 * This level 18, although with struct with same name is different from cifs
776 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
779 struct smb2_file_all_info { /* data block encoding of response to level 18 */
780 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
781 __le64 LastAccessTime;
782 __le64 LastWriteTime;
785 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
786 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
787 __le64 EndOfFile; /* size ie offset to first free byte in file */
788 __le32 NumberOfLinks; /* hard links */
791 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
795 __le64 CurrentByteOffset;
797 __le32 AlignmentRequirement;
798 __le32 FileNameLength;
800 } __packed; /* level 18 Query */
802 struct smb2_file_basic_info { /* data block encoding of response to level 18 */
803 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
804 __le64 LastAccessTime;
805 __le64 LastWriteTime;
808 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
811 struct smb2_file_alt_name_info {
812 __le32 FileNameLength;
816 struct smb2_file_stream_info {
817 __le32 NextEntryOffset;
818 __le32 StreamNameLength;
820 __le64 StreamAllocationSize;
824 struct smb2_file_eof_info { /* encoding of request for level 10 */
825 __le64 EndOfFile; /* new end of file value */
826 } __packed; /* level 20 Set */
828 struct smb2_file_ntwrk_info {
830 __le64 LastAccessTime;
831 __le64 LastWriteTime;
833 __le64 AllocationSize;
839 struct smb2_file_standard_info {
840 __le64 AllocationSize;
842 __le32 NumberOfLinks; /* hard links */
846 } __packed; /* level 18 Query */
848 struct smb2_file_ea_info {
852 struct smb2_file_alloc_info {
853 __le64 AllocationSize;
856 struct smb2_file_disposition_info {
860 struct smb2_file_pos_info {
861 __le64 CurrentByteOffset;
864 #define FILE_MODE_INFO_MASK cpu_to_le32(0x0000100e)
866 struct smb2_file_mode_info {
870 #define COMPRESSION_FORMAT_NONE 0x0000
871 #define COMPRESSION_FORMAT_LZNT1 0x0002
873 struct smb2_file_comp_info {
874 __le64 CompressedFileSize;
875 __le16 CompressionFormat;
876 __u8 CompressionUnitShift;
882 struct smb2_file_attr_tag_info {
883 __le32 FileAttributes;
887 #define SL_RESTART_SCAN 0x00000001
888 #define SL_RETURN_SINGLE_ENTRY 0x00000002
889 #define SL_INDEX_SPECIFIED 0x00000004
891 struct smb2_ea_info_req {
892 __le32 NextEntryOffset;
895 } __packed; /* level 15 Query */
897 struct smb2_ea_info {
898 __le32 NextEntryOffset;
901 __le16 EaValueLength;
903 /* optionally followed by value */
904 } __packed; /* level 15 Query */
906 struct create_ea_buf_req {
907 struct create_context ccontext;
909 struct smb2_ea_info ea;
912 struct create_sd_buf_req {
913 struct create_context ccontext;
915 struct smb_ntsd ntsd;
918 /* Find File infolevels */
919 #define SMB_FIND_FILE_POSIX_INFO 0x064
921 /* Level 100 query info */
922 struct smb311_posix_qinfo {
924 __le64 LastAccessTime;
925 __le64 LastWriteTime;
928 __le64 AllocationSize;
929 __le32 DosAttributes;
933 /* beginning of POSIX Create Context Response */
939 * var sized owner SID
940 * var sized group SID
941 * le32 filenamelength
946 struct smb2_posix_info {
947 __le32 NextEntryOffset;
950 __le64 LastAccessTime;
951 __le64 LastWriteTime;
954 __le64 AllocationSize;
955 __le32 DosAttributes;
959 /* beginning of POSIX Create Context Response */
967 * var sized owner SID
968 * var sized group SID
969 * le32 filenamelength
975 void init_smb2_1_server(struct ksmbd_conn *conn);
976 void init_smb3_0_server(struct ksmbd_conn *conn);
977 void init_smb3_02_server(struct ksmbd_conn *conn);
978 int init_smb3_11_server(struct ksmbd_conn *conn);
980 void init_smb2_max_read_size(unsigned int sz);
981 void init_smb2_max_write_size(unsigned int sz);
982 void init_smb2_max_trans_size(unsigned int sz);
984 bool is_smb2_neg_cmd(struct ksmbd_work *work);
985 bool is_smb2_rsp(struct ksmbd_work *work);
987 u16 get_smb2_cmd_val(struct ksmbd_work *work);
988 void set_smb2_rsp_status(struct ksmbd_work *work, __le32 err);
989 int init_smb2_rsp_hdr(struct ksmbd_work *work);
990 int smb2_allocate_rsp_buf(struct ksmbd_work *work);
991 bool is_chained_smb2_message(struct ksmbd_work *work);
992 int init_smb2_neg_rsp(struct ksmbd_work *work);
993 void smb2_set_err_rsp(struct ksmbd_work *work);
994 int smb2_check_user_session(struct ksmbd_work *work);
995 int smb2_get_ksmbd_tcon(struct ksmbd_work *work);
996 bool smb2_is_sign_req(struct ksmbd_work *work, unsigned int command);
997 int smb2_check_sign_req(struct ksmbd_work *work);
998 void smb2_set_sign_rsp(struct ksmbd_work *work);
999 int smb3_check_sign_req(struct ksmbd_work *work);
1000 void smb3_set_sign_rsp(struct ksmbd_work *work);
1001 int find_matching_smb2_dialect(int start_index, __le16 *cli_dialects,
1002 __le16 dialects_count);
1003 struct file_lock *smb_flock_init(struct file *f);
1004 int setup_async_work(struct ksmbd_work *work, void (*fn)(void **),
1006 void smb2_send_interim_resp(struct ksmbd_work *work, __le32 status);
1007 struct channel *lookup_chann_list(struct ksmbd_session *sess,
1008 struct ksmbd_conn *conn);
1009 void smb3_preauth_hash_rsp(struct ksmbd_work *work);
1010 bool smb3_is_transform_hdr(void *buf);
1011 int smb3_decrypt_req(struct ksmbd_work *work);
1012 int smb3_encrypt_resp(struct ksmbd_work *work);
1013 bool smb3_11_final_sess_setup_resp(struct ksmbd_work *work);
1014 int smb2_set_rsp_credits(struct ksmbd_work *work);
1016 /* smb2 misc functions */
1017 int ksmbd_smb2_check_message(struct ksmbd_work *work);
1019 /* smb2 command handlers */
1020 int smb2_handle_negotiate(struct ksmbd_work *work);
1021 int smb2_negotiate_request(struct ksmbd_work *work);
1022 int smb2_sess_setup(struct ksmbd_work *work);
1023 int smb2_tree_connect(struct ksmbd_work *work);
1024 int smb2_tree_disconnect(struct ksmbd_work *work);
1025 int smb2_session_logoff(struct ksmbd_work *work);
1026 int smb2_open(struct ksmbd_work *work);
1027 int smb2_query_info(struct ksmbd_work *work);
1028 int smb2_query_dir(struct ksmbd_work *work);
1029 int smb2_close(struct ksmbd_work *work);
1030 int smb2_echo(struct ksmbd_work *work);
1031 int smb2_set_info(struct ksmbd_work *work);
1032 int smb2_read(struct ksmbd_work *work);
1033 int smb2_write(struct ksmbd_work *work);
1034 int smb2_flush(struct ksmbd_work *work);
1035 int smb2_cancel(struct ksmbd_work *work);
1036 int smb2_lock(struct ksmbd_work *work);
1037 int smb2_ioctl(struct ksmbd_work *work);
1038 int smb2_oplock_break(struct ksmbd_work *work);
1039 int smb2_notify(struct ksmbd_work *ksmbd_work);
1042 * Get the body of the smb2 message excluding the 4 byte rfc1002 headers
1043 * from request/response buffer.
1045 static inline void *smb2_get_msg(void *buf)
1050 #endif /* _SMB2PDU_H */