public void Trans2FindNext2Request( int messageId, int sessionId, int treeId, bool isSigned, bool isReparse, [Domain("InfoLevelFind")] InformationLevel informationLevel, int sid, int gmtTokenIndex, bool isFlagsKnowsLongNameSet) { #region Create Packet SmbTrans2FindNext2RequestPacket smbPacket = new SmbTrans2FindNext2RequestPacket(); ushort uid = (ushort)this.uId[(uint)sessionId]; ushort tid = (ushort)this.tId[(uint)treeId]; NamespaceCifs.Trans2SmbParametersFlags transactOptions = NamespaceCifs.Trans2SmbParametersFlags.NONE; string fileName = string.Empty; if (gmtTokenIndex < (int)uint.MinValue) { fileName = Site.Properties["SmbTestCaseBadGmt"].ToString(); } else { if (this.gmtTokens.ContainsKey(gmtTokenIndex)) { fileName = this.gmtTokens[gmtTokenIndex]; } else { fileName = this.gmtTokens[ValidgmtTokenIndex]; } } NamespaceCifs.Trans2FindFlags findFlags = (NamespaceCifs.Trans2FindFlags)(ushort.Parse(Site.Properties["SmbTransportFindFlags"])); ushort searchCount = ushort.Parse(Site.Properties["SmbTransportSearchCount"]); smbPacket = this.smbClientStack.CreateTrans2FindNext2Request( tid, fileName, transactOptions, searchCount, (ushort)this.sId[(uint)sid], uint.MinValue, findFlags, isReparse, isFlagsKnowsLongNameSet, (FindInformationLevel)this.informationLevelBytes[(ushort)informationLevel]); if (isSigned) { NamespaceCifs.CifsClientPerConnection connection = this.smbClientStack.Context.GetConnection(ConnectionId); NamespaceCifs.CifsClientPerSession session = this.smbClientStack.Context.GetSession(ConnectionId, uid); smbPacket.Sign(connection.ClientNextSendSequenceNumber, session.SessionKey); } #endregion #region Send and Receive ExpectPacket this.smbClientStack.SendPacket(smbPacket); StackPacket response = this.smbClientStack.ExpectPacket(this.timeout); NamespaceCifs.SmbPacket smbPacketResponse = (NamespaceCifs.SmbPacket)response; this.QueryUidTable(smbPacketResponse); this.QueryTidTable(smbPacketResponse); VerifyTransport(smbPacketResponse); VerifyCommonMessageSyntax(smbPacketResponse); if (response.GetType() == typeof(SmbErrorResponsePacket)) { SmbErrorResponsePacket smbErrorResponsePacket = response as SmbErrorResponsePacket; NamespaceCifs.SmbHeader smbErrorHeader = smbErrorResponsePacket.SmbHeader; if (smbErrorHeader.Status == (uint)MessageStatus.StatusInvalidInfoClass) { smbErrorHeader.Status = (uint)MessageStatus.NotSupported; } this.ErrorResponse(smbErrorHeader.Mid + this.addMidMark, (MessageStatus)smbErrorHeader.Status); } else { SmbTrans2FindNext2ResponsePacket smbTrans2FindNext2Packet = response as SmbTrans2FindNext2ResponsePacket; NamespaceCifs.SmbHeader smtTrans2FindNext2ResponseHeader = smbTrans2FindNext2Packet.SmbHeader; SmbTrans2FindNext2RequestPacket lastPacketFindNext = smbPacket as SmbTrans2FindNext2RequestPacket; NamespaceCifs.TRANS2_FIND_NEXT2_Request_Trans2_Parameters trans2FindNext2RequestHeader = lastPacketFindNext.Trans2Parameters; bool isFileIDEqualZero = true; switch (trans2FindNext2RequestHeader.InformationLevel) { case NamespaceCifs.FindInformationLevel.SMB_FIND_FILE_FULL_DIRECTORY_INFO: { if (smbTrans2FindNext2Packet.SmbData.Trans2_Data.Length != uint.MinValue) { NamespaceFscc.FsccFileFullDirectoryInformationResponsePacket findNextFsccFullDirectoryPacket = new NamespaceFscc.FsccFileFullDirectoryInformationResponsePacket(); findNextFsccFullDirectoryPacket.FromBytes(smbTrans2FindNext2Packet.SmbData.Trans2_Data); NamespaceFscc.FileFullDirectoryInformation findNextFullDirectoryInformation = new NamespaceFscc.FileFullDirectoryInformation(); findNextFullDirectoryInformation = findNextFsccFullDirectoryPacket.Payload; if (findNextFullDirectoryInformation.FileNameLength == uint.MinValue) { isFileIDEqualZero = true; } VerifyMessageSyntaxSmbFindFileIdFullDirectoryInfo(findNextFullDirectoryInformation); } break; } case NamespaceCifs.FindInformationLevel.SMB_FIND_FILE_BOTH_DIRECTORY_INFO: { if (smbTrans2FindNext2Packet.SmbData.Trans2_Data.Length != uint.MinValue) { NamespaceFscc.FsccFileBothDirectoryInformationResponsePacket findNextFsccBothDirectoryPacket = new NamespaceFscc.FsccFileBothDirectoryInformationResponsePacket(); findNextFsccBothDirectoryPacket.FromBytes(smbTrans2FindNext2Packet.SmbData.Trans2_Data); NamespaceFscc.FileBothDirectoryInformation findNextBothDirectoryInformation = new NamespaceFscc.FileBothDirectoryInformation(); findNextBothDirectoryInformation = findNextFsccBothDirectoryPacket.Payload; if (findNextBothDirectoryInformation.FileNameLength == uint.MinValue) { isFileIDEqualZero = true; } if (this.smbClientStack.Capability.IsSupportsExtendedSecurity == true) { VerifyMessageSyntaxSmbFindFileBothDirectoryInfo(findNextBothDirectoryInformation); } } break; } case NamespaceCifs.FindInformationLevel.SMB_FIND_FILE_DIRECTORY_INFO: { if (SmbAdapter.fileSystemType == FileSystemType.Fat) { isFileIDEqualZero = true; } else { isFileIDEqualZero = false; } break; } } this.Trans2FindNext2Response( smtTrans2FindNext2ResponseHeader.Mid + this.addMidMark, this.QueryUidTable(smbPacketResponse), this.QueryTidTable(smbPacketResponse), (smbPacketResponse).IsSignRequired, isFileIDEqualZero, (MessageStatus)smtTrans2FindNext2ResponseHeader.Status); } #endregion }
public void Trans2FindFirst2RequestInvalidFileToken( int messageId, int sessionId, int treeId, bool isSigned, bool isReparse, InformationLevel informationLevel, int gmtTokenIndex, bool isFlagsKnowsLongNameSet, bool isGmtPatten) { #region Create Packet SmbTrans2FindFirst2RequestPacket smbPacket = new SmbTrans2FindFirst2RequestPacket(); ushort uid = (ushort)this.uId[(uint)sessionId]; ushort tid = (ushort)this.tId[(uint)treeId]; NamespaceCifs.Trans2SmbParametersFlags transactOptions = NamespaceCifs.Trans2SmbParametersFlags.NONE; string fileName = Site.Properties["SmbTestCaseBadGmt"].ToString(); ushort searchCount = ushort.Parse(Site.Properties["SmbTransportSearchCount"]); NamespaceCifs.Trans2FindFlags findFlags = (NamespaceCifs.Trans2FindFlags)(ushort.Parse(Site.Properties["SmbTransportFindFlags"])); NamespaceCifs.SmbFileAttributes searchAttributes = NamespaceCifs.SmbFileAttributes.SMB_FILE_ATTRIBUTE_NORMAL; NamespaceCifs.Trans2FindFirst2SearchStorageType searchStorageType = NamespaceCifs.Trans2FindFirst2SearchStorageType.FILE_NON_DIRECTORY_FILE; isReparse = true; isFlagsKnowsLongNameSet = true; smbPacket = this.smbClientStack.CreateTrans2FindFirst2Request( tid, fileName, transactOptions, searchCount, findFlags, searchAttributes, searchStorageType, isReparse, isFlagsKnowsLongNameSet, FindInformationLevel.SMB_INFO_STANDARD); if (isSigned) { NamespaceCifs.CifsClientPerConnection connection = this.smbClientStack.Context.GetConnection(ConnectionId); NamespaceCifs.CifsClientPerSession session = this.smbClientStack.Context.GetSession(ConnectionId, uid); smbPacket.Sign(connection.ClientNextSendSequenceNumber, session.SessionKey); } #endregion #region Send and Receive ExpectPacket this.smbClientStack.SendPacket(smbPacket); StackPacket response = this.smbClientStack.ExpectPacket(this.timeout); NamespaceCifs.SmbPacket smbPacketResponse = (NamespaceCifs.SmbPacket)response; this.QueryUidTable(smbPacketResponse); this.QueryTidTable(smbPacketResponse); VerifyTransport(smbPacketResponse); VerifyCommonMessageSyntax(smbPacketResponse); if (response.GetType() == typeof(SmbErrorResponsePacket)) { SmbErrorResponsePacket smbErrorResponsePacket = response as SmbErrorResponsePacket; NamespaceCifs.SmbHeader smbErrorHeader = smbErrorResponsePacket.SmbHeader; if (smbErrorHeader.Status == (uint)MessageStatus.StatusInvalidInfoClass) { smbErrorHeader.Status = (uint)MessageStatus.NotSupported; } this.ErrorResponse(smbErrorHeader.Mid + this.addMidMark, (MessageStatus)smbErrorHeader.Status); } else { NamespaceCifs.TRANS2_FIND_FIRST2_Request_Trans2_Parameters trans2FindFirst2RequestHeader = smbPacket.Trans2Parameters; SmbTrans2FindFirst2ResponsePacket smbTrans2FindFirst2Packet = response as SmbTrans2FindFirst2ResponsePacket; NamespaceCifs.SmbHeader smbTrans2FindFirst2ResponseHeader = smbTrans2FindFirst2Packet.SmbHeader; NamespaceCifs.TRANS2_FIND_FIRST2_Response_Trans2_Parameters trans2FindFirst2ResponseHeader = smbTrans2FindFirst2Packet.Trans2Parameters; bool isFileIDEqualZero = false; bool isReturnEnumPreviousVersion = false; ushort inforLevel = (ushort)trans2FindFirst2RequestHeader.InformationLevel; if (inforLevel == this.informationLevelBytes[(ushort)InformationLevel.SmbFindFileIdFullDirectoryInfo]) { if (smbTrans2FindFirst2Packet.SmbData.Trans2_Data.Length != uint.MinValue) { NamespaceFscc.FsccFileFullDirectoryInformationResponsePacket fsccFullDirectoryPacket = new NamespaceFscc.FsccFileFullDirectoryInformationResponsePacket(); fsccFullDirectoryPacket.FromBytes(smbTrans2FindFirst2Packet.SmbData.Trans2_Data); NamespaceFscc.FileFullDirectoryInformation fullDirectoryInformation = new NamespaceFscc.FileFullDirectoryInformation(); fullDirectoryInformation = fsccFullDirectoryPacket.Payload; if (fullDirectoryInformation.FileNameLength == uint.MinValue) { isFileIDEqualZero = true; } VerifyMessageSyntaxSmbFindFileIdFullDirectoryInfo(fullDirectoryInformation); this.isfindIdFullDirectoryInfo = true; } } else if (inforLevel == this.informationLevelBytes[(ushort)InformationLevel.SmbFindFileIdBothDirectoryInfo]) { if (smbTrans2FindFirst2Packet.SmbData.Trans2_Data.Length != uint.MinValue) { NamespaceFscc.FsccFileBothDirectoryInformationResponsePacket fsccBothDirectoryPacket = new NamespaceFscc.FsccFileBothDirectoryInformationResponsePacket(); fsccBothDirectoryPacket.FromBytes(smbTrans2FindFirst2Packet.SmbData.Trans2_Data); NamespaceFscc.FileBothDirectoryInformation bothDirectoryInformation = new NamespaceFscc.FileBothDirectoryInformation(); bothDirectoryInformation = fsccBothDirectoryPacket.Payload; if (bothDirectoryInformation.FileNameLength == uint.MinValue) { isFileIDEqualZero = true; } if (this.smbClientStack.Capability.IsSupportsExtendedSecurity == true) { VerifyMessageSyntaxSmbFindFileBothDirectoryInfo(bothDirectoryInformation); } this.isfinIdBothDirectoryInfo = true; } } else { if (SmbAdapter.fileSystemType == FileSystemType.Fat) { isFileIDEqualZero = true; } else { isFileIDEqualZero = false; } if (this.sutOsVersion == Platform.Win2K3) { isReturnEnumPreviousVersion = false; } else { isReturnEnumPreviousVersion = true; } } if (!this.sId.ContainsValue(trans2FindFirst2ResponseHeader.SID)) { this.sId.Add((uint)(gmtTokenIndex), (uint)trans2FindFirst2ResponseHeader.SID); } VerifyMessageSyntaxTrans2FindFirst2Request( informationLevel, smbTrans2FindFirst2Packet, this.isfindIdFullDirectoryInfo, this.isfinIdBothDirectoryInfo); this.isfindIdFullDirectoryInfo = false; this.isfinIdBothDirectoryInfo = false; this.Trans2FindFirst2Response( smbTrans2FindFirst2ResponseHeader.Mid + this.addMidMark, this.QueryUidTable(smbPacketResponse), this.QueryTidTable(smbPacketResponse), smbPacketResponse.IsSignRequired, isFileIDEqualZero, gmtTokenIndex, isReturnEnumPreviousVersion, (MessageStatus)smbTrans2FindFirst2ResponseHeader.Status, true, true); } #endregion }
/// <summary> /// Verify the FILE_BOTH_DIR_INFORMATION, which is specified in TD 2.4.8 /// </summary> /// <param name="fileBothDirectoryInformation"> FileBothDirectoryInformation type data </param> /// <param name="allocationSize">A 64-bit signed integer that contains the file allocation size, in bytes</param> /// <param name="endOfFilePositon">A 64-bit signed integer that contains the absolute new end-of-file position as a byte offset from the start of the file</param> /// <param name="isNoEntries">no other entries follow this one[FILE_ID_BOTH_DIR_INFORMATION entry</param> public void VerifyFileBothDirectoryInformationOfFSCC( FileBothDirectoryInformation fileBothDirectoryInformation, long allocationSize //bool isNoEntries ) { Site.DefaultProtocolDocShortName = "MS-FSCC"; // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1061 actual CreationTime: {0}", fileBothDirectoryInformation.CreationTime.ToString()); // // Verify MS-FSCC requirement: MS-FSCC_R1061 // int sizeOfCreationTime = 8; bool isVerifyR1061 = ( typeof(Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Fscc.FILETIME) == fileBothDirectoryInformation.CreationTime.GetType() && (Marshal.SizeOf(fileBothDirectoryInformation.CreationTime) == sizeOfCreationTime)); Site.CaptureRequirementIfIsTrue( isVerifyR1061, 1061, @"[In FILE_BOTH_DIR_INFORMATION]CreationTime (8 bytes): A 64-bit signed integer that contains the time when the file was created."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1062 "); // // Verify MS-FSCC requirement: MS-FSCC_R1062 // Site.CaptureRequirementIfAreEqual<Type>( typeof(Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Fscc.FILETIME), fileBothDirectoryInformation.CreationTime.GetType(), 1062, @"[In FILE_BOTH_DIR_INFORMATION]CreationTime (8 bytes): All dates and times are in absolute system-time format, which is represented as a FILETIME (section 2.1.1) structure."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1063 actual CreationTime: {0}", fileBothDirectoryInformation.CreationTime.ToString()); // // Verify MS-FSCC requirement: MS-FSCC_R1063 // bool isVerifyR1063 = ( fileBothDirectoryInformation.LastWriteTime.dwHighDateTime >= 0 && fileBothDirectoryInformation.LastWriteTime.dwLowDateTime >= 0 && Marshal.SizeOf(fileBothDirectoryInformation.LastWriteTime) == sizeOfCreationTime); Site.CaptureRequirementIfIsTrue( isVerifyR1063, 1063, @"[In FILE_BOTH_DIR_INFORMATION]CreationTime (8 bytes): This value MUST be greater than or equal to 0."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1070 Actual EndOfFile: {0}", fileBothDirectoryInformation.EndOfFile); // // Verify MS-FSCC requirement: MS-FSCC_R1070 // bool isVerifyR1070 = ( fileBothDirectoryInformation.EndOfFile.GetType() == typeof(Int64) && Marshal.SizeOf(fileBothDirectoryInformation.EndOfFile) == 8); Site.CaptureRequirementIfIsTrue( isVerifyR1070, 1070, @"[In FILE_BOTH_DIR_INFORMATION]EndOfFile (8 bytes): A 64-bit signed integer that contains the absolute new end-of-file position as a byte offset from the start of the file."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1071 EndOfFile: {0}", fileBothDirectoryInformation.EndOfFile); // // Verify MS-FSCC requirement: MS-FSCC_R1071 // const int sizeOfEndOfFile = 8; // As we parse the file by using the EndofFile, the sucessfully parsing have verified the actual value, // only verify the size of endoffile Site.CaptureRequirementIfAreEqual<int>( sizeOfEndOfFile, Marshal.SizeOf(fileBothDirectoryInformation.EndOfFile), 1071, @"[In FILE_BOTH_DIR_INFORMATION]EndOfFile (8 bytes): EndOfFile specifies the offset to the byte immediately following the last valid byte in the file."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1073 EndOfFile: {0}", fileBothDirectoryInformation.EndOfFile); // // Verify MS-FSCC requirement: MS-FSCC_R1073 // Site.CaptureRequirementIfIsTrue( fileBothDirectoryInformation.EndOfFile >= 0, 1073, @"[In FILE_BOTH_DIR_INFORMATION]EndOfFile (8 bytes): The value of this field MUST be greater than or equal to 0."); // // Verify MS-FSCC requirement: MS-FSCC_R1149 // Site.CaptureRequirementIfAreEqual<uint>( fileBothDirectoryInformation.FileNameLength, (uint)fileBothDirectoryInformation.FileName.Length, 1149, @"[In FILE_BOTH_DIR_INFORMATION]FileName (variable): This field MUST be handled as a sequence of FileNameLength bytes."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1079 FileNameLength: {0}, type: {1}", fileBothDirectoryInformation.FileNameLength, typeof(UInt32)); // // Verify MS-FSCC requirement: MS-FSCC_R1079 // bool isVerifyR1079 = ( fileBothDirectoryInformation.FileNameLength.GetType() == typeof(UInt32) && fileBothDirectoryInformation.FileNameLength == fileBothDirectoryInformation.FileName.Length); Site.CaptureRequirementIfIsTrue( isVerifyR1079, 1079, @"[In FILE_BOTH_DIR_INFORMATION]FileNameLength (4 bytes): A 32-bit unsigned integer that contains the length, in bytes, of the FileName field."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1064 actual LastAccessTime: {0}", fileBothDirectoryInformation.LastAccessTime.ToString()); // // Verify MS-FSCC requirement: MS-FSCC_R1064 // // Verify the LastAccessTime's type and value const int sizeOfLastAccessTime = 8; bool isVerifyR1064 = ( fileBothDirectoryInformation.LastAccessTime.GetType() == typeof(Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Fscc.FILETIME) && (Marshal.SizeOf(fileBothDirectoryInformation.LastAccessTime) == sizeOfLastAccessTime)); Site.CaptureRequirementIfIsTrue( isVerifyR1064, 1064, @"[In FILE_BOTH_DIR_INFORMATION]LastAccessTime (8 bytes): A 64-bit signed integer that contains the last time the file was accessed in the format of a FILETIME structure."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1065 actual LastAccessTime: {0}", fileBothDirectoryInformation.LastAccessTime.ToString()); // // Verify MS-FSCC requirement: MS-FSCC_R1065 // bool isVerifyR1065 = ( fileBothDirectoryInformation.LastAccessTime.dwHighDateTime >= 0 && fileBothDirectoryInformation.LastAccessTime.dwLowDateTime >= 0); Site.CaptureRequirementIfIsTrue( isVerifyR1065, 1065, @"[In FILE_BOTH_DIR_INFORMATION]LastAccessTime (8 bytes): This value MUST be greater than or equal to 0."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1066 actual LastWriteTime: {0}", fileBothDirectoryInformation.LastWriteTime.ToString()); // // Verify MS-FSCC requirement: MS-FSCC_R1066 // const int sizeOfLastWriteTime = 8; bool isVerifyR1066 = ( fileBothDirectoryInformation.LastWriteTime.GetType() == typeof(Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Fscc.FILETIME) && Marshal.SizeOf(fileBothDirectoryInformation.LastWriteTime) == sizeOfLastWriteTime); Site.CaptureRequirementIfIsTrue( isVerifyR1066, 1066, @"[In FILE_BOTH_DIR_INFORMATION]LastWriteTime (8 bytes): A 64-bit signed integer that contains the last time information was written to the file in the format of a FILETIME structure."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1067 actual LastWriteTime: {0}", fileBothDirectoryInformation.LastWriteTime.ToString()); // // Verify MS-FSCC requirement: MS-FSCC_R1067 // bool isVerifyR1067 = ( fileBothDirectoryInformation.LastWriteTime.dwHighDateTime >= 0 && fileBothDirectoryInformation.LastWriteTime.dwLowDateTime >= 0); Site.CaptureRequirementIfIsTrue( isVerifyR1067, 1067, @"[In FILE_BOTH_DIR_INFORMATION]LastWriteTime (8 bytes): This value MUST be greater than or equal to 0."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1068 actual ChangeTime: {0}", fileBothDirectoryInformation.ChangeTime.ToString()); // // Verify MS-FSCC requirement: MS-FSCC_R1068 // const int sizeOfChangeTime = 8; bool isVerifyR1068 = ( fileBothDirectoryInformation.ChangeTime.GetType() == typeof(Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Fscc.FILETIME) && Marshal.SizeOf(fileBothDirectoryInformation.ChangeTime) == sizeOfChangeTime); Site.CaptureRequirementIfIsTrue( isVerifyR1068, 1068, @"[In FILE_BOTH_DIR_INFORMATION]ChangeTime (8 bytes): A 64-bit signed integer that contains the last time the file was changed in the format of a FILETIME structure."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1069 Actual ChangeTime: {0}", fileBothDirectoryInformation.ChangeTime.ToString()); // // Verify MS-FSCC requirement: MS-FSCC_R1069 // bool isVerifyR1069 = ( fileBothDirectoryInformation.ChangeTime.dwHighDateTime >= 0 && fileBothDirectoryInformation.ChangeTime.dwLowDateTime >= 0); Site.CaptureRequirementIfIsTrue( isVerifyR1069, 1069, @"[In FILE_BOTH_DIR_INFORMATION]ChangeTime (8 bytes): This value MUST be greater than or equal to 0."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1074 Actual AllocationSize: {0},expected AllocationSize: {1}", fileBothDirectoryInformation.AllocationSize, allocationSize); // // Verify MS-FSCC requirement: MS-FSCC_R1074 // bool isVerifyR1074 = ( typeof(Int64) == fileBothDirectoryInformation.AllocationSize.GetType() && fileBothDirectoryInformation.AllocationSize == allocationSize); Site.CaptureRequirementIfIsTrue( isVerifyR1074, 1074, @"[In FILE_BOTH_DIR_INFORMATION]AllocationSize (8 bytes): A 64-bit signed integer that contains the file allocation size, in bytes."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1086 Actual Reserved: {0}", fileBothDirectoryInformation.Reserved); // // Verify MS-FSCC requirement: MS-FSCC_R1086 // // This field can contain any valude, so we just verify its size const int sizeOfReserved = 1; Site.CaptureRequirementIfAreEqual<int>( sizeOfReserved, Marshal.SizeOf(fileBothDirectoryInformation.Reserved), 1086, @"[In FILE_BOTH_DIR_INFORMATION]Reserved (1 byte): This field can contain any value."); Site.DefaultProtocolDocShortName = Site.Properties["ProtocolShortName"]; }
public void Trans2FindFirst2Request( int messageId, int sessionId, int treeId, bool isSigned, bool isReparse, [Domain("InfoLevelFind")] InformationLevel informationLevel, int gmtTokenIndex, bool isFlagsKnowsLongNameSet, bool isGmtPatten) { #region Create Packet SmbTrans2FindFirst2RequestPacket smbPacket = new SmbTrans2FindFirst2RequestPacket(); ushort uid = (ushort)this.uId[(uint)sessionId]; ushort tid = (ushort)this.tId[(uint)treeId]; NamespaceCifs.Trans2SmbParametersFlags transactOptions = NamespaceCifs.Trans2SmbParametersFlags.NONE; string fileName = string.Empty; if (gmtTokenIndex < uint.MinValue) { fileName = Site.Properties["SmbTestCaseBadGmt"].ToString(); } else { if (this.gmtTokens.ContainsKey(gmtTokenIndex)) { fileName = this.gmtTokens[gmtTokenIndex]; } else { fileName = this.gmtTokens[ValidgmtTokenIndex]; } } ushort searchCount = ushort.Parse(Site.Properties["SmbTransportSearchCount"]); NamespaceCifs.Trans2FindFlags findFlags = (NamespaceCifs.Trans2FindFlags)(ushort.Parse(Site.Properties["SmbTransportFindFlags"])); NamespaceCifs.SmbFileAttributes searchAttributes = (NamespaceCifs.SmbFileAttributes)(ushort.Parse(Site.Properties["SmbTransportSearchFileAttributes"])); NamespaceCifs.Trans2FindFirst2SearchStorageType searchStorageType = (NamespaceCifs.Trans2FindFirst2SearchStorageType) (ushort.Parse(Site.Properties["SmbTransportSearchStorageType"])); smbPacket = this.smbClientStack.CreateTrans2FindFirst2Request( tid, fileName, transactOptions, searchCount, findFlags, searchAttributes, searchStorageType, isReparse, isFlagsKnowsLongNameSet, (FindInformationLevel)this.informationLevelBytes[(ushort)informationLevel]); if (isSigned) { NamespaceCifs.CifsClientPerConnection connection = this.smbClientStack.Context.GetConnection(ConnectionId); NamespaceCifs.CifsClientPerSession session = this.smbClientStack.Context.GetSession(ConnectionId, uid); smbPacket.Sign(connection.ClientNextSendSequenceNumber, session.SessionKey); } #endregion #region Send and Receive ExpectPacket this.smbClientStack.SendPacket(smbPacket); StackPacket response = this.smbClientStack.ExpectPacket(this.timeout); NamespaceCifs.SmbPacket smbPacketResponse = (NamespaceCifs.SmbPacket)response; this.QueryUidTable(smbPacketResponse); this.QueryTidTable(smbPacketResponse); VerifyTransport(smbPacketResponse); VerifyCommonMessageSyntax(smbPacketResponse); if (response.GetType() == typeof(SmbErrorResponsePacket)) { SmbErrorResponsePacket smbErrorResponsePacket = response as SmbErrorResponsePacket; NamespaceCifs.SmbHeader smbErrorHeader = smbErrorResponsePacket.SmbHeader; if (smbErrorHeader.Status == (uint)MessageStatus.StatusInvalidInfoClass) { smbErrorHeader.Status = (uint)MessageStatus.NotSupported; } //Workaround temp code (How to trigger SUCCESS for TRANS2_FIND_FIRST2 Request) if (smbErrorHeader.Status == (uint)MessageStatus.ObjectNameNotFound && !bool.Parse(Site.Properties["IsTDQ33049Fixed"])) { smbErrorHeader.Status = (uint)MessageStatus.InvalidParameter; } this.ErrorResponse(smbErrorHeader.Mid + this.addMidMark, (MessageStatus)smbErrorHeader.Status); } else { NamespaceCifs.TRANS2_FIND_FIRST2_Request_Trans2_Parameters trans2FindFirst2RequestHeader = smbPacket.Trans2Parameters; SmbTrans2FindFirst2ResponsePacket smbTrans2FindFirst2Packet = response as SmbTrans2FindFirst2ResponsePacket; NamespaceCifs.SmbHeader smbTrans2FindFirst2ResponseHeader = smbTrans2FindFirst2Packet.SmbHeader; NamespaceCifs.TRANS2_FIND_FIRST2_Response_Trans2_Parameters trans2FindFirst2ResponseHeader = smbTrans2FindFirst2Packet.Trans2Parameters; bool isFileIDEqualZero = false; bool isReturnEnumPreviousVersion = false; ushort inforLevel = (ushort)trans2FindFirst2RequestHeader.InformationLevel; if (inforLevel == this.informationLevelBytes[(ushort)InformationLevel.SmbFindFileIdFullDirectoryInfo]) { if (smbTrans2FindFirst2Packet.SmbData.Trans2_Data.Length != uint.MinValue) { NamespaceFscc.FsccFileFullDirectoryInformationResponsePacket fsccFullDirectoryPacket = new NamespaceFscc.FsccFileFullDirectoryInformationResponsePacket(); fsccFullDirectoryPacket.FromBytes(smbTrans2FindFirst2Packet.SmbData.Trans2_Data); NamespaceFscc.FileFullDirectoryInformation fullDirectoryInformation = new NamespaceFscc.FileFullDirectoryInformation(); fullDirectoryInformation = fsccFullDirectoryPacket.Payload; if (fullDirectoryInformation.FileNameLength == uint.MinValue) { isFileIDEqualZero = true; } VerifyMessageSyntaxSmbFindFileIdFullDirectoryInfo(fullDirectoryInformation); this.isfindIdFullDirectoryInfo = true; } } else if (inforLevel == this.informationLevelBytes[(ushort)InformationLevel.SmbFindFileIdBothDirectoryInfo]) { if (smbTrans2FindFirst2Packet.SmbData.Trans2_Data.Length != uint.MinValue) { NamespaceFscc.FsccFileBothDirectoryInformationResponsePacket fsccBothDirectoryPacket = new NamespaceFscc.FsccFileBothDirectoryInformationResponsePacket(); fsccBothDirectoryPacket.FromBytes(smbTrans2FindFirst2Packet.SmbData.Trans2_Data); NamespaceFscc.FileBothDirectoryInformation bothDirectoryInformation = new NamespaceFscc.FileBothDirectoryInformation(); bothDirectoryInformation = fsccBothDirectoryPacket.Payload; long allocationSize = long.Parse(Site.Properties["AllocationSizeForFSCC"]); VerifyFileBothDirectoryInformationOfFSCC( bothDirectoryInformation, allocationSize ); bool isNoOtherEntriesFollow = Boolean.Parse(Site.Properties["BsNoOtherEntriesFollowForFSCC"]); VerifyDataTypeFileBothDirectoryInformationOfFSCC(bothDirectoryInformation, isNoOtherEntriesFollow); VerifyMessageSyntaxSmbFindFileBothDirectoryInfo(bothDirectoryInformation); isfinIdBothDirectoryInfo = true; if (bothDirectoryInformation.FileNameLength == uint.MinValue) { isFileIDEqualZero = true; } if (this.smbClientStack.Capability.IsSupportsExtendedSecurity == true) { VerifyMessageSyntaxSmbFindFileBothDirectoryInfo(bothDirectoryInformation); } this.isfinIdBothDirectoryInfo = true; } } else { if (SmbAdapter.fileSystemType == FileSystemType.Fat) { isFileIDEqualZero = true; } else { isFileIDEqualZero = false; } if (this.sutOsVersion == Platform.Win2K3) { isReturnEnumPreviousVersion = false; } else { isReturnEnumPreviousVersion = true; } } if (!this.sId.ContainsValue(trans2FindFirst2ResponseHeader.SID)) { this.sId.Add((uint)(gmtTokenIndex), (uint)trans2FindFirst2ResponseHeader.SID); } VerifyMessageSyntaxTrans2FindFirst2Request( informationLevel, smbTrans2FindFirst2Packet, this.isfindIdFullDirectoryInfo, this.isfinIdBothDirectoryInfo); this.isfindIdFullDirectoryInfo = false; this.isfinIdBothDirectoryInfo = false; this.Trans2FindFirst2Response( smbTrans2FindFirst2ResponseHeader.Mid + this.addMidMark, this.QueryUidTable(smbPacketResponse), this.QueryTidTable(smbPacketResponse), (smbPacketResponse).IsSignRequired, isFileIDEqualZero, gmtTokenIndex, isReturnEnumPreviousVersion, (MessageStatus)smbTrans2FindFirst2ResponseHeader.Status, true, true); } #endregion }
public void VerifyDataTypeFileBothDirectoryInformationOfFSCC( FileBothDirectoryInformation FileBothDirectoryInformationData, bool isNoOtherEntriesFollow) { Site.DefaultProtocolDocShortName = "MS-FSCC"; // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1054 "); // // Verify MS-FSCC requirement 1054 // // As the infra parses the packet by using the offset info, it's useless for us to verify if it's // valid again, this rs will be only verifed the size here. const int sizeOfNextEntryOffset = 4; Site.CaptureRequirementIfAreEqual<int>( sizeOfNextEntryOffset, Marshal.SizeOf(FileBothDirectoryInformationData.NextEntryOffset), 1054, @"[In FILE_BOTH_DIR_INFORMATION]NextEntryOffset (4 bytes): A 32-bit unsigned integer that contains the byte offset from the beginning of this entry, at which the next FILE_BOTH_DIR_INFORMATION entry is located, if multiple entries are present in a buffer."); // If no other entries follow this element. if (isNoOtherEntriesFollow) { // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1055, actual NextEntryOffset:{0}.", FileBothDirectoryInformationData.NextEntryOffset); // // Verify MS-FSCC requirement 1055 // Site.CaptureRequirementIfIsTrue( FileBothDirectoryInformationData.NextEntryOffset == 0 && Marshal.SizeOf(FileBothDirectoryInformationData.NextEntryOffset) == sizeOfNextEntryOffset, 1055, @"[In FILE_BOTH_DIR_INFORMATION]NextEntryOffset (4 bytes): This member is zero if no other entries follow this one."); } // if multiple entries are present in a buffer else { // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1056, actual NextEntryOffset:{0}.", FileBothDirectoryInformationData.NextEntryOffset); // // Verify MS-FSCC requirement 1056 // // This rs is informative in fact, and will be only verified the size, as the FILE_BOTH_DIR_INFORMATION structure we used // is parsed according to this offset information. Site.CaptureRequirementIfAreEqual<int>( sizeOfNextEntryOffset, Marshal.SizeOf(FileBothDirectoryInformationData.NextEntryOffset), 1056, @"[In FILE_BOTH_DIR_INFORMATION]NextEntryOffset (4 bytes): An implementation MUST use this value to determine the location of the next entry (if multiple entries are present in a buffer)."); } #region this rs will be coverd when all the elements have been verified // // Verify MS-FSCC requirement 1053 // // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1053 "); // As all the elements in the structure have been verified above. // This rs will be captured directly. Site.CaptureRequirement( 1053, @"[In FileBothDirectoryInformation]The FILE_BOTH_DIR_INFORMATION data element is as follows [NextEntryOffset, FileIndex, CreationTime, ..., LastAccessTime, ..., LastWriteTime, ..., ChangeTime, ..., EndOfFile, ..., AllocationSize, ..., FileAttributes, FileNameLength, EaSize, ShortNameLength, Reserved, ShortName, ..., ..., ..., ..., ..., ..., FileName (variable), ...]. "); #endregion Site.DefaultProtocolDocShortName = Site.Properties["ProtocolShortName"]; }