SCSIDataOutPDU.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Copyright (C) 2012-2016 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using Utilities;
  11. namespace ISCSI
  12. {
  13. // Data-Out = Data sent to the target (WRITE operations)
  14. public class SCSIDataOutPDU : ISCSIPDU
  15. {
  16. public LUNStructure LUN;
  17. public uint TargetTransferTag;
  18. public uint ExpStatSN;
  19. public uint DataSN;
  20. public uint BufferOffset;
  21. public SCSIDataOutPDU()
  22. {
  23. OpCode = ISCSIOpCodeName.SCSIDataOut;
  24. }
  25. public SCSIDataOutPDU(byte[] buffer) : base(buffer)
  26. {
  27. LUN = new LUNStructure(LUNOrOpCodeSpecific, 0);
  28. TargetTransferTag = BigEndianConverter.ToUInt32(OpCodeSpecific, 0);
  29. ExpStatSN = BigEndianConverter.ToUInt32(OpCodeSpecific, 8);
  30. DataSN = BigEndianConverter.ToUInt32(OpCodeSpecific, 16);
  31. BufferOffset = BigEndianConverter.ToUInt32(OpCodeSpecific, 20);
  32. }
  33. public override byte[] GetBytes()
  34. {
  35. LUNOrOpCodeSpecific = LUN.GetBytes();
  36. Array.Copy(BigEndianConverter.GetBytes(TargetTransferTag), 0, OpCodeSpecific, 0, 4);
  37. Array.Copy(BigEndianConverter.GetBytes(ExpStatSN), 0, OpCodeSpecific, 8, 4);
  38. Array.Copy(BigEndianConverter.GetBytes(DataSN), 0, OpCodeSpecific, 16, 4);
  39. Array.Copy(BigEndianConverter.GetBytes(BufferOffset), 0, OpCodeSpecific, 20, 4);
  40. return base.GetBytes();
  41. }
  42. }
  43. }