SCSIDataOutPDU.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 SCSI;
  11. using Utilities;
  12. namespace ISCSI
  13. {
  14. // Data-Out = Data sent to the target (WRITE operations)
  15. public class SCSIDataOutPDU : ISCSIPDU
  16. {
  17. public LUNStructure LUN;
  18. public uint TargetTransferTag;
  19. public uint ExpStatSN;
  20. public uint DataSN;
  21. public uint BufferOffset;
  22. public SCSIDataOutPDU()
  23. {
  24. OpCode = ISCSIOpCodeName.SCSIDataOut;
  25. }
  26. public SCSIDataOutPDU(byte[] buffer, int offset) : base(buffer, offset)
  27. {
  28. LUN = new LUNStructure(LUNOrOpCodeSpecific, 0);
  29. TargetTransferTag = BigEndianConverter.ToUInt32(OpCodeSpecific, 0);
  30. ExpStatSN = BigEndianConverter.ToUInt32(OpCodeSpecific, 8);
  31. DataSN = BigEndianConverter.ToUInt32(OpCodeSpecific, 16);
  32. BufferOffset = BigEndianConverter.ToUInt32(OpCodeSpecific, 20);
  33. }
  34. public override byte[] GetBytes()
  35. {
  36. LUNOrOpCodeSpecific = LUN.GetBytes();
  37. BigEndianWriter.WriteUInt32(OpCodeSpecific, 0, TargetTransferTag);
  38. BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpStatSN);
  39. BigEndianWriter.WriteUInt32(OpCodeSpecific, 16, DataSN);
  40. BigEndianWriter.WriteUInt32(OpCodeSpecific, 20, BufferOffset);
  41. return base.GetBytes();
  42. }
  43. }
  44. }