NOPInPDU.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 Utilities;
  11. namespace ISCSI
  12. {
  13. // NOP-Out = Sent back from the target to the initiator (in response to a NOP-In PDU)
  14. public class NOPInPDU : ISCSIPDU
  15. {
  16. public LUNStructure LUN;
  17. public uint TargetTransferTag;
  18. public uint StatSN;
  19. public uint ExpCmdSN;
  20. public uint MaxCmdSN;
  21. public NOPInPDU()
  22. {
  23. OpCode = ISCSIOpCodeName.NOPIn;
  24. Final = true;
  25. }
  26. public NOPInPDU(byte[] buffer) : base(buffer)
  27. {
  28. LUN = new LUNStructure(LUNOrOpCodeSpecific, 0);
  29. TargetTransferTag = BigEndianConverter.ToUInt32(OpCodeSpecific, 0);
  30. StatSN = BigEndianConverter.ToUInt32(OpCodeSpecific, 4);
  31. ExpCmdSN = BigEndianConverter.ToUInt32(OpCodeSpecific, 8);
  32. MaxCmdSN = BigEndianConverter.ToUInt32(OpCodeSpecific, 12);
  33. }
  34. public override byte[] GetBytes()
  35. {
  36. LUNOrOpCodeSpecific = LUN.GetBytes();
  37. Array.Copy(BigEndianConverter.GetBytes(TargetTransferTag), 0, OpCodeSpecific, 0, 4);
  38. Array.Copy(BigEndianConverter.GetBytes(StatSN), 0, OpCodeSpecific, 4, 4);
  39. Array.Copy(BigEndianConverter.GetBytes(ExpCmdSN), 0, OpCodeSpecific, 8, 4);
  40. Array.Copy(BigEndianConverter.GetBytes(MaxCmdSN), 0, OpCodeSpecific, 12, 4);
  41. return base.GetBytes();
  42. }
  43. }
  44. }