| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace Renci.SshNet.Messages.Connection |
| | | 4 | | { |
| | | 5 | | internal sealed class TcpIpForwardGlobalRequestMessage : GlobalRequestMessage |
| | | 6 | | { |
| | | 7 | | private byte[] _addressToBind; |
| | | 8 | | |
| | | 9 | | public TcpIpForwardGlobalRequestMessage(string addressToBind, uint portToBind) |
| | 137 | 10 | | : base(Ascii.GetBytes("tcpip-forward"), wantReply: true) |
| | 137 | 11 | | { |
| | 137 | 12 | | AddressToBind = addressToBind; |
| | 137 | 13 | | PortToBind = portToBind; |
| | 137 | 14 | | } |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Gets the address to bind to. |
| | | 18 | | /// </summary> |
| | | 19 | | public string AddressToBind |
| | | 20 | | { |
| | 405 | 21 | | get { return Utf8.GetString(_addressToBind, 0, _addressToBind.Length); } |
| | 411 | 22 | | private set { _addressToBind = Utf8.GetBytes(value); } |
| | | 23 | | } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Gets port number to bind to. |
| | | 27 | | /// </summary> |
| | 274 | 28 | | public uint PortToBind { 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 |
| | 2 | 39 | | { |
| | 2 | 40 | | var capacity = base.BufferCapacity; |
| | 2 | 41 | | capacity += 4; // AddressToBind length |
| | 2 | 42 | | capacity += _addressToBind.Length; // AddressToBind |
| | 2 | 43 | | capacity += 4; // PortToBind |
| | 2 | 44 | | return capacity; |
| | 2 | 45 | | } |
| | | 46 | | } |
| | | 47 | | |
| | | 48 | | /// <summary> |
| | | 49 | | /// Called when type specific data need to be loaded. |
| | | 50 | | /// </summary> |
| | | 51 | | protected override void LoadData() |
| | 0 | 52 | | { |
| | 0 | 53 | | throw new NotImplementedException(); |
| | | 54 | | } |
| | | 55 | | |
| | | 56 | | /// <summary> |
| | | 57 | | /// Called when type specific data need to be saved. |
| | | 58 | | /// </summary> |
| | | 59 | | protected override void SaveData() |
| | 2 | 60 | | { |
| | 2 | 61 | | base.SaveData(); |
| | 2 | 62 | | WriteBinaryString(_addressToBind); |
| | 2 | 63 | | Write(PortToBind); |
| | 2 | 64 | | } |
| | | 65 | | } |
| | | 66 | | } |