Skip to content

Commit

Permalink
Add defines and structs for smb3.1 dialect
Browse files Browse the repository at this point in the history
Add new structures and defines for SMB3.11 negotiate, session setup and tcon

See MS-SMB2-diff.pdf section 2.2.3 for additional protocol documentation.

Reviewed-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: Steve French <steve.french@primarydata.com>
  • Loading branch information
Steve French committed Jun 28, 2015
1 parent 5f7fbf7 commit eed0e17
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion fs/cifs/smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
return rc;

req->hdr.SessionId = 0; /* First session, not a reauthenticate */
req->VcNumber = 0; /* MBZ */
req->Flags = 0; /* MBZ */
/* to enable echos and oplocks */
req->hdr.CreditRequest = cpu_to_le16(3);

Expand Down
40 changes: 35 additions & 5 deletions fs/cifs/smb2pdu.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ struct smb2_transform_hdr {
__u64 SessionId;
} __packed;

/* Encryption Algorithms */
#define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001)

/*
* SMB2 flag definitions
*/
Expand Down Expand Up @@ -221,6 +218,32 @@ struct smb2_negotiate_req {
#define SMB2_NT_FIND 0x00100000
#define SMB2_LARGE_FILES 0x00200000

#define SMB311_SALT_SIZE 32
/* Hash Algorithm Types */
#define SMB2_PREAUTH_INTEGRITY_SHA512 0x0001

struct smb2_preauth_neg_context {
__le16 ContextType; /* 1 */
__le16 DataLength;
__le32 Reserved;
__le16 HashAlgorithmCount; /* 1 */
__le16 SaltLength;
__le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */
__u8 Salt[SMB311_SALT_SIZE];
} __packed;

/* Encryption Algorithms Ciphers */
#define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001)
#define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002)

struct smb2_encryption_neg_context {
__le16 ContextType; /* 2 */
__le16 DataLength;
__le32 Reserved;
__le16 CipherCount; /* 1 for time being, only AES-128-CCM */
__le16 Ciphers; /* Ciphers[0] since only one used now */
} __packed;

struct smb2_negotiate_rsp {
struct smb2_hdr hdr;
__le16 StructureSize; /* Must be 65 */
Expand All @@ -240,10 +263,14 @@ struct smb2_negotiate_rsp {
__u8 Buffer[1]; /* variable length GSS security buffer */
} __packed;

/* Flags */
#define SMB2_SESSION_REQ_FLAG_BINDING 0x01
#define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04

struct smb2_sess_setup_req {
struct smb2_hdr hdr;
__le16 StructureSize; /* Must be 25 */
__u8 VcNumber;
__u8 Flags;
__u8 SecurityMode;
__le32 Capabilities;
__le32 Channel;
Expand Down Expand Up @@ -278,10 +305,13 @@ struct smb2_logoff_rsp {
__le16 Reserved;
} __packed;

/* Flags/Reserved for SMB3.1.1 */
#define SMB2_SHAREFLAG_CLUSTER_RECONNECT 0x0001

struct smb2_tree_connect_req {
struct smb2_hdr hdr;
__le16 StructureSize; /* Must be 9 */
__le16 Reserved;
__le16 Reserved; /* Flags in SMB3.1.1 */
__le16 PathOffset;
__le16 PathLength;
__u8 Buffer[1]; /* variable length */
Expand Down

0 comments on commit eed0e17

Please sign in to comment.