X11ForwardingRequestInfo.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. namespace Renci.SshNet.Messages.Connection
  2. {
  3. /// <summary>
  4. /// Represents "x11-req" type channel request information
  5. /// </summary>
  6. internal class X11ForwardingRequestInfo : RequestInfo
  7. {
  8. /// <summary>
  9. /// Channel request name
  10. /// </summary>
  11. public const string NAME = "x11-req";
  12. /// <summary>
  13. /// Gets the name of the request.
  14. /// </summary>
  15. /// <value>
  16. /// The name of the request.
  17. /// </value>
  18. public override string RequestName
  19. {
  20. get { return X11ForwardingRequestInfo.NAME; }
  21. }
  22. /// <summary>
  23. /// Gets or sets a value indicating whether it is a single connection.
  24. /// </summary>
  25. /// <value>
  26. /// <c>true</c> if it is a single connection; otherwise, <c>false</c>.
  27. /// </value>
  28. public bool IsSingleConnection { get; set; }
  29. /// <summary>
  30. /// Gets or sets the authentication protocol.
  31. /// </summary>
  32. /// <value>
  33. /// The authentication protocol.
  34. /// </value>
  35. public string AuthenticationProtocol { get; set; }
  36. /// <summary>
  37. /// Gets or sets the authentication cookie.
  38. /// </summary>
  39. /// <value>
  40. /// The authentication cookie.
  41. /// </value>
  42. public byte[] AuthenticationCookie { get; set; }
  43. /// <summary>
  44. /// Gets or sets the screen number.
  45. /// </summary>
  46. /// <value>
  47. /// The screen number.
  48. /// </value>
  49. public uint ScreenNumber { get; set; }
  50. /// <summary>
  51. /// Initializes a new instance of the <see cref="X11ForwardingRequestInfo"/> class.
  52. /// </summary>
  53. public X11ForwardingRequestInfo()
  54. {
  55. this.WantReply = true;
  56. }
  57. /// <summary>
  58. /// Initializes a new instance of the <see cref="X11ForwardingRequestInfo"/> class.
  59. /// </summary>
  60. /// <param name="isSingleConnection">if set to <c>true</c> it is a single connection.</param>
  61. /// <param name="protocol">The protocol.</param>
  62. /// <param name="cookie">The cookie.</param>
  63. /// <param name="screenNumber">The screen number.</param>
  64. public X11ForwardingRequestInfo(bool isSingleConnection, string protocol, byte[] cookie, uint screenNumber)
  65. : this()
  66. {
  67. this.IsSingleConnection = isSingleConnection;
  68. this.AuthenticationProtocol = protocol;
  69. this.AuthenticationCookie = cookie;
  70. this.ScreenNumber = screenNumber;
  71. }
  72. /// <summary>
  73. /// Called when type specific data need to be loaded.
  74. /// </summary>
  75. protected override void LoadData()
  76. {
  77. base.LoadData();
  78. this.IsSingleConnection = this.ReadBoolean();
  79. this.AuthenticationProtocol = this.ReadAsciiString();
  80. this.AuthenticationCookie = this.ReadBinaryString();
  81. this.ScreenNumber = this.ReadUInt32();
  82. }
  83. /// <summary>
  84. /// Called when type specific data need to be saved.
  85. /// </summary>
  86. protected override void SaveData()
  87. {
  88. base.SaveData();
  89. this.Write(this.IsSingleConnection);
  90. this.WriteAscii(this.AuthenticationProtocol);
  91. this.WriteBinaryString(this.AuthenticationCookie);
  92. this.Write(this.ScreenNumber);
  93. }
  94. }
  95. }