< Summary

Information
Class: Renci.SshNet.Messages.Connection.DirectTcpipChannelInfo
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Connection\ChannelOpen\DirectTcpipChannelInfo.cs
Line coverage
100%
Covered lines: 42
Uncovered lines: 0
Coverable lines: 42
Total lines: 129
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_ChannelType()100%1100%
get_HostToConnect()100%1100%
set_HostToConnect(...)100%1100%
get_PortToConnect()100%1100%
get_OriginatorAddress()100%1100%
set_OriginatorAddress(...)100%1100%
get_OriginatorPort()100%1100%
get_BufferCapacity()100%1100%
.ctor(...)100%1100%
.ctor(...)100%1100%
LoadData()100%1100%
SaveData()100%1100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Connection\ChannelOpen\DirectTcpipChannelInfo.cs

#LineLine coverage
 1using System;
 2
 3namespace Renci.SshNet.Messages.Connection
 4{
 5    /// <summary>
 6    /// Used to open "direct-tcpip" channel type.
 7    /// </summary>
 8    internal sealed class DirectTcpipChannelInfo : ChannelOpenInfo
 9    {
 10        private byte[] _hostToConnect;
 11        private byte[] _originatorAddress;
 12
 13        /// <summary>
 14        /// Specifies channel open type.
 15        /// </summary>
 16        public const string NAME = "direct-tcpip";
 17
 18        /// <summary>
 19        /// Gets the type of the channel to open.
 20        /// </summary>
 21        /// <value>
 22        /// The type of the channel to open.
 23        /// </value>
 24        public override string ChannelType
 25        {
 16526            get { return NAME; }
 27        }
 28
 29        /// <summary>
 30        /// Gets the host to connect.
 31        /// </summary>
 32        public string HostToConnect
 33        {
 6334            get { return Utf8.GetString(_hostToConnect, 0, _hostToConnect.Length); }
 12935            private set { _hostToConnect = Utf8.GetBytes(value); }
 36        }
 37
 38        /// <summary>
 39        /// Gets the port to connect.
 40        /// </summary>
 11341        public uint PortToConnect { get; private set; }
 42
 43        /// <summary>
 44        /// Gets the originator address.
 45        /// </summary>
 46        public string OriginatorAddress
 47        {
 6348            get { return Utf8.GetString(_originatorAddress, 0, _originatorAddress.Length); }
 12949            private set { _originatorAddress = Utf8.GetBytes(value); }
 50        }
 51
 52        /// <summary>
 53        /// Gets the originator port.
 54        /// </summary>
 11355        public uint OriginatorPort { get; private set; }
 56
 57        /// <summary>
 58        /// Gets the size of the message in bytes.
 59        /// </summary>
 60        /// <value>
 61        /// The size of the messages in bytes.
 62        /// </value>
 63        protected override int BufferCapacity
 64        {
 65            get
 4666            {
 4667                var capacity = base.BufferCapacity;
 4668                capacity += 4; // HostToConnect length
 4669                capacity += _hostToConnect.Length; // HostToConnect
 4670                capacity += 4; // PortToConnect
 4671                capacity += 4; // OriginatorAddress length
 4672                capacity += _originatorAddress.Length; // OriginatorAddress
 4673                capacity += 4; // OriginatorPort
 4674                return capacity;
 4675            }
 76        }
 77
 78        /// <summary>
 79        /// Initializes a new instance of the <see cref="DirectTcpipChannelInfo"/> class from the
 80        /// specified data.
 81        /// </summary>
 82        /// <exception cref="ArgumentNullException"><paramref name="data"/> is <see langword="null"/>.</exception>
 383        public DirectTcpipChannelInfo(byte[] data)
 384        {
 385            Load(data);
 386        }
 87
 88        /// <summary>
 89        /// Initializes a new instance of the <see cref="DirectTcpipChannelInfo"/> class.
 90        /// </summary>
 91        /// <param name="hostToConnect">The host to connect.</param>
 92        /// <param name="portToConnect">The port to connect.</param>
 93        /// <param name="originatorAddress">The originator address.</param>
 94        /// <param name="originatorPort">The originator port.</param>
 4395        public DirectTcpipChannelInfo(string hostToConnect, uint portToConnect, string originatorAddress, uint originato
 4396        {
 4397            HostToConnect = hostToConnect;
 4398            PortToConnect = portToConnect;
 4399            OriginatorAddress = originatorAddress;
 43100            OriginatorPort = originatorPort;
 43101        }
 102
 103        /// <summary>
 104        /// Called when type specific data need to be loaded.
 105        /// </summary>
 106        protected override void LoadData()
 3107        {
 3108            base.LoadData();
 109
 3110            _hostToConnect = ReadBinary();
 3111            PortToConnect = ReadUInt32();
 3112            _originatorAddress = ReadBinary();
 3113            OriginatorPort = ReadUInt32();
 3114        }
 115
 116        /// <summary>
 117        /// Called when type specific data need to be saved.
 118        /// </summary>
 119        protected override void SaveData()
 46120        {
 46121            base.SaveData();
 122
 46123            WriteBinaryString(_hostToConnect);
 46124            Write(PortToConnect);
 46125            WriteBinaryString(_originatorAddress);
 46126            Write(OriginatorPort);
 46127        }
 128    }
 129}