| | | 1 | | namespace Renci.SshNet.Messages.Transport |
| | | 2 | | { |
| | | 3 | | /// <summary> |
| | | 4 | | /// Represents SSH_MSG_DEBUG message. |
| | | 5 | | /// </summary> |
| | | 6 | | [Message("SSH_MSG_DEBUG", 4)] |
| | | 7 | | public class DebugMessage : Message |
| | | 8 | | { |
| | | 9 | | private byte[] _message; |
| | | 10 | | private byte[] _language; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Gets a value indicating whether the message to be always displayed. |
| | | 14 | | /// </summary> |
| | | 15 | | /// <value> |
| | | 16 | | /// <see langword="true"/> if the message always to be displayed; otherwise, <see langword="false"/>. |
| | | 17 | | /// </value> |
| | 1280 | 18 | | public bool IsAlwaysDisplay { get; private set; } |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Gets debug message. |
| | | 22 | | /// </summary> |
| | | 23 | | public string Message |
| | | 24 | | { |
| | 0 | 25 | | get { return Utf8.GetString(_message, 0, _message.Length); } |
| | | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Gets message language. |
| | | 30 | | /// </summary> |
| | | 31 | | public string Language |
| | | 32 | | { |
| | 0 | 33 | | get { return Utf8.GetString(_language, 0, _language.Length); } |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Gets the size of the message in bytes. |
| | | 38 | | /// </summary> |
| | | 39 | | /// <value> |
| | | 40 | | /// The size of the messages in bytes. |
| | | 41 | | /// </value> |
| | | 42 | | protected override int BufferCapacity |
| | | 43 | | { |
| | | 44 | | get |
| | 0 | 45 | | { |
| | 0 | 46 | | var capacity = base.BufferCapacity; |
| | 0 | 47 | | capacity += 1; // IsAlwaysDisplay |
| | 0 | 48 | | capacity += 4; // Message length |
| | 0 | 49 | | capacity += _message.Length; // Message |
| | 0 | 50 | | capacity += 4; // Language length |
| | 0 | 51 | | capacity += _language.Length; // Language |
| | 0 | 52 | | return capacity; |
| | 0 | 53 | | } |
| | | 54 | | } |
| | | 55 | | |
| | | 56 | | /// <summary> |
| | | 57 | | /// Called when type specific data need to be loaded. |
| | | 58 | | /// </summary> |
| | | 59 | | protected override void LoadData() |
| | 1280 | 60 | | { |
| | 1280 | 61 | | IsAlwaysDisplay = ReadBoolean(); |
| | 1280 | 62 | | _message = ReadBinary(); |
| | 1280 | 63 | | _language = ReadBinary(); |
| | 1280 | 64 | | } |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Called when type specific data need to be saved. |
| | | 68 | | /// </summary> |
| | | 69 | | protected override void SaveData() |
| | 0 | 70 | | { |
| | 0 | 71 | | Write(IsAlwaysDisplay); |
| | 0 | 72 | | WriteBinaryString(_message); |
| | 0 | 73 | | WriteBinaryString(_language); |
| | 0 | 74 | | } |
| | | 75 | | |
| | | 76 | | internal override void Process(Session session) |
| | 1280 | 77 | | { |
| | 1280 | 78 | | session.OnDebugReceived(this); |
| | 1280 | 79 | | } |
| | | 80 | | } |
| | | 81 | | } |