SessionParameters.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. namespace ISCSI.Client
  11. {
  12. public class SessionParameters
  13. {
  14. public const int DefaultMaxBurstLength = 262144;
  15. public const int DefaultFirstBurstLength = 65536;
  16. public ulong ISID; // Initiator Session ID
  17. public ushort TSIH; // Target Session Identifying Handle
  18. public bool InitialR2T;
  19. public bool ImmediateData;
  20. public int MaxBurstLength = DefaultMaxBurstLength;
  21. public int FirstBurstLength = DefaultFirstBurstLength;
  22. public int DefaultTime2Wait;
  23. public int DefaultTime2Retain;
  24. public int MaxOutstandingR2T;
  25. public bool DataPDUInOrder;
  26. public bool DataSequenceInOrder;
  27. public int ErrorRecoveryLevel;
  28. private ushort m_nextCID = 1;
  29. private uint m_nextTaskTag = 1;
  30. private uint m_nextCmdSN = 1;
  31. public ushort GetNextCID()
  32. {
  33. ushort cid = m_nextCID;
  34. m_nextCID++;
  35. return cid;
  36. }
  37. /// <summary>
  38. /// Allocate Initiator Task Tag
  39. /// </summary>
  40. public uint GetNextTaskTag()
  41. {
  42. uint taskTag = m_nextTaskTag;
  43. m_nextTaskTag++;
  44. return taskTag;
  45. }
  46. // CmdSN does not advance after a command marked for immediate delivery is sent
  47. public uint GetNextCmdSN(bool increment)
  48. {
  49. uint cmdSN = m_nextCmdSN;
  50. if (increment)
  51. {
  52. m_nextCmdSN++;
  53. }
  54. return cmdSN;
  55. }
  56. }
  57. }