using System;
namespace Renci.SshNet.Messages.Connection
{
internal sealed class CancelTcpIpForwardGlobalRequestMessage : GlobalRequestMessage
{
private byte[] _addressToBind;
public CancelTcpIpForwardGlobalRequestMessage(string addressToBind, uint portToBind)
: base(Ascii.GetBytes("cancel-tcpip-forward"), wantReply: true)
{
AddressToBind = addressToBind;
PortToBind = portToBind;
}
///
/// Gets the address to bind to.
///
public string AddressToBind
{
get { return Utf8.GetString(_addressToBind, 0, _addressToBind.Length); }
private set { _addressToBind = Utf8.GetBytes(value); }
}
///
/// Gets port number to bind to.
///
public uint PortToBind { get; private set; }
///
/// Gets the size of the message in bytes.
///
///
/// The size of the messages in bytes.
///
protected override int BufferCapacity
{
get
{
var capacity = base.BufferCapacity;
capacity += 4; // AddressToBind length
capacity += _addressToBind.Length; // AddressToBind
capacity += 4; // PortToBind
return capacity;
}
}
///
/// Called when type specific data need to be loaded.
///
protected override void LoadData()
{
throw new NotImplementedException();
}
///
/// Called when type specific data need to be saved.
///
protected override void SaveData()
{
base.SaveData();
WriteBinaryString(_addressToBind);
Write(PortToBind);
}
}
}