DirectTcpipChannelInfo.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. namespace Renci.SshNet.Messages.Connection
  2. {
  3. /// <summary>
  4. /// Used to open "direct-tcpip" channel type
  5. /// </summary>
  6. internal class DirectTcpipChannelInfo : ChannelOpenInfo
  7. {
  8. /// <summary>
  9. /// Specifies channel open type
  10. /// </summary>
  11. public const string NAME = "direct-tcpip";
  12. /// <summary>
  13. /// Gets the type of the channel to open.
  14. /// </summary>
  15. /// <value>
  16. /// The type of the channel to open.
  17. /// </value>
  18. public override string ChannelType
  19. {
  20. get { return NAME; }
  21. }
  22. /// <summary>
  23. /// Gets the host to connect.
  24. /// </summary>
  25. public string HostToConnect { get; private set; }
  26. /// <summary>
  27. /// Gets the port to connect.
  28. /// </summary>
  29. public uint PortToConnect { get; private set; }
  30. /// <summary>
  31. /// Gets the originator address.
  32. /// </summary>
  33. public string OriginatorAddress { get; private set; }
  34. /// <summary>
  35. /// Gets the originator port.
  36. /// </summary>
  37. public uint OriginatorPort { get; private set; }
  38. /// <summary>
  39. /// Initializes a new instance of the <see cref="DirectTcpipChannelInfo"/> class.
  40. /// </summary>
  41. public DirectTcpipChannelInfo()
  42. {
  43. }
  44. /// <summary>
  45. /// Initializes a new instance of the <see cref="DirectTcpipChannelInfo"/> class.
  46. /// </summary>
  47. /// <param name="hostToConnect">The host to connect.</param>
  48. /// <param name="portToConnect">The port to connect.</param>
  49. /// <param name="originatorAddress">The originator address.</param>
  50. /// <param name="originatorPort">The originator port.</param>
  51. public DirectTcpipChannelInfo(string hostToConnect, uint portToConnect, string originatorAddress, uint originatorPort)
  52. {
  53. HostToConnect = hostToConnect;
  54. PortToConnect = portToConnect;
  55. OriginatorAddress = originatorAddress;
  56. OriginatorPort = originatorPort;
  57. }
  58. /// <summary>
  59. /// Called when type specific data need to be loaded.
  60. /// </summary>
  61. protected override void LoadData()
  62. {
  63. base.LoadData();
  64. HostToConnect = ReadString();
  65. PortToConnect = ReadUInt32();
  66. OriginatorAddress = ReadString();
  67. OriginatorPort = ReadUInt32();
  68. }
  69. /// <summary>
  70. /// Called when type specific data need to be saved.
  71. /// </summary>
  72. protected override void SaveData()
  73. {
  74. base.SaveData();
  75. Write(HostToConnect);
  76. Write(PortToConnect);
  77. Write(OriginatorAddress);
  78. Write(OriginatorPort);
  79. }
  80. }
  81. }