CIFS Protocol Operation

The client initiates a session using a negotiation command to determine server capabilities and agree on an acceptable protocol dialect for the session. ANDX-type client commands may chain multiple I/O commands together in a single client request. TRANSACTION and TRANSACTION2-type commands support large data transfers.

A CIFS client/server session negotiation uses two CIFS packet types (_NEGOTIATE and _SESSION_SETUP_ANDX) to exchange system capabilities and to authenticate. To negotiate a CIFS session, the client first approaches the server with a list of the CIFS dialects that the client can support. From this list, the server selects the best dialect to use, warns the client if user challenge-response authentication is required, and sends a challenge security blob. The format of the server security blob conforms to RFC 2478 (GSS-API).

Each client request or server response packet consists of a fixed header (SMB Packet Header) and a variable data portion. The fixed header includes a command code, status flags, and client process and server file identifiers. The format of the data portion may vary according to the CIFS command used. The server returns the client request command code in its response packet.

Code Description
SMB_COM_NEGOTIATE Must be the first packet sent by the client to the server. This packet includes a list of SMB dialects supported by the client. The server response indicates which SMB dialect should be used.
SMB_COM_SESSION_SETUP_ANDX Transmits the user name and credentials to the server for verification. A successful server response has Uid field set in SMB header used for subsequent SMBs on behalf of this user.
SMB_COM_TREE_CONNECT_ANDX Transmits the name of the disk share that the client wants to access. Successful server response has the Tid field set in the SMB header used for subsequent packets referring to this resource.
SMB_COM_OPEN_ANDX Transmits the name of the file, relative to the TID, that the client wants to open. Successful server response includes a file identifier (FID) that the client should supply for subsequent operations on this file.
SMB_COM_READ Client supplies TID, FID, file offset, and number of bytes to read. Successful server response includes the requested file data.
SMB_COM_CLOSE Client closes the file represented by TID and FID. Server responds with success code.
SMB_COM_TREE_DISCONNECT Client disconnects from resource represented by TID.

The following topics discuss CIFS operation in further detail:

See Also

Royalty-Free CIFS Technical Reference License Agreement