/// <summary> /// Downloads the next portion of a FastTransfer stream. /// </summary> /// <param name="serverId">A 32-bit signed integer represent the Identity of server.</param> /// <param name="downloadHandleIndex">A fast transfer stream object handle index. </param> /// <param name="bufferSize">Specifies the maximum amount of data to be output in the TransferBuffer.</param> /// <param name="transferBufferIndex">The index of data get from the fast transfer stream.</param> /// <param name="abstractFastTransferStream">Fast transfer stream.</param> /// <param name="transferDataSmallOrEqualToBufferSize">Variable to not if the transferData is small or equal to bufferSize</param> /// <returns>Indicate the result of this ROP operation.</returns> public RopResult FastTransferSourceGetBuffer(int serverId, int downloadHandleIndex, BufferSize bufferSize, out int transferBufferIndex, out AbstractFastTransferStream abstractFastTransferStream, out bool transferDataSmallOrEqualToBufferSize) { // Initialize ROP data. SyntacticalBase.AllPropList = null; RopResult returnValue = RopResult.InvalidParameter; this.totalTransferBufferList.Clear(); transferBufferIndex = -1; abstractFastTransferStream = new AbstractFastTransferStream(); transferDataSmallOrEqualToBufferSize = false; if (downloadHandleIndex < 0) { return returnValue; } if (bufferSize == BufferSize.Greater && !Common.IsRequirementEnabled(2625, this.Site)) { returnValue = RopResult.BufferTooSmall; return returnValue; } RopFastTransferSourceGetBufferResponse response = new RopFastTransferSourceGetBufferResponse(); uint sourceHandle = this.handleContainer[downloadHandleIndex]; uint downloadContextHandle = sourceHandle; // Construct ROP request. RopFastTransferSourceGetBufferRequest fastTransferSourceGetBufferRequest; fastTransferSourceGetBufferRequest.RopId = 0x4e; fastTransferSourceGetBufferRequest.LogonId = 0x00; fastTransferSourceGetBufferRequest.InputHandleIndex = 0x00; fastTransferSourceGetBufferRequest.BufferSize = (ushort)bufferSize; if (bufferSize != BufferSize.Normal) { fastTransferSourceGetBufferRequest.MaximumBufferSize = null; } else { fastTransferSourceGetBufferRequest.MaximumBufferSize = (ushort)bufferSize; } bool isRunIntoPartial = false; bool isRunIntoNoRoom = false; do { IDeserializable tempRopResponse = null; if ((tempRopResponse = this.Process(serverId, fastTransferSourceGetBufferRequest, downloadContextHandle)) != null) { // Send request and get response. response = (RopFastTransferSourceGetBufferResponse)tempRopResponse; byte[] transferBuffer = new byte[(int)response.TransferBufferSize]; if (response.ReturnValue == 0) { if (bufferSize != BufferSize.Normal) { transferDataSmallOrEqualToBufferSize = transferBuffer.Length <= (int)bufferSize; } for (int i = 0; i < (int)response.TransferBufferSize; i++) { transferBuffer[i] = response.TransferBuffer[i]; } this.totalTransferBufferList.Add(transferBuffer); if (response.TransferStatus == (ushort)TransferStatus.Partial) { isRunIntoPartial = true; } if (response.TransferStatus == (ushort)TransferStatus.NoRoom) { isRunIntoNoRoom = true; } } } else { break; } } while (response.TransferStatus != (ushort)TransferStatus.Done && (RopResult)response.ReturnValue == RopResult.Success); if (response.TransferBuffer == null) { returnValue = (RopResult)this.ropResult; } else { returnValue = (RopResult)response.ReturnValue; } bool isReachedBufferTooSmall = (bufferSize == BufferSize.Greater) && (returnValue == RopResult.BufferTooSmall); this.VerifyTransferStatus(isRunIntoPartial, isRunIntoNoRoom, isReachedBufferTooSmall); if (isReachedBufferTooSmall) { this.previousGetBufferResult = RopResult.BufferTooSmall; } if (response.TransferStatus == (ushort)TransferStatus.Done) { returnValue = RopResult.Success; int bufferlength = 0; foreach (byte[] blengt in this.totalTransferBufferList) { bufferlength += blengt.Length; } byte[] totalTransferBuffer = new byte[bufferlength]; int index = 0; foreach (byte[] buffer in this.totalTransferBufferList) { Array.Copy(buffer, 0, totalTransferBuffer, index, buffer.Length); index += buffer.Length; } byte[] requiredTransferBuffer = this.ProcessFXSourceGetBuffer(totalTransferBuffer); using (FastTransferStream fs = new FastTransferStream(requiredTransferBuffer, true)) { // Verify FastTransfer Stream this.VerifyFastTransferStream(fs, this.streamType); } abstractFastTransferStream = this.GenerateAbstractFastTransferStream(serverId, requiredTransferBuffer); if (bufferSize == BufferSize.Greater) { transferBufferIndex = -1; } else { transferBufferIndex = AdapterHelper.GetStreamBufferIndex(); } int k = this.streamBufferContainer.Count; foreach (byte[] subBuffer in this.totalTransferBufferList) { this.streamBufferContainer.Add(++k, subBuffer); } } if (response.RopId != 0x00) { // Verify ROP FastTransferSourceGetBuffer this.VerifyRopFastTransferSourceGetBuffer(response); } return returnValue; }
/// <summary> /// Verify ropFastTransferSourceGetBufferResponse Response /// </summary> /// <param name="ropFastTransferSourceGetBufferResponse">The response of RopFastTransferSourceGetBufferResponse request</param> /// <param name="inputHandleIndex">The field of InputHandleIndex in RopFastTransferSourceGetBufferResponse request</param> private void VerifyRopFastTransferSourceGetBufferResponse(RopFastTransferSourceGetBufferResponse ropFastTransferSourceGetBufferResponse, byte inputHandleIndex) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3724"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3724 Site.CaptureRequirementIfAreEqual<Type>( typeof(byte), ropFastTransferSourceGetBufferResponse.RopId.GetType(), 3724, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer] RopId (1 byte): An unsigned integer."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3726"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3726 Site.CaptureRequirementIfAreEqual<byte>( (byte)RopId.RopFastTransferSourceGetBuffer, ropFastTransferSourceGetBufferResponse.RopId, 3726, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer, RopId (1 byte):] For this operation [RopFastTransferSourceGetBuffer] this field is set to 0x4E."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3727"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3727 Site.CaptureRequirementIfAreEqual<Type>( typeof(byte), ropFastTransferSourceGetBufferResponse.InputHandleIndex.GetType(), 3727, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer] InputHandleIndex (1 byte): An unsigned integer."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3728"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3728 Site.CaptureRequirementIfAreEqual<byte>( inputHandleIndex, ropFastTransferSourceGetBufferResponse.InputHandleIndex, 3728, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer, InputHandleIndex (1 byte):] This index MUST be set to the value specified in the InputHandleIndex field in the request."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3730"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3730 Site.CaptureRequirementIfAreEqual<Type>( typeof(uint), ropFastTransferSourceGetBufferResponse.ReturnValue.GetType(), 3730, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer] ReturnValue (4 bytes): An unsigned integer."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3732"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3732 Site.CaptureRequirementIfAreEqual<Type>( typeof(ushort), ropFastTransferSourceGetBufferResponse.TransferStatus.GetType(), 3732, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer]TransferStatus (2 bytes): An enumeration."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3733,TransferStatus's value:{0}", ropFastTransferSourceGetBufferResponse.TransferStatus); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3733 bool isVerifyR3733 = (ropFastTransferSourceGetBufferResponse.TransferStatus == (ushort)TransferStatus.Error) || (ropFastTransferSourceGetBufferResponse.TransferStatus == (ushort)TransferStatus.Partial) || (ropFastTransferSourceGetBufferResponse.TransferStatus == (ushort)TransferStatus.Done); Site.CaptureRequirementIfIsTrue( isVerifyR3733, 3733, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer, TransferStatus (2 bytes):] The possible values[the value of Error is 0x0000, the value of Partial is 0x0001 and the value of Done is 0x0003] for this enumeration are specified in [MS-OXCFXICS] section 2.2.3.1.1.5.2. "); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3736"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3736 Site.CaptureRequirementIfAreEqual<Type>( typeof(ushort), ropFastTransferSourceGetBufferResponse.InProgressCount.GetType(), 3736, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer]InProgressCount (2 bytes): An unsigned integer."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3738"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3738 Site.CaptureRequirementIfAreEqual<Type>( typeof(ushort), ropFastTransferSourceGetBufferResponse.TotalStepCount.GetType(), 3738, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer]TotalStepCount (2 bytes): An unsigned integer."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3741,the Reserved's value:{0}", ropFastTransferSourceGetBufferResponse.Reserved); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3741 bool isVerifyR3741 = (ropFastTransferSourceGetBufferResponse.Reserved.GetType() == typeof(byte)) && (ropFastTransferSourceGetBufferResponse.Reserved == ReservedOneByte); Site.CaptureRequirementIfIsTrue( isVerifyR3741, 3741, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer, Reserved (1 byte):] The server MUST set this field to 0x00."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3740"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3740 Site.CaptureRequirementIfAreEqual<Type>( typeof(byte), ropFastTransferSourceGetBufferResponse.Reserved.GetType(), 3740, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer] Reserved (1 byte): Reserved."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3742"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3742 Site.CaptureRequirementIfAreEqual<Type>( typeof(ushort), ropFastTransferSourceGetBufferResponse.TransferBufferSize.GetType(), 3742, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer]TransferBufferSize (2 bytes): An unsigned integer."); if (ropFastTransferSourceGetBufferResponse.ReturnValue != ReturnValueForRopFastTransferSourceGetBufferResponse) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3745"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3745 // The ropFastTransferSourceGetBufferResponse.TransferBuffer isNotNull, indicating this filed is present. Site.CaptureRequirementIfIsNotNull( ropFastTransferSourceGetBufferResponse.TransferBuffer, 3745, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer, TransferBuffer (variable):] That is present if the ReturnValue is not 0x00000480."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3746"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3746 // When the return value is not 0x00000480,TransferBuffer present. Site.CaptureRequirementIfAreEqual<ushort>( ropFastTransferSourceGetBufferResponse.TransferBufferSize, (ushort)ropFastTransferSourceGetBufferResponse.TransferBuffer.Length, 3746, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer, TransferBuffer (variable):] If present, the size of this field, in bytes, is specified by the TransferBufferSize field."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3744"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3744 Site.CaptureRequirementIfAreEqual<Type>( typeof(byte[]), ropFastTransferSourceGetBufferResponse.TransferBuffer.GetType(), 3744, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer]TransferBuffer (variable): An array of bytes."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCROPS_R3957"); // Verify MS-OXCROPS requirement: MS-OXCROPS_R3957 // When the value of the BackoffTime is null indicating this filed is not present. // Else the value of this filed is not equal null Site.CaptureRequirementIfIsTrue( ropFastTransferSourceGetBufferResponse.BackoffTime == null, 3957, @"[In RopFastTransferSourceGetBuffer ROP Response Buffer, BackoffTime (4 bytes):This field is] not present otherwise[if the ReturnValue is not 0x00000480]."); } }