# < Summary

Information

Class: | Renci.SshNet.Messages.Connection.ChannelOpenMessage
Assembly: | Renci.SshNet
File(s): | \home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Connection\ChannelOpen\ChannelOpenMessage.cs

Line coverage
100%

Covered lines: | 58
Uncovered lines: | 0
Coverable lines: | 58
Total lines: | 154
Line coverage: | 100%

Branch coverage
100%

Covered branches: | 10
Total branches: | 10
Branch coverage: | 100%

Method coverage

Feature is only available for sponsors

Upgrade to PRO version

# Metrics

Method | Branch coverage | Cyclomatic complexity | Line coverage
--- | --- | --- | ---
get_ChannelType() | 100% | 1 | 100%
get_LocalChannelNumber() | 100% | 1 | 100%
get_InitialWindowSize() | 100% | 1 | 100%
get_MaximumPacketSize() | 100% | 1 | 100%
get_Info() | 100% | 1 | 100%
get_BufferCapacity() | 100% | 1 | 100%
.ctor() | 100% | 1 | 100%
.ctor(...) | 100% | 2 | 100%
LoadData() | 100% | 8 | 100%
SaveData() | 100% | 1 | 100%
Process(...) | 100% | 1 | 100%

# File(s)

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

| # | Line |  | Line coverage
--- | --- | --- | --- | ---
|  | `1` |  | `using System;`
|  | `2` |  | `using System.Globalization;`
|  | `3` |  | ``
|  | `4` |  | `namespace Renci.SshNet.Messages.Connection`
|  | `5` |  | `{`
|  | `6` |  | `/// <summary>`
|  | `7` |  | `/// Represents SSH_MSG_CHANNEL_OPEN message.`
|  | `8` |  | `/// </summary>`
|  | `9` |  | `[Message("SSH_MSG_CHANNEL_OPEN", MessageNumber)]`
|  | `10` |  | `public class ChannelOpenMessage : Message`
|  | `11` |  | `{`
|  | `12` |  | `internal const byte MessageNumber = 90;`
|  | `13` |  | ``
|  | `14` |  | `private byte[] _infoBytes;`
|  | `15` |  | ``
|  | `16` |  | `/// <summary>`
|  | `17` |  | `/// Gets the type of the channel as ASCII encoded byte array.`
|  | `18` |  | `/// </summary>`
|  | `19` |  | `/// <value>`
|  | `20` |  | `/// The type of the channel.`
|  | `21` |  | `/// </value>`
| 5826 | `22` |  | `public byte[] ChannelType { get; private set; }`
|  | `23` |  | ``
|  | `24` |  | `/// <summary>`
|  | `25` |  | `/// Gets or sets the local channel number.`
|  | `26` |  | `/// </summary>`
|  | `27` |  | `/// <value>`
|  | `28` |  | `/// The local channel number.`
|  | `29` |  | `/// </value>`
| 4396 | `30` |  | `public uint LocalChannelNumber { get; protected set; }`
|  | `31` |  | ``
|  | `32` |  | `/// <summary>`
|  | `33` |  | `/// Gets the initial size of the window.`
|  | `34` |  | `/// </summary>`
|  | `35` |  | `/// <value>`
|  | `36` |  | `/// The initial size of the window.`
|  | `37` |  | `/// </value>`
| 4339 | `38` |  | `public uint InitialWindowSize { get; private set; }`
|  | `39` |  | ``
|  | `40` |  | `/// <summary>`
|  | `41` |  | `/// Gets the maximum size of the packet.`
|  | `42` |  | `/// </summary>`
|  | `43` |  | `/// <value>`
|  | `44` |  | `/// The maximum size of the packet.`
|  | `45` |  | `/// </value>`
| 4339 | `46` |  | `public uint MaximumPacketSize { get; private set; }`
|  | `47` |  | ``
|  | `48` |  | `/// <summary>`
|  | `49` |  | `/// Gets channel specific open information.`
|  | `50` |  | `/// </summary>`
| 2628 | `51` |  | `public ChannelOpenInfo Info { get; private set; }`
|  | `52` |  | ``
|  | `53` |  | `/// <summary>`
|  | `54` |  | `/// Gets the size of the message in bytes.`
|  | `55` |  | `/// </summary>`
|  | `56` |  | `/// <value>`
|  | `57` |  | `/// The size of the messages in bytes.`
|  | `58` |  | `/// </value>`
|  | `59` |  | `protected override int BufferCapacity`
|  | `60` |  | `{`
|  | `61` |  | `get`
| 1779 | `62` |  | `{`
| 1779 | `63` |  | `var capacity = base.BufferCapacity;`
| 1779 | `64` |  | `capacity += 4; // ChannelType length`
| 1779 | `65` |  | `capacity += ChannelType.Length; // ChannelType`
| 1779 | `66` |  | `capacity += 4; // LocalChannelNumber`
| 1779 | `67` |  | `capacity += 4; // InitialWindowSize`
| 1779 | `68` |  | `capacity += 4; // MaximumPacketSize`
| 1779 | `69` |  | `capacity += _infoBytes.Length; // Info`
| 1779 | `70` |  | `return capacity;`
| 1779 | `71` |  | `}`
|  | `72` |  | `}`
|  | `73` |  | ``
|  | `74` |  | `/// <summary>`
|  | `75` |  | `/// Initializes a new instance of the <see cref="ChannelOpenMessage"/> class.`
|  | `76` |  | `/// </summary>`
| 8 | `77` |  | `public ChannelOpenMessage()`
| 8 | `78` |  | `{`
|  | `79` |  | `// Required for dynamicly loading request type when it comes from the server`
| 8 | `80` |  | `}`
|  | `81` |  | ``
|  | `82` |  | `/// <summary>`
|  | `83` |  | `/// Initializes a new instance of the <see cref="ChannelOpenMessage"/> class.`
|  | `84` |  | `/// </summary>`
|  | `85` |  | `/// <param name="channelNumber">The channel number.</param>`
|  | `86` |  | `/// <param name="initialWindowSize">Initial size of the window.</param>`
|  | `87` |  | `/// <param name="maximumPacketSize">Maximum size of the packet.</param>`
|  | `88` |  | `/// <param name="info">Information specific to the type of the channel to open.</param>`
|  | `89` |  | `/// <exception cref="ArgumentNullException"><paramref name="info"/> is <see langword="null"/>.</exception>`
| 2193 | `90` |  | `public ChannelOpenMessage(uint channelNumber, uint initialWindowSize, uint maximumPacketSize, ChannelOpenInfo in`
| 2193 | `91` |  | `{`
| 2193 | `92` |  | `if (info == null)`
| 3 | `93` |  | `{`
| 3 | `94` |  | `throw new ArgumentNullException(nameof(info));`
|  | `95` |  | `}`
|  | `96` |  | ``
| 2190 | `97` |  | `ChannelType = Ascii.GetBytes(info.ChannelType);`
| 2190 | `98` |  | `LocalChannelNumber = channelNumber;`
| 2190 | `99` |  | `InitialWindowSize = initialWindowSize;`
| 2190 | `100` |  | `MaximumPacketSize = maximumPacketSize;`
| 2190 | `101` |  | `Info = info;`
| 2190 | `102` |  | `_infoBytes = info.GetBytes();`
| 2190 | `103` |  | `}`
|  | `104` |  | ``
|  | `105` |  | `/// <summary>`
|  | `106` |  | `/// Called when type specific data need to be loaded.`
|  | `107` |  | `/// </summary>`
|  | `108` |  | `protected override void LoadData()`
| 17 | `109` |  | `{`
| 17 | `110` |  | `ChannelType = ReadBinary();`
| 17 | `111` |  | `LocalChannelNumber = ReadUInt32();`
| 17 | `112` |  | `InitialWindowSize = ReadUInt32();`
| 17 | `113` |  | `MaximumPacketSize = ReadUInt32();`
| 17 | `114` |  | `_infoBytes = ReadBytes();`
|  | `115` |  | ``
| 17 | `116` |  | `var channelName = Ascii.GetString(ChannelType, 0, ChannelType.Length);`
|  | `117` |  | ``
| 17 | `118` |  | `switch (channelName)`
|  | `119` |  | `{`
|  | `120` |  | `case SessionChannelOpenInfo.Name:`
| 3 | `121` |  | `Info = new SessionChannelOpenInfo(_infoBytes);`
| 3 | `122` |  | `break;`
|  | `123` |  | `case X11ChannelOpenInfo.Name:`
| 3 | `124` |  | `Info = new X11ChannelOpenInfo(_infoBytes);`
| 3 | `125` |  | `break;`
|  | `126` |  | `case DirectTcpipChannelInfo.NAME:`
| 3 | `127` |  | `Info = new DirectTcpipChannelInfo(_infoBytes);`
| 3 | `128` |  | `break;`
|  | `129` |  | `case ForwardedTcpipChannelInfo.NAME:`
| 5 | `130` |  | `Info = new ForwardedTcpipChannelInfo(_infoBytes);`
| 5 | `131` |  | `break;`
|  | `132` |  | `default:`
| 3 | `133` |  | `throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Channel type '{0}' is not`
|  | `134` |  | `}`
| 14 | `135` |  | `}`
|  | `136` |  | ``
|  | `137` |  | `/// <summary>`
|  | `138` |  | `/// Called when type specific data need to be saved.`
|  | `139` |  | `/// </summary>`
|  | `140` |  | `protected override void SaveData()`
| 1779 | `141` |  | `{`
| 1779 | `142` |  | `WriteBinaryString(ChannelType);`
| 1779 | `143` |  | `Write(LocalChannelNumber);`
| 1779 | `144` |  | `Write(InitialWindowSize);`
| 1779 | `145` |  | `Write(MaximumPacketSize);`
| 1779 | `146` |  | `Write(_infoBytes);`
| 1779 | `147` |  | `}`
|  | `148` |  | ``
|  | `149` |  | `internal override void Process(Session session)`
| 2 | `150` |  | `{`
| 2 | `151` |  | `session.OnChannelOpenReceived(this);`
| 2 | `152` |  | `}`
|  | `153` |  | `}`
|  | `154` |  | `}`

# Methods/Properties

get_ChannelType()
get_LocalChannelNumber()
get_InitialWindowSize()
get_MaximumPacketSize()
get_Info()
get_BufferCapacity()
.ctor()
.ctor(System.UInt32,System.UInt32,System.UInt32,Renci.SshNet.Messages.Connection.ChannelOpenInfo)
LoadData()
SaveData()
Process(Renci.SshNet.Session)