SNMP 2.0.0
|
#include <src/BER.h>
Public Member Functions | |
BER (const unsigned int type) | |
Creates a BER object. | |
virtual | ~BER () |
BER destructor. | |
virtual void | encode (Stream &stream) |
Encodes BER type and length to stream. | |
template<typename T > | |
void | encodeNumeric (T value, Stream &stream) |
Encodes BER numeric value to stream. | |
virtual void | decode (Stream &stream, const uint8_t flag=Flag::None) |
Decodes BER type and length from stream. | |
template<typename T > | |
void | decodeNumeric (T *value, Stream &stream, const uint8_t flag=Flag::None) |
Decodes BER numeric value from stream. | |
virtual uint8_t * | encode (uint8_t *buffer) |
Encodes BER type and length to memory buffer. | |
template<typename T > | |
uint8_t * | encodeNumeric (T value, uint8_t *buffer) |
Encodes BER numeric value to memory buffer. | |
virtual uint8_t * | decode (uint8_t *buffer) |
Decodes BER type and length from memory buffer. | |
template<typename T > | |
uint8_t * | decodeNumeric (T *value, uint8_t *buffer, const uint8_t flag=Flag::None) |
Decodes BER numeric value from memory buffer. | |
template<typename T > | |
void | setNegative (T value) |
Computes BER length of a negative integer. | |
template<typename T > | |
void | setPositive (T value) |
Computes BER length of a positive integer. | |
const unsigned int | getType () const |
Gets the BER type. | |
const unsigned int | getLength () const |
Gets the BER length. | |
virtual const unsigned int | getSize (const bool refresh=false) |
Gets the size of the BER. | |
Public Member Functions inherited from SNMP::Base | |
void | encode7bits (uint32_t value, uint8_t *buffer, const uint8_t size) |
Encodes integer value to memory buffer. | |
Protected Member Functions | |
BER * | create (const Type &type) |
Creates a BER of given type. | |
Protected Attributes | |
Length | _length |
Type | _type |
Protected Attributes inherited from SNMP::Base | |
unsigned int | _size = 0 |
Additional Inherited Members | |
Static Public Member Functions inherited from SNMP::Base | |
static void | encode7bits (uint32_t value, Stream &stream, const uint8_t size) |
Encodes integer value to stream. | |
BER object.
This class is the base class of all the BER objects.
A BER object uses the TLV format. TLV is an acronym for type, length and value.
|
inline |
Creates a BER of given type.
type | BER type. |
Referenced by SNMP::ArrayBER< U >::decode(), SNMP::ArrayBER< U >::decode(), SNMP::OpaqueBER::decode(), and SNMP::OpaqueBER::decode().
|
inlinevirtual |
Decodes BER type and length from stream.
stream | Stream to read from. |
flag | Decoding flag. |
Reimplemented in SNMP::ArrayBER< U >, SNMP::ArrayBER< 2 >, SNMP::ArrayBER< SNMP_CAPACITY >, SNMP::BooleanBER, SNMP::FloatBER, SNMP::IntegerBER, SNMP::ObjectIdentifierBER, SNMP::OctetStringBER, SNMP::OpaqueBER, SNMP::UIntegerBER< T >, SNMP::UIntegerBER< uint32_t >, and SNMP::UIntegerBER< uint64_t >.
Definition at line 849 of file BER.h.
References _length, _type, SNMP::Length::decode(), SNMP::Type::decode(), SNMP::Flag::None, and SNMP::Flag::Typed.
Referenced by SNMP::ArrayBER< U >::decode(), SNMP::ArrayBER< U >::decode(), SNMP::BooleanBER::decode(), SNMP::BooleanBER::decode(), SNMP::ObjectIdentifierBER::decode(), SNMP::ObjectIdentifierBER::decode(), SNMP::OctetStringBER::decode(), SNMP::OctetStringBER::decode(), SNMP::OpaqueBER::decode(), SNMP::OpaqueBER::decode(), decodeNumeric(), and decodeNumeric().
|
inlinevirtual |
Decodes BER type and length from memory buffer.
buffer | Pointer to the buffer. |
Reimplemented in SNMP::ArrayBER< U >, SNMP::ArrayBER< 2 >, SNMP::ArrayBER< SNMP_CAPACITY >, SNMP::BooleanBER, SNMP::FloatBER, SNMP::IntegerBER, SNMP::ObjectIdentifierBER, SNMP::OctetStringBER, SNMP::OpaqueBER, SNMP::UIntegerBER< T >, SNMP::UIntegerBER< uint32_t >, and SNMP::UIntegerBER< uint64_t >.
Definition at line 921 of file BER.h.
References _length, _type, SNMP::Length::decode(), and SNMP::Type::decode().
|
inline |
Decodes BER numeric value from stream.
SNMP numeric values are big-endian. Most significants bytes are read first.
T | C++ type of the numeric value. |
value | Numeric value to decode. |
stream | Stream to read from. |
flag | Decoding flag. |
Definition at line 867 of file BER.h.
References _length, and decode().
Referenced by SNMP::FloatBER::decode(), SNMP::FloatBER::decode(), SNMP::IntegerBER::decode(), SNMP::IntegerBER::decode(), SNMP::UIntegerBER< T >::decode(), and SNMP::UIntegerBER< T >::decode().
|
inline |
Decodes BER numeric value from memory buffer.
SNMP numeric values are big-endian. Most significants bytes are read first.
T | C++ type of the numeric value. |
value | Numeric value to decode. |
buffer | Pointer to the buffer. |
flag | Decoding flag. |
|
inlinevirtual |
Encodes BER type and length to stream.
stream | Stream to write to. |
Reimplemented in SNMP::ArrayBER< U >, SNMP::ArrayBER< 2 >, SNMP::ArrayBER< SNMP_CAPACITY >, SNMP::BooleanBER, SNMP::FloatBER, SNMP::IntegerBER, SNMP::ObjectIdentifierBER, SNMP::OctetStringBER, SNMP::OpaqueBER, SNMP::UIntegerBER< T >, SNMP::UIntegerBER< uint32_t >, and SNMP::UIntegerBER< uint64_t >.
Definition at line 819 of file BER.h.
References _length, _type, SNMP::Length::encode(), and SNMP::Type::encode().
Referenced by SNMP::ArrayBER< U >::encode(), SNMP::ArrayBER< U >::encode(), SNMP::BooleanBER::encode(), SNMP::BooleanBER::encode(), SNMP::ObjectIdentifierBER::encode(), SNMP::ObjectIdentifierBER::encode(), SNMP::OctetStringBER::encode(), SNMP::OctetStringBER::encode(), SNMP::OpaqueBER::encode(), SNMP::OpaqueBER::encode(), encodeNumeric(), and encodeNumeric().
|
inlinevirtual |
Encodes BER type and length to memory buffer.
buffer | Pointer to the buffer. |
Reimplemented in SNMP::ArrayBER< U >, SNMP::ArrayBER< 2 >, SNMP::ArrayBER< SNMP_CAPACITY >, SNMP::BooleanBER, SNMP::FloatBER, SNMP::IntegerBER, SNMP::ObjectIdentifierBER, SNMP::OctetStringBER, SNMP::OpaqueBER, SNMP::UIntegerBER< T >, SNMP::UIntegerBER< uint32_t >, and SNMP::UIntegerBER< uint64_t >.
Definition at line 888 of file BER.h.
References _length, _type, SNMP::Length::encode(), and SNMP::Type::encode().
|
inline |
Encodes BER numeric value to stream.
SNMP numeric values are big-endian. Most significants bytes are written first.
T | C++ type of the integer. |
value | Integer value to encode. |
stream | Stream to write to. |
Definition at line 834 of file BER.h.
References _length, and encode().
Referenced by SNMP::FloatBER::encode(), SNMP::FloatBER::encode(), SNMP::IntegerBER::encode(), SNMP::IntegerBER::encode(), SNMP::UIntegerBER< T >::encode(), and SNMP::UIntegerBER< T >::encode().
|
inline |
Encodes BER numeric value to memory buffer.
SNMP numeric values are big-endian. Most significants bytes are written first.
T | C++ type of the numeric value. |
value | Numeric value to encode. |
buffer | Pointer to the buffer. |
|
inline |
|
inlinevirtual |
Gets the size of the BER.
The size of the BER is computed from:
refresh | Unused. |
Reimplemented in SNMP::ArrayBER< U >, SNMP::ArrayBER< 2 >, SNMP::ArrayBER< SNMP_CAPACITY >, SNMP::Message, and SNMP::OpaqueBER.
Definition at line 1021 of file BER.h.
References _length, SNMP::Base::_size, and _type.
Referenced by SNMP::ArrayBER< U >::add(), SNMP::ArrayBER< U >::decode(), SNMP::OpaqueBER::decode(), SNMP::ArrayBER< U >::getSize(), and SNMP::OpaqueBER::getSize().
|
inline |
|
inline |
Computes BER length of a negative integer.
T | C++ type of the integer. |
value | Integer value. |
Definition at line 962 of file BER.h.
References _length.
Referenced by SNMP::IntegerBER::setValue().
|
inline |
Computes BER length of a positive integer.
T | C++ type of the integer. |
value | Integer value. |
Definition at line 980 of file BER.h.
References _length.
Referenced by SNMP::IntegerBER::setValue(), and SNMP::UIntegerBER< T >::setValue().
|
protected |
BER length.
Definition at line 1028 of file BER.h.
Referenced by SNMP::ArrayBER< U >::add(), SNMP::OctetStringBER::allocate(), BER(), SNMP::BooleanBER::BooleanBER(), SNMP::ArrayBER< U >::decode(), SNMP::ArrayBER< U >::decode(), decode(), decode(), SNMP::ObjectIdentifierBER::decode(), SNMP::ObjectIdentifierBER::decode(), SNMP::OctetStringBER::decode(), SNMP::OctetStringBER::decode(), SNMP::OpaqueBER::decode(), SNMP::OpaqueBER::decode(), decodeNumeric(), decodeNumeric(), encode(), encode(), SNMP::OctetStringBER::encode(), SNMP::OctetStringBER::encode(), encodeNumeric(), encodeNumeric(), SNMP::FloatBER::FloatBER(), getLength(), SNMP::ArrayBER< U >::getSize(), getSize(), SNMP::OpaqueBER::getSize(), SNMP::IPAddressBER::IPAddressBER(), SNMP::ArrayBER< U >::remove(), setNegative(), setPositive(), SNMP::ObjectIdentifierBER::setValue(), and SNMP::OctetStringBER::setValue().
|
protected |