Skip to main content

smb_server_proto_smb1/
consts.rs

1//! SMB1 command opcodes ([MS-CIFS] §2.2.2, extended by [MS-SMB] §2.2.4).
2
3/// SMB_COM_CREATE_DIRECTORY.
4pub const COM_CREATE_DIRECTORY: u8 = 0x00;
5/// SMB_COM_DELETE_DIRECTORY.
6pub const COM_DELETE_DIRECTORY: u8 = 0x01;
7/// SMB_COM_CLOSE.
8pub const COM_CLOSE: u8 = 0x04;
9/// SMB_COM_FLUSH.
10pub const COM_FLUSH: u8 = 0x05;
11/// SMB_COM_DELETE.
12pub const COM_DELETE: u8 = 0x06;
13/// SMB_COM_RENAME.
14pub const COM_RENAME: u8 = 0x07;
15/// SMB_COM_QUERY_INFORMATION.
16pub const COM_QUERY_INFORMATION: u8 = 0x08;
17/// SMB_COM_SET_INFORMATION.
18pub const COM_SET_INFORMATION: u8 = 0x09;
19/// SMB_COM_CHECK_DIRECTORY.
20pub const COM_CHECK_DIRECTORY: u8 = 0x10;
21/// SMB_COM_PROCESS_EXIT.
22pub const COM_PROCESS_EXIT: u8 = 0x11;
23/// SMB_COM_SEEK.
24pub const COM_SEEK: u8 = 0x12;
25/// SMB_COM_LOCK_BYTE_RANGE.
26pub const COM_LOCK_BYTE_RANGE: u8 = 0x0C;
27/// SMB_COM_UNLOCK_BYTE_RANGE.
28pub const COM_UNLOCK_BYTE_RANGE: u8 = 0x0D;
29/// SMB_COM_LOCKING_ANDX (byte-range locks).
30pub const COM_LOCKING_ANDX: u8 = 0x24;
31/// SMB_COM_ECHO.
32pub const COM_ECHO: u8 = 0x26;
33/// SMB_COM_NT_CANCEL.
34pub const COM_NT_CANCEL: u8 = 0xA4;
35/// SMB_COM_NT_RENAME.
36pub const COM_NT_RENAME: u8 = 0xA5;
37/// SMB_COM_READ_ANDX.
38pub const COM_READ_ANDX: u8 = 0x2E;
39/// SMB_COM_WRITE_ANDX.
40pub const COM_WRITE_ANDX: u8 = 0x2F;
41/// SMB_COM_TRANSACTION2.
42pub const COM_TRANSACTION2: u8 = 0x32;
43/// SMB_COM_TREE_DISCONNECT.
44pub const COM_TREE_DISCONNECT: u8 = 0x71;
45/// SMB_COM_NEGOTIATE ([MS-SMB] §2.2.4.5).
46pub const COM_NEGOTIATE: u8 = 0x72;
47/// SMB_COM_SESSION_SETUP_ANDX ([MS-SMB] §2.2.4.6).
48pub const COM_SESSION_SETUP_ANDX: u8 = 0x73;
49/// SMB_COM_LOGOFF_ANDX.
50pub const COM_LOGOFF_ANDX: u8 = 0x74;
51/// SMB_COM_TREE_CONNECT_ANDX ([MS-SMB] §2.2.4.7).
52pub const COM_TREE_CONNECT_ANDX: u8 = 0x75;
53/// SMB_COM_QUERY_INFORMATION_DISK.
54pub const COM_QUERY_INFORMATION_DISK: u8 = 0x80;
55/// SMB_COM_NT_CREATE_ANDX ([MS-SMB] §2.2.4.9).
56pub const COM_NT_CREATE_ANDX: u8 = 0xA2;
57
58/// AndX terminator: no successor command follows.
59pub const ANDX_NONE: u8 = 0xFF;
60
61/// A parameter "word" is two bytes ([MS-CIFS] §2.2.3.1).
62pub const WORD_LEN: usize = 2;
63/// The ByteCount field preceding the data section is two bytes.
64pub const BYTE_COUNT_LEN: usize = 2;
65/// SMB_STRING/data-buffer format byte that prefixes a variable data block
66/// ([MS-CIFS] §2.2.3.3).
67pub const BUFFER_FORMAT_DATA: u8 = 0x04;
68
69/// CreateOptions bit flags ([MS-SMB2] §2.2.13 / [MS-CIFS] §2.2.4.64.1).
70pub mod create_options {
71    /// The file being opened or created is a directory.
72    pub const FILE_DIRECTORY_FILE: u32 = 0x0000_0001;
73    /// The file being opened must not be a directory.
74    pub const FILE_NON_DIRECTORY_FILE: u32 = 0x0000_0040;
75    /// Delete the file when the last open handle is closed.
76    pub const FILE_DELETE_ON_CLOSE: u32 = 0x0000_1000;
77}
78
79/// AndX chaining block layout within the parameter words ([MS-CIFS] §2.2.3.4).
80pub mod andx {
81    /// Minimum WordCount to carry the AndXCommand + AndXReserved.
82    pub const MIN_WCT: usize = 2;
83    /// Minimum WordCount to also carry the AndXOffset.
84    pub const MIN_WCT_OFFSET: usize = 3;
85    /// Byte offset of the AndXOffset within the parameter words.
86    pub const OFFSET_POS: usize = 2;
87}
88
89/// Header flags ([MS-CIFS] §2.2.1.2).
90pub mod flags {
91    /// This message is a response.
92    pub const RESPONSE: u8 = 0x80;
93    /// Case-insensitive pathnames requested.
94    pub const CASE_SENSITIVE: u8 = 0x08;
95}
96
97/// Header flags2 ([MS-CIFS] §2.2.1.3, extended by [MS-SMB]).
98pub mod flags2 {
99    /// Long file names supported/used.
100    pub const LONG_NAMES: u16 = 0x0001;
101    /// Strings are UTF-16LE.
102    pub const UNICODE: u16 = 0x8000;
103    /// Status field carries NTSTATUS codes instead of DOS errors.
104    pub const NT_STATUS: u16 = 0x4000;
105}
106
107/// Server capabilities advertised at negotiate time ([MS-SMB] §2.2.4.5).
108pub mod caps {
109    /// Unicode string support.
110    pub const CAP_UNICODE: u32 = 0x0000_0004;
111    /// 64-bit file offsets.
112    pub const CAP_LARGE_FILES: u32 = 0x0000_0008;
113    /// NT SMB command set (`NT_CREATE_ANDX`, TRANS2 pass-through, …).
114    pub const CAP_NT_SMBS: u32 = 0x0000_0010;
115    /// NT status codes in the header status field.
116    pub const CAP_STATUS32: u32 = 0x0000_0040;
117    /// Level II oplocks.
118    pub const CAP_LEVEL2_OPLOCKS: u32 = 0x0000_0080;
119    /// Lock-and-read supported.
120    pub const CAP_LOCK_AND_READ: u32 = 0x0000_0100;
121    /// NT-style FIND commands.
122    pub const CAP_NT_FIND: u32 = 0x0000_0200;
123    /// Pass-through information levels.
124    pub const CAP_INFOLEVEL_PASSTHRU: u32 = 0x0000_2000;
125    /// Large reads via READ_ANDX.
126    pub const CAP_LARGE_READX: u32 = 0x0000_4000;
127    /// Large writes via WRITE_ANDX.
128    pub const CAP_LARGE_WRITEX: u32 = 0x0000_8000;
129    /// Extended security (SPNEGO/NTLMSSP blobs in session setup).
130    pub const CAP_EXTENDED_SECURITY: u32 = 0x8000_0000;
131}