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

Forward declaration to OptionInt. More...

#include <option_definition.h>

Public Member Functions

 OptionInt (Option::Universe u, uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
 Constructor. More...
 
 OptionInt (Option::Universe u, uint16_t type, T value)
 Constructor. More...
 
virtual OptionPtr clone () const
 Copies this option and returns a pointer to the copy. More...
 
getValue () const
 Return option value. 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 setValue (T value)
 Set option value. More...
 
virtual std::string toText (int indent=0) const
 Returns option carrying an integer value in the textual format. More...
 
virtual void unpack (OptionBufferConstIter begin, OptionBufferConstIter end)
 Parses received buffer. More...
 

Detailed Description

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

Forward declaration to OptionInt.

This template class represents DHCP option with single value.

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

This value is of integer type and can be any of the following:

  • uint8_t,
  • uint16_t,
  • uint32_t,
  • int8_t,
  • int16_t,
  • int32_t.
Parameters
Tdata field type (see above).

Definition at line 64 of file option_definition.h.

Constructor & Destructor Documentation

◆ OptionInt() [1/2]

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

Constructor.

Parameters
uuniverse (V4 or V6)
typeoption type.
valueoption value.
Exceptions
isc::dhcp::InvalidDataTypeif data field type provided as template parameter is not a supported integer type.
Todo:
Extend constructor to set encapsulated option space name.

Definition at line 65 of file option_int.h.

References DHCP4_OPTION_SPACE, DHCP6_OPTION_SPACE, isc_throw, and isc::dhcp::Option::V4.

◆ OptionInt() [2/2]

template<typename T >
isc::dhcp::OptionInt< T >::OptionInt ( Option::Universe  u,
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 shorter than data size.
isc::dhcp::InvalidDataTypeif data field type provided as template parameter is not a supported integer type.
Todo:
Extend constructor to set encapsulated option space name.

Definition at line 88 of file option_int.h.

References DHCP4_OPTION_SPACE, DHCP6_OPTION_SPACE, isc_throw, isc::dhcp::OptionInt< T >::unpack(), and isc::dhcp::Option::V4.

+ Here is the call graph for this function:

Member Function Documentation

◆ clone()

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

Copies this option and returns a pointer to the copy.

Definition at line 99 of file option_int.h.

◆ getValue()

template<typename T >
T isc::dhcp::OptionInt< T >::getValue ( ) const
inline

Return option value.

Returns
option value.

Definition at line 190 of file option_int.h.

Referenced by isc::dhcp::OptionInt< T >::toText().

◆ len()

template<typename T >
virtual uint16_t isc::dhcp::OptionInt< 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 197 of file option_int.h.

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

◆ pack()

template<typename T >
void isc::dhcp::OptionInt< 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 field 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 111 of file option_int.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:

◆ setValue()

template<typename T >
void isc::dhcp::OptionInt< T >::setValue ( value)
inline

Set option value.

Parameters
valuenew option value.

Definition at line 185 of file option_int.h.

◆ toText()

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

Returns option carrying an integer value in the textual format.

The returned value also includes the suboptions if present.

Parameters
indentNumber of spaces to be inserted before the text.

Definition at line 217 of file option_int.h.

References isc::dhcp::OptionDataTypeUtil::getDataTypeName(), and isc::dhcp::OptionInt< T >::getValue().

+ Here is the call graph for this function:

◆ unpack()

template<typename T >
virtual void isc::dhcp::OptionInt< 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::OutOfRangeif provided buffer is shorter than data size.
isc::dhcp::InvalidDataTypeif size of a data field 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 147 of file option_int.h.

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

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

+ Here is the call graph for this function:

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