ConnectionParameters.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 System.Net;
  11. using Utilities;
  12. namespace ISCSI.Server
  13. {
  14. public class TransferEntry
  15. {
  16. public SCSICommandPDU Command;
  17. public uint NextR2TSN;
  18. public TransferEntry(SCSICommandPDU command, uint nextR2TSN)
  19. {
  20. Command = command;
  21. NextR2TSN = nextR2TSN;
  22. }
  23. }
  24. public class ConnectionParameters
  25. {
  26. public ushort CID; // connection ID, generated by the initiator
  27. public string InitiatorName = String.Empty;
  28. public IPEndPoint InitiatorEndPoint;
  29. public int InitiatorMaxRecvDataSegmentLength = DefaultParameters.Connection.MaxRecvDataSegmentLength;
  30. public int TargetMaxRecvDataSegmentLength = ISCSIServer.DeclaredParameters.MaxRecvDataSegmentLength;
  31. public uint StatSN = 0; // Initial StatSN, any number will do
  32. // Dictionary of current transfers: <transfer-tag, TransferEntry>
  33. private Dictionary<uint, TransferEntry> n_transfers = new Dictionary<uint, TransferEntry>();
  34. public TransferEntry AddTransfer(uint transferTag, SCSICommandPDU command, uint nextR2TSN)
  35. {
  36. TransferEntry entry = new TransferEntry(command, nextR2TSN);
  37. n_transfers.Add(transferTag, entry);
  38. return entry;
  39. }
  40. public TransferEntry GetTransferEntry(uint transferTag)
  41. {
  42. TransferEntry result;
  43. n_transfers.TryGetValue(transferTag, out result);
  44. return result;
  45. }
  46. public void RemoveTransfer(uint transferTag)
  47. {
  48. n_transfers.Remove(transferTag);
  49. }
  50. }
  51. }