YpaHeL1
YpaHeL1

Reputation: 113

SMB protocol, linking a request to a response

I am implementing a SMB protocol decoder.

I don’t understand how, when reading a file/named pipe, the client understands that the response is associated with one of many open files/named pipes.

The client sends the file descriptor (file id), but the server does not send it back in the response. The server does not send any data linking the request to the response.

You can verify this by reading about SMB operations such as: SMB_COM_READ, TRANS_READ_NMPIPE in the MS-CIFS standard.

If there were several read requests or even several files/named pipes open, then how does the client understand which request the server responded to?

Upvotes: 0

Views: 239

Answers (1)

YpaHeL1
YpaHeL1

Reputation: 113

One can bind requests using a map using file_id as a key, while each request is added to the queue, and the decoding of each response is based on this queue.

(Binding requests) Each request will be placed in the map with the key file_id, and when subsequent requests to the file received, I can find out all the previous requests.

(Binding requests and responses) Also, each request is placed in a queue and an file_id is assigned to it, the file_ids of requests to one file are equal, when a response is received, the top element of the queue will be retrieved and an file_id will be obtained from it.

Upvotes: 0

Related Questions