| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace Renci.SshNet.Messages.Transport |
| | | 4 | | { |
| | | 5 | | /// <summary> |
| | | 6 | | /// Represents SSH_MSG_IGNORE message. |
| | | 7 | | /// </summary> |
| | | 8 | | [Message("SSH_MSG_IGNORE", MessageNumber)] |
| | | 9 | | public class IgnoreMessage : Message |
| | | 10 | | { |
| | | 11 | | internal const byte MessageNumber = 2; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Gets ignore message data if this message has been initialised |
| | | 15 | | /// with data to be sent. Otherwise, returns an empty array. |
| | | 16 | | /// </summary> |
| | 332 | 17 | | public byte[] Data { get; private set; } |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Initializes a new instance of the <see cref="IgnoreMessage"/> class. |
| | | 21 | | /// </summary> |
| | 188 | 22 | | public IgnoreMessage() |
| | 188 | 23 | | { |
| | 188 | 24 | | Data = Array.Empty<byte>(); |
| | 188 | 25 | | } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Initializes a new instance of the <see cref="IgnoreMessage"/> class. |
| | | 29 | | /// </summary> |
| | | 30 | | /// <param name="data">The data.</param> |
| | 78 | 31 | | public IgnoreMessage(byte[] data) |
| | 78 | 32 | | { |
| | 78 | 33 | | if (data is null) |
| | 3 | 34 | | { |
| | 3 | 35 | | throw new ArgumentNullException(nameof(data)); |
| | | 36 | | } |
| | | 37 | | |
| | 75 | 38 | | Data = data; |
| | 75 | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Gets the size of the message in bytes. |
| | | 43 | | /// </summary> |
| | | 44 | | /// <value> |
| | | 45 | | /// The size of the messages in bytes. |
| | | 46 | | /// </value> |
| | | 47 | | protected override int BufferCapacity |
| | | 48 | | { |
| | | 49 | | get |
| | 27 | 50 | | { |
| | 27 | 51 | | var capacity = base.BufferCapacity; |
| | 27 | 52 | | capacity += 4; // Data length |
| | 27 | 53 | | capacity += Data.Length; // Data |
| | 27 | 54 | | return capacity; |
| | 27 | 55 | | } |
| | | 56 | | } |
| | | 57 | | |
| | | 58 | | /// <summary> |
| | | 59 | | /// Called when type specific data need to be loaded. |
| | | 60 | | /// </summary> |
| | | 61 | | protected override void LoadData() |
| | 4 | 62 | | { |
| | | 63 | | // Do nothing - this data is supposed to be ignored. |
| | 4 | 64 | | } |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Called when type specific data need to be saved. |
| | | 68 | | /// </summary> |
| | | 69 | | protected override void SaveData() |
| | 27 | 70 | | { |
| | 27 | 71 | | WriteBinaryString(Data); |
| | 27 | 72 | | } |
| | | 73 | | |
| | | 74 | | internal override void Process(Session session) |
| | 1 | 75 | | { |
| | 1 | 76 | | session.OnIgnoreReceived(this); |
| | 1 | 77 | | } |
| | | 78 | | } |
| | | 79 | | } |