|
SNMP 2.1.0
|
BER object to handle octet string. More...
#include <src/BER.h>
Public Member Functions | |
| OctetStringBER (const char *value) | |
| Creates an OctetStringBER object. | |
| OctetStringBER (const char *value, const uint32_t length) | |
| Creates an OctetStringBER object. | |
| virtual | ~OctetStringBER () |
| OctetStringBER destructor. | |
| virtual void | encode (Stream &stream) |
| Encodes OctetStringBER to stream. | |
| virtual void | decode (Stream &stream, const uint8_t flag=Flag::None) |
| Decodes OctetStringBER from stream. | |
| virtual uint8_t * | encode (uint8_t *buffer) |
| Encodes OctetStringBER to memory buffer. | |
| virtual uint8_t * | decode (uint8_t *buffer) |
| Decodes OctetStringBER from memory buffer. | |
| const char * | getValue () const |
| Gets the OctetStringBER value. | |
| void | setValue (const char *value, const unsigned int length) |
| Sets the OctetStringBER value. | |
| const bool | getBit (const unsigned int index) const |
| Gets bit at a given index in the OctetStringBER value. | |
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. | |
| 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 | |
| OctetStringBER (const uint8_t type=Type::OctetString) | |
| Creates an empty OctetStringBER object. | |
| void | allocate () |
| Allocates the char array. | |
Protected Member Functions inherited from SNMP::BER | |
| BER * | create (const Type &type) |
| Creates a BER of given type. | |
Protected Attributes | |
| char * | _value |
Protected Attributes inherited from SNMP::BER | |
| 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 to handle octet string.
Example
| Octet String | Encoding |
|---|---|
| 01 23 45 67 89 AB CD EF | 04 08 01 23 45 67 89 AB CD EF |
|
inline |
Creates an OctetStringBER object.
Creates an OctetStringBER object from a pointer to a null-terminated array of char.
The constructor allocates a char array and copies the value parameter.
| value | OctetStringBER char pointer value. |
Definition at line 1301 of file BER.h.
References OctetStringBER().
Referenced by SNMP::IPAddressBER::IPAddressBER(), OctetStringBER(), and OctetStringBER().
| SNMP::OctetStringBER::OctetStringBER | ( | const char * | value, |
| const uint32_t | length ) |
Creates an OctetStringBER object.
Creates an OctetStringBER object from a pointer to an array of char and the array length.
The constructor allocates a char array and copies the value parameter.
| value | OctetStringBER char pointer value. |
| length | Value length. |
Definition at line 72 of file BER.cpp.
References OctetStringBER(), and setValue().
|
inlinevirtual |
OctetStringBER destructor.
Releases the char array.
Definition at line 1323 of file BER.h.
References _value.
|
inlineprotected |
Creates an empty OctetStringBER object.
| type | OctetStringBER type. |
Definition at line 1431 of file BER.h.
References _value, SNMP::BER::BER(), and SNMP::Type::OctetString.
|
inlineprotected |
Allocates the char array.
Definition at line 1439 of file BER.h.
References SNMP::BER::_length, and _value.
Referenced by decode(), SNMP::IPAddressBER::IPAddressBER(), and setValue().
|
inlinevirtual |
Decodes OctetStringBER from stream.
Type and length are decoded by the inherited BER::decode() then OctetStringBER value is decoded.
| stream | Stream to read from. |
| flag | Decoding flag. |
Reimplemented from SNMP::BER.
Definition at line 1350 of file BER.h.
References SNMP::BER::_length, _value, allocate(), SNMP::BER::decode(), and SNMP::Flag::None.
|
inlinevirtual |
Decodes OctetStringBER from memory buffer.
Type and length are decoded by the inherited BER::decode() then OctetStringBER value is decoded.
| buffer | Pointer to the buffer. |
Reimplemented from SNMP::BER.
Definition at line 1380 of file BER.h.
References SNMP::BER::_length, SNMP::BER::decode(), and setValue().
|
inlinevirtual |
Encodes OctetStringBER to stream.
Type and length are encoded by the inherited BER::encode() then OctetStringBER value is encoded.
| stream | Stream to write to. |
Reimplemented from SNMP::BER.
Definition at line 1336 of file BER.h.
References SNMP::BER::_length, _value, and SNMP::BER::encode().
|
inlinevirtual |
Encodes OctetStringBER to memory buffer.
Type and length are encoded by the inherited BER::encode() then OctetStringBER value is encoded.
| buffer | Pointer to the buffer. |
Reimplemented from SNMP::BER.
Definition at line 1365 of file BER.h.
References SNMP::BER::_length, _value, and SNMP::BER::encode().
|
inline |
Gets bit at a given index in the OctetStringBER value.
| index | Index of the bit. |
Definition at line 1416 of file BER.h.
References _value.
|
inline |
Gets the OctetStringBER value.
Definition at line 1392 of file BER.h.
References _value.
|
inline |
Sets the OctetStringBER value.
| value | OctetStringBER char pointer value. |
| length | Value length. |
Definition at line 1404 of file BER.h.
References SNMP::BER::_length, _value, and allocate().
Referenced by decode(), and OctetStringBER().
|
protected |
OctetStringBER char array pointer value.
Definition at line 1424 of file BER.h.
Referenced by allocate(), decode(), encode(), encode(), getBit(), SNMP::IPAddressBER::getValue(), getValue(), SNMP::IPAddressBER::IPAddressBER(), OctetStringBER(), setValue(), and ~OctetStringBER().