| | | 1 | | namespace Renci.SshNet.Messages.Connection |
| | | 2 | | { |
| | | 3 | | /// <summary> |
| | | 4 | | /// Represents "subsystem" type channel request information. |
| | | 5 | | /// </summary> |
| | | 6 | | internal sealed class SubsystemRequestInfo : RequestInfo |
| | | 7 | | { |
| | | 8 | | private byte[] _subsystemName; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Channel request name. |
| | | 12 | | /// </summary> |
| | | 13 | | public const string Name = "subsystem"; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Gets the name of the request. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <value> |
| | | 19 | | /// The name of the request. |
| | | 20 | | /// </value> |
| | | 21 | | public override string RequestName |
| | | 22 | | { |
| | 1854 | 23 | | get { return Name; } |
| | | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Gets the name of the subsystem. |
| | | 28 | | /// </summary> |
| | | 29 | | /// <value> |
| | | 30 | | /// The name of the subsystem. |
| | | 31 | | /// </value> |
| | | 32 | | public string SubsystemName |
| | | 33 | | { |
| | 0 | 34 | | get { return Ascii.GetString(_subsystemName, 0, _subsystemName.Length); } |
| | 1854 | 35 | | private set { _subsystemName = Ascii.GetBytes(value); } |
| | | 36 | | } |
| | | 37 | | |
| | | 38 | | protected override int BufferCapacity |
| | | 39 | | { |
| | | 40 | | get |
| | 618 | 41 | | { |
| | 618 | 42 | | var capacity = base.BufferCapacity; |
| | 618 | 43 | | capacity += 4; // SubsystemName length |
| | 618 | 44 | | capacity += _subsystemName.Length; // SubsystemName |
| | 618 | 45 | | return capacity; |
| | 618 | 46 | | } |
| | | 47 | | } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Initializes a new instance of the <see cref="SubsystemRequestInfo"/> class. |
| | | 51 | | /// </summary> |
| | 3422 | 52 | | public SubsystemRequestInfo() |
| | 3422 | 53 | | { |
| | 3422 | 54 | | WantReply = true; |
| | 3422 | 55 | | } |
| | | 56 | | |
| | | 57 | | /// <summary> |
| | | 58 | | /// Initializes a new instance of the <see cref="SubsystemRequestInfo"/> class. |
| | | 59 | | /// </summary> |
| | | 60 | | /// <param name="subsystem">The subsystem.</param> |
| | | 61 | | public SubsystemRequestInfo(string subsystem) |
| | 618 | 62 | | : this() |
| | 618 | 63 | | { |
| | 618 | 64 | | SubsystemName = subsystem; |
| | 618 | 65 | | } |
| | | 66 | | |
| | | 67 | | /// <summary> |
| | | 68 | | /// Called when type specific data need to be loaded. |
| | | 69 | | /// </summary> |
| | | 70 | | protected override void LoadData() |
| | 0 | 71 | | { |
| | 0 | 72 | | base.LoadData(); |
| | | 73 | | |
| | 0 | 74 | | _subsystemName = ReadBinary(); |
| | 0 | 75 | | } |
| | | 76 | | |
| | | 77 | | /// <summary> |
| | | 78 | | /// Called when type specific data need to be saved. |
| | | 79 | | /// </summary> |
| | | 80 | | protected override void SaveData() |
| | 618 | 81 | | { |
| | 618 | 82 | | base.SaveData(); |
| | | 83 | | |
| | 618 | 84 | | WriteBinaryString(_subsystemName); |
| | 618 | 85 | | } |
| | | 86 | | } |
| | | 87 | | } |