2.5.11 RAP Response Data Marshaling

Depending on the command, the response for a Remote Administration Protocol command can contain one or more fixed-size items, each of which can contain offsets to variable-length data (typically strings). These fixed-size items MUST be returned in the RAPOutData field of the SMB_COM_TRANSACTION response that corresponds to the SMB_COM_TRANSACTION request that contained the Remote Administration Protocol request.

 The server MUST NOT return more information in the Data field of the SMB_COM_TRANSACTION response than is specified in the ReceiveBufferSize of the Remote Administration Protocol request. This section uses the term "response buffer" to represent a buffer, whose size is ReceiveBufferSize, that will be sent in the RAPOutData field of the response.

When a server implementing the Remote Administration Protocol copies the fixed-size items into the response buffer, it copies them beginning at the buffer's first byte. Variable-length data is copied into the response buffer after the fixed-size items.<65>

 When a Remote Administration Protocol server copies a fixed-size item to the response buffer, the Remote Administration Protocol server MUST copy the entire structure into the response buffer. If the Remote Administration Protocol server cannot fit the entire data structure into the response buffer, it MUST set the Win32ErrorCode in the Remote Administration Protocol response message to ERROR_MORE_DATA, and continue processing items.

 If the server cannot fit any of the fixed-size data structures into the response buffer, the Remote Administration Protocol server MUST set the Win32ErrorCode in the Remote Administration Protocol response message to NERR_BufTooSmall (0x084B).

 When marshaling more than one data structure, the Remote Administration Protocol server MUST pack each response data structure after the previous response data structure.

When marshaling a variable-length string that is pointed to by an offset in the fixed-size section, if the string data does not fit into the response buffer, the corresponding field in the fixed-size section MUST be set to 0. All strings are encoded in ASCII data and are terminated with a single null character. If the source string is null, then it MUST be marshaled as an empty string consisting of a single null character.

 For certain Remote Administration Protocol commands, such as NetPrintQEnum and NetPrintQGetInfo, the fixed-size portion of the response packet also contains auxiliary data structures. For more information on these commands, see [RYAN] page 410. If the Remote Administration Protocol server cannot fit all of the auxiliary structures into the response buffer, it MUST NOT copy any of the data in the fixed-size structure OR the auxiliary data structures to the response buffer.

As an example of this marshaling format, consider the case of a server marshaling a fixed-size data structure that has one or more auxiliary data structures associated with it. In this example, the fixed-size data structure consists of two 16-bit unsigned integers, an unsigned AUXCOUNT value, and an additional 16-bit unsigned integer, while the auxiliary data structure consists of two 32-bit unsigned integers. If the server marshals two instances of the data structure (called Data 1 and Data 2, for example), both of which have three auxiliary data structures associated with it, the server MUST marshal the following values into the response buffer.


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

Data 1 W 1 value

Data 1 W 2 value

Data 1 AUXCOUNT=3

Data 1 W 3 value

Data 1 AUX 1 D 1 value

Data 1 AUX 1 D 2 value

Data 1 AUX 2 D 1 value

Data 1 AUX 2 D 2 value

Data 1 AUX 3 D 1 value

Data 1 AUX 3 D 2 value

Data 2 W 1 value

Data 2 W 2 value

Data 2 AUXCOUNT=3

Data 2 W 3 value

Data 2 AUX 1 D 1 value

Data 2 AUX 1 D 2 value

Data 2 AUX 2 D 1 value

Data 2 AUX 2 D 2 value

Data 2 AUX 3 D 1 value

Data 2 AUX 3 D 2 value