< Summary

Information
Class: Renci.SshNet.Messages.Connection.ForwardedTcpipChannelInfo
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Connection\ChannelOpen\ForwardedTcpipChannelInfo.cs
Line coverage
100%
Covered lines: 42
Uncovered lines: 0
Coverable lines: 42
Total lines: 138
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
.ctor(...)100%1100%
.ctor(...)100%1100%
get_ChannelType()100%1100%
get_ConnectedAddress()100%1100%
set_ConnectedAddress(...)100%1100%
get_ConnectedPort()100%1100%
get_OriginatorAddress()100%1100%
set_OriginatorAddress(...)100%1100%
get_OriginatorPort()100%1100%
get_BufferCapacity()100%1100%
LoadData()100%1100%
SaveData()100%1100%

File(s)

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

#LineLine coverage
 1using System;
 2
 3namespace Renci.SshNet.Messages.Connection
 4{
 5    /// <summary>
 6    /// Used to open "forwarded-tcpip" channel type.
 7    /// </summary>
 8    internal sealed class ForwardedTcpipChannelInfo : ChannelOpenInfo
 9    {
 10        /// <summary>
 11        /// Specifies channel open type.
 12        /// </summary>
 13        public const string NAME = "forwarded-tcpip";
 14
 15        private byte[] _connectedAddress;
 16        private byte[] _originatorAddress;
 17
 18        /// <summary>
 19        /// Initializes a new instance of the <see cref="ForwardedTcpipChannelInfo"/> class from the
 20        /// specified data.
 21        /// </summary>
 22        /// <exception cref="ArgumentNullException"><paramref name="data"/> is <see langword="null"/>.</exception>
 523        public ForwardedTcpipChannelInfo(byte[] data)
 524        {
 525            Load(data);
 526        }
 27
 28        /// <summary>
 29        /// Initializes a new instance of the <see cref="ForwardedTcpipChannelInfo"/> class with the
 30        /// specified connector address and port, and originator address and port.
 31        /// </summary>
 13832        public ForwardedTcpipChannelInfo(string connectedAddress, uint connectedPort, string originatorAddress, uint ori
 13833        {
 13834            ConnectedAddress = connectedAddress;
 13835            ConnectedPort = connectedPort;
 13836            OriginatorAddress = originatorAddress;
 13837            OriginatorPort = originatorPort;
 13838        }
 39
 40        /// <summary>
 41        /// Gets the type of the channel to open.
 42        /// </summary>
 43        /// <value>
 44        /// The type of the channel to open.
 45        /// </value>
 46        public override string ChannelType
 47        {
 44148            get { return NAME; }
 49        }
 50
 51        /// <summary>
 52        /// Gets the connected address.
 53        /// </summary>
 54        /// <value>
 55        /// The connected address.
 56        /// </value>
 57        public string ConnectedAddress
 58        {
 37259            get { return Utf8.GetString(_connectedAddress, 0, _connectedAddress.Length); }
 41460            private set { _connectedAddress = Utf8.GetBytes(value); }
 61        }
 62
 63        /// <summary>
 64        /// Gets the connected port.
 65        /// </summary>
 66        /// <value>
 67        /// The connected port.
 68        /// </value>
 40269        public uint ConnectedPort { get; private set; }
 70
 71        /// <summary>
 72        /// Gets the originator address.
 73        /// </summary>
 74        /// <value>
 75        /// The originator address.
 76        /// </value>
 77        public string OriginatorAddress
 78        {
 20479            get { return Utf8.GetString(_originatorAddress, 0, _originatorAddress.Length); }
 41480            private set { _originatorAddress = Utf8.GetBytes(value); }
 81        }
 82
 83        /// <summary>
 84        /// Gets the originator port.
 85        /// </summary>
 86        /// <value>
 87        /// The originator port.
 88        /// </value>
 34989        public uint OriginatorPort { get; private set; }
 90
 91        /// <summary>
 92        /// Gets the size of the message in bytes.
 93        /// </summary>
 94        /// <value>
 95        /// The size of the messages in bytes.
 96        /// </value>
 97        protected override int BufferCapacity
 98        {
 99            get
 138100            {
 138101                var capacity = base.BufferCapacity;
 138102                capacity += 4; // ConnectedAddress length
 138103                capacity += _connectedAddress.Length; // ConnectedAddress
 138104                capacity += 4; // ConnectedPort
 138105                capacity += 4; // OriginatorAddress length
 138106                capacity += _originatorAddress.Length; // OriginatorAddress
 138107                capacity += 4; // OriginatorPort
 138108                return capacity;
 138109            }
 110        }
 111
 112        /// <summary>
 113        /// Called when type specific data need to be loaded.
 114        /// </summary>
 115        protected override void LoadData()
 5116        {
 5117            base.LoadData();
 118
 5119            _connectedAddress = ReadBinary();
 5120            ConnectedPort = ReadUInt32();
 5121            _originatorAddress = ReadBinary();
 5122            OriginatorPort = ReadUInt32();
 5123        }
 124
 125        /// <summary>
 126        /// Called when type specific data need to be saved.
 127        /// </summary>
 128        protected override void SaveData()
 138129        {
 138130            base.SaveData();
 131
 138132            WriteBinaryString(_connectedAddress);
 138133            Write(ConnectedPort);
 138134            WriteBinaryString(_originatorAddress);
 138135            Write(OriginatorPort);
 138136        }
 137    }
 138}