2.2.21 SMB2 WRITE Request

The SMB2 WRITE Request packet is sent by the client to write data to the file or named pipe on the server. This request is composed of an SMB2 header, as specified in section 2.2.1, followed by this request structure:


0


1


2


3


4


5


6


7


8


9

1
0


1


2


3


4


5


6


7


8


9

2
0


1


2


3


4


5


6


7


8


9

3
0


1

StructureSize

DataOffset

Length

Offset

...

FileId

...

...

...

Channel

RemainingBytes

WriteChannelInfoOffset

WriteChannelInfoLength

Flags

Buffer (variable)

...

StructureSize (2 bytes): The client MUST set this field to 49, indicating the size of the request structure, not including the header. The client MUST set it to this value regardless of how long Buffer[] actually is in the request being sent.

DataOffset (2 bytes): The offset, in bytes, from the beginning of the SMB2 header to the data being written.

Length (4 bytes): The length of the data being written, in bytes. The length of the data being written can be zero bytes.

Offset (8 bytes): The offset, in bytes, of where to write the data in the destination file. If the write is being executed on a pipe, the Offset MUST be set to 0 by the client and MUST be ignored by the server.

FileId (16 bytes): An SMB2_FILEID, as specified in section 2.2.14.1.

The identifier of the file or pipe on which to perform the write.

Channel (4 bytes): For the SMB 2.0.2 and 2.1 dialects, this field MUST NOT be used and MUST be reserved. The client MUST set this field to 0, and the server MUST ignore it on receipt. For the SMB 3.x dialect family, this field MUST contain exactly one of the following values:

Value

Meaning

SMB2_CHANNEL_NONE

0x00000000

No channel information is present in the request. The RemainingBytes, WriteChannelInfoOffset and WriteChannelInfoLength fields MUST be set to zero by the client and MUST be ignored by the server.

SMB2_CHANNEL_RDMA_V1

0x00000001

One or more SMB_DIRECT_BUFFER_DESCRIPTOR_V1 structures as specified in [MS-SMBD] section 2.2.3.1 are present in the channel information specified by RemainingBytes, WriteChannelInfoOffset and WriteChannelInfoLength fields.

SMB2_CHANNEL_RDMA_V1_INVALIDATE

0x00000002

This flag is not valid for the SMB 3.0 dialect. One or more SMB_DIRECT_BUFFER_DESCRIPTOR_V1 structures as specified in [MS-SMBD] section 2.2.3.1 are present in the channel information specified by the RemainingBytes, WriteChannelInfoOffset and WriteChannelInfoLength fields. The server is requested to perform remote invalidation when responding to the request as specified in [MS-SMBD] section 3.1.4.2.

SMB2_CHANNEL_RDMA_TRANSFORM

0x00000003

This flag is not valid for SMB 3.0 and 3.0.2 dialects. When connection supports RDMA transform, SMB2_RDMA_TRANSFORM structure is present in the channel information specified by the RemainingBytes, WriteChannelInfoOffset, and WriteChannelInfoLength fields.<56>

RemainingBytes (4 bytes): For the SMB 3.x dialect family, if the Channel field of the request contains SMB2_CHANNEL_RDMA_V1, SMB2_CHANNEL_RDMA_V1_INVALIDATE, or SMB2_CHANNEL_RDMA_TRANSFORM, this field contains the length, in bytes, of the data being written.

WriteChannelInfoOffset (2 bytes): For the SMB 3.x dialect family, if the Channel field of the request contains SMB2_CHANNEL_RDMA_V1, SMB2_CHANNEL_RDMA_V1_INVALIDATE, or SMB2_CHANNEL_RDMA_TRANSFORM, it contains the offset, in bytes, from the beginning of the SMB2 header to the channel data as specified by the Channel field of the request.

WriteChannelInfoLength (2 bytes): For the SMB 3.x dialect family, if the Channel field of the request contains SMB2_CHANNEL_RDMA_V1, SMB2_CHANNEL_RDMA_V1_INVALIDATE, or SMB2_CHANNEL_RDMA_TRANSFORM, it contains the length, in bytes, of the channel data as specified by the Channel field of the request.

Flags (4 bytes): A Flags field indicates how to process the operation. This field MUST be constructed using zero or more of the following values:

Value

Meaning

SMB2_WRITEFLAG_WRITE_THROUGH

0x00000001

The server performs File write-through on the write operation. This value is not valid for the SMB 2.0.2 dialect.

SMB2_WRITEFLAG_WRITE_UNBUFFERED

0x00000002

File buffering is not performed. This bit is not valid for the SMB 2.0.2, 2.1, and 3.0 dialects.

Buffer (variable): A variable-length buffer that contains the data to write and the write channel information, as described by DataOffset, Length, WriteChannelInfoOffset, and WriteChannelInfoLength.