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

BER object to handle IP address. More...

#include <src/BER.h>

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

Public Member Functions

 IPAddressBER (IPAddress value)
 Creates an IPAddressBER object.
 
const uint8_t * getValue ()
 Gets the IPAddressBER value.
 
- Public Member Functions inherited from SNMP::OctetStringBER
 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.
 

Static Private Attributes

static constexpr uint8_t LENGTH = 4
 

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::OctetStringBER
 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
BERcreate (const Type &type)
 Creates a BER of given type.
 
- Protected Attributes inherited from SNMP::OctetStringBER
char * _value
 
- 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 IP address.

  • Type is TYPE_IPADDRESS.
  • Length is fixed, 4 bytes, short form encoding.
  • Size is fixed, 6 bytes.

Example

IP address Encoding
0.0.0.0 40 04 00 00 00 00
8.8.8.8 40 04 08 08 08 08
192.168.0.1 40 04 C0 A8 00 01

Definition at line 2053 of file BER.h.

Constructor & Destructor Documentation

◆ IPAddressBER()

SNMP::IPAddressBER::IPAddressBER ( IPAddress value)
inline

Creates an IPAddressBER object.

IP address bytes are stored internally in a bytes array.

Parameters
valueIPAddressBER IPAddress value.

Definition at line 2062 of file BER.h.

References SNMP::BER::_length, SNMP::OctetStringBER::_value, SNMP::OctetStringBER::allocate(), and LENGTH.

Member Function Documentation

◆ getValue()

const uint8_t * SNMP::IPAddressBER::getValue ( )
inline

Gets the IPAddressBER value.

Returns
IPAddressBER bytes array value.

Definition at line 2076 of file BER.h.

References SNMP::OctetStringBER::_value.

Member Data Documentation

◆ LENGTH

uint8_t SNMP::IPAddressBER::LENGTH = 4
staticconstexprprivate

Fixed length of the IPAddressBER.

Definition at line 2082 of file BER.h.

Referenced by IPAddressBER().


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