SNMP 2.0.0
|
Base class for BER array of BERs. More...
#include <src/BER.h>
Public Member Functions | |
ArrayBER (const uint8_t type) | |
Creates an ArrayBER. | |
~ArrayBER () | |
ArrayBER destructor. | |
virtual void | encode (Stream &stream) |
Encodes ArrayBER to stream. | |
virtual void | decode (Stream &stream, const uint8_t flag=Flag::None) |
Decodes ArrayBER from stream. | |
virtual uint8_t * | encode (uint8_t *buffer) |
Encodes ArrayBER to memory buffer. | |
virtual uint8_t * | decode (uint8_t *buffer) |
Decodes ArrayBER from memory buffer. | |
virtual const unsigned int | getSize (const bool refresh=false) |
Gets the size of the ArrayBER. | |
BER * | operator[] (const unsigned int index) |
Array subscript operator. | |
const uint8_t | count () const |
Gets the count of BERs in the array. | |
Public Member Functions inherited from SNMP::BER | |
BER (const unsigned int type) | |
Creates a BER object. | |
virtual | ~BER () |
BER destructor. | |
template<typename T > | |
void | encodeNumeric (T value, Stream &stream) |
Encodes BER numeric value to stream. | |
template<typename T > | |
void | decodeNumeric (T *value, Stream &stream, const uint8_t flag=Flag::None) |
Decodes BER numeric value from stream. | |
template<typename T > | |
uint8_t * | encodeNumeric (T value, uint8_t *buffer) |
Encodes BER numeric value to 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. | |
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 * | add (BER *ber) |
Adds a BER to the array. | |
void | remove () |
Removes the last BER in the array. | |
Protected Member Functions inherited from SNMP::BER | |
BER * | create (const Type &type) |
Creates a BER of given type. | |
Private Attributes | |
uint8_t | _count = 0 |
std::vector< BER * > | _bers |
BER * | _bers [U] |
Friends | |
class | Message |
class | VarBind |
class | VarBindList |
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. | |
Protected Attributes inherited from SNMP::BER | |
Length | _length |
Type | _type |
Protected Attributes inherited from SNMP::Base | |
unsigned int | _size = 0 |
Base class for BER array of BERs.
BERs are stored in an array or a vector depending on the definition of SNMP_VECTORS.
U | Size of the array. Used only if SNMP_VECTORS is set to 0 or undefined. |
|
inline |
|
inline |
ArrayBER destructor.
Delete all BERs of the array.
Definition at line 1731 of file BER.h.
References SNMP::ArrayBER< U >::_bers, and SNMP::ArrayBER< U >::_count.
|
inlineprotected |
Adds a BER to the array.
The length of the array is updated.
ber | BER to add. |
Definition at line 1899 of file BER.h.
References SNMP::ArrayBER< U >::_bers, SNMP::ArrayBER< U >::_count, SNMP::BER::_length, and SNMP::BER::getSize().
Referenced by SNMP::Message::add(), SNMP::Message::build(), SNMP::ArrayBER< U >::decode(), and SNMP::ArrayBER< U >::decode().
|
inline |
Gets the count of BERs in the array.
Definition at line 1886 of file BER.h.
References SNMP::ArrayBER< U >::_count.
|
inlinevirtual |
Decodes ArrayBER from stream.
Type and length are decoded by the inherited BER::decode() then each BER of the array is decoded.
Decoding of BER from stream implies 3 steps.
stream | Stream to read from. |
flag | Decoding flag. |
Reimplemented from SNMP::BER.
Definition at line 1776 of file BER.h.
References SNMP::BER::_length, SNMP::ArrayBER< U >::add(), SNMP::BER::create(), SNMP::BER::decode(), SNMP::Type::decode(), SNMP::BER::getSize(), and SNMP::Flag::Typed.
|
inlinevirtual |
Decodes ArrayBER from memory buffer.
Type and length are decoded by the inherited BER::decode() then each BER of the array is decoded.
buffer | Pointer to the buffer. |
Reimplemented from SNMP::BER.
Definition at line 1826 of file BER.h.
References SNMP::BER::_length, SNMP::ArrayBER< U >::add(), SNMP::BER::create(), SNMP::BER::decode(), and SNMP::Type::decode().
|
inlinevirtual |
Encodes ArrayBER to stream.
Type and length are encoded by the inherited BER::encode() then each BER of the array is encoded.
stream | Stream to write to. |
Reimplemented from SNMP::BER.
Definition at line 1753 of file BER.h.
References SNMP::ArrayBER< U >::_bers, SNMP::ArrayBER< U >::_count, and SNMP::BER::encode().
|
inlinevirtual |
Encodes ArrayBER to memory buffer.
Type and length are encoded by the inherited BER::encode() then each BER of the array is encoded.
buffer | Pointer to the buffer. |
Reimplemented from SNMP::BER.
Definition at line 1803 of file BER.h.
References SNMP::ArrayBER< U >::_bers, SNMP::ArrayBER< U >::_count, and SNMP::BER::encode().
|
inlinevirtual |
Gets the size of the ArrayBER.
The size of the ArrayBER is computed from:
Length is the sum of the size of all the BERs in the array.
refresh | If true, computes size, if false returns already computed size. |
Reimplemented from SNMP::BER.
Reimplemented in SNMP::Message.
Definition at line 1859 of file BER.h.
References SNMP::ArrayBER< U >::_bers, SNMP::ArrayBER< U >::_count, SNMP::BER::_length, and SNMP::BER::getSize().
Referenced by SNMP::Message::getSize().
|
inline |
|
inlineprotected |
Removes the last BER in the array.
The length of the array is updated.
Definition at line 1918 of file BER.h.
References SNMP::ArrayBER< U >::_bers, SNMP::ArrayBER< U >::_count, and SNMP::BER::_length.
Referenced by SNMP::Message::parse().
|
friend |
|
private |
Vector of BERs.
Definition at line 1937 of file BER.h.
Referenced by SNMP::ArrayBER< U >::add(), SNMP::ArrayBER< U >::encode(), SNMP::ArrayBER< U >::encode(), SNMP::ArrayBER< U >::getSize(), SNMP::ArrayBER< U >::operator[](), SNMP::ArrayBER< U >::remove(), and SNMP::ArrayBER< U >::~ArrayBER().
|
private |
|
private |
Count of BERs in the array.
Definition at line 1934 of file BER.h.
Referenced by SNMP::ArrayBER< U >::add(), SNMP::ArrayBER< U >::count(), SNMP::ArrayBER< U >::encode(), SNMP::ArrayBER< U >::encode(), SNMP::ArrayBER< U >::getSize(), SNMP::ArrayBER< U >::remove(), and SNMP::ArrayBER< U >::~ArrayBER().