private void InvalidOffset(VariableType variableType, InvalidOffsetType offsetType) { ConnectToVHD(); STORAGE_QOS_CONTROL_Response?sqosResponse; STORAGE_QOS_CONTROL_Request sqosRequest = client.ConstructSqosRequest( SqosConst.STORAGE_QOS_VERSION_1, SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_PROBE_POLICY, Guid.NewGuid(), TestConfig.SqosPolicyId, Guid.NewGuid(), TestConfig.SqosInitiatorName, TestConfig.SqosInitiatorNodeName); ushort invalidOffset = 0; ushort nameLength = variableType == VariableType.InitiatorName ? sqosRequest.InitiatorNameLength : sqosRequest.InitiatorNodeNameLength; int requestSize = TypeMarshal.ToBytes <STORAGE_QOS_CONTROL_Request>(sqosRequest).Length; if (offsetType == InvalidOffsetType.Large) { // Set the offset to make the sum of Length and offset be greater than RequestSize. invalidOffset = (ushort)(requestSize - nameLength + 1); } if (variableType == VariableType.InitiatorName) { sqosRequest.InitiatorNameOffset = invalidOffset; } else { sqosRequest.InitiatorNodeNameOffset = invalidOffset; } BaseTestSite.Log.Add( LogEntryKind.TestStep, "Client sends an SQOS request with {0}Offset set to {1} and expects STATUS_INVALID_PARAMETER", variableType, invalidOffset); uint status = client.SendAndReceiveSqosPacket( treeId, fileId, sqosRequest, out sqosResponse, checker: (header, response) => { }); string failReason = offsetType == InvalidOffsetType.Small ? String.Format( "if Request.{0}Length:{1} is greater than 0 and Request.{0}Offset:{2} is less than 104.", variableType, nameLength, invalidOffset) : String.Format( "if (Request.{0}Length:{1} + Request.{0}Offset:{2}) is greater than RequestSize:{3}.", variableType, nameLength, invalidOffset, requestSize); if (TestConfig.Platform == Platform.WindowsServer10 && status != Smb2Status.STATUS_INVALID_PARAMETER) { } else { BaseTestSite.Assert.AreEqual( (uint)Smb2Status.STATUS_INVALID_PARAMETER, status, "3.2.5.1.2: The server MUST fail the request with error STATUS_INVALID_PARAMETER " + failReason); } }
private void InvalidOffset(VariableType variableType, InvalidOffsetType offsetType) { ConnectToVHD(); SqosResponsePacket sqosResponse; SqosRequestPacket sqosRequest = new SqosRequestPacket(TestConfig.SqosClientDialect == SQOS_PROTOCOL_VERSION.Sqos10 ? SqosRequestType.V10 : SqosRequestType.V11, (ushort)TestConfig.SqosClientDialect, SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_PROBE_POLICY, Guid.NewGuid(), TestConfig.SqosPolicyId, Guid.NewGuid(), TestConfig.SqosInitiatorName, TestConfig.SqosInitiatorNodeName); ushort invalidOffset = 0; int nameLength = variableType == VariableType.InitiatorName ? TestConfig.SqosInitiatorName.Length : TestConfig.SqosInitiatorNodeName.Length; int requestSize = sqosRequest.ToBytes().Length; if (offsetType == InvalidOffsetType.Large) { // Set the offset to make the sum of Length and offset be greater than RequestSize. invalidOffset = (ushort)(requestSize - nameLength + 1); } if (variableType == VariableType.InitiatorName) { sqosRequest.InitiatorNameOffset = invalidOffset; } else { sqosRequest.InitiatorNodeNameOffset = invalidOffset; } BaseTestSite.Log.Add( LogEntryKind.TestStep, "Client sends an SQOS request with {0}Offset set to {1} and expects STATUS_INVALID_PARAMETER", variableType, invalidOffset); uint status = client.SendAndReceiveSqosPacket( sqosRequest, out sqosResponse); string failReason = offsetType == InvalidOffsetType.Small ? String.Format( "if Request.{0}Length:{1} is greater than 0 and Request.{0}Offset:{2} is less than 104.", variableType, nameLength, invalidOffset) : String.Format( "if (Request.{0}Length:{1} + Request.{0}Offset:{2}) is greater than RequestSize:{3}.", variableType, nameLength, invalidOffset, requestSize); BaseTestSite.Assert.AreEqual( (uint)Smb2Status.STATUS_INVALID_PARAMETER, status, "3.2.5.1.2: The server MUST fail the request with error STATUS_INVALID_PARAMETER " + failReason); }
private void InvalidOffset(VariableType variableType, InvalidOffsetType offsetType) { ConnectToVHD(); STORAGE_QOS_CONTROL_Response? sqosResponse; STORAGE_QOS_CONTROL_Request sqosRequest = client.ConstructSqosRequest( SqosConst.STORAGE_QOS_VERSION_1, SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_PROBE_POLICY, Guid.NewGuid(), TestConfig.SqosPolicyId, Guid.NewGuid(), TestConfig.SqosInitiatorName, TestConfig.SqosInitiatorNodeName); ushort invalidOffset = 0; ushort nameLength = variableType == VariableType.InitiatorName ? sqosRequest.InitiatorNameLength : sqosRequest.InitiatorNodeNameLength; int requestSize = TypeMarshal.ToBytes<STORAGE_QOS_CONTROL_Request>(sqosRequest).Length; if (offsetType == InvalidOffsetType.Large) { // Set the offset to make the sum of Length and offset be greater than RequestSize. invalidOffset = (ushort)(requestSize - nameLength + 1); } if (variableType == VariableType.InitiatorName) { sqosRequest.InitiatorNameOffset = invalidOffset; } else { sqosRequest.InitiatorNodeNameOffset = invalidOffset; } BaseTestSite.Log.Add( LogEntryKind.TestStep, "Client sends an SQOS request with {0}Offset set to {1} and expects STATUS_INVALID_PARAMETER", variableType, invalidOffset); uint status = client.SendAndReceiveSqosPacket( treeId, fileId, sqosRequest, out sqosResponse, checker: (header, response) => { }); string failReason = offsetType == InvalidOffsetType.Small ? String.Format( "if Request.{0}Length:{1} is greater than 0 and Request.{0}Offset:{2} is less than 104.", variableType, nameLength, invalidOffset) : String.Format( "if (Request.{0}Length:{1} + Request.{0}Offset:{2}) is greater than RequestSize:{3}.", variableType, nameLength, invalidOffset, requestSize); if (TestConfig.Platform == Platform.WindowsServer2016 && status != Smb2Status.STATUS_INVALID_PARAMETER) { } else { BaseTestSite.Assert.AreEqual( (uint)Smb2Status.STATUS_INVALID_PARAMETER, status, "3.2.5.1.2: The server MUST fail the request with error STATUS_INVALID_PARAMETER " + failReason); } }