SNMP 2.0.0
Loading...
Searching...
No Matches
SNMP::OpaqueBER Class Reference

BER object to handle embedded BER object. More...

#include <src/BER.h>

Inheritance diagram for SNMP::OpaqueBER:
[legend]
Collaboration diagram for SNMP::OpaqueBER:
[legend]

Public Member Functions

 OpaqueBER (BER *ber)
 Creates an OpaqueBER.
 
virtual ~OpaqueBER ()
 OpaqueBER destructor.
 
virtual void encode (Stream &stream)
 Encodes OpaqueBER to stream.
 
virtual void decode (Stream &stream, const uint8_t flag=Flag::None)
 Decodes OpaqueBER from stream.
 
virtual uint8_t * encode (uint8_t *buffer)
 Encodes OpaqueBER to memory buffer.
 
virtual uint8_t * decode (uint8_t *buffer)
 Decodes OpaqueBER from memory buffer.
 
virtual const unsigned int getSize (const bool refresh=false)
 Gets the size of the OpaqueBER.
 
BERgetBER ()
 Gets the embedded BER.
 
- 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.
 

Private Attributes

BER_ber
 

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 Member Functions inherited from SNMP::BER
BERcreate (const Type &type)
 Creates a BER of given type.
 
- Protected Attributes inherited from SNMP::BER
Length _length
 
Type _type
 
- Protected Attributes inherited from SNMP::Base
unsigned int _size = 0
 

Detailed Description

BER object to handle embedded BER object.

  • Type is TYPE_OPAQUE.
  • Length is variable, short or long form encoding.
  • Size is variable.

Example

BER Encoding
9F 78 04 C2 C7 FF FE 44 07 9F 78 04 C2 C7 FF FE
See also
The Domestication of the Opaque Type for SNMP

Definition at line 2312 of file BER.h.

Constructor & Destructor Documentation

◆ OpaqueBER()

SNMP::OpaqueBER::OpaqueBER ( BER * ber)

Creates an OpaqueBER.

Parameters
berBER object.

◆ ~OpaqueBER()

virtual SNMP::OpaqueBER::~OpaqueBER ( )
inlinevirtual

OpaqueBER destructor.

Releases embedded BER object.

Definition at line 2326 of file BER.h.

References _ber.

Member Function Documentation

◆ decode() [1/2]

virtual void SNMP::OpaqueBER::decode ( Stream & stream,
const uint8_t flag = Flag::None )
inlinevirtual

Decodes OpaqueBER from stream.

Type and length are decoded by the inherited BER::decode() then the embedded BER is decoded.

Decoding of embedded BER from stream implies 3 steps.

  • Type of embedded BER is read from stream.
  • Embedded BER object is created from read type.
  • Embedded BER is decoded from stream with flag set to Flag::Typed to skip type decoding already done.
Parameters
streamStream to read from.
flagDecoding flag.

Reimplemented from SNMP::BER.

Definition at line 2360 of file BER.h.

References _ber, SNMP::BER::_length, SNMP::BER::create(), SNMP::BER::decode(), SNMP::Type::decode(), SNMP::BER::getSize(), and SNMP::Flag::Typed.

◆ decode() [2/2]

virtual uint8_t * SNMP::OpaqueBER::decode ( uint8_t * buffer)
inlinevirtual

Decodes OpaqueBER from memory buffer.

Type and length are decoded by the inherited BER::decode() then the embedded BER is decoded.

Parameters
bufferPointer to the buffer.
Returns
Next position to be read in buffer.

Reimplemented from SNMP::BER.

Definition at line 2399 of file BER.h.

References _ber, SNMP::BER::_length, SNMP::BER::create(), SNMP::BER::decode(), and SNMP::Type::decode().

◆ encode() [1/2]

virtual void SNMP::OpaqueBER::encode ( Stream & stream)
inlinevirtual

Encodes OpaqueBER to stream.

Type and length are encoded by the inherited BER::encode() then the embedded BER is encoded.

Parameters
streamStream to write to.

Reimplemented from SNMP::BER.

Definition at line 2339 of file BER.h.

References _ber, and SNMP::BER::encode().

◆ encode() [2/2]

virtual uint8_t * SNMP::OpaqueBER::encode ( uint8_t * buffer)
inlinevirtual

Encodes OpaqueBER to memory buffer.

Type and length are encoded by the inherited BER::encode() then the embedded BER is encoded.

Parameters
bufferPointer to the buffer.
Returns
Next position to be written in buffer.

Reimplemented from SNMP::BER.

Definition at line 2385 of file BER.h.

References _ber, and SNMP::BER::encode().

◆ getBER()

BER * SNMP::OpaqueBER::getBER ( )
inline

Gets the embedded BER.

Returns
BER.

Definition at line 2442 of file BER.h.

References _ber.

◆ getSize()

virtual const unsigned int SNMP::OpaqueBER::getSize ( const bool refresh = false)
inlinevirtual

Gets the size of the OpaqueBER.

The size of the OpaqueBER is computed from:

Length is the size of the embedded BER.

Parameters
refreshIf true, computes size, if false returns already computed size.
Returns
BER size.

Reimplemented from SNMP::BER.

Definition at line 2430 of file BER.h.

References _ber, SNMP::BER::_length, and SNMP::BER::getSize().

Member Data Documentation

◆ _ber

BER* SNMP::OpaqueBER::_ber
private

Embedded BER.

Definition at line 2448 of file BER.h.

Referenced by decode(), decode(), encode(), encode(), getBER(), getSize(), and ~OpaqueBER().


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