Dangerous SNMP
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
BerStream Class Reference

A BerStream represents a BER-encoded stream of data. More...

#include <berstream.hpp>

Public Member Functions

 BerStream (ByteStream *byteStream)
 TODO.
 
bool copyTo (std::vector< char > &buffer)
 TODO.
 
unsigned int remainingReadLength () const
 This returns the number of bytes remaining in the stream. More...
 
unsigned int remainingWriteLength () const
 This returns the number of bytes remaining in the stream. More...
 
bool peekType (uint8_t &type)
 This reads an ASN.1 type from the BerStream. More...
 
bool readType (uint8_t &type)
 This reads an ASN.1 type from the BerStream. More...
 
bool readLength (unsigned int &length)
 This reads an ASN.1 length from the BerStream. More...
 
template<typename EncodingClass >
bool read (typename EncodingClass::value_type &value)
 This performs a full, logical read of a kind of encoded data. More...
 
bool readBytes (char *buffer, unsigned int bufferSize, unsigned int &bytesRead)
 This reads an arbitrary amount of bytes into the specified character buffer. More...
 
bool readFullTlv (std::vector< char > &buffer)
 This reads a full TLV set of data and fills out the whole thing (including the type, the length, and the value) exactly as read. More...
 
bool writeType (uint8_t type)
 This writes the given ASN.1 type to the buffer in BER. More...
 
bool writeLength (unsigned int encodedLength)
 This writes the length to the buffer in BER. More...
 
template<typename EncodingClass >
bool write (const typename EncodingClass::value_type &value)
 This performs a full, logical write of a kind of encoded data. More...
 
bool writeBytes (const char *buffer, unsigned int bufferSize, unsigned int &bytesWritten)
 This writes the bytes given to the BerStream. More...
 

Protected Attributes

ByteStream_byteStream
 TODO.
 

Detailed Description

A BerStream represents a BER-encoded stream of data.

It is a wrapper around a ByteStream instance, allowing only BER encoding and decoding operations.

Member Function Documentation

bool peekType ( uint8_t &  type)

This reads an ASN.1 type from the BerStream.

However, this does not advance the read head of the BerStream.

Parameters
typeA reference to the integer to store the type.
Returns
true on success, false on failure.
bool read ( typename EncodingClass::value_type &  value)

This performs a full, logical read of a kind of encoded data.

EncodingClass The encoding class to use.

Parameters
valueA reference to the value in which to store the data.
Returns
true on success, false on failure.
bool readBytes ( char *  buffer,
unsigned int  bufferSize,
unsigned int &  bytesRead 
)

This reads an arbitrary amount of bytes into the specified character buffer.

Parameters
bufferThe character buffer in which to store the read bytes.
bufferSizeThe number of bytes to read. "buffer" must be at least this size.
bytesReadA reference to an integer to hold the number of bytes that were actually read.
bool readFullTlv ( std::vector< char > &  buffer)

This reads a full TLV set of data and fills out the whole thing (including the type, the length, and the value) exactly as read.

Parameters
bufferThe vector in which to store the data.
Returns
true on success, false on failure.
bool readLength ( unsigned int &  length)

This reads an ASN.1 length from the BerStream.

Parameters
lengthA reference to the integer to store the length.
Returns
true on success, false on failure.
bool readType ( uint8_t &  type)

This reads an ASN.1 type from the BerStream.

Parameters
typeA reference to the integer to store the type.
Returns
true on success, false on failure.
unsigned int remainingReadLength ( ) const
inline

This returns the number of bytes remaining in the stream.

Returns
The number of bytes remaining.
unsigned int remainingWriteLength ( ) const
inline

This returns the number of bytes remaining in the stream.

Returns
The number of bytes remaining.
bool write ( const typename EncodingClass::value_type &  value)

This performs a full, logical write of a kind of encoded data.

EncodingClass The encoding class to use.

Parameters
valueA reference to the value in to write.
Returns
true on success, false on failure.
bool writeBytes ( const char *  buffer,
unsigned int  bufferSize,
unsigned int &  bytesWritten 
)

This writes the bytes given to the BerStream.

Parameters
bufferThe bytes to write.
bufferSizeThe number of bytes to write. "buffer" must be at least this size.
bytesWrittenA reference to an integer to store the number of bytes actually written.
Returns
true on success, false on failure.
bool writeLength ( unsigned int  encodedLength)

This writes the length to the buffer in BER.

Parameters
encodedLengthThe length to write.
Returns
true on success, false on failure.
bool writeType ( uint8_t  type)

This writes the given ASN.1 type to the buffer in BER.

Parameters
typeThe type to write.
Returns
true on success, false on failure.

The documentation for this class was generated from the following file: