LogoutResponsePDU.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. public class LogoutResponsePDU : ISCSIPDU
  14. {
  15. public LogoutResponse Response;
  16. public uint StatSN;
  17. public uint ExpCmdSN;
  18. public uint MaxCmdSN;
  19. public ushort TimeToWait;
  20. public ushort TimeToRetain;
  21. public LogoutResponsePDU() : base()
  22. {
  23. OpCode = ISCSIOpCodeName.LogoutResponse;
  24. Final = true;
  25. }
  26. public LogoutResponsePDU(byte[] buffer, int offset) : base(buffer, offset)
  27. {
  28. Response = (LogoutResponse)OpCodeSpecificHeader[1];
  29. StatSN = BigEndianConverter.ToUInt32(OpCodeSpecific, 4);
  30. ExpCmdSN = BigEndianConverter.ToUInt32(OpCodeSpecific, 8);
  31. MaxCmdSN = BigEndianConverter.ToUInt32(OpCodeSpecific, 12);
  32. TimeToWait = BigEndianConverter.ToUInt16(OpCodeSpecific, 20);
  33. TimeToRetain = BigEndianConverter.ToUInt16(OpCodeSpecific, 22);
  34. }
  35. public override byte[] GetBytes()
  36. {
  37. OpCodeSpecificHeader[1] = (byte)Response;
  38. BigEndianWriter.WriteUInt32(OpCodeSpecific, 4, StatSN);
  39. BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpCmdSN);
  40. BigEndianWriter.WriteUInt32(OpCodeSpecific, 12, MaxCmdSN);
  41. BigEndianWriter.WriteUInt16(OpCodeSpecific, 20, TimeToWait);
  42. BigEndianWriter.WriteUInt16(OpCodeSpecific, 22, TimeToRetain);
  43. return base.GetBytes();
  44. }
  45. }
  46. }