|
SNMP 2.1.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 object.
| type | BER type. |
Definition at line 800 of file BER.h.
References _length, and _type.
Referenced by SNMP::ArrayBER< U >::add(), SNMP::ArrayBER< U >::ArrayBER(), SNMP::BooleanBER::BooleanBER(), create(), SNMP::ArrayBER< U >::decode(), SNMP::ArrayBER< U >::decode(), SNMP::FloatBER::FloatBER(), SNMP::OpaqueBER::getBER(), SNMP::IntegerBER::IntegerBER(), SNMP::NullBER::NullBER(), SNMP::ObjectIdentifierBER::ObjectIdentifierBER(), SNMP::OctetStringBER::OctetStringBER(), SNMP::OpaqueBER::OpaqueBER(), SNMP::ArrayBER< U >::operator[](), and SNMP::UIntegerBER< T >::UIntegerBER().
Creates a BER of given type.
| type | BER type. |
Definition at line 15 of file BER.cpp.
References BER(), SNMP::Type::Boolean, SNMP::Type::Counter32, SNMP::Type::Counter64, SNMP::Type::EndOfMIBView, SNMP::Type::Float, SNMP::Type::Gauge32, SNMP::Type::GetBulkRequest, SNMP::Type::GetNextRequest, SNMP::Type::GetRequest, SNMP::Type::GetResponse, SNMP::Type::InformRequest, SNMP::Type::Integer, SNMP::Type::IPAddress, SNMP::Type::NoSuchInstance, SNMP::Type::NoSuchObject, SNMP::Type::Null, SNMP::Type::ObjectIdentifier, SNMP::Type::OctetString, SNMP::Type::Opaque, SNMP::Type::OpaqueFloat, SNMP::Type::Report, SNMP::Type::Sequence, SNMP::Type::SetRequest, SNMP::Type::SNMPv2Trap, SNMP::Type::TimeTicks, and SNMP::Type::Trap.
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 850 of file BER.h.
References _length, _type, 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 >.
|
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 868 of file BER.h.
References _length, decode(), and SNMP::Flag::None.
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. |
Definition at line 940 of file BER.h.
References _length, decode(), and SNMP::Flag::None.
|
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 820 of file BER.h.
References _length, and _type.
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 >.
|
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 835 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 1022 of file BER.h.
References _length, SNMP::Base::_size, and _type.
Referenced by SNMP::ArrayBER< U >::add(), SNMP::ArrayBER< U >::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 963 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 981 of file BER.h.
References _length.
Referenced by SNMP::IntegerBER::setValue(), and SNMP::UIntegerBER< T >::setValue().
|
protected |
BER length.
Definition at line 1029 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::OpaqueBER::OpaqueBER(), SNMP::ArrayBER< U >::remove(), setNegative(), setPositive(), SNMP::ObjectIdentifierBER::setValue(), and SNMP::OctetStringBER::setValue().
|
protected |