| | | 1 | | namespace Renci.SshNet.Messages.Connection |
| | | 2 | | { |
| | | 3 | | /// <summary> |
| | | 4 | | /// Represents SSH_MSG_GLOBAL_REQUEST message. |
| | | 5 | | /// </summary> |
| | | 6 | | [Message("SSH_MSG_GLOBAL_REQUEST", 80)] |
| | | 7 | | public class GlobalRequestMessage : Message |
| | | 8 | | { |
| | | 9 | | private byte[] _requestName; |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Gets the name of the request. |
| | | 13 | | /// </summary> |
| | | 14 | | /// <value> |
| | | 15 | | /// The name of the request. |
| | | 16 | | /// </value> |
| | | 17 | | public string RequestName |
| | | 18 | | { |
| | 18 | 19 | | get { return Ascii.GetString(_requestName, 0, _requestName.Length); } |
| | | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// Gets a value indicating whether message reply should be sent.. |
| | | 24 | | /// </summary> |
| | | 25 | | /// <value> |
| | | 26 | | /// <see langword="true"/> if message reply should be sent; otherwise, <see langword="false"/>. |
| | | 27 | | /// </value> |
| | 1450 | 28 | | public bool WantReply { get; private set; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Gets the size of the message in bytes. |
| | | 32 | | /// </summary> |
| | | 33 | | /// <value> |
| | | 34 | | /// The size of the messages in bytes. |
| | | 35 | | /// </value> |
| | | 36 | | protected override int BufferCapacity |
| | | 37 | | { |
| | | 38 | | get |
| | 7 | 39 | | { |
| | 7 | 40 | | var capacity = base.BufferCapacity; |
| | 7 | 41 | | capacity += 4; // RequestName length |
| | 7 | 42 | | capacity += _requestName.Length; // RequestName |
| | 7 | 43 | | capacity += 1; // WantReply |
| | 7 | 44 | | return capacity; |
| | 7 | 45 | | } |
| | | 46 | | } |
| | | 47 | | |
| | | 48 | | /// <summary> |
| | | 49 | | /// Initializes a new instance of the <see cref="GlobalRequestMessage"/> class. |
| | | 50 | | /// </summary> |
| | 1157 | 51 | | public GlobalRequestMessage() |
| | 1157 | 52 | | { |
| | 1157 | 53 | | } |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// Initializes a new instance of the <see cref="GlobalRequestMessage"/> class. |
| | | 57 | | /// </summary> |
| | | 58 | | /// <param name="requestName">Name of the request.</param> |
| | | 59 | | /// <param name="wantReply">if set to <see langword="true"/> [want reply].</param> |
| | 283 | 60 | | internal GlobalRequestMessage(byte[] requestName, bool wantReply) |
| | 283 | 61 | | { |
| | 283 | 62 | | _requestName = requestName; |
| | 283 | 63 | | WantReply = wantReply; |
| | 283 | 64 | | } |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Called when type specific data need to be loaded. |
| | | 68 | | /// </summary> |
| | | 69 | | protected override void LoadData() |
| | 1154 | 70 | | { |
| | 1154 | 71 | | _requestName = ReadBinary(); |
| | 1154 | 72 | | WantReply = ReadBoolean(); |
| | 1154 | 73 | | } |
| | | 74 | | |
| | | 75 | | /// <summary> |
| | | 76 | | /// Called when type specific data need to be saved. |
| | | 77 | | /// </summary> |
| | | 78 | | protected override void SaveData() |
| | 7 | 79 | | { |
| | 7 | 80 | | WriteBinaryString(_requestName); |
| | 7 | 81 | | Write(WantReply); |
| | 7 | 82 | | } |
| | | 83 | | |
| | | 84 | | internal override void Process(Session session) |
| | 1154 | 85 | | { |
| | 1154 | 86 | | session.OnGlobalRequestReceived(this); |
| | 1154 | 87 | | } |
| | | 88 | | } |
| | | 89 | | } |