Kea  1.5.0
isc::dhcp::OptionIntArray< T > Class Template Reference

Forward declaration to OptionIntArray. More...

#include <option_definition.h>

Public Member Functions

 OptionIntArray (const Option::Universe u, const uint16_t type)
 Constructor. More...
 
 OptionIntArray (const Option::Universe u, const uint16_t type, const OptionBuffer &buf)
 Constructor. More...
 
 OptionIntArray (const Option::Universe u, const uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
 Constructor. More...
 
void addValue (const T value)
 Adds a new value to the array. More...
 
virtual OptionPtr clone () const
 Copies this option and returns a pointer to the copy. More...
 
const std::vector< T > & getValues () const
 Return collection of option values. More...
 
virtual uint16_t len () const
 returns complete length of option More...
 
void pack (isc::util::OutputBuffer &buf) const
 Writes option in wire-format to buf, returns pointer to first unused byte after stored option. More...
 
void setValues (const std::vector< T > &values)
 Set option values. More...
 
virtual std::string toText (int indent=0) const
 Returns textual representation of the option. More...
 
virtual void unpack (OptionBufferConstIter begin, OptionBufferConstIter end)
 Parses received buffer. More...
 

Detailed Description

template<typename T>
class isc::dhcp::OptionIntArray< T >

Forward declaration to OptionIntArray.

This template class represents DHCP (v4 or v6) option with an array of integer values.

Forward declaration of OptionIntArray.

This forward declaration is needed to access the OptionIntArray class without having to include the option_int_array.h header file. It is required because this header includes libdhcp++.h, and including option_int_array.h would cause circular inclusion between libdhcp++.h, option_definition.h and option_int_array.h.

The type of the elements in the array can be any of the following:

  • uint8_t,
  • uint16_t,
  • uint32_t,
  • int8_t,
  • int16_t,
  • int32_t.
Warning
Since this option may convey variable number of integer values, sub-options are should not be added in this option as there is no way to distinguish them from other data. The API will allow addition of sub-options but they will be ignored during packing and unpacking option data.
Parameters
Tdata field type (see above).

Definition at line 74 of file option_definition.h.

Constructor & Destructor Documentation

◆ OptionIntArray() [1/3]

template<typename T >
isc::dhcp::OptionIntArray< T >::OptionIntArray ( const Option::Universe  u,
const uint16_t  type 
)
inline

Constructor.

Creates option with empty values vector.

Parameters
uuniverse (V4 or V6).
typeoption type.
Exceptions
isc::dhcp::InvalidDataTypeif data field type provided as template parameter is not a supported integer type.

Definition at line 73 of file option_int_array.h.

References isc_throw.

◆ OptionIntArray() [2/3]

template<typename T >
isc::dhcp::OptionIntArray< T >::OptionIntArray ( const Option::Universe  u,
const uint16_t  type,
const OptionBuffer buf 
)
inline

Constructor.

Parameters
uuniverse (V4 or V6).
typeoption type.
bufbuffer with option data (must not be empty).
Exceptions
isc::OutOfRangeif provided buffer is empty or its length is not multiple of size of the data type in bytes.
isc::dhcp::InvalidDataTypeif data field type provided as template parameter is not a supported integer type.

Definition at line 91 of file option_int_array.h.

References isc_throw, and isc::dhcp::OptionIntArray< T >::unpack().

+ Here is the call graph for this function:

◆ OptionIntArray() [3/3]

template<typename T >
isc::dhcp::OptionIntArray< T >::OptionIntArray ( const Option::Universe  u,
const uint16_t  type,
OptionBufferConstIter  begin,
OptionBufferConstIter  end 
)
inline

Constructor.

This constructor creates option from a buffer. This constructor may throw exception if unpack function throws during buffer parsing.

Parameters
uuniverse (V4 or V6).
typeoption type.
beginiterator to first byte of option data.
enditerator to end of option data (first byte after option end).
Exceptions
isc::OutOfRangeif provided buffer is empty or its length is not multiple of size of the data type in bytes.
isc::dhcp::InvalidDataTypeif data field type provided as template parameter is not a supported integer type.

Definition at line 115 of file option_int_array.h.

References isc_throw, and isc::dhcp::OptionIntArray< T >::unpack().

+ Here is the call graph for this function:

Member Function Documentation

◆ addValue()

template<typename T >
void isc::dhcp::OptionIntArray< T >::addValue ( const T  value)
inline

Adds a new value to the array.

Parameters
valuea value being added.

Definition at line 132 of file option_int_array.h.

◆ clone()

template<typename T >
virtual OptionPtr isc::dhcp::OptionIntArray< T >::clone ( ) const
inlinevirtual

Copies this option and returns a pointer to the copy.

Definition at line 125 of file option_int_array.h.

◆ getValues()

template<typename T >
const std::vector<T>& isc::dhcp::OptionIntArray< T >::getValues ( ) const
inline

Return collection of option values.

Returns
collection of values.

Definition at line 230 of file option_int_array.h.

◆ len()

template<typename T >
virtual uint16_t isc::dhcp::OptionIntArray< T >::len ( ) const
inlinevirtual

returns complete length of option

Returns length of this option, including option header and suboptions

Returns
length of this option

Definition at line 242 of file option_int_array.h.

References isc::dhcp::Option::V4.

◆ pack()

template<typename T >
void isc::dhcp::OptionIntArray< T >::pack ( isc::util::OutputBuffer buf) const
inline

Writes option in wire-format to buf, returns pointer to first unused byte after stored option.

Parameters
[out]bufbuffer (option will be stored here)
Exceptions
isc::dhcp::InvalidDataTypeif size of a data fields type is not equal to 1, 2 or 4 bytes. The data type is not checked in this function because it is checked in a constructor.

Definition at line 144 of file option_int_array.h.

References isc_throw, isc::util::OutputBuffer::writeUint16(), isc::util::OutputBuffer::writeUint32(), and isc::util::OutputBuffer::writeUint8().

+ Here is the call graph for this function:

◆ setValues()

template<typename T >
void isc::dhcp::OptionIntArray< T >::setValues ( const std::vector< T > &  values)
inline

Set option values.

Parameters
valuescollection of values to be set for option.

Definition at line 235 of file option_int_array.h.

◆ toText()

template<typename T >
virtual std::string isc::dhcp::OptionIntArray< T >::toText ( int  indent = 0) const
inlinevirtual

Returns textual representation of the option.

Parameters
indentNumber of space characters to be inserted before the text.
Returns
textual representation of the option.

Definition at line 260 of file option_int_array.h.

References isc::dhcp::OptionDataTypeUtil::getDataTypeName().

+ Here is the call graph for this function:

◆ unpack()

template<typename T >
virtual void isc::dhcp::OptionIntArray< T >::unpack ( OptionBufferConstIter  begin,
OptionBufferConstIter  end 
)
inlinevirtual

Parses received buffer.

Parses received buffer and returns offset to the first unused byte after parsed option.

Parameters
beginiterator to first byte of option data
enditerator to end of option data (first byte after option end)
Exceptions
isc::dhcp::InvalidDataTypeif size of a data fields type is not equal to 1, 2 or 4 bytes. The data type is not checked in this function because it is checked in a constructor.

Definition at line 184 of file option_int_array.h.

References isc_throw, isc::util::readUint16(), and isc::util::readUint32().

Referenced by isc::dhcp::OptionIntArray< T >::OptionIntArray().

+ Here is the call graph for this function:

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