NOPInPDU.cs 1.7 KB

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