SMB3: Add defines for new negotiate contexts
authorSteve French <stfrench@microsoft.com>
Thu, 18 Apr 2019 16:03:58 +0000 (11:03 -0500)
committerSteve French <stfrench@microsoft.com>
Wed, 8 May 2019 04:24:55 +0000 (23:24 -0500)
See the latest MS-SMB2 protocol specification updates.
These will be needed for implementing compression support
on the wire for example.

Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/smb2pdu.c
fs/cifs/smb2pdu.h

index 36cc343..a932dcc 100644 (file)
@@ -459,10 +459,7 @@ smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
        return rc;
 }
 
-
-#define SMB2_PREAUTH_INTEGRITY_CAPABILITIES    cpu_to_le16(1)
-#define SMB2_ENCRYPTION_CAPABILITIES           cpu_to_le16(2)
-#define SMB2_POSIX_EXTENSIONS_AVAILABLE                cpu_to_le16(0x100)
+/* For explanation of negotiate contexts see MS-SMB2 section 2.2.3.1 */
 
 static void
 build_preauth_ctxt(struct smb2_preauth_neg_context *pneg_ctxt)
index ee89776..58158e9 100644 (file)
@@ -251,6 +251,14 @@ struct smb2_negotiate_req {
 #define SMB2_NT_FIND                   0x00100000
 #define SMB2_LARGE_FILES               0x00200000
 
+
+/* Negotiate Contexts - ContextTypes. See MS-SMB2 section 2.2.3.1 for details */
+#define SMB2_PREAUTH_INTEGRITY_CAPABILITIES    cpu_to_le16(1)
+#define SMB2_ENCRYPTION_CAPABILITIES           cpu_to_le16(2)
+#define SMB2_COMPRESSION_CAPABILITIES          cpu_to_le16(3)
+#define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID      cpu_to_le16(5)
+#define SMB2_POSIX_EXTENSIONS_AVAILABLE                cpu_to_le16(0x100)
+
 struct smb2_neg_context {
        __le16  ContextType;
        __le16  DataLength;
@@ -288,6 +296,24 @@ struct smb2_encryption_neg_context {
        __le16  Ciphers[1]; /* Ciphers[0] since only one used now */
 } __packed;
 
+/* See MS-SMB2 2.2.3.1.3 */
+#define SMB3_COMPRESS_NONE     0x0000
+#define SMB3_COMPRESS_LZNT1    0x0001
+#define SMB3_COMPRESS_LZ77     0x0002
+#define SMB3_COMPRESS_LZ77_HUFF        0x0003
+
+struct smb2_compression_capabilities_context {
+       __le16  CompressionAlgorithmCount;
+       __u16   Padding;
+       __u32   Reserved;
+       __u16   CompressionAlgorithms[1];
+} __packed;
+
+/*
+ * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4.
+ * Its struct simply contains NetName, an array of Unicode characters
+ */
+
 #define POSIX_CTXT_DATA_LEN    16
 struct smb2_posix_neg_context {
        __le16  ContextType; /* 0x100 */