2.2 Message Syntax
The CIFS Protocol is composed of, and driven by, SMB commands. SMB commands are comprised of SMB message exchanges between the client and the server. SMB commands can be categorized by functionality as follows.
Session management |
Transaction subprotocol |
---|---|
SMB_COM_NEGOTIATE SMB_COM_SESSION_SETUP_ANDX SMB_COM_TREE_CONNECT SMB_COM_TREE_CONNECT_ANDX SMB_COM_TREE_DISCONNECT SMB_COM_LOGOFF_ANDX |
SMB_COM_TRANSACTION SMB_COM_TRANSACTION_SECONDARY SMB_COM_TRANSACTION2 SMB_COM_TRANSACTION2_SECONDARY SMB_COM_NT_TRANSACT SMB_COM_NT_TRANSACT_SECONDARY |
File/directory access methods |
Read/write/lock methods |
---|---|
SMB_COM_CREATE_DIRECTORY SMB_COM_DELETE_DIRECTORY SMB_COM_OPEN SMB_COM_OPEN_ANDX SMB_COM_CREATE SMB_COM_CREATE_NEW SMB_COM_CREATE_TEMPORARY SMB_COM_NT_CREATE_ANDX SMB_COM_CLOSE SMB_COM_DELETE |
SMB_COM_FLUSH SMB_COM_SEEK SMB_COM_READ SMB_COM_LOCK_AND_READ SMB_COM_LOCK_BYTE_RANGE SMB_COM_UNLOCK_BYTE_RANGE SMB_COM_LOCKING_ANDX SMB_COM_READ_ANDX SMB_COM_READ_RAW SMB_COM_READ_MPX SMB_COM_WRITE SMB_COM_WRITE_AND_CLOSE SMB_COM_WRITE_AND_UNLOCK SMB_COM_WRITE_ANDX SMB_COM_WRITE_RAW SMB_COM_WRITE_COMPLETE SMB_COM_WRITE_MPX |
Query directory information |
Query/set attributes methods |
---|---|
SMB_COM_CHECK_DIRECTORY SMB_COM_SEARCH SMB_COM_FIND SMB_COM_FIND_UNIQUE SMB_COM_FIND_CLOSE SMB_COM_FIND_CLOSE2 |
SMB_COM_RENAME SMB_COM_NT_RENAME SMB_COM_QUERY_INFORMATION SMB_COM_SET_INFORMATION SMB_COM_QUERY_INFORMATION_DISK SMB_COM_QUERY_INFORMATION2 SMB_COM_SET_INFORMATION2 |
Printing methods |
Other |
---|---|
SMB_COM_OPEN_PRINT_FILE SMB_COM_WRITE_PRINT_FILE SMB_COM_CLOSE_PRINT_FILE |
SMB_COM_ECHO SMB_COM_PROCESS_EXIT SMB_COM_NT_CANCEL SMB_COM_INVALID SMB_COM_IOCTL SMB_COM_NO_ANDX_COMMAND |
CIFS has evolved over time. As a result, some commands have become obsolete and other commands have been proposed but never implemented. The client MUST NOT use the commands listed in the table below. The server SHOULD return implementation-specific error codes in response to receiving any of these command requests.
Obsolete |
Reserved but not implemented |
---|---|
SMB_COM_COPY SMB_COM_MOVE SMB_COM_READ_MPX_SECONDARY SMB_COM_SECURITY_PACKAGE_ANDX SMB_COM_WRITE_MPX_SECONDARY SMB_COM_GET_PRINT_QUEUE |
SMB_COM_CLOSE_AND_TREE_DISC SMB_COM_FIND_NOTIFY_CLOSE SMB_COM_IOCTL_SECONDARY SMB_COM_NEW_FILE_SIZE SMB_COM_QUERY_SERVER SMB_COM_READ_BULK SMB_COM_WRITE_BULK SMB_COM_WRITE_BULK_DATA |
Specifications for the commands listed in the preceding tables are located in section 2.2.3.
An SMB message is the payload packet encapsulated in a transport packet. SMB messages are divided into three blocks: a fixed-length SMB Header (section 2.2.3.1), and two variable-length blocks called SMB Parameters (section 2.2.3.2) and SMB Data (section 2.2.3.3).
Unless otherwise specified, multiple-byte fields (SHORT, USHORT, LONG, and so on) in an SMB message MUST be transmitted in little-endian order (least-significant byte first). Unless otherwise indicated, numeric fields are integers of the specified byte length.
In dialects prior to NT LAN Manager, data alignment was not a consideration in SMB messages. Commands introduced in the NT LAN Manager dialect, however, can include fixed or variable-length padding fields used to align succeeding fields to 16-bit or 32-bit boundaries. Unicode strings, also introduced in NT LAN Manager, MUST be aligned to 16-bit boundaries unless otherwise noted.
Unless otherwise noted, fields marked as "reserved" SHOULD be set to zero when sent and MUST be ignored on receipt. These fields are reserved for future protocol expansion and MUST NOT be used for implementation-specific functionality. When it is necessary to insert padding bytes into a buffer for data alignment purposes, such bytes SHOULD be set to 0x00 when sent and MUST be ignored on receipt.
CIFS defines a set of data types and data structures that are commonly used across multiple commands in the protocol. These are specified in section 2.2.1. Some data structures exist that are used only in one or two commands. Those are specified in their respective command's subsection of section 2.2.4. All data types encountered in sections 2 and 3 that are not defined in section 2.2 are found in [MS-DTYP].
Unless otherwise noted, when an error occurs the server MUST return a response SMB message with a proper status code in the header (see section 2.2.3.1). Error responses SHOULD be sent with empty SMB Parameters and SMB Data blocks (WordCount and ByteCount fields set to zero; see sections 2.2.3.2 and 2.2.3.3 respectively).
CIFS defines a number of constants, including CIFS-specific error codes, which are commonly used across multiple commands in the protocol. The CIFS specific error codes include STATUS_INVALID_SMB and all status code constants with names beginning with STATUS_SMB_ and STATUS_OS2. These status codes are specified in section 2.2.2.4. All other constants in section 2 and 3 that begin with STATUS_ are defined in [MS-ERREF] section 2.3.