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
databyte[]Bytes array.
Exceptions
- ArgumentNullException
datais null.
Load(byte[], int, int)
Loads data from the specified buffer.
public void Load(byte[] data, int offset, int count)
Parameters
databyte[]Bytes array.
offsetintThe zero-based offset in
dataat which to begin reading SSH data.countintThe number of bytes to load.
Exceptions
- ArgumentNullException
datais 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
lengthintNumber of bytes to read.
Returns
- byte[]
An array of bytes that was read from the internal buffer.
Exceptions
- ArgumentOutOfRangeException
lengthis 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
encodingEncodingThe 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
dataBigIntegermpint 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
databyte[]Byte array data to write.
Exceptions
- ArgumentNullException
datais 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
bufferbyte[]An array of bytes. This method write
countbytes from buffer to the current SSH data stream.offsetintThe zero-based offset in
bufferat which to begin writing bytes to the SSH data stream.countintThe number of bytes to be written to the current SSH data stream.
Exceptions
- ArgumentNullException
bufferis null.- ArgumentException
The sum of
offsetandcountis greater than the buffer length.- ArgumentOutOfRangeException
offsetorcountis negative.
Write(IDictionary<string, string>)
Writes extension-pair data into internal buffer.
protected void Write(IDictionary<string, string> data)
Parameters
dataIDictionary<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
datais null.
Write(string, Encoding)
Writes string data into internal buffer using the specified encoding.
protected void Write(string data, Encoding encoding)
Parameters
Exceptions
- ArgumentNullException
datais null.- ArgumentNullException
encodingis null.
Write(string[])
Writes name-list data into internal buffer.
protected void Write(string[] data)
Parameters
datastring[]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
bufferbyte[]An array of bytes. This method write
countbytes from buffer to the current SSH data stream.offsetintThe zero-based byte offset in
bufferat which to begin writing bytes to the SSH data stream.countintThe number of bytes to be written to the current SSH data stream.
Exceptions
- ArgumentNullException
bufferis null.- ArgumentException
The sum of
offsetandcountis greater than the buffer length.- ArgumentOutOfRangeException
offsetorcountis negative.
WriteBinaryString(byte[])
Writes data into internal buffer.
protected void WriteBinaryString(byte[] buffer)
Parameters
bufferbyte[]The data to write.
Exceptions
- ArgumentNullException
bufferis null.
WriteBytes(SshDataStream)
Writes the current message to the specified SshDataStream.
protected virtual void WriteBytes(SshDataStream stream)
Parameters
streamSshDataStreamThe SshDataStream to write the message to.