ISCSISession.cs 2.3 KB

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