public void CloseRequest( CloseFlagType closeFlagType, FileIdVolatileType volatileType, FileIdPersistentType persistentType) { Flags_Values flags = (closeFlagType == CloseFlagType.PostQueryAttribSet) ? Flags_Values.CLOSE_FLAG_POSTQUERY_ATTRIB : Flags_Values.NONE; FILEID file; file.Persistent = (persistentType == FileIdPersistentType.EqualToOpenDurableFileID) ? fileID.Persistent : (fileID.Persistent - 1); file.Volatile = (volatileType == FileIdVolatileType.ValidFileIdVolatile) ? fileID.Volatile : 0; QueryResponseStatus queryResponse = QueryResponseStatus.QueryResponseNotExist; uint status = testClient.Close( treeId, file, (header, response) => { if (response.FileAttributes != File_Attributes.NONE) { queryResponse = QueryResponseStatus.QueryResponseExist; } }, flags); CloseResponse((ModelSmb2Status)status, queryResponse); }
public static void CloseResponse(ModelSmb2Status status, QueryResponseStatus queryResponseStatus) { Condition.IsTrue(State == ModelState.Connected); ModelCloseRequest closeRequest = ModelHelper.RetrieveOutstandingRequest <ModelCloseRequest>(ref Request); string log = null; if (closeRequest.VolatileType == FileIdVolatileType.InvalidFileIdVolatile) { ModelHelper.Log(LogType.TestTag, TestTag.InvalidIdentifier); log = "FileId.Volatile of the Close Request is invalid, so the server cannot locate the open using FileId.Volatile as the lookup key."; } else if (closeRequest.PersistentType == FileIdPersistentType.NotEqualToOpenDurableFileID) { ModelHelper.Log(LogType.TestTag, TestTag.InvalidIdentifier); log = "FileId.Persistent is not equal to Open.DurableFileId."; } else if (!HasOpen) { log = "The Open was not be created or was closed before."; } if (log != null) { ModelHelper.Log(LogType.Requirement, "3.3.5.10: Next, the server MUST locate the open being closed by performing a lookup in the Session.OpenTable, using FileId.Volatile of the request as the lookup key. " + "If no open is found, or if Open.DurableFileId is not equal to FileId.Persistent, the server MUST fail the request with STATUS_FILE_CLOSED."); ModelHelper.Log(LogType.TestInfo, log); Condition.IsTrue(status == ModelSmb2Status.STATUS_FILE_CLOSED); return; } ModelHelper.Log(LogType.TestInfo, "The Close Request doesn't contain any invalid fields, the open is closed successfully and server should return STATUS_SUCCESS"); Condition.IsTrue(status == ModelSmb2Status.STATUS_SUCCESS); HasOpen = false; if (closeRequest.CloseType == CloseFlagType.PostQueryAttribSet) { ModelHelper.Log(LogType.Requirement, "3.3.5.10: If SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB is set in the Flags field of the request, the server MUST query the attributes of the file after the close."); ModelHelper.Log(LogType.TestInfo, "SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB is set in the Flags field of the Close Request."); Condition.IsTrue(queryResponseStatus == QueryResponseStatus.QueryResponseExist); } else { ModelHelper.Log(LogType.TestInfo, "SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB is not set, then the server should not query the attribute of the file after the close"); Condition.IsTrue(queryResponseStatus == QueryResponseStatus.QueryResponseNotExist); } }