Skip to content

Commit 94d5b8d

Browse files
ZhangGuoDongsmfrench
authored andcommitted
smb: move some SMB1 definitions into common/smb1pdu.h
These definitions are only used by SMB1, so move them into the new common/smb1pdu.h. KSMBD only implements SMB_COM_NEGOTIATE, see MS-SMB2 3.3.5.2. Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 05f5e35 commit 94d5b8d

5 files changed

Lines changed: 58 additions & 43 deletions

File tree

fs/smb/client/cifspdu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <net/sock.h>
1313
#include <linux/unaligned.h>
1414
#include "../common/smbfsctl.h"
15-
#include "../common/smb2pdu.h"
15+
#include "../common/smb1pdu.h"
1616

1717
#define CIFS_PROT 0
1818
#define POSIX_PROT (CIFS_PROT+1)

fs/smb/common/smb1pdu.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* SPDX-License-Identifier: LGPL-2.1 */
2+
/*
3+
*
4+
* Copyright (C) International Business Machines Corp., 2002,2009
5+
* 2018 Samsung Electronics Co., Ltd.
6+
* Author(s): Steve French <sfrench@us.ibm.com>
7+
* Namjae Jeon <linkinjeon@kernel.org>
8+
*
9+
*/
10+
11+
#ifndef _COMMON_SMB1_PDU_H
12+
#define _COMMON_SMB1_PDU_H
13+
14+
#define SMB1_PROTO_NUMBER cpu_to_le32(0x424d53ff)
15+
16+
/*
17+
* See MS-CIFS 2.2.3.1
18+
* MS-SMB 2.2.3.1
19+
*/
20+
struct smb_hdr {
21+
__u8 Protocol[4];
22+
__u8 Command;
23+
union {
24+
struct {
25+
__u8 ErrorClass;
26+
__u8 Reserved;
27+
__le16 Error;
28+
} __packed DosError;
29+
__le32 CifsError;
30+
} __packed Status;
31+
__u8 Flags;
32+
__le16 Flags2; /* note: le */
33+
__le16 PidHigh;
34+
union {
35+
struct {
36+
__le32 SequenceNumber; /* le */
37+
__u32 Reserved; /* zero */
38+
} __packed Sequence;
39+
__u8 SecuritySignature[8]; /* le */
40+
} __packed Signature;
41+
__u8 pad[2];
42+
__u16 Tid;
43+
__le16 Pid;
44+
__u16 Uid;
45+
__le16 Mid;
46+
__u8 WordCount;
47+
} __packed;
48+
49+
/* See MS-CIFS 2.2.4.52.1 */
50+
typedef struct smb_negotiate_req {
51+
struct smb_hdr hdr; /* wct = 0 */
52+
__le16 ByteCount;
53+
unsigned char DialectsArray[];
54+
} __packed SMB_NEGOTIATE_REQ;
55+
56+
#endif /* _COMMON_SMB1_PDU_H */

fs/smb/common/smb2pdu.h

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,39 +1986,6 @@ struct smb2_lease_ack {
19861986
__le64 LeaseDuration;
19871987
} __packed;
19881988

1989-
/*
1990-
* See MS-CIFS 2.2.3.1
1991-
* MS-SMB 2.2.3.1
1992-
*/
1993-
struct smb_hdr {
1994-
__u8 Protocol[4];
1995-
__u8 Command;
1996-
union {
1997-
struct {
1998-
__u8 ErrorClass;
1999-
__u8 Reserved;
2000-
__le16 Error;
2001-
} __packed DosError;
2002-
__le32 CifsError;
2003-
} __packed Status;
2004-
__u8 Flags;
2005-
__le16 Flags2; /* note: le */
2006-
__le16 PidHigh;
2007-
union {
2008-
struct {
2009-
__le32 SequenceNumber; /* le */
2010-
__u32 Reserved; /* zero */
2011-
} __packed Sequence;
2012-
__u8 SecuritySignature[8]; /* le */
2013-
} __packed Signature;
2014-
__u8 pad[2];
2015-
__u16 Tid;
2016-
__le16 Pid;
2017-
__u16 Uid;
2018-
__le16 Mid;
2019-
__u8 WordCount;
2020-
} __packed;
2021-
20221989
#define OP_BREAK_STRUCT_SIZE_20 24
20231990
#define OP_BREAK_STRUCT_SIZE_21 36
20241991

@@ -2123,11 +2090,4 @@ struct smb_hdr {
21232090
#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \
21242091
| READ_CONTROL | SYNCHRONIZE)
21252092

2126-
/* See MS-CIFS 2.2.4.52.1 */
2127-
typedef struct smb_negotiate_req {
2128-
struct smb_hdr hdr; /* wct = 0 */
2129-
__le16 ByteCount;
2130-
unsigned char DialectsArray[];
2131-
} __packed SMB_NEGOTIATE_REQ;
2132-
21332093
#endif /* _COMMON_SMB2PDU_H */

fs/smb/common/smbglob.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#ifndef _COMMON_SMB_GLOB_H
1212
#define _COMMON_SMB_GLOB_H
1313

14-
#define SMB1_PROTO_NUMBER cpu_to_le32(0x424d53ff)
15-
1614
struct smb_version_values {
1715
char *version_string;
1816
__u16 protocol_id;

fs/smb/server/smb_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "glob.h"
1212
#include "../common/smbglob.h"
13+
#include "../common/smb1pdu.h"
1314
#include "../common/smb2pdu.h"
1415
#include "../common/fscc.h"
1516
#include "smb2pdu.h"

0 commit comments

Comments
 (0)