Class SshData
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
Methods
GetBytes()
Gets data bytes array.
public byte[] GetBytes()
Returns
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
intThe zero-based offset in
data
at which to begin reading SSH data.count
intThe 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
Exceptions
- InvalidOperationException
Attempt to read past the end of the stream.
ReadByte()
Reads next byte data type from internal buffer.
protected byte ReadByte()
Returns
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
intNumber 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
EncodingThe character encoding to use.
Returns
ReadUInt16()
Reads the next ushort from the internal buffer.
protected ushort ReadUInt16()
Returns
Exceptions
- InvalidOperationException
Attempt to read past the end of the stream.
ReadUInt32()
Reads the next uint from the internal buffer.
protected uint ReadUInt32()
Returns
Exceptions
- InvalidOperationException
Attempt to read past the end of the stream.
ReadUInt64()
Reads the next ulong from the internal buffer.
protected ulong ReadUInt64()
Returns
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
BigIntegermpint data to write.
Write(bool)
Writes bool into internal buffer.
protected void Write(bool data)
Parameters
Write(byte)
Writes byte data into internal buffer.
protected void Write(byte data)
Parameters
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
intThe zero-based offset in
buffer
at which to begin writing bytes to the SSH data stream.count
intThe number of bytes to be written to the current SSH data stream.
Exceptions
- ArgumentNullException
buffer
is null.- ArgumentException
The sum of
offset
andcount
is greater than the buffer length.- ArgumentOutOfRangeException
offset
orcount
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
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
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
Write(ulong)
Writes ulong data into internal buffer.
protected void Write(ulong data)
Parameters
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
intThe zero-based byte offset in
buffer
at which to begin writing bytes to the SSH data stream.count
intThe number of bytes to be written to the current SSH data stream.
Exceptions
- ArgumentNullException
buffer
is null.- ArgumentException
The sum of
offset
andcount
is greater than the buffer length.- ArgumentOutOfRangeException
offset
orcount
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
SshDataStreamThe SshDataStream to write the message to.