Table of Contents

Class SshData

Namespace
Renci.SshNet.Common
Assembly
Renci.SshNet.dll

Base ssh data serialization type.

public abstract class SshData
Inheritance
SshData
Derived
Inherited Members

Constructors

SshData()

protected SshData()

Properties

BufferCapacity

Gets the size of the message in bytes.

protected virtual int BufferCapacity { get; }

Property Value

int

The size of the messages in bytes.

DataStream

Gets the underlying SshDataStream that is used for reading and writing SSH data.

protected SshDataStream DataStream { get; }

Property Value

SshDataStream

The underlying SshDataStream that is used for reading and writing SSH data.

IsEndOfData

Gets a value indicating whether all data from the buffer has been read.

protected bool IsEndOfData { get; }

Property Value

bool

true if this instance is end of data; otherwise, false.

Methods

GetBytes()

Gets data bytes array.

public byte[] GetBytes()

Returns

byte[]

A byte array representation of data structure.

Load(byte[])

Loads data from specified bytes.

public void Load(byte[] data)

Parameters

data byte[]

Bytes array.

Exceptions

ArgumentNullException

data is null.

Load(byte[], int, int)

Loads data from the specified buffer.

public void Load(byte[] data, int offset, int count)

Parameters

data byte[]

Bytes array.

offset int

The zero-based offset in data at which to begin reading SSH data.

count int

The number of bytes to load.

Exceptions

ArgumentNullException

data is null.

LoadData()

Called when type specific data need to be loaded.

protected abstract void LoadData()

ReadBinary()

Reads next data type as byte array from internal buffer.

protected byte[] ReadBinary()

Returns

byte[]

The bytes read.

ReadBoolean()

Reads the next bool from the internal buffer.

protected bool ReadBoolean()

Returns

bool

The bool that was read.

Exceptions

InvalidOperationException

Attempt to read past the end of the stream.

ReadByte()

Reads next byte data type from internal buffer.

protected byte ReadByte()

Returns

byte

The byte read.

Exceptions

InvalidOperationException

Attempt to read past the end of the stream.

ReadBytes()

Reads all data left in internal buffer at current position.

protected byte[] ReadBytes()

Returns

byte[]

An array of bytes containing the remaining data in the internal buffer.

ReadBytes(int)

Reads next specified number of bytes data type from internal buffer.

protected byte[] ReadBytes(int length)

Parameters

length int

Number of bytes to read.

Returns

byte[]

An array of bytes that was read from the internal buffer.

Exceptions

ArgumentOutOfRangeException

length is greater than the number of bytes available to be read.

ReadExtensionPair()

Reads next extension-pair data type from internal buffer.

protected Dictionary<string, string> ReadExtensionPair()

Returns

Dictionary<string, string>

Extensions pair dictionary.

ReadNamesList()

Reads next name-list data type from internal buffer.

protected string[] ReadNamesList()

Returns

string[]

String array or read data.

ReadString(Encoding)

Reads the next string from the internal buffer using the specified encoding.

protected string ReadString(Encoding encoding = null)

Parameters

encoding Encoding

The character encoding to use.

Returns

string

The string that was read.

ReadUInt16()

Reads the next ushort from the internal buffer.

protected ushort ReadUInt16()

Returns

ushort

The ushort that was read.

Exceptions

InvalidOperationException

Attempt to read past the end of the stream.

ReadUInt32()

Reads the next uint from the internal buffer.

protected uint ReadUInt32()

Returns

uint

The uint that was read.

Exceptions

InvalidOperationException

Attempt to read past the end of the stream.

ReadUInt64()

Reads the next ulong from the internal buffer.

protected ulong ReadUInt64()

Returns

ulong

The ulong that was read.

Exceptions

InvalidOperationException

Attempt to read past the end of the stream.

SaveData()

Called when type specific data need to be saved.

protected abstract void SaveData()

Write(BigInteger)

Writes mpint data into internal buffer.

protected void Write(BigInteger data)

Parameters

data BigInteger

mpint data to write.

Write(bool)

Writes bool into internal buffer.

protected void Write(bool data)

Parameters

data bool

bool data to write.

Write(byte)

Writes byte data into internal buffer.

protected void Write(byte data)

Parameters

data byte

byte data to write.

Write(byte[])

Writes bytes array data into internal buffer.

protected void Write(byte[] data)

Parameters

data byte[]

Byte array data to write.

Exceptions

ArgumentNullException

data is null.

Write(byte[], int, int)

Writes a sequence of bytes to the current SSH data stream and advances the current position within this stream by the number of bytes written.

protected void Write(byte[] buffer, int offset, int count)

Parameters

buffer byte[]

An array of bytes. This method write count bytes from buffer to the current SSH data stream.

offset int

The zero-based offset in buffer at which to begin writing bytes to the SSH data stream.

count int

The number of bytes to be written to the current SSH data stream.

Exceptions

ArgumentNullException

buffer is null.

ArgumentException

The sum of offset and count is greater than the buffer length.

ArgumentOutOfRangeException

offset or count is negative.

Write(IDictionary<string, string>)

Writes extension-pair data into internal buffer.

protected void Write(IDictionary<string, string> data)

Parameters

data IDictionary<string, string>

extension-pair data to write.

Write(string)

Writes string data into internal buffer using default encoding.

protected void Write(string data)

Parameters

data string

string data to write.

Exceptions

ArgumentNullException

data is null.

Write(string, Encoding)

Writes string data into internal buffer using the specified encoding.

protected void Write(string data, Encoding encoding)

Parameters

data string

string data to write.

encoding Encoding

The character encoding to use.

Exceptions

ArgumentNullException

data is null.

ArgumentNullException

encoding is null.

Write(string[])

Writes name-list data into internal buffer.

protected void Write(string[] data)

Parameters

data string[]

name-list data to write.

Write(uint)

Writes uint data into internal buffer.

protected void Write(uint data)

Parameters

data uint

uint data to write.

Write(ulong)

Writes ulong data into internal buffer.

protected void Write(ulong data)

Parameters

data ulong

ulong data to write.

WriteBinary(byte[], int, int)

Writes data into internal buffer.

protected void WriteBinary(byte[] buffer, int offset, int count)

Parameters

buffer byte[]

An array of bytes. This method write count bytes from buffer to the current SSH data stream.

offset int

The zero-based byte offset in buffer at which to begin writing bytes to the SSH data stream.

count int

The number of bytes to be written to the current SSH data stream.

Exceptions

ArgumentNullException

buffer is null.

ArgumentException

The sum of offset and count is greater than the buffer length.

ArgumentOutOfRangeException

offset or count is negative.

WriteBinaryString(byte[])

Writes data into internal buffer.

protected void WriteBinaryString(byte[] buffer)

Parameters

buffer byte[]

The data to write.

Exceptions

ArgumentNullException

buffer is null.

WriteBytes(SshDataStream)

Writes the current message to the specified SshDataStream.

protected virtual void WriteBytes(SshDataStream stream)

Parameters

stream SshDataStream

The SshDataStream to write the message to.