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

BER object to handle integer. More...

#include <src/BER.h>

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

Public Member Functions

 IntegerBER (const int32_t value)
 Creates an IntegerBER object.
 
virtual void encode (Stream &stream)
 Encodes IntegerBER to stream.
 
virtual void decode (Stream &stream, const uint8_t flag=Flag::None)
 Decodes IntegerBER from stream.
 
virtual uint8_t * encode (uint8_t *buffer)
 Encodes IntegerBER to memory buffer.
 
virtual uint8_t * decode (uint8_t *buffer)
 Decodes IntegerBER from memory buffer.
 
const int32_t getValue () const
 Gets the IntegerBER value.
 
void setValue (const int32_t value)
 Sets the IntegerBER 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.
 

Private Attributes

int32_t _value
 

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 integer.

  • Type is TYPE_INTEGER.
  • Length is variable, from 1 to 4 byte(s), short form encoding.
  • Size is variable, from 3 to 6 bytes.

Example

Integer Encoding
0 02 01 00
127 02 01 7F
128 02 02 00 80
256 02 02 01 00
2147483647 02 04 7F FF FF FF
-128 02 01 80
-129 02 02 FF 7F
-2147483648 02 04 80 00 00 00

Definition at line 1178 of file BER.h.

Constructor & Destructor Documentation

◆ IntegerBER()

SNMP::IntegerBER::IntegerBER ( const int32_t value)
inline

Creates an IntegerBER object.

Parameters
valueIntegerBER integer value.

Definition at line 1185 of file BER.h.

References setValue().

Member Function Documentation

◆ decode() [1/2]

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

Decodes IntegerBER from stream.

The inherited BER::decodeNumeric<T>() template function decodes type, length and value.

Parameters
streamStream to read from.
flagDecoding flag.

Reimplemented from SNMP::BER.

Definition at line 1212 of file BER.h.

References _value, and SNMP::BER::decodeNumeric().

◆ decode() [2/2]

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

Decodes IntegerBER from memory buffer.

The inherited BER::decodeNumeric<T>() template function decodes type, length and value.

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

Reimplemented from SNMP::BER.

Definition at line 1239 of file BER.h.

References _value, and SNMP::BER::decodeNumeric().

◆ encode() [1/2]

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

Encodes IntegerBER to stream.

The inherited BER::encodeNumeric<T>() template function encodes type, length and value.

Parameters
streamStream to write to.

Reimplemented from SNMP::BER.

Definition at line 1199 of file BER.h.

References _value, and SNMP::BER::encodeNumeric().

◆ encode() [2/2]

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

Encodes IntegerBER to memory buffer.

The inherited BER::encodeNumeric<T>() template function encodes type, length and value.

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

Reimplemented from SNMP::BER.

Definition at line 1226 of file BER.h.

References _value, and SNMP::BER::encodeNumeric().

◆ getValue()

const int32_t SNMP::IntegerBER::getValue ( ) const
inline

Gets the IntegerBER value.

Returns
IntegerBER integer value.

Definition at line 1249 of file BER.h.

References _value.

◆ setValue()

void SNMP::IntegerBER::setValue ( const int32_t value)
inline

Sets the IntegerBER value.

Note
Length is updated.
Parameters
valueIntegerBER integer value.

Definition at line 1260 of file BER.h.

References _value, SNMP::BER::setNegative(), and SNMP::BER::setPositive().

Referenced by IntegerBER().

Member Data Documentation

◆ _value

int32_t SNMP::IntegerBER::_value
private

IntegerBER integer value.

Definition at line 1271 of file BER.h.

Referenced by decode(), decode(), encode(), encode(), getValue(), and setValue().


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