NOPOutPDU.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. // NOP-Out = Sent from the initiator to the target
  14. public class NOPOutPDU : ISCSIPDU
  15. {
  16. public LUNStructure LUN;
  17. public uint TargetTransferTag;
  18. public uint CmdSN;
  19. public uint ExpStatSN;
  20. public NOPOutPDU()
  21. {
  22. OpCode = ISCSIOpCodeName.NOPOut;
  23. Final = true;
  24. }
  25. public NOPOutPDU(byte[] buffer) : base(buffer)
  26. {
  27. LUN = new LUNStructure(LUNOrOpCodeSpecific, 0);
  28. TargetTransferTag = BigEndianConverter.ToUInt32(OpCodeSpecific, 0);
  29. CmdSN = BigEndianConverter.ToUInt32(OpCodeSpecific, 4);
  30. ExpStatSN = BigEndianConverter.ToUInt32(OpCodeSpecific, 8);
  31. }
  32. public override byte[] GetBytes()
  33. {
  34. LUNOrOpCodeSpecific = LUN.GetBytes();
  35. Array.Copy(BigEndianConverter.GetBytes(TargetTransferTag), 0, OpCodeSpecific, 0, 4);
  36. Array.Copy(BigEndianConverter.GetBytes(CmdSN), 0, OpCodeSpecific, 4, 4);
  37. Array.Copy(BigEndianConverter.GetBytes(ExpStatSN), 0, OpCodeSpecific, 8, 4);
  38. return base.GetBytes();
  39. }
  40. }
  41. }