NOPOutPDU.cs 1.6 KB

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